relatedDealersList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="relatedDealersList-wrap">
  3. <div ref="headerBar">
  4. <a-page-header :ghost="false" :backIcon="false" class="header-bar">
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span class="subTitle-word text-overflow" style="max-width:300px;margin-left:15px;">省仓名称:{{ $route.params.name ||'--' }}</span>
  9. </template>
  10. </a-page-header>
  11. </div>
  12. <a-card size="small" :bordered="false" class="relatedDealersList-cont">
  13. <a-tabs v-model="activeKeyVal">
  14. <a-tab-pane key="1" tab="设置供应商">
  15. <a-spin :spinning="spinning" tip="Loading...">
  16. <!-- 筛选条件 -->
  17. <div class="table-page-search-wrapper">
  18. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  19. <a-row :gutter="15">
  20. <a-col :md="6" :sm="24">
  21. <a-form-model-item label="地区">
  22. <AreaList id="actualSalesReportList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="区域/分区">
  27. <subarea ref="subarea" id="relatedDealersList-subarea" @change="subareaChange"></subarea>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="经销商名称">
  32. <a-input id="relatedDealersList-purchaseBillNo" v-model.trim="queryParam.nameLike" allowClear placeholder="请输入经销商名称"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  36. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="inventoryCheckMakeInventoryList-refresh">查询</a-button>
  37. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryCheckMakeInventoryList-reset">重置</a-button>
  38. <a-button
  39. style="margin-left: 10px"
  40. type="primary"
  41. class="button-warning"
  42. @click="handleExport"
  43. :disabled="disabled"
  44. :loading="exportLoading"
  45. >导出</a-button>
  46. </a-col>
  47. </a-row>
  48. </a-form>
  49. </div>
  50. <div class="relatedDealersList-btn" style="margin-bottom:10px;">
  51. <a-button type="primary" class="button-info" @click="openDealersModal">新增经销商</a-button>
  52. </div>
  53. <!-- 列表 -->
  54. <s-table
  55. class="sTable"
  56. ref="table"
  57. size="small"
  58. :rowKey="(record) => record.dealerSn"
  59. rowKeyName="dealerSn"
  60. :columns="columns"
  61. :data="loadData"
  62. :defaultLoadData="false"
  63. :style="{ height: tableHeight+70+'px' }"
  64. :scroll="{ y: tableHeight }"
  65. :rowClassName="(record, index) => record.checkProfitLossQty < 0 ? 'redBg-row':''"
  66. bordered>
  67. <!-- 地区 -->
  68. <template slot="address" slot-scope="text, record">
  69. {{ record.provinceName }}/{{ record.cityName }}/{{ record.districtName }}
  70. </template>
  71. <!-- 操作 -->
  72. <template slot="action" slot-scope="text, record">
  73. <a-button
  74. size="small"
  75. type="link"
  76. v-if="$hasPermissions('B_dealerAccount_edit')"
  77. class="button-info"
  78. @click="handleDelete(record)"
  79. id="provincialWarehouse-edit-btn">解绑</a-button>
  80. <span v-else>--</span>
  81. </template>
  82. </s-table>
  83. </a-spin>
  84. </a-tab-pane>
  85. </a-tabs>
  86. </a-card>
  87. <!-- 关联经销商 -->
  88. <a-drawer
  89. title="选择经销商"
  90. placement="right"
  91. closable
  92. :visible="openDealerModal"
  93. class="lookUpCustomers-modal"
  94. @close="closeDealerModal"
  95. width="72%"
  96. >
  97. <div class="dealerModalCon">
  98. <chooseDealer ref="dealerChoose" :itemSn="$route.params.sn" @plAdd="handleAddDealer"></chooseDealer>
  99. </div>
  100. </a-drawer>
  101. </div>
  102. </template>
  103. <script>
  104. import { commonMixin } from '@/utils/mixin'
  105. import { STable } from '@/components'
  106. import chooseDealer from './chooseDealer.vue'
  107. import subarea from '@/views/common/subarea.js'
  108. import AreaList from '@/views/common/areaList.js'
  109. import { hdExportExcel } from '@/libs/exportExcel'
  110. import { queryServiceCenterDealerPage, serviceCenterBinding, serviceCenterUnbinding, serviceCenterExport } from '@/api/serviceCenter'
  111. export default {
  112. name: 'LookUpCustomers',
  113. mixins: [commonMixin],
  114. components: { STable, chooseDealer, subarea, AreaList },
  115. data () {
  116. return {
  117. spinning: false,
  118. isShow: this.openModal, // 是否打开弹框
  119. disabled: false,
  120. exportLoading: false,
  121. queryParam: {
  122. subareaSn: undefined,
  123. subareaAreaSn: undefined,
  124. provinceSn: undefined,
  125. citySn: undefined,
  126. districtSn: undefined,
  127. nameLike: '',
  128. relationType: 'PURCHASE'
  129. },
  130. tableHeight: 0,
  131. activeKeyVal: '1',
  132. // 加载数据方法 必须为 Promise 对象
  133. loadData: parameter => {
  134. this.disabled = true
  135. this.spinning = true
  136. return queryServiceCenterDealerPage(Object.assign(parameter, this.queryParam)).then(res => {
  137. let data
  138. if (res.status == 200) {
  139. data = res.data
  140. const no = (data.pageNo - 1) * data.pageSize
  141. for (var i = 0; i < data.list.length; i++) {
  142. data.list[i].no = no + i + 1
  143. data.list[i].loginFlag = Number(data.list[i].loginFlag)
  144. }
  145. this.disabled = false
  146. }
  147. this.spinning = false
  148. return data
  149. })
  150. },
  151. columns: [
  152. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  153. { title: '地区', scopedSlots: { customRender: 'address' }, width: '20%', align: 'center', ellipsis: true },
  154. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '经销商名称', dataIndex: 'dealerName', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  157. { title: '商户类型', dataIndex: 'dealerLevelDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '商户级别', dataIndex: 'dealerTypeDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  160. ],
  161. openDealerModal: false
  162. }
  163. },
  164. methods: {
  165. // 打开经销商弹窗
  166. openDealersModal () {
  167. this.openDealerModal = true
  168. this.$nextTick(() => {
  169. this.$refs.dealerChoose.pageInit()
  170. })
  171. },
  172. // 关闭关联经销商弹窗
  173. closeDealerModal () {
  174. this.openDealerModal = false
  175. this.$refs.dealerChoose.clearSelect()
  176. },
  177. // 关联经销商
  178. handleAddDealer (list) {
  179. this.spinning = true
  180. const params = {
  181. serviceCenterSn: this.$route.params.sn,
  182. dealerList: list
  183. }
  184. serviceCenterBinding(params).then(res => {
  185. if (res.status == 200) {
  186. this.$message.success(res.message)
  187. }
  188. this.spinning = false
  189. this.closeDealerModal()
  190. this.$refs.table.refresh()
  191. })
  192. },
  193. areaChange (val) {
  194. this.queryParam.provinceSn = val[0] ? val[0] : ''
  195. this.queryParam.citySn = val[1] ? val[1] : ''
  196. this.queryParam.districtSn = val[2] ? val[2] : ''
  197. },
  198. subareaChange (val) {
  199. this.queryParam.subareaSn = val[0] ? val[0] : undefined
  200. this.queryParam.subareaAreaSn = val[1] ? val[1] : undefined
  201. },
  202. // 解绑
  203. handleDelete (row) {
  204. const _this = this
  205. this.$confirm({
  206. title: '提示',
  207. content: '解绑后,该经销商无法向省仓采购,确定解绑吗?',
  208. centered: true,
  209. onOk () {
  210. const ajaxData = {
  211. serviceCenterSn: _this.$route.params.sn,
  212. dealerSn: row.dealerSn
  213. }
  214. _this.submitDel(ajaxData)
  215. }
  216. })
  217. },
  218. submitDel (params) {
  219. this.spinning = true
  220. serviceCenterUnbinding(params).then(res => {
  221. if (res.status == 200) {
  222. this.$message.success('解绑成功')
  223. this.$refs.table.refresh(true)
  224. }
  225. this.spinning = false
  226. })
  227. },
  228. // 重置
  229. resetSearchForm () {
  230. this.queryParam = {
  231. subareaSn: undefined,
  232. subareaAreaSn: undefined,
  233. provinceSn: undefined,
  234. citySn: undefined,
  235. districtSn: undefined,
  236. nameLike: '',
  237. serviceCenterSn: this.$route.params.sn,
  238. relationType: 'PURCHASE'
  239. }
  240. this.$refs.areaList.clearData()
  241. this.$refs.subarea.clearData()
  242. this.$refs.table.refresh()
  243. },
  244. // 导出
  245. handleExport () {
  246. const _this = this
  247. _this.exportLoading = true
  248. _this.spinning = true
  249. _this.queryParam.serviceCenterName = this.$route.params.name
  250. hdExportExcel(serviceCenterExport, _this.queryParam, '省仓客户列表导出', function () {
  251. _this.exportLoading = false
  252. _this.spinning = false
  253. })
  254. },
  255. // 返回
  256. handleBack () {
  257. this.$router.push({ name: 'provincialWarehouseList' })
  258. },
  259. pageInit () {
  260. const _this = this
  261. this.$nextTick(() => { // 页面渲染完成后的回调
  262. _this.setTableH()
  263. })
  264. _this.resetSearchForm()
  265. },
  266. setTableH () {
  267. const headHeight = this.$refs.headerBar.offsetHeight
  268. this.tableHeight = window.innerHeight - headHeight - 340
  269. }
  270. },
  271. watch: {
  272. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  273. this.setTableH()
  274. }
  275. },
  276. activated () {
  277. this.pageInit()
  278. },
  279. beforeRouteEnter (to, from, next) {
  280. next(vm => {})
  281. }
  282. }
  283. </script>
  284. <style lang="less" scoped>
  285. .relatedDealersList-wrap{
  286. .table-operator{
  287. text-align:right;
  288. }
  289. }
  290. </style>