lookUpCustomersModal.vue 12 KB

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