list.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="dealerAccountNewList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" id="dealerAccountNewList-form" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="5" :sm="24">
  9. <a-form-item label="经销商名称">
  10. <custList ref="custList" dataAuthFlag="0" id="dealerAccountNewList-dealerName" placeholder="请输入经销商名称搜索" @change="custChange"></custList>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="5" :sm="24">
  14. <a-form-item label="区域">
  15. <subarea id="dealerAccountNewList-subarea" ref="subarea" @change="subareaChange"></subarea>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="5" :sm="24">
  19. <a-form-item label="商户级别">
  20. <v-select code="DEALER_LEVEL" id="dealerAccountNewList-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择商户级别"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="5" :sm="24">
  24. <a-form-item label="商户类型">
  25. <dealerType id="dealerAccountNewList-dealerType" changeOnSelect v-model="dealerType" @change="getDealerType" allowClear></dealertype>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="4" :sm="24">
  29. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="dealerAccountNewList-refresh">查询</a-button>
  30. <a-button style="margin:0 5px;" @click="resetSearchForm" :disabled="disabled" id="dealerAccountNewList-reset">重置</a-button>
  31. <a-button
  32. type="primary"
  33. v-if="$hasPermissions('B_dealerAccountExport')"
  34. class="button-warning"
  35. @click="handleExport"
  36. :disabled="disabled"
  37. :loading="exportLoading"
  38. id="dealerAccountNewList-export">导出</a-button>
  39. </a-col>
  40. </a-row>
  41. </a-form>
  42. </div>
  43. </a-card>
  44. <a-card size="small" :bordered="false">
  45. <a-spin :spinning="spinning" tip="Loading...">
  46. <!-- 列表 -->
  47. <s-table
  48. class="sTable fixPagination"
  49. ref="table"
  50. :style="{ height: tableHeight+70+'px' }"
  51. size="small"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. :pageSize="30"
  56. :scroll="{ y: tableHeight }"
  57. :defaultLoadData="false"
  58. bordered>
  59. <!-- 轮胎补贴金额 -->
  60. <template slot="moneyNum" slot-scope="text, record">
  61. <span v-if="$hasPermissions('M_dealerAccountDetail')&&(record.subsidyTire||record.subsidyTire==0)" :id="'dealerAccountNewList-tireMoney'+record.id" class="link-bule" @click="handleDetail(record)">{{ toThousands(record.subsidyTire) }}</span>
  62. <span v-else>{{ toThousands(record.subsidyTire) }}</span>
  63. </template>
  64. <!-- 商户类型 -->
  65. <template slot="dealerType" slot-scope="text, record">
  66. {{ record.dealerTypeName1 }}{{ record.dealerTypeName1?'>':'' }}{{ record.dealerTypeName2 }}
  67. </template>
  68. </s-table>
  69. </a-spin>
  70. </a-card>
  71. </div>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. // 组件
  76. import { STable, VSelect } from '@/components'
  77. import subarea from '@/views/common/subarea.js'
  78. import dealerType from '@/views/common/dealerType.js'
  79. import custList from '@/views/common/custList.vue'
  80. import { hdExportExcel } from '@/libs/exportExcel'
  81. // 接口
  82. import { dealerAccountList, dealerAccountExport } from '@/api/dealerAccount'
  83. export default {
  84. name: 'DealerAccountNewList',
  85. mixins: [commonMixin],
  86. components: { STable, VSelect, custList, subarea, dealerType },
  87. data () {
  88. return {
  89. spinning: false,
  90. tableHeight: 0, // 表格高度
  91. disabled: false, // 查询、重置按钮是否可操作
  92. exportLoading: false, // 导出加载状态
  93. queryParam: { // 查询条件
  94. dealerSn: undefined, // 经销商sn
  95. subareaArea: {
  96. subareaSn: undefined, // 区域
  97. subareaAreaSn: undefined // 分区
  98. },
  99. dealerLevel: undefined, // 商户级别
  100. dealerType1: undefined, // 商户类型
  101. dealerType2: undefined // 商户类型
  102. },
  103. dealerType: [], // 所选商户类型 列表
  104. columns: [
  105. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  106. { title: '经销商名称', dataIndex: 'dealerEntity.dealerName', width: '20%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  107. { title: '轮胎补贴金额(¥)', scopedSlots: { customRender: 'moneyNum' }, width: '12%', align: 'right' },
  108. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  109. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  110. { title: '商户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '商户类型', dataIndex: 'dealerType', scopedSlots: { customRender: 'dealerType' }, width: '16%', align: 'center', ellipsis: true },
  112. { title: '创建时间', dataIndex: 'createDate', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  113. ],
  114. // 加载数据方法 必须为 Promise 对象
  115. loadData: parameter => {
  116. this.disabled = true
  117. this.spinning = true
  118. return dealerAccountList(Object.assign(parameter, this.queryParam)).then(res => {
  119. let data
  120. if (res.status == 200) {
  121. data = res.data
  122. // 计算表格序号
  123. const no = (data.pageNo - 1) * data.pageSize
  124. for (var i = 0; i < data.list.length; i++) {
  125. data.list[i].no = no + i + 1
  126. }
  127. }
  128. this.disabled = false
  129. this.spinning = false
  130. return data
  131. })
  132. }
  133. }
  134. },
  135. methods: {
  136. // 客户名称 change
  137. custChange (val) {
  138. this.queryParam.dealerSn = val.key
  139. },
  140. // 区域 change
  141. subareaChange (val) {
  142. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  143. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  144. },
  145. // 商户类型 change
  146. getDealerType (v, o) {
  147. this.queryParam.dealerType1 = v[0]
  148. this.queryParam.dealerType2 = v[1]
  149. },
  150. // 轮胎补贴金额 点击跳转详情页
  151. handleDetail (row) {
  152. this.$router.push({ name: 'dealerAccountDetail', params: { sn: row.dealerSn, name: row.dealerEntity.dealerName, num: row.subsidyTire } })
  153. },
  154. // 重置
  155. resetSearchForm () {
  156. this.queryParam.dealerSn = undefined
  157. this.queryParam.subareaArea.subareaSn = undefined
  158. this.queryParam.subareaArea.subareaAreaSn = undefined
  159. this.queryParam.dealerLevel = undefined
  160. this.queryParam.dealerType1 = undefined
  161. this.queryParam.dealerType2 = undefined
  162. this.dealerType = []
  163. this.$refs.custList.resetForm()
  164. this.$refs.subarea.clearData()
  165. this.$refs.table.refresh(true)
  166. },
  167. // 导出
  168. handleExport () {
  169. const _this = this
  170. // _this.$store.state.app.curActionPermission = 'B_sales_export'
  171. _this.exportLoading = true
  172. _this.spinning = true
  173. hdExportExcel(dealerAccountExport, _this.queryParam, '经销商账户列表', function () {
  174. _this.exportLoading = false
  175. _this.spinning = false
  176. _this.showExport = true
  177. // _this.$store.state.app.curActionPermission = ''
  178. })
  179. },
  180. // 初始化
  181. pageInit () {
  182. const _this = this
  183. this.$nextTick(() => { // 页面渲染完成后的回调
  184. _this.setTableH()
  185. })
  186. },
  187. // 计算表格高度
  188. setTableH () {
  189. const tableSearchH = this.$refs.tableSearch.offsetHeight
  190. this.tableHeight = window.innerHeight - tableSearchH - 195
  191. }
  192. },
  193. watch: {
  194. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  195. this.setTableH()
  196. }
  197. },
  198. mounted () {
  199. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  200. this.pageInit()
  201. this.resetSearchForm()
  202. }
  203. },
  204. activated () {
  205. // 如果是新页签打开,则重置当前页面
  206. if (this.$store.state.app.isNewTab) {
  207. this.pageInit()
  208. this.resetSearchForm()
  209. }
  210. // 仅刷新列表,不重置页面
  211. if (this.$store.state.app.updateList) {
  212. this.$refs.table.refresh()
  213. this.pageInit()
  214. }
  215. }
  216. }
  217. </script>