list.vue 14 KB

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