list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. <template>
  2. <a-card size="small" :bordered="false" class="merchantInfoManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  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" 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="5" :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="7" :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="7" :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. <s-table
  61. class="sTable fixPagination"
  62. ref="table"
  63. :style="{ height: tableHeight+84.5+'px' }"
  64. size="small"
  65. :rowKey="(record) => record.id"
  66. :columns="columns"
  67. :data="loadData"
  68. :scroll="{ y: tableHeight }"
  69. :defaultLoadData="false"
  70. bordered>
  71. <!-- 经销商 -->
  72. <template slot="dealerName" slot-scope="text, record">
  73. <span v-if="$hasPermissions('B_merchantInfo_detail')" style="color: #ed1c24;cursor: pointer;" @click="handleDetail(record)">{{ record.dealerName }}</span>
  74. <span v-else>{{ record.dealerName }}</span>
  75. </template>
  76. <!-- 区域 -->
  77. <template slot="area" slot-scope="text, record">
  78. <div v-if="record.subareaNameSet&&record.subareaNameSet.length!=0">
  79. <span v-for="(item, index) in record.subareaNameSet" :key="index">{{ item }}{{ index+1 == record.subareaNameSet.length ? '' : ',' }}</span>
  80. </div>
  81. <span v-else>--</span>
  82. </template>
  83. <!-- 操作 -->
  84. <template slot="action" slot-scope="text, record">
  85. <a-button size="small" type="link" class="button-warning" v-if="record.auditState == 'WAIT' && $hasPermissions('B_merchantInfo_audit')" @click="handleAudit(record)" >审核</a-button>
  86. <a-button size="small" type="link" class="button-info" v-if="$hasPermissions('B_merchantInfo_cooperation')" @click="handleCooperation(record)" >合作设置</a-button>
  87. <a-button size="small" type="link" class="button-error" v-if="record.auditState != 'WAIT' && $hasPermissions('B_merchantInfo_distribution')" @click="handleDistribution(record)">经销权</a-button>
  88. <a-button size="small" type="link" class="button-primary" v-if="$hasPermissions('B_merchantInfo_level')" @click="handleLevel(record)">级别设置</a-button>
  89. <a-button size="small" type="link" class="button-info" v-if="$hasPermissions('B_merchantInfo_edit')" @click="handleEdit(record)">编辑</a-button>
  90. <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>
  91. </template>
  92. </s-table>
  93. </a-spin>
  94. <!-- 产品详情 -->
  95. <merchant-info-management-detail-modal :openModal="openModal" :isAudit="isAudit" :itemId="itemId" @ok="resetForm" @close="closeModal" />
  96. <!-- 合作设置 -->
  97. <UpdateCooperate ref="updateCooperate" :openUcModal="openUcModal" @ok="resetForm" @close="openUcModal=false"></UpdateCooperate>
  98. <!-- 级别设置 -->
  99. <UpdateDealerLeve ref="updateDealerLevel" :openUdModal="openUdModal" @ok="resetForm" @close="openUdModal=false"></UpdateDealerLeve>
  100. </a-card>
  101. </template>
  102. <script>
  103. import { commonMixin } from '@/utils/mixin'
  104. import moment from 'moment'
  105. import { dealerQueryList, dealerExport } from '@/api/dealer'
  106. import { STable, VSelect } from '@/components'
  107. import subarea from '@/views/common/subarea.js'
  108. import merchantInfoManagementDetailModal from './detailModal.vue'
  109. import UpdateCooperate from './updateCooperate.vue'
  110. import UpdateDealerLeve from './updateDealerLevel.vue'
  111. export default {
  112. name: 'MerchantInfoManagementList',
  113. mixins: [commonMixin],
  114. components: { STable, VSelect, merchantInfoManagementDetailModal, subarea, UpdateCooperate, UpdateDealerLeve },
  115. data () {
  116. return {
  117. spinning: false,
  118. advanced: true, // 高级搜索 展开/关闭
  119. tableHeight: 0,
  120. queryParam: { // 查询条件
  121. nameLike: '', // 商户名称、别名
  122. dealerType: undefined, // 商户类型
  123. subareaSn: undefined, // 区域
  124. auditState: undefined, // 审核状态
  125. cooperateFlag: undefined // 合作状态
  126. },
  127. disabled: false, // 查询、重置按钮是否可操作
  128. exportLoading: false, // 导出loading
  129. dateFormat: 'YYYY-MM-DD',
  130. total: 0,
  131. columns: [
  132. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  133. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  134. { title: '区域', scopedSlots: { customRender: 'area' }, width: '7%', align: 'center' },
  135. { title: '商户名称', scopedSlots: { customRender: 'dealerName' }, width: '10%', align: 'center', ellipsis: true },
  136. { title: '商户别名', dataIndex: 'dealerAlias', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  137. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '联系人', dataIndex: 'contact', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  140. { title: '联系电话', dataIndex: 'dealerTelephone', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '绑定手机号码', dataIndex: 'managerMobile', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '审核状态', dataIndex: 'auditStateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '合作状态', dataIndex: 'cooperateFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '生效时间', dataIndex: 'cooperateEffectiveTime', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  146. ],
  147. loading: false,
  148. // 加载数据方法 必须为 Promise 对象
  149. loadData: parameter => {
  150. this.disabled = true
  151. this.spinning = true
  152. return dealerQueryList(Object.assign(parameter, this.queryParam)).then(res => {
  153. let data
  154. if (res.status == 200) {
  155. data = res.data
  156. const no = (data.pageNo - 1) * data.pageSize
  157. this.total = data.count || 0
  158. for (var i = 0; i < data.list.length; i++) {
  159. data.list[i].no = no + i + 1
  160. }
  161. this.disabled = false
  162. }
  163. this.spinning = false
  164. return data
  165. })
  166. },
  167. openModal: false, // 查看详情 弹框
  168. openUcModal: false, // 合作设置 弹框
  169. openUdModal: false, // 级别设置 弹框
  170. itemId: '', // 当前商户sn
  171. isAudit: false
  172. }
  173. },
  174. methods: {
  175. // 重置列表
  176. resetSearchForm () {
  177. this.queryParam = {
  178. nameLike: '', // 商户名称、别名
  179. dealerType: undefined, // 商户类型
  180. subareaSn: undefined, // 区域
  181. auditState: undefined, // 审核状态
  182. cooperateFlag: undefined // 合作状态
  183. }
  184. this.$refs.table.refresh(true)
  185. },
  186. // 刷新当前列表
  187. resetForm () {
  188. this.$refs.table.refresh()
  189. this.openModal = false
  190. this.isAudit = false
  191. this.openUcModal = false
  192. this.openUdModal = false
  193. },
  194. // 新增
  195. handleAdd () {
  196. this.$router.push({ name: `merchantInfoManagementAdd` })
  197. },
  198. // 编辑
  199. handleEdit (row) {
  200. this.$router.push({ name: `merchantInfoManagementEdit`, params: { id: row.dealerSn } })
  201. },
  202. // 合作设置
  203. handleCooperation (row) {
  204. this.$refs.updateCooperate.setData(row)
  205. this.openUcModal = true
  206. },
  207. // 价格级别
  208. handleLevel (row) {
  209. this.$refs.updateDealerLevel.setData(row)
  210. this.openUdModal = true
  211. },
  212. // 经销权
  213. handleDistribution (row) {
  214. this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn } })
  215. },
  216. // 审核
  217. handleAudit (row) {
  218. this.itemId = row.dealerSn
  219. this.openModal = true
  220. this.isAudit = true
  221. },
  222. // 详情
  223. handleDetail (row) {
  224. this.itemId = row.dealerSn
  225. this.openModal = true
  226. this.isAudit = false
  227. },
  228. // 关闭弹框
  229. closeModal () {
  230. this.itemId = ''
  231. this.openModal = false
  232. },
  233. // 导出
  234. handleExport () {
  235. const _this = this
  236. const params = this.queryParam
  237. this.exportLoading = true
  238. _this.spinning = true
  239. dealerExport(params).then(res => {
  240. this.exportLoading = false
  241. _this.spinning = false
  242. if (res.type == 'application/json') {
  243. var reader = new FileReader()
  244. reader.addEventListener('loadend', function () {
  245. const obj = JSON.parse(reader.result)
  246. _this.$notification.error({
  247. message: '提示',
  248. description: obj.message
  249. })
  250. })
  251. reader.readAsText(res)
  252. } else {
  253. this.download(res)
  254. }
  255. })
  256. },
  257. download (data) {
  258. if (!data) { return }
  259. const url = window.URL.createObjectURL(new Blob([data]))
  260. const link = document.createElement('a')
  261. link.style.display = 'none'
  262. link.href = url
  263. const a = moment().format('YYYYMMDDHHmmss')
  264. const fname = '经销商资料' + a
  265. link.setAttribute('download', fname + '.xlsx')
  266. document.body.appendChild(link)
  267. link.click()
  268. },
  269. pageInit () {
  270. const _this = this
  271. this.$nextTick(() => { // 页面渲染完成后的回调
  272. _this.setTableH()
  273. })
  274. },
  275. setTableH () {
  276. const tableSearchH = this.$refs.tableSearch.offsetHeight
  277. this.tableHeight = window.innerHeight - tableSearchH - 238
  278. }
  279. },
  280. watch: {
  281. advanced (newValue, oldValue) {
  282. const _this = this
  283. this.$nextTick(() => { // 页面渲染完成后的回调
  284. _this.setTableH()
  285. })
  286. },
  287. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  288. this.setTableH()
  289. }
  290. },
  291. mounted () {
  292. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  293. this.pageInit()
  294. this.resetSearchForm()
  295. }
  296. },
  297. activated () {
  298. // 如果是新页签打开,则重置当前页面
  299. if (this.$store.state.app.isNewTab) {
  300. this.pageInit()
  301. this.resetSearchForm()
  302. }
  303. // 仅刷新列表,不重置页面
  304. if (this.$store.state.app.updateList) {
  305. this.$refs.table.refresh()
  306. this.pageInit()
  307. }
  308. },
  309. beforeRouteEnter (to, from, next) {
  310. next(vm => {})
  311. }
  312. }
  313. </script>
  314. <style lang="less">
  315. .merchantInfoManagementList-wrap{
  316. .productPic{
  317. cursor: pointer;
  318. }
  319. }
  320. </style>