list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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" style="margin-bottom: 10px;">
  36. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="merchantInfoManagementList-refresh">查询</a-button>
  37. <a-button style="margin-left: 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: 5px">
  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" 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="small"
  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: true, // 高级搜索 展开/关闭
  118. queryParam: { // 查询条件
  119. nameLike: '', // 商户名称、别名
  120. dealerType: undefined, // 商户类型
  121. subareaSn: undefined, // 区域
  122. auditState: undefined, // 审核状态
  123. cooperateFlag: undefined // 合作状态
  124. },
  125. disabled: false, // 查询、重置按钮是否可操作
  126. exportLoading: false, // 导出loading
  127. dateFormat: 'YYYY-MM-DD',
  128. total: 0,
  129. columns: [
  130. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  131. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '区域', scopedSlots: { customRender: 'area' }, width: 200, align: 'center' },
  133. { title: '商户名称', scopedSlots: { customRender: 'dealerName' }, align: 'center', ellipsis: true },
  134. { title: '商户别名', dataIndex: 'dealerAlias', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  135. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  136. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '联系人', dataIndex: 'contact', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  138. { title: '联系电话', dataIndex: 'dealerTelephone', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '绑定手机号码', dataIndex: 'managerMobile', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '审核状态', dataIndex: 'auditStateDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '合作状态', dataIndex: 'cooperateFlagDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '生效时间', dataIndex: 'cooperateEffectiveTime', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '操作', scopedSlots: { customRender: 'action' }, width: 240, align: 'center', fixed: 'right' }
  144. ],
  145. loading: false,
  146. // 加载数据方法 必须为 Promise 对象
  147. loadData: parameter => {
  148. this.disabled = true
  149. return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
  150. const data = res.data
  151. const no = (data.pageNo - 1) * data.pageSize
  152. this.total = data.count || 0
  153. for (var i = 0; i < data.list.length; i++) {
  154. data.list[i].no = no + i + 1
  155. }
  156. this.disabled = false
  157. return data
  158. })
  159. },
  160. openModal: false, // 查看详情 弹框
  161. openUcModal: false, // 合作设置 弹框
  162. openUdModal: false, // 级别设置 弹框
  163. itemId: '', // 当前商户sn
  164. isAudit: false
  165. }
  166. },
  167. computed: {
  168. tableHeight () {
  169. return window.innerHeight - (this.advanced ? 330 : 290)
  170. }
  171. },
  172. methods: {
  173. // 重置列表
  174. resetSearchForm () {
  175. this.queryParam = {
  176. nameLike: '', // 商户名称、别名
  177. dealerType: undefined, // 商户类型
  178. subareaSn: undefined, // 区域
  179. auditState: undefined, // 审核状态
  180. cooperateFlag: undefined // 合作状态
  181. }
  182. this.$refs.table.refresh(true)
  183. },
  184. // 刷新当前列表
  185. resetForm () {
  186. this.$refs.table.refresh()
  187. this.openModal = false
  188. this.isAudit = false
  189. this.openUcModal = false
  190. this.openUdModal = false
  191. },
  192. // 新增
  193. handleAdd () {
  194. this.$router.push({ name: `merchantInfoManagementAdd` })
  195. },
  196. // 编辑
  197. handleEdit (row) {
  198. this.$router.push({ name: `merchantInfoManagementEdit`, params: { id: row.dealerSn } })
  199. },
  200. // 合作设置
  201. handleCooperation (row) {
  202. this.$refs.updateCooperate.setData(row)
  203. this.openUcModal = true
  204. },
  205. // 价格级别
  206. handleLevel (row) {
  207. this.$refs.updateDealerLevel.setData(row)
  208. this.openUdModal = true
  209. },
  210. // 经销权
  211. handleDistribution (row) {
  212. this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn } })
  213. },
  214. // 审核
  215. handleAudit (row) {
  216. this.itemId = row.dealerSn
  217. this.openModal = true
  218. this.isAudit = true
  219. },
  220. // 详情
  221. handleDetail (row) {
  222. this.itemId = row.dealerSn
  223. this.openModal = true
  224. this.isAudit = false
  225. },
  226. // 关闭弹框
  227. closeModal () {
  228. this.itemId = ''
  229. this.openModal = false
  230. },
  231. // 导出
  232. handleExport () {
  233. const _this = this
  234. const params = this.queryParam
  235. this.exportLoading = true
  236. _this.spinning = true
  237. dealerExport(params).then(res => {
  238. this.exportLoading = false
  239. _this.spinning = false
  240. if (res.type == 'application/json') {
  241. var reader = new FileReader()
  242. reader.addEventListener('loadend', function () {
  243. const obj = JSON.parse(reader.result)
  244. _this.$notification.error({
  245. message: '提示',
  246. description: obj.message
  247. })
  248. })
  249. reader.readAsText(res)
  250. } else {
  251. this.download(res)
  252. }
  253. })
  254. },
  255. download (data) {
  256. if (!data) { return }
  257. const url = window.URL.createObjectURL(new Blob([data]))
  258. const link = document.createElement('a')
  259. link.style.display = 'none'
  260. link.href = url
  261. const a = moment().format('YYYYMMDDHHmmss')
  262. const fname = '经销商资料' + a
  263. link.setAttribute('download', fname + '.xlsx')
  264. document.body.appendChild(link)
  265. link.click()
  266. }
  267. },
  268. beforeRouteEnter (to, from, next) {
  269. next(vm => {
  270. })
  271. }
  272. }
  273. </script>
  274. <style lang="less">
  275. .merchantInfoManagementList-wrap{
  276. .productPic{
  277. cursor: pointer;
  278. }
  279. }
  280. </style>