lookUpCustomersModal.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <a-modal
  3. centered
  4. class="lookUpCustomers-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="参与经销商"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. width="60%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-card size="small" :bordered="false">
  13. <!-- 筛选条件 -->
  14. <div class="table-page-search-wrapper">
  15. <a-form layout="inline" id="lookUpCustomers-form" @keyup.enter.native="$refs.table.refresh(true)">
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="地区">
  19. <AreaList id="lookUpCustomers-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-model-item label="区域/分区">
  24. <subarea ref="subarea" id="lookUpCustomers-subarea" @change="subareaChange"></subarea>
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24">
  28. <a-form-item label="经销商名称">
  29. <a-input id="lookUpCustomers-purchaseBillNo" v-model.trim="queryParam.dealerName" allowClear placeholder="请输入经销商名称"/>
  30. </a-form-item>
  31. </a-col>
  32. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  33. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="lookUpCustomers-refresh">查询</a-button>
  34. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="lookUpCustomers-reset">重置</a-button>
  35. <a-button
  36. type="primary"
  37. style="margin-left: 10px"
  38. id="lookUpCustomers-export"
  39. class="button-warning"
  40. @click="handleExport"
  41. :disabled="disabled"
  42. :loading="exportLoading">导出</a-button>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <!-- 列表 -->
  48. <s-table
  49. class="sTable"
  50. ref="table"
  51. size="small"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. :defaultLoadData="false"
  56. :scroll="{ y: 450 }"
  57. :rowClassName="(record, index) => record.checkProfitLossQty < 0 ? 'redBg-row':''"
  58. bordered>
  59. <!-- 地区 -->
  60. <template slot="address" slot-scope="text, record">
  61. <span v-if="record.dealerEntity&&record.dealerEntity.provinceName">{{ record.dealerEntity.provinceName }}/{{ record.dealerEntity.cityName }}/{{ record.dealerEntity.districtName }}</span>
  62. <span v-else>--</span>
  63. </template>
  64. </s-table>
  65. </a-card>
  66. <div class="btn-cont">
  67. <a-button id="lookUpCustomers-modal-close" @click="isShow = false">关闭</a-button>
  68. </div>
  69. </a-spin>
  70. </a-modal>
  71. </template>
  72. <script>
  73. import { commonMixin } from '@/utils/mixin'
  74. import { hdExportExcel } from '@/libs/exportExcel'
  75. // 组件
  76. import { STable } from '@/components'
  77. import ProductType from '@/views/common/productType.js'
  78. import subarea from '@/views/common/subarea.js'
  79. import AreaList from '@/views/common/areaList.js'
  80. // 接口
  81. import { dealerExport } from '@/api/promoTerminal'
  82. import { shopBannerSeeDealer, shopBannerExport } from '@/api/shopBanner'
  83. export default {
  84. name: 'LookUpCustomersModal',
  85. components: { STable, ProductType, subarea, AreaList },
  86. mixins: [commonMixin],
  87. props: {
  88. openModal: { // 弹框显示状态
  89. type: Boolean,
  90. default: false
  91. }
  92. },
  93. data () {
  94. return {
  95. spinning: false,
  96. isShow: this.openModal, // 是否打开弹框
  97. disabled: false, // 查询、重置按钮是否可操作
  98. advanced: false, // 高级搜索 展开/关闭
  99. exportShow: false, // 导出弹窗显示
  100. exportLoading: false, // 导出按钮加载状态
  101. // 查询条件
  102. queryParam: {
  103. // 区域分区
  104. subareaArea: {
  105. subareaSn: undefined, // 区域
  106. subareaAreaSn: undefined// 分区
  107. },
  108. provinceSn: undefined, // 省sn
  109. citySn: undefined, // 市sn
  110. districtSn: undefined, // 区sn
  111. dealerName: undefined// 经销商名称
  112. },
  113. // 加载数据方法 必须为 Promise 对象
  114. loadData: parameter => {
  115. this.disabled = true
  116. this.spinning = true
  117. const params = Object.assign(parameter, this.queryParam)
  118. return shopBannerSeeDealer(params).then(res => {
  119. let data
  120. if (res.status == 200) {
  121. data = res.data
  122. const no = (data.pageNo - 1) * data.pageSize
  123. for (var i = 0; i < data.list.length; i++) {
  124. data.list[i].no = no + i + 1
  125. }
  126. this.disabled = false
  127. }
  128. this.spinning = false
  129. return data
  130. })
  131. },
  132. snObj: undefined, // 经销商列表
  133. columns: [// 表头
  134. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  135. { title: '地区', scopedSlots: { customRender: 'address' }, width: '20%', align: 'center', ellipsis: true },
  136. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '经销商名称', dataIndex: 'dealerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  139. { title: '商户类型', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '商户级别', dataIndex: 'dealerEntity.dealerTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  141. ]
  142. }
  143. },
  144. methods: {
  145. // 地区
  146. areaChange (val) {
  147. this.queryParam.provinceSn = val[0] ? val[0] : ''
  148. this.queryParam.citySn = val[1] ? val[1] : ''
  149. this.queryParam.districtSn = val[2] ? val[2] : ''
  150. },
  151. // 区域分区
  152. subareaChange (val) {
  153. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  154. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  155. },
  156. // 初始化
  157. pageInit (data) {
  158. this.snObj = data
  159. this.queryParam = Object.assign(this.queryParam, data)
  160. this.$refs.table.refresh(true)
  161. },
  162. // 重置
  163. resetSearchForm () {
  164. this.queryParam = Object.assign({
  165. provinceSn: undefined,
  166. citySn: undefined,
  167. districtSn: undefined,
  168. subareaArea: {
  169. subareaSn: undefined,
  170. subareaAreaSn: undefined
  171. }
  172. }, this.snObj)
  173. this.queryParam.dealerName = undefined
  174. this.$refs.areaList.clearData()
  175. this.$refs.subarea.clearData()
  176. this.$refs.table.refresh(true)
  177. },
  178. // 导出
  179. handleExport () {
  180. const _this = this
  181. _this.exportLoading = true
  182. _this.spinning = true
  183. hdExportExcel(shopBannerExport, _this.queryParam, '首页轮播图参与经销商列表导出', function () {
  184. _this.exportLoading = false
  185. _this.spinning = false
  186. _this.showExport = true
  187. })
  188. }
  189. },
  190. watch: {
  191. // 父页面传过来的弹框状态
  192. openModal (newValue, oldValue) {
  193. this.isShow = newValue
  194. },
  195. // 重定义的弹框状态
  196. isShow (newValue, oldValue) {
  197. if (!newValue) {
  198. this.$emit('close')
  199. this.resetSearchForm()
  200. }
  201. }
  202. }
  203. }
  204. </script>
  205. <style lang="less" scoped>
  206. .lookUpCustomers-modal{
  207. .ant-modal-body{
  208. padding: 0 24px 24px;
  209. }
  210. .redBg-row{
  211. background-color: #f5cdc8;
  212. }
  213. .btn-cont {
  214. text-align: center;
  215. margin: 5px 0 10px;
  216. }
  217. .table-page-search-wrapper{
  218. margin-bottom:6px;
  219. /deep/.ant-select-selection{
  220. border:0 !important;
  221. box-shadow: none !important;
  222. }
  223. .ant-form.ant-form-inline .ant-form-item{
  224. border:1px solid #dadada;
  225. border-radius: 3px;
  226. overflow: hidden;
  227. margin-bottom: 10px!important;
  228. /deep/.ant-form-item-label{
  229. padding-left: 11px !important;
  230. padding-right: 0!important;
  231. }
  232. }
  233. }
  234. }
  235. </style>