lookUpCustomersModal.vue 13 KB

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