list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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-success" 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 moment from 'moment'
  104. import { dealerQueryList, dealerExport } from '@/api/dealer'
  105. import { STable, VSelect } from '@/components'
  106. import subarea from '@/views/common/subarea.js'
  107. import merchantInfoManagementDetailModal from './detailModal.vue'
  108. import UpdateCooperate from './updateCooperate.vue'
  109. import UpdateDealerLeve from './updateDealerLevel.vue'
  110. export default {
  111. components: { STable, VSelect, merchantInfoManagementDetailModal, subarea, UpdateCooperate, UpdateDealerLeve },
  112. data () {
  113. return {
  114. spinning: false,
  115. advanced: true, // 高级搜索 展开/关闭
  116. tableHeight: 0,
  117. queryParam: { // 查询条件
  118. nameLike: '', // 商户名称、别名
  119. dealerType: undefined, // 商户类型
  120. subareaSn: undefined, // 区域
  121. auditState: undefined, // 审核状态
  122. cooperateFlag: undefined // 合作状态
  123. },
  124. disabled: false, // 查询、重置按钮是否可操作
  125. exportLoading: false, // 导出loading
  126. dateFormat: 'YYYY-MM-DD',
  127. total: 0,
  128. columns: [
  129. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  130. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  131. { title: '区域', scopedSlots: { customRender: 'area' }, width: '7%', align: 'center' },
  132. { title: '商户名称', scopedSlots: { customRender: 'dealerName' }, width: '10%', align: 'center', ellipsis: true },
  133. { title: '商户别名', dataIndex: 'dealerAlias', width: '10%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  134. { title: '商户类型', dataIndex: 'dealerTypeDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  135. { title: '商户级别', dataIndex: 'dealerLevelDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  136. { title: '联系人', dataIndex: 'contact', width: '7%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  137. { title: '联系电话', dataIndex: 'dealerTelephone', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  138. { title: '绑定手机号码', dataIndex: 'managerMobile', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '审核状态', dataIndex: 'auditStateDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '合作状态', dataIndex: 'cooperateFlagDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '生效时间', dataIndex: 'cooperateEffectiveTime', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  142. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  143. ],
  144. loading: false,
  145. // 加载数据方法 必须为 Promise 对象
  146. loadData: parameter => {
  147. this.disabled = true
  148. this.spinning = 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. this.spinning = false
  158. return data
  159. })
  160. },
  161. openModal: false, // 查看详情 弹框
  162. openUcModal: false, // 合作设置 弹框
  163. openUdModal: false, // 级别设置 弹框
  164. itemId: '', // 当前商户sn
  165. isAudit: false
  166. }
  167. },
  168. methods: {
  169. // 重置列表
  170. resetSearchForm () {
  171. this.queryParam = {
  172. nameLike: '', // 商户名称、别名
  173. dealerType: undefined, // 商户类型
  174. subareaSn: undefined, // 区域
  175. auditState: undefined, // 审核状态
  176. cooperateFlag: undefined // 合作状态
  177. }
  178. this.$refs.table.refresh(true)
  179. },
  180. // 刷新当前列表
  181. resetForm () {
  182. this.$refs.table.refresh()
  183. this.openModal = false
  184. this.isAudit = false
  185. this.openUcModal = false
  186. this.openUdModal = false
  187. },
  188. // 新增
  189. handleAdd () {
  190. this.$router.push({ name: `merchantInfoManagementAdd` })
  191. },
  192. // 编辑
  193. handleEdit (row) {
  194. this.$router.push({ name: `merchantInfoManagementEdit`, params: { id: row.dealerSn } })
  195. },
  196. // 合作设置
  197. handleCooperation (row) {
  198. this.$refs.updateCooperate.setData(row)
  199. this.openUcModal = true
  200. },
  201. // 价格级别
  202. handleLevel (row) {
  203. this.$refs.updateDealerLevel.setData(row)
  204. this.openUdModal = true
  205. },
  206. // 经销权
  207. handleDistribution (row) {
  208. this.$router.push({ name: `merchantInfoManagementSet`, params: { sn: row.dealerSn } })
  209. },
  210. // 审核
  211. handleAudit (row) {
  212. this.itemId = row.dealerSn
  213. this.openModal = true
  214. this.isAudit = true
  215. },
  216. // 详情
  217. handleDetail (row) {
  218. this.itemId = row.dealerSn
  219. this.openModal = true
  220. this.isAudit = false
  221. },
  222. // 关闭弹框
  223. closeModal () {
  224. this.itemId = ''
  225. this.openModal = false
  226. },
  227. // 导出
  228. handleExport () {
  229. const _this = this
  230. const params = this.queryParam
  231. this.exportLoading = true
  232. _this.spinning = true
  233. dealerExport(params).then(res => {
  234. this.exportLoading = false
  235. _this.spinning = false
  236. if (res.type == 'application/json') {
  237. var reader = new FileReader()
  238. reader.addEventListener('loadend', function () {
  239. const obj = JSON.parse(reader.result)
  240. _this.$notification.error({
  241. message: '提示',
  242. description: obj.message
  243. })
  244. })
  245. reader.readAsText(res)
  246. } else {
  247. this.download(res)
  248. }
  249. })
  250. },
  251. download (data) {
  252. if (!data) { return }
  253. const url = window.URL.createObjectURL(new Blob([data]))
  254. const link = document.createElement('a')
  255. link.style.display = 'none'
  256. link.href = url
  257. const a = moment().format('YYYYMMDDHHmmss')
  258. const fname = '经销商资料' + a
  259. link.setAttribute('download', fname + '.xlsx')
  260. document.body.appendChild(link)
  261. link.click()
  262. },
  263. pageInit () {
  264. const _this = this
  265. this.$nextTick(() => { // 页面渲染完成后的回调
  266. _this.setTableH()
  267. })
  268. },
  269. setTableH () {
  270. const tableSearchH = this.$refs.tableSearch.offsetHeight
  271. this.tableHeight = window.innerHeight - tableSearchH - 235
  272. }
  273. },
  274. watch: {
  275. advanced (newValue, oldValue) {
  276. const _this = this
  277. setTimeout(() => {
  278. _this.setTableH()
  279. }, 400)
  280. }
  281. },
  282. mounted () {
  283. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  284. this.pageInit()
  285. this.resetSearchForm()
  286. }
  287. },
  288. activated () {
  289. // 如果是新页签打开,则重置当前页面
  290. if (this.$store.state.app.isNewTab) {
  291. this.pageInit()
  292. this.resetSearchForm()
  293. }
  294. // 仅刷新列表,不重置页面
  295. if (this.$store.state.app.updateList) {
  296. this.$refs.table.refresh()
  297. this.pageInit()
  298. }
  299. },
  300. beforeRouteEnter (to, from, next) {
  301. next(vm => {})
  302. }
  303. }
  304. </script>
  305. <style lang="less">
  306. .merchantInfoManagementList-wrap{
  307. .productPic{
  308. cursor: pointer;
  309. }
  310. }
  311. </style>