lookUpCustomersModal.vue 11 KB

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