lookUpCustomersModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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" @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="actualSalesReportList-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="salesManagementList-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="salesManagementList-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="inventoryCheckMakeInventoryList-refresh">查询</a-button>
  34. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckMakeInventoryList-reset">重置</a-button>
  35. <a-button
  36. style="margin-left: 10px"
  37. type="primary"
  38. class="button-warning"
  39. @click="handleExport"
  40. :disabled="disabled"
  41. :loading="exportLoading"
  42. >导出</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.dealerSn"
  53. rowKeyName="dealerSn"
  54. :columns="columns"
  55. :data="loadData"
  56. :defaultLoadData="false"
  57. :scroll="{ y: 450 }"
  58. :rowClassName="(record, index) => record.dataActType ==='CREATE'? 'fontRed':record.dataActType ==='DELETE'?'fontGreen':''"
  59. bordered>
  60. <!-- 地区 -->
  61. <template slot="address" slot-scope="text, record">
  62. {{ record.provinceName }}/{{ record.cityName }}/{{ record.districtName }}
  63. </template>
  64. </s-table>
  65. </a-card>
  66. <div class="btn-cont" v-if="showType ==='isEdit'">
  67. <a-button type="primary" class="button-warning" @click="editDealerModal">修改</a-button>
  68. <a-button type="primary" style="margin-left: 15px;" :loading="spinning" id="promotion-modal-save" @click="submitAudit">提交审核</a-button>
  69. </div>
  70. <div class="btn-cont" v-if="showType === 'isAudit'&& $hasPermissions('B_dealerAudit') ">
  71. <a-button @click="handleAudit('AUDIT_REJECT')">审核不通过</a-button>
  72. <a-button type="primary" style="margin-left: 15px;" :loading="spinning" id="promotion-modal-save" @click="handleAudit('AUDIT_PASS')">审核通过</a-button>
  73. </div>
  74. <div class="btn-cont" v-if="showType === 'isAudit' && !$hasPermissions('B_dealerAudit')">
  75. <a-button id="lookUpCustomers-modal-back" @click="isShow = false">关闭</a-button>
  76. </div>
  77. <div class="btn-cont" v-if="showType === 'isClose'">
  78. <a-button id="lookUpCustomers-modal-back" @click="isShow = false">关闭</a-button>
  79. </div>
  80. </a-spin>
  81. <!-- 选择参与客户 -->
  82. <a-modal
  83. title="选择经销商"
  84. :visible="openDealerModal"
  85. :footer="null"
  86. centered
  87. class="lookUpCustomers-modal"
  88. @cancel="openDealerModal = false"
  89. width="60%"
  90. >
  91. <div class="dealerModalCon">
  92. <chooseDealer ref="dealerChoose" @plAdd="handleAddDealer"></chooseDealer>
  93. </div>
  94. </a-modal>
  95. </a-modal>
  96. </template>
  97. <script>
  98. import { commonMixin } from '@/utils/mixin'
  99. import { STable } from '@/components'
  100. import subarea from '@/views/common/subarea.js'
  101. import AreaList from '@/views/common/areaList.js'
  102. import { hdExportExcel } from '@/libs/exportExcel'
  103. import { dealerExport } from '@/api/promoTerminal'
  104. import { queryAuditPageList, dealerMidwayUpdate } from '@/api/promotion'
  105. import chooseDealer from './chooseDealer'
  106. export default {
  107. name: 'LookUpCustomersModal',
  108. components: { STable, subarea, AreaList, chooseDealer },
  109. mixins: [commonMixin],
  110. props: {
  111. openModal: { // 弹框显示状态
  112. type: Boolean,
  113. default: false
  114. },
  115. itemSn: {// 促销sn
  116. type: String,
  117. default: ''
  118. },
  119. showType: {
  120. type: String,
  121. default: ''
  122. },
  123. chooseDealerList: {
  124. type: Array,
  125. default: () => {
  126. return []
  127. }
  128. }
  129. },
  130. data () {
  131. return {
  132. spinning: false,
  133. isShow: this.openModal, // 是否打开弹框
  134. disabled: false,
  135. exportLoading: false,
  136. queryParam: {
  137. subareaArea: {
  138. subareaSn: undefined,
  139. subareaAreaSn: undefined
  140. },
  141. provinceSn: undefined,
  142. citySn: undefined,
  143. districtSn: undefined,
  144. dealerName: undefined
  145. },
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. this.spinning = true
  150. this.queryParam.promotionSn = this.itemSn
  151. const params = Object.assign(parameter, this.queryParam)
  152. return queryAuditPageList(params).then(res => {
  153. let data
  154. if (res.status == 200) {
  155. data = res.data
  156. const no = (data.pageNo - 1) * data.pageSize
  157. for (var i = 0; i < data.list.length; i++) {
  158. data.list[i].no = no + i + 1
  159. }
  160. this.disabled = false
  161. }
  162. this.spinning = false
  163. return data
  164. })
  165. },
  166. columns: [
  167. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  168. { title: '地区', scopedSlots: { customRender: 'address' }, width: '20%', align: 'center', ellipsis: true },
  169. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '经销商名称', dataIndex: 'dealerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  172. { title: '商户类型', dataIndex: 'dealerLevelDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  173. { title: '商户级别', dataIndex: 'dealerTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  174. ],
  175. openDealerModal: false, // 修改弹窗
  176. updateFlag: false
  177. }
  178. },
  179. methods: {
  180. // 修改参与客户
  181. editDealerModal () {
  182. const _this = this
  183. _this.openDealerModal = true
  184. const arr = _this.chooseDealerList
  185. // 选择参与客户回显
  186. _this.$nextTick(() => {
  187. _this.$refs.dealerChoose.pageInit(arr)
  188. })
  189. },
  190. // 添加经销商
  191. handleAddDealer (list) {
  192. const newArr = []
  193. list.forEach(item => {
  194. const obj = {
  195. dealerScope: this.itemSn ? 'SOME_DEALER' : 'ALL_DEALER',
  196. promotionSn: this.itemSn ? this.itemSn : undefined,
  197. dealerSn: item.dealerSn
  198. }
  199. newArr.push(obj)
  200. })
  201. this.openDealerModal = false
  202. this.updateDataList(newArr)
  203. },
  204. // 更新列表显示状态
  205. updateDataList (list) {
  206. const ajaxData = {
  207. promotionSn: this.itemSn ? this.itemSn : undefined,
  208. promotionDealerList: list
  209. }
  210. dealerMidwayUpdate(ajaxData).then(res => {
  211. if (res.status == 200) {
  212. this.$message.success(res.message)
  213. this.$refs.table.refresh()
  214. }
  215. })
  216. },
  217. areaChange (val) {
  218. this.queryParam.provinceSn = val[0] ? val[0] : ''
  219. this.queryParam.citySn = val[1] ? val[1] : ''
  220. this.queryParam.districtSn = val[2] ? val[2] : ''
  221. },
  222. subareaChange (val) {
  223. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  224. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  225. },
  226. // 重置
  227. resetSearchForm () {
  228. this.queryParam = Object.assign({
  229. provinceSn: undefined,
  230. citySn: undefined,
  231. districtSn: undefined,
  232. subareaArea: {
  233. subareaSn: undefined,
  234. subareaAreaSn: undefined
  235. }
  236. }, this.snObj)
  237. this.queryParam.dealerName = undefined
  238. this.updateFlag = false
  239. this.$refs.areaList.clearData()
  240. this.$refs.subarea.clearData()
  241. this.$refs.table.clearTable()
  242. },
  243. // 导出
  244. handleExport () {
  245. const _this = this
  246. _this.exportLoading = true
  247. _this.spinning = true
  248. hdExportExcel(dealerExport, _this.queryParam, '促销经销商列表导出', function () {
  249. _this.exportLoading = false
  250. _this.spinning = false
  251. _this.showExport = true
  252. })
  253. },
  254. // 提交审核
  255. submitAudit () {
  256. this.$emit('submitAudit')
  257. this.isShow = false
  258. },
  259. handleAudit (statusInfo) {
  260. this.$emit('handleAudit', statusInfo)
  261. this.isShow = false
  262. }
  263. },
  264. watch: {
  265. // 父页面传过来的弹框状态
  266. openModal (newValue, oldValue) {
  267. this.isShow = newValue
  268. },
  269. // 重定义的弹框状态
  270. isShow (newValue, oldValue) {
  271. if (!newValue) {
  272. this.$emit('close')
  273. this.resetSearchForm()
  274. } else {
  275. console.log('this.showType', this.showType)
  276. this.$nextTick(() => {
  277. this.$refs.table.refresh(true)
  278. })
  279. }
  280. }
  281. }
  282. }
  283. </script>
  284. <style lang="less" scoped>
  285. .lookUpCustomers-modal{
  286. .ant-modal-body{
  287. padding: 0 24px 24px;
  288. }
  289. .redBg-row{
  290. background-color: #f5cdc8;
  291. }
  292. .btn-cont {
  293. text-align: center;
  294. margin: 5px 0 10px;
  295. }
  296. .table-page-search-wrapper{
  297. margin-bottom:6px;
  298. /deep/.ant-select-selection{
  299. border:0 !important;
  300. box-shadow: none !important;
  301. }
  302. .ant-form.ant-form-inline .ant-form-item{
  303. border:1px solid #dadada;
  304. border-radius: 3px;
  305. overflow: hidden;
  306. margin-bottom: 10px!important;
  307. /deep/.ant-form-item-label{
  308. padding-left: 11px !important;
  309. padding-right: 0!important;
  310. }
  311. }
  312. }
  313. /deep/.fontRed{
  314. color:red;
  315. }
  316. /deep/.fontGreen{
  317. color:green;
  318. }
  319. }
  320. </style>