list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="merchantInfoManagementList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="区域">
  10. <subarea id="merchantInfoManagementList-subarea" ref="subarea" @change="subareaChange"></subarea>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="经销商名称/商户别名">
  15. <a-input id="merchantInfoManagementList-nameLike" v-model.trim="queryParam.nameLike" allowClear placeholder="请输入商户名称/别名"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="商户类型">
  20. <dealerType id="merchantInfoManagementList-dealerType" changeOnSelect v-model="dealerType" @change="getDealerType" allowClear></dealertype>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="商户级别">
  25. <v-select code="DEALER_LEVEL" id="merchantInfoManagementList-dealerLevel" v-model="queryParam.dealerLevel" allowClear placeholder="请选择商户级别"></v-select>
  26. </a-form-item>
  27. </a-col>
  28. <template v-if="advanced">
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="审核状态">
  31. <v-select code="AUDIT_STATE" id="merchantInfoManagementList-auditState" v-model="queryParam.auditState" allowClear placeholder="请选择审核状态"></v-select>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="合作状态">
  36. <v-select code="DEALER_COOPERATE_FLAG" id="merchantInfoManagementList-cooperateFlag" v-model="queryParam.cooperateFlag" allowClear placeholder="请选择合作状态"></v-select>
  37. </a-form-item>
  38. </a-col>
  39. </template>
  40. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  41. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="merchantInfoManagementList-refresh">查询</a-button>
  42. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="merchantInfoManagementList-reset">重置</a-button>
  43. <a-button
  44. style="margin-left: 5px"
  45. type="primary"
  46. v-if="$hasPermissions('B_merchantInfo_export')"
  47. class="button-warning"
  48. @click="handleExport"
  49. :disabled="disabled"
  50. :loading="exportLoading"
  51. id="merchantInfoManagementList-export">导出</a-button>
  52. <a @click="advanced=!advanced" style="margin-left: 5px" id="merchantInfoManagementList-advanced">
  53. {{ advanced ? '收起' : '展开' }}
  54. <a-icon :type="advanced ? 'up' : 'down'"/>
  55. </a>
  56. </a-col>
  57. </a-row>
  58. </a-form>
  59. </div>
  60. </a-card>
  61. <a-card size="small" :bordered="false">
  62. <a-spin :spinning="spinning" tip="Loading...">
  63. <!-- 操作按钮 -->
  64. <div class="table-operator">
  65. <a-button id="merchantInfoManagementList-add" type="primary" v-if="$hasPermissions('B_merchantInfo_add')" @click="handleAdd">新增</a-button>
  66. </div>
  67. <!-- 列表 -->
  68. <s-table
  69. class="sTable fixPagination"
  70. ref="table"
  71. :style="{ height: tableHeight+70+'px' }"
  72. size="small"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ y: tableHeight }"
  77. :defaultLoadData="false"
  78. bordered>
  79. <!-- 经销商 -->
  80. <template slot="dealerName" slot-scope="text, record">
  81. <span v-if="$hasPermissions('B_merchantInfo_detail')" :id="'merchantInfoManagementList-dealerName'+record.id" :title="record.dealerName" class="link-bule" @click="handleDetail(record)">{{ record.dealerName }}</span>
  82. <span v-else :title="record.dealerName">{{ record.dealerName }}</span>
  83. </template>
  84. <!-- 操作 -->
  85. <template slot="action" slot-scope="text, record">
  86. <a-button
  87. size="small"
  88. :id="'merchantInfoManagementList-audit-btn'+record.id"
  89. type="link"
  90. class="button-warning"
  91. v-if="record.auditState == 'WAIT' && $hasPermissions('B_merchantInfo_audit')"
  92. @click="handleAudit(record)" >审核</a-button>
  93. <a-button
  94. size="small"
  95. :id="'merchantInfoManagementList-cooperation-btn'+record.id"
  96. type="link"
  97. class="button-info"
  98. v-if="$hasPermissions('B_merchantInfo_cooperation')"
  99. @click="handleCooperation(record)" >合作设置</a-button>
  100. <a-button
  101. size="small"
  102. :id="'merchantInfoManagementList-level-btn'+record.id"
  103. type="link"
  104. class="button-primary"
  105. v-if="$hasPermissions('B_merchantInfo_level')"
  106. @click="handleLevel(record)">级别设置</a-button>
  107. <a-button
  108. size="small"
  109. :id="'merchantInfoManagementList-edit-btn'+record.id"
  110. type="link"
  111. class="button-info"
  112. v-if="$hasPermissions('B_merchantInfo_edit')"
  113. @click="handleEdit(record)">编辑</a-button>
  114. <br>
  115. <a-button
  116. size="small"
  117. :id="'merchantInfoManagementList-price-btn'+record.id"
  118. type="link"
  119. class="button-error"
  120. v-if="record.auditState != 'WAIT'&&record.dealerLevel && $hasPermissions('B_merchantInfo_priceSpread')"
  121. @click="handlePriceSpread(record)">差价</a-button>
  122. <a-button
  123. size="small"
  124. :id="'merchantInfoManagementList-power-btn'+record.id"
  125. type="link"
  126. class="button-error"
  127. v-if="record.auditState != 'WAIT'&&record.dealerLevel && $hasPermissions('B_merchantInfo_distribution')"
  128. @click="handleDistribution(record)">经销权</a-button>
  129. <span v-if="!(record.auditState == 'WAIT' && $hasPermissions('B_merchantInfo_audit')) && !$hasPermissions('B_merchantInfo_cooperation') && !(record.auditState != 'WAIT' && $hasPermissions('B_merchantInfo_distribution')) && !$hasPermissions('B_merchantInfo_level') && !$hasPermissions('B_merchantInfo_edit')">--</span>
  130. </template>
  131. </s-table>
  132. </a-spin>
  133. <!-- 产品详情 -->
  134. <merchant-info-management-detail-modal
  135. v-drag
  136. :openModal="openModal"
  137. :isAudit="isAudit"
  138. :itemId="itemId"
  139. @ok="resetForm"
  140. @close="closeModal" />
  141. <!-- 合作设置 -->
  142. <UpdateCooperate ref="updateCooperate" v-drag :openUcModal="openUcModal" @ok="resetForm" @close="openUcModal=false"></UpdateCooperate>
  143. <!-- 级别设置 -->
  144. <UpdateDealerLeve ref="updateDealerLevel" v-drag :openUdModal="openUdModal" @ok="resetForm" @close="openUdModal=false"></UpdateDealerLeve>
  145. </a-card>
  146. </div>
  147. </template>
  148. <script>
  149. import { commonMixin } from '@/utils/mixin'
  150. import moment from 'moment'
  151. // 组件
  152. import { STable, VSelect } from '@/components'
  153. import subarea from '@/views/common/subarea.js'
  154. import merchantInfoManagementDetailModal from './detailModal.vue'
  155. import UpdateCooperate from './updateCooperate.vue'
  156. import UpdateDealerLeve from './updateDealerLevel.vue'
  157. import dealerType from '@/views/common/dealerType.js'
  158. // 接口
  159. import { dealerQueryList, dealerExport } from '@/api/dealer'
  160. export default {
  161. name: 'MerchantInfoManagementList',
  162. mixins: [commonMixin],
  163. components: { STable, VSelect, merchantInfoManagementDetailModal, subarea, UpdateCooperate, UpdateDealerLeve, dealerType },
  164. data () {
  165. return {
  166. spinning: false,
  167. advanced: true, // 高级搜索 展开/关闭
  168. tableHeight: 0, // 表格高度
  169. dealerType: [], // 所选商户类型 列表
  170. queryParam: { // 查询条件
  171. nameLike: '', // 商户名称、别名
  172. dealerType1: undefined, // 商户类型
  173. dealerType2: undefined, // 商户类型
  174. dealerLevel: undefined, // 商户级别
  175. subareaArea: {
  176. subareaSn: undefined, // 区域
  177. subareaAreaSn: undefined // 分区
  178. },
  179. auditState: undefined, // 审核状态
  180. cooperateFlag: undefined // 合作状态
  181. },
  182. disabled: false, // 查询、重置按钮是否可操作
  183. exportLoading: false, // 导出loading
  184. dateFormat: 'YYYY-MM-DD', // 日期显示格式
  185. total: 0, // 总计
  186. columns: [
  187. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  188. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '商户名称', scopedSlots: { customRender: 'dealerName' }, width: '12%', align: 'left' },
  192. { title: '商户别名', dataIndex: 'dealerAlias', width: '12%', align: 'left', customRender: function (text) { return text || '--' } },
  193. { title: '商户类型', dataIndex: 'dealerTypeName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '联系人', dataIndex: 'contact', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '联系电话', dataIndex: 'dealerTelephone', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  197. { title: '绑定手机号码', dataIndex: 'managerMobile', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '审核状态', dataIndex: 'auditStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  199. { title: '合作状态', dataIndex: 'cooperateFlagDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  200. { title: '生效时间', dataIndex: 'cooperateEffectiveTime', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '操作', scopedSlots: { customRender: 'action' }, width: '12%', align: 'center' }
  202. ],
  203. // 加载数据方法 必须为 Promise 对象
  204. loadData: parameter => {
  205. this.disabled = true
  206. this.spinning = true
  207. return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
  208. let data
  209. if (res.status == 200) {
  210. data = res.data
  211. // 计算表格序号
  212. const no = (data.pageNo - 1) * data.pageSize
  213. this.total = data.count || 0
  214. for (var i = 0; i < data.list.length; i++) {
  215. data.list[i].no = no + i + 1
  216. if (data.list[i].dealerTypeName1) {
  217. data.list[i].dealerTypeName = data.list[i].dealerTypeName1 + '>' + data.list[i].dealerTypeName2
  218. }
  219. }
  220. this.disabled = false
  221. }
  222. this.spinning = false
  223. return data
  224. })
  225. },
  226. openModal: false, // 查看详情 弹框
  227. openUcModal: false, // 合作设置 弹框
  228. openUdModal: false, // 级别设置 弹框
  229. itemId: '', // 当前商户sn
  230. isAudit: false// 是否显示审核按钮
  231. }
  232. },
  233. methods: {
  234. // 区域 change
  235. subareaChange (val) {
  236. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  237. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  238. },
  239. // 商户类型 change
  240. getDealerType (v, o) {
  241. this.queryParam.dealerType1 = v[0]
  242. this.queryParam.dealerType2 = v[1]
  243. },
  244. // 重置列表
  245. resetSearchForm () {
  246. this.dealerType = []
  247. this.queryParam = {
  248. nameLike: '', // 商户名称、别名
  249. dealerType1: undefined, // 商户类型
  250. dealerType2: undefined, // 商户类型
  251. dealerLevel: undefined, // 商户级别
  252. subareaArea: {
  253. subareaSn: undefined,
  254. subareaAreaSn: undefined
  255. },
  256. auditState: undefined, // 审核状态
  257. cooperateFlag: undefined // 合作状态
  258. }
  259. this.$refs.subarea.clearData()
  260. this.$refs.table.refresh(true)
  261. },
  262. // 刷新当前列表
  263. resetForm () {
  264. this.$refs.table.refresh()
  265. this.openModal = false
  266. this.isAudit = false
  267. this.openUcModal = false
  268. this.openUdModal = false
  269. },
  270. // 新增
  271. handleAdd () {
  272. this.$router.push({ name: `merchantInfoManagementAdd` })
  273. },
  274. // 编辑
  275. handleEdit (row) {
  276. this.$router.push({ name: `merchantInfoManagementEdit`, params: { id: row.dealerSn } })
  277. },
  278. // 合作设置
  279. handleCooperation (row) {
  280. this.$refs.updateCooperate.setData(row)
  281. this.openUcModal = true
  282. },
  283. // 价格级别
  284. handleLevel (row) {
  285. this.$refs.updateDealerLevel.setData(row)
  286. this.openUdModal = true
  287. },
  288. // 经销权
  289. handleDistribution (row) {
  290. this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn, name: row.dealerName, dealerLevel: row.dealerLevel } })
  291. },
  292. // 差价
  293. handlePriceSpread (row) {
  294. this.$router.push({ name: `rebateBinding`, params: { sn: row.dealerSn, name: row.dealerName } })
  295. },
  296. // 审核
  297. handleAudit (row) {
  298. this.itemId = row.dealerSn
  299. this.openModal = true
  300. this.isAudit = true
  301. },
  302. // 详情
  303. handleDetail (row) {
  304. this.itemId = row.dealerSn
  305. this.openModal = true
  306. this.isAudit = false
  307. },
  308. // 关闭弹框
  309. closeModal () {
  310. this.itemId = ''
  311. this.openModal = false
  312. },
  313. // 导出
  314. handleExport () {
  315. const _this = this
  316. const params = this.queryParam
  317. this.exportLoading = true
  318. _this.spinning = true
  319. dealerExport(params).then(res => {
  320. this.exportLoading = false
  321. _this.spinning = false
  322. if (res.type == 'application/json') {
  323. var reader = new FileReader()
  324. reader.addEventListener('loadend', function () {
  325. const obj = JSON.parse(reader.result)
  326. _this.$notification.error({
  327. message: '提示',
  328. description: obj.message
  329. })
  330. })
  331. reader.readAsText(res)
  332. } else {
  333. this.download(res)
  334. }
  335. })
  336. },
  337. // 导出成功
  338. download (data) {
  339. if (!data) { return }
  340. const url = window.URL.createObjectURL(new Blob([data]))
  341. const link = document.createElement('a')
  342. link.style.display = 'none'
  343. link.href = url
  344. const a = moment().format('YYYYMMDDHHmmss')
  345. const fname = '经销商资料' + a
  346. link.setAttribute('download', fname + '.xlsx')
  347. document.body.appendChild(link)
  348. link.click()
  349. },
  350. // 初始化
  351. pageInit () {
  352. const _this = this
  353. this.$nextTick(() => { // 页面渲染完成后的回调
  354. _this.setTableH()
  355. })
  356. },
  357. // 计算表格高度
  358. setTableH () {
  359. const tableSearchH = this.$refs.tableSearch.offsetHeight
  360. this.tableHeight = window.innerHeight - tableSearchH - 235
  361. }
  362. },
  363. watch: {
  364. // 展开关闭 监听表格高度变化
  365. advanced (newValue, oldValue) {
  366. const _this = this
  367. this.$nextTick(() => { // 页面渲染完成后的回调
  368. _this.setTableH()
  369. })
  370. },
  371. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  372. this.setTableH()
  373. }
  374. },
  375. mounted () {
  376. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  377. this.pageInit()
  378. this.resetSearchForm()
  379. }
  380. },
  381. activated () {
  382. // 如果是新页签打开,则重置当前页面
  383. if (this.$store.state.app.isNewTab) {
  384. this.pageInit()
  385. this.resetSearchForm()
  386. }
  387. // 仅刷新列表,不重置页面
  388. if (this.$store.state.app.updateList) {
  389. this.$refs.table.refresh()
  390. this.pageInit()
  391. }
  392. },
  393. beforeRouteEnter (to, from, next) {
  394. next(vm => {})
  395. }
  396. }
  397. </script>
  398. <style lang="less">
  399. .merchantInfoManagementList-wrap{
  400. .productPic{
  401. cursor: pointer;
  402. }
  403. }
  404. </style>