lookUpCustomersModal.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. <div v-if="queryParam.bannerSn">
  62. <span v-if="record.dealerEntity&&record.dealerEntity.provinceName">{{ record.dealerEntity.provinceName }}/{{ record.dealerEntity.cityName }}/{{ record.dealerEntity.districtName }}</span>
  63. <span v-else>--</span>
  64. </div>
  65. <div v-else>
  66. <span v-if="record.provinceName">{{ record.provinceName }}/{{ record.cityName }}/{{ record.districtName }}</span>
  67. <span v-else>--</span>
  68. </div>
  69. </template>
  70. <!-- 商户类型 -->
  71. <template slot="businessType" slot-scope="text, record" >
  72. <div v-if="queryParam.bannerSn">
  73. <span v-if="record.dealerEntity&&record.dealerEntity.dealerTypeName1">{{ record.dealerEntity.dealerTypeName1 }}{{ record.dealerEntity.dealerTypeName1?'>'+record.dealerEntity.dealerTypeName2:record.dealerEntity.dealerTypeName2 }}</span>
  74. <span v-else>--</span>
  75. </div>
  76. <div v-else>
  77. {{ record.dealerTypeName1 }}{{ record.dealerTypeName1?'>'+record.dealerTypeName2:record.dealerTypeName2 }}
  78. </div>
  79. </template>
  80. <!-- 商户级别 -->
  81. <template slot="businessLevel" slot-scope="text, record" >
  82. <div v-if="queryParam.bannerSn">
  83. <span v-if="record.dealerEntity&&record.dealerEntity.dealerLevelDictValue">{{ record.dealerEntity.dealerLevelDictValue }}</span>
  84. <span v-else>--</span>
  85. </div>
  86. <div v-else>
  87. {{ record.dealerLevelDictValue||'--' }}
  88. </div>
  89. </template>
  90. </s-table>
  91. </a-card>
  92. <div class="btn-cont">
  93. <a-button id="lookUpCustomers-modal-close" @click="isShow = false">关闭</a-button>
  94. </div>
  95. </a-spin>
  96. </a-modal>
  97. </template>
  98. <script>
  99. import { commonMixin } from '@/utils/mixin'
  100. import { hdExportExcel } from '@/libs/exportExcel'
  101. // 组件
  102. import { STable } from '@/components'
  103. import ProductType from '@/views/common/productType.js'
  104. import subarea from '@/views/common/subarea.js'
  105. import AreaList from '@/views/common/areaList.js'
  106. // 接口
  107. import { dealerExport } from '@/api/promoTerminal'
  108. import { shopBannerSeeDealer, shopBannerExport } from '@/api/shopBanner'
  109. import { queryDealerPageList } from '@/api/dealer'
  110. export default {
  111. name: 'LookUpCustomersModal',
  112. components: { STable, ProductType, subarea, AreaList },
  113. mixins: [commonMixin],
  114. props: {
  115. openModal: { // 弹框显示状态
  116. type: Boolean,
  117. default: false
  118. }
  119. },
  120. data () {
  121. return {
  122. spinning: false,
  123. isShow: this.openModal, // 是否打开弹框
  124. disabled: false, // 查询、重置按钮是否可操作
  125. advanced: false, // 高级搜索 展开/关闭
  126. exportShow: false, // 导出弹窗显示
  127. exportLoading: false, // 导出按钮加载状态
  128. // 查询条件
  129. queryParam: {
  130. // 区域分区
  131. subareaArea: {
  132. subareaSn: undefined, // 区域
  133. subareaAreaSn: undefined// 分区
  134. },
  135. provinceSn: undefined, // 省sn
  136. citySn: undefined, // 市sn
  137. districtSn: undefined, // 区sn
  138. dealerName: undefined// 经销商名称
  139. },
  140. // 加载数据方法 必须为 Promise 对象
  141. loadData: parameter => {
  142. this.disabled = true
  143. this.spinning = true
  144. const params = Object.assign(parameter, this.queryParam)
  145. const ajaxName = this.queryParam.bannerSn ? shopBannerSeeDealer : queryDealerPageList
  146. return ajaxName(params).then(res => {
  147. let data
  148. if (res.status == 200) {
  149. data = res.data
  150. const no = (data.pageNo - 1) * data.pageSize
  151. for (var i = 0; i < data.list.length; i++) {
  152. data.list[i].no = no + i + 1
  153. }
  154. this.disabled = false
  155. }
  156. this.spinning = false
  157. return data
  158. })
  159. },
  160. snObj: undefined, // 经销商列表
  161. columns: [// 表头
  162. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  163. { title: '地区', scopedSlots: { customRender: 'address' }, width: '20%', align: 'center', ellipsis: true },
  164. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  165. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  166. { title: '经销商名称', dataIndex: 'dealerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  167. { title: '商户类型', scopedSlots: { customRender: 'businessType' }, width: '20%', align: 'center' },
  168. { title: '商户级别', scopedSlots: { customRender: 'businessLevel' }, width: '13%', align: 'center' }
  169. ]
  170. }
  171. },
  172. methods: {
  173. // 地区
  174. areaChange (val) {
  175. this.queryParam.provinceSn = val[0] ? val[0] : ''
  176. this.queryParam.citySn = val[1] ? val[1] : ''
  177. this.queryParam.districtSn = val[2] ? val[2] : ''
  178. },
  179. // 区域分区
  180. subareaChange (val) {
  181. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  182. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  183. },
  184. // 初始化
  185. pageInit (data) {
  186. this.snObj = data
  187. this.queryParam = Object.assign(this.queryParam, data)
  188. this.$refs.table.refresh(true)
  189. },
  190. // 重置
  191. resetSearchForm () {
  192. this.queryParam = Object.assign({
  193. provinceSn: undefined,
  194. citySn: undefined,
  195. districtSn: undefined,
  196. subareaArea: {
  197. subareaSn: undefined,
  198. subareaAreaSn: undefined
  199. }
  200. }, this.snObj)
  201. this.queryParam.dealerName = undefined
  202. this.$refs.areaList.clearData()
  203. this.$refs.subarea.clearData()
  204. this.$refs.table.refresh(true)
  205. },
  206. // 导出
  207. handleExport () {
  208. const _this = this
  209. _this.exportLoading = true
  210. _this.spinning = true
  211. const ajaxExportName = this.queryParam.bannerSn ? shopBannerExport : dealerExport
  212. const exportName = this.queryParam.bannerSn ? '首页轮播图参与经销商列表导出' : '促销活动参与经销商列表导出'
  213. hdExportExcel(ajaxExportName, _this.queryParam, exportName, function () {
  214. _this.exportLoading = false
  215. _this.spinning = false
  216. _this.showExport = true
  217. })
  218. }
  219. },
  220. watch: {
  221. // 父页面传过来的弹框状态
  222. openModal (newValue, oldValue) {
  223. this.isShow = newValue
  224. },
  225. // 重定义的弹框状态
  226. isShow (newValue, oldValue) {
  227. if (!newValue) {
  228. this.$emit('close')
  229. this.resetSearchForm()
  230. }
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="less" scoped>
  236. .lookUpCustomers-modal{
  237. .ant-modal-body{
  238. padding: 0 24px 24px;
  239. }
  240. .redBg-row{
  241. background-color: #f5cdc8;
  242. }
  243. .btn-cont {
  244. text-align: center;
  245. margin: 5px 0 10px;
  246. }
  247. .table-page-search-wrapper{
  248. margin-bottom:6px;
  249. /deep/.ant-select-selection{
  250. border:0 !important;
  251. box-shadow: none !important;
  252. }
  253. .ant-form.ant-form-inline .ant-form-item{
  254. border:1px solid #dadada;
  255. border-radius: 3px;
  256. overflow: hidden;
  257. margin-bottom: 10px!important;
  258. /deep/.ant-form-item-label{
  259. padding-left: 11px !important;
  260. padding-right: 0!important;
  261. }
  262. }
  263. }
  264. }
  265. </style>