list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <a-card size="small" :bordered="false" class="merchantInfoManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div 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" v-model="queryParam.subareaSn"></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. <v-select code="DEALER_TYPE" id="merchantInfoManagementList-dealerType" v-model="queryParam.dealerType" allowClear placeholder="请选择商户类型"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="审核状态">
  26. <v-select code="AUDIT_STATE" id="merchantInfoManagementList-auditState" v-model="queryParam.auditState" allowClear placeholder="请选择审核状态"></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="合作状态">
  31. <v-select code="DEALER_COOPERATE_FLAG" id="merchantInfoManagementList-cooperateFlag" v-model="queryParam.cooperateFlag" allowClear placeholder="请选择合作状态"></v-select>
  32. </a-form-item>
  33. </a-col>
  34. </template>
  35. <a-col :md="6" :sm="24">
  36. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="merchantInfoManagementList-refresh">查询</a-button>
  37. <a-button style="margin: 0 0 18px 5px" @click="resetSearchForm" :disabled="disabled" id="merchantInfoManagementList-reset">重置</a-button>
  38. <a-button
  39. style="margin-left: 5px"
  40. type="primary"
  41. v-if="$hasPermissions('B_merchantInfo_export')"
  42. class="button-warning"
  43. @click="handleExport"
  44. :disabled="disabled"
  45. :loading="exportLoading"
  46. id="merchantInfoManagementList-export">导出</a-button>
  47. <a @click="advanced=!advanced" style="margin-left: 8px">
  48. {{ advanced ? '收起' : '展开' }}
  49. <a-icon :type="advanced ? 'up' : 'down'"/>
  50. </a>
  51. </a-col>
  52. </a-row>
  53. </a-form>
  54. </div>
  55. <!-- 操作按钮 -->
  56. <div class="table-operator">
  57. <a-button id="merchantInfoManagementList-add" type="primary" v-if="$hasPermissions('B_merchantInfo_add')" class="button-error" @click="handleAdd">新增</a-button>
  58. </div>
  59. <!-- 总计 -->
  60. <a-alert type="info" showIcon style="margin-bottom:15px">
  61. <div slot="message">合计:<strong>{{ total }}</strong>条</div>
  62. </a-alert>
  63. <!-- 列表 -->
  64. <s-table
  65. class="sTable"
  66. ref="table"
  67. size="default"
  68. :rowKey="(record) => record.id"
  69. :columns="columns"
  70. :data="loadData"
  71. :scroll="{ x: 2240, y: tableHeight }"
  72. bordered>
  73. <!-- 经销商 -->
  74. <template slot="dealerName" slot-scope="text, record">
  75. <span v-if="$hasPermissions('B_merchantInfo_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.dealerName }}</span>
  76. <span v-else>{{ record.dealerName }}</span>
  77. </template>
  78. <!-- 区域 -->
  79. <template slot="area" slot-scope="text, record">
  80. <div v-if="record.subareaNameSet&&record.subareaNameSet.length!=0">
  81. <span v-for="(item, index) in record.subareaNameSet" :key="index">{{ item }}{{ index+1 == record.subareaNameSet.length ? '' : ',' }}</span>
  82. </div>
  83. <span v-else>--</span>
  84. </template>
  85. <!-- 操作 -->
  86. <template slot="action" slot-scope="text, record">
  87. <a-button size="small" type="link" class="button-warning" v-if="record.auditState == 'WAIT' && $hasPermissions('B_merchantInfo_audit')" @click="handleAudit(record)" >审核</a-button>
  88. <a-button size="small" type="link" class="button-success" v-if="$hasPermissions('B_merchantInfo_cooperation')" @click="handleCooperation(record)" >合作设置</a-button>
  89. <a-button size="small" type="link" class="button-error" v-if="record.auditState != 'WAIT' && $hasPermissions('B_merchantInfo_distribution')" @click="handleDistribution(record)">经销权</a-button>
  90. <a-button size="small" type="link" class="button-primary" v-if="$hasPermissions('B_merchantInfo_level')" @click="handleLevel(record)">级别设置</a-button>
  91. <a-button size="small" type="link" class="button-info" v-if="$hasPermissions('B_merchantInfo_edit')" @click="handleEdit(record)">编辑</a-button>
  92. <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>
  93. </template>
  94. </s-table>
  95. </a-spin>
  96. <!-- 产品详情 -->
  97. <merchant-info-management-detail-modal :openModal="openModal" :isAudit="isAudit" :itemId="itemId" @ok="resetForm" @close="closeModal" />
  98. <!-- 合作设置 -->
  99. <UpdateCooperate ref="updateCooperate" :openUcModal="openUcModal" @ok="resetForm" @close="openUcModal=false"></UpdateCooperate>
  100. <!-- 级别设置 -->
  101. <UpdateDealerLeve ref="updateDealerLevel" :openUdModal="openUdModal" @ok="resetForm" @close="openUdModal=false"></UpdateDealerLeve>
  102. </a-card>
  103. </template>
  104. <script>
  105. import moment from 'moment'
  106. import { dealerQueryList, dealerExport } from '@/api/dealer'
  107. import { STable, VSelect } from '@/components'
  108. import subarea from '@/views/common/subarea.js'
  109. import merchantInfoManagementDetailModal from './detailModal.vue'
  110. import UpdateCooperate from './updateCooperate.vue'
  111. import UpdateDealerLeve from './updateDealerLevel.vue'
  112. export default {
  113. components: { STable, VSelect, merchantInfoManagementDetailModal, subarea, UpdateCooperate, UpdateDealerLeve },
  114. data () {
  115. return {
  116. spinning: false,
  117. advanced: false, // 高级搜索 展开/关闭
  118. tableHeight: 0,
  119. queryParam: { // 查询条件
  120. nameLike: '', // 商户名称、别名
  121. dealerType: undefined, // 商户类型
  122. subareaSn: undefined, // 区域
  123. auditState: undefined, // 审核状态
  124. cooperateFlag: undefined // 合作状态
  125. },
  126. disabled: false, // 查询、重置按钮是否可操作
  127. exportLoading: false, // 导出loading
  128. dateFormat: 'YYYY-MM-DD',
  129. total: 0,
  130. columns: [
  131. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  132. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  133. { title: '区域', scopedSlots: { customRender: 'area' }, width: 200, align: 'center' },
  134. { title: '商户名称', scopedSlots: { customRender: 'dealerName' }, align: 'center', ellipsis: true },
  135. { title: '商户别名', dataIndex: 'dealerAlias', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  136. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '联系人', dataIndex: 'contact', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  139. { title: '联系电话', dataIndex: 'dealerTelephone', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '绑定手机号码', dataIndex: 'managerMobile', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '审核状态', dataIndex: 'auditStateDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '合作状态', dataIndex: 'cooperateFlagDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '生效时间', dataIndex: 'cooperateEffectiveTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center', fixed: 'right' }
  145. ],
  146. loading: false,
  147. // 加载数据方法 必须为 Promise 对象
  148. loadData: parameter => {
  149. this.disabled = true
  150. if (this.tableHeight == 0) {
  151. this.tableHeight = window.innerHeight - 440
  152. }
  153. return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
  154. const data = res.data
  155. const no = (data.pageNo - 1) * data.pageSize
  156. this.total = data.count
  157. for (var i = 0; i < data.list.length; i++) {
  158. data.list[i].no = no + i + 1
  159. }
  160. this.disabled = false
  161. return data
  162. })
  163. },
  164. openModal: false, // 查看详情 弹框
  165. openUcModal: false, // 合作设置 弹框
  166. openUdModal: false, // 级别设置 弹框
  167. itemId: '', // 当前商户sn
  168. isAudit: false
  169. }
  170. },
  171. methods: {
  172. // 重置列表
  173. resetSearchForm () {
  174. this.queryParam = {
  175. nameLike: '', // 商户名称、别名
  176. dealerType: undefined, // 商户类型
  177. subareaSn: undefined, // 区域
  178. auditState: undefined, // 审核状态
  179. cooperateFlag: undefined // 合作状态
  180. }
  181. this.$refs.table.refresh(true)
  182. },
  183. // 刷新当前列表
  184. resetForm () {
  185. this.$refs.table.refresh()
  186. this.openModal = false
  187. this.isAudit = false
  188. this.openUcModal = false
  189. this.openUdModal = false
  190. },
  191. // 新增
  192. handleAdd () {
  193. this.$router.push({ name: `merchantInfoManagementAdd` })
  194. },
  195. // 编辑
  196. handleEdit (row) {
  197. this.$router.push({ name: `merchantInfoManagementEdit`, params: { id: row.dealerSn } })
  198. },
  199. // 合作设置
  200. handleCooperation (row) {
  201. this.$refs.updateCooperate.setData(row)
  202. this.openUcModal = true
  203. },
  204. // 价格级别
  205. handleLevel (row) {
  206. this.$refs.updateDealerLevel.setData(row)
  207. this.openUdModal = true
  208. },
  209. // 经销权
  210. handleDistribution (row) {
  211. this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn } })
  212. },
  213. // 审核
  214. handleAudit (row) {
  215. this.itemId = row.dealerSn
  216. this.openModal = true
  217. this.isAudit = true
  218. },
  219. // 详情
  220. handleDetail (row) {
  221. this.itemId = row.dealerSn
  222. this.openModal = true
  223. this.isAudit = false
  224. },
  225. // 关闭弹框
  226. closeModal () {
  227. this.itemId = ''
  228. this.openModal = false
  229. },
  230. // 导出
  231. handleExport () {
  232. const _this = this
  233. const params = this.queryParam
  234. this.exportLoading = true
  235. _this.spinning = true
  236. dealerExport(params).then(res => {
  237. this.exportLoading = false
  238. _this.spinning = false
  239. if (res.type == 'application/json') {
  240. var reader = new FileReader()
  241. reader.addEventListener('loadend', function () {
  242. const obj = JSON.parse(reader.result)
  243. _this.$notification.error({
  244. message: '提示',
  245. description: obj.message
  246. })
  247. })
  248. reader.readAsText(res)
  249. } else {
  250. this.download(res)
  251. }
  252. })
  253. },
  254. download (data) {
  255. if (!data) { return }
  256. const url = window.URL.createObjectURL(new Blob([data]))
  257. const link = document.createElement('a')
  258. link.style.display = 'none'
  259. link.href = url
  260. const a = moment().format('YYYYMMDDHHmmss')
  261. const fname = '经销商资料' + a
  262. link.setAttribute('download', fname + '.xlsx')
  263. document.body.appendChild(link)
  264. link.click()
  265. }
  266. },
  267. beforeRouteEnter (to, from, next) {
  268. next(vm => {
  269. })
  270. }
  271. }
  272. </script>
  273. <style lang="less">
  274. .merchantInfoManagementList-wrap{
  275. .productPic{
  276. cursor: pointer;
  277. }
  278. }
  279. </style>