list.vue 15 KB

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