chooseDealer.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="8" :sm="24">
  8. <a-form-model-item label="地区">
  9. <AreaList id="viewDealers-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  10. </a-form-model-item>
  11. </a-col>
  12. <a-col :md="8" :sm="24">
  13. <a-form-item label="经销商名称/别名">
  14. <a-input id="chooseDealer-nameLike" v-model.trim="queryParam.nameLike" allowClear placeholder="请输入经销商名称/别名"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="8" :sm="24">
  18. <a-form-item label="商户类型">
  19. <dealerType id="chooseDealer-dealerType" v-model="queryParam.dealerType" allowClear></dealertype>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :md="8" :sm="24">
  23. <a-form-model-item label="商户级别" prop="dealerLevel">
  24. <v-select code="DEALER_LEVEL" id="ucModal-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择商户级别"></v-select>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="8" :sm="24">
  28. <a-form-item label="所在区域/分区">
  29. <subarea id="chooseDealer-subarea" ref="subarea" @change="subareaChange"></subarea>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
  33. <a-button type="primary" @click="searchForm(true)" :disabled="disabled" id="chooseDealer-refresh">查询</a-button>
  34. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="chooseDealer-reset">重置</a-button>
  35. </a-col>
  36. </a-row>
  37. </a-form>
  38. <!-- 列表 -->
  39. <div style="margin-bottom: 10px">
  40. <a-button type="primary" ghost :loading="loading" @click="handleBatchAudit">批量添加</a-button>
  41. <span style="margin-left: 5px">
  42. <template v-if="selectCount"> {{ `已选 ${selectCount} 项` }} </template>
  43. </span>
  44. </div>
  45. </div>
  46. <s-table
  47. class="sTable fixPagination"
  48. ref="table"
  49. :style="{ height: tableHeight+70+'px' }"
  50. :scroll="{ y: tableHeight -30 }"
  51. :rowKey="(record) => record.dealerSn"
  52. rowKeyName="dealerSn"
  53. :columns="columns"
  54. :data="loadData"
  55. :row-selection="{ columnWidth: 40 }"
  56. @rowSelection="rowSelectionFun"
  57. :defaultLoadData="false"
  58. bordered>
  59. <!-- 地区 -->
  60. <template slot="addressInfo" slot-scope="text, record">
  61. {{ record.provinceName }}{{ '-'+ record.cityName }}{{ '-'+ record.districtName }}
  62. </template>
  63. </s-table>
  64. </a-spin>
  65. </template>
  66. <script>
  67. import { commonMixin } from '@/utils/mixin'
  68. import { STable, VSelect } from '@/components'
  69. import AreaList from '@/views/common/areaList.js'
  70. import subarea from '@/views/common/subarea.js'
  71. import dealerType from '@/views/common/dealerType.js'
  72. import { getDealerListInfo, dealerQueryList } from '@/api/dealer'
  73. export default {
  74. name: 'ChooseDealer',
  75. mixins: [commonMixin],
  76. components: { STable, VSelect, subarea, AreaList, dealerType },
  77. props: {
  78. pageType: {
  79. type: String,
  80. default: 'dealerPromotion'
  81. },
  82. itemSn: {
  83. type: String,
  84. default: ''
  85. }
  86. },
  87. data () {
  88. return {
  89. tableHeight: 0,
  90. spinning: false,
  91. queryParam: { // 查询条件
  92. nameLike: '',
  93. dealerType: null,
  94. dealerLevel: null,
  95. subareaArea: {
  96. subareaSn: undefined, // 区域
  97. subareaAreaSn: undefined // 分区
  98. },
  99. auditState: undefined,
  100. provinceSn: undefined,
  101. citySn: undefined,
  102. districtSn: undefined
  103. },
  104. disabled: false, // 查询、重置按钮是否可操作
  105. loading: false, // 批量添加loading,
  106. rowSelectionInfo: null,
  107. columns: [
  108. { title: '经销商名称', dataIndex: 'dealerName', width: '30%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  109. { title: '商户别名', dataIndex: 'dealerAlias', align: 'left', width: '30%', customRender: function (text) { return text || '--' }, ellipsis: true },
  110. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  111. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  112. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '30%', align: 'center', ellipsis: true },
  113. { title: '所在区域', dataIndex: 'subareaArea.subareaName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  114. { title: '所在分区', dataIndex: 'subareaArea.subareaAreaName', width: '20%', align: 'center', customRender: function (text) { return text || '--' } }
  115. ],
  116. // 加载数据方法 必须为 Promise 对象
  117. loadData: parameter => {
  118. this.disabled = true
  119. this.spinning = true
  120. this.queryParam.notDealerSn = this.itemSn
  121. this.queryParam.pageType = this.pageType
  122. return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
  123. let data
  124. if (res.status == 200) {
  125. data = res.data
  126. const no = (data.pageNo - 1) * data.pageSize
  127. for (var i = 0; i < data.list.length; i++) {
  128. data.list[i].no = no + i + 1
  129. }
  130. this.disabled = false
  131. }
  132. this.spinning = false
  133. return data
  134. })
  135. }
  136. }
  137. },
  138. computed: {
  139. selectCount () {
  140. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length
  141. }
  142. },
  143. methods: {
  144. // 表格选中项
  145. rowSelectionFun (obj) {
  146. this.rowSelectionInfo = obj || null
  147. },
  148. areaChange (val) {
  149. this.queryParam.provinceSn = val[0] ? val[0] : ''
  150. this.queryParam.citySn = val[1] ? val[1] : ''
  151. this.queryParam.districtSn = val[2] ? val[2] : ''
  152. },
  153. searchForm () {
  154. this.$refs.table.refresh()
  155. },
  156. subareaChange (val) {
  157. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  158. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  159. },
  160. // 重置
  161. resetSearchForm () {
  162. this.queryParam = {
  163. nameLike: '',
  164. dealerType: null,
  165. dealerLevel: null,
  166. subareaArea: {
  167. subareaSn: undefined, // 区域
  168. subareaAreaSn: undefined // 分区
  169. },
  170. auditState: undefined,
  171. provinceSn: undefined,
  172. citySn: undefined,
  173. districtSn: undefined
  174. }
  175. this.$refs.subarea.clearData()
  176. this.$refs.areaList.clearData()
  177. this.$refs.table.refresh()
  178. },
  179. clearSelect () {
  180. this.$refs.table.clearSelected()
  181. },
  182. // 批量添加
  183. handleBatchAudit () {
  184. const _this = this
  185. if (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys && _this.rowSelectionInfo.selectedRowKeys.length < 1) {
  186. _this.$message.warning('请在列表勾选后再进行批量操作!')
  187. return
  188. }
  189. this.$emit('plAdd', _this.rowSelectionInfo.selectedRows)
  190. },
  191. pageInit (data) {
  192. this.setTableH()
  193. this.$refs.table.refresh()
  194. },
  195. setTableH () {
  196. const headHeight = this.$refs.tableSearch.offsetHeight
  197. this.tableHeight = window.innerHeight - headHeight - 190
  198. }
  199. },
  200. watch: {
  201. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  202. this.setTableH()
  203. }
  204. }
  205. }
  206. </script>