list.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <a-card size="small" :bordered="false" class="approveStore-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. <a-input allowClear placeholder="请输入经销商名称" v-model.tirm="queryParam.dealerName"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="商城状态">
  15. <v-select
  16. v-model="queryParam.openFlag"
  17. ref="openFlag"
  18. id="approveStore-openFlag"
  19. code="OPEN_FLAG"
  20. placeholder="请选择商城状态"
  21. allowClear></v-select>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="支付状态">
  26. <v-select
  27. v-model="queryParam.payOpenFlag"
  28. ref="payOpenFlag"
  29. id="approveStore-payOpenFlag"
  30. :list="payStatusList"
  31. placeholder="请选择支付状态"
  32. allowClear></v-select>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <div>
  37. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="approveStore-refresh">查询</a-button>
  38. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="approveStore-reset">重置</a-button>
  39. </div>
  40. </a-col>
  41. </a-row>
  42. </a-form>
  43. </div>
  44. <!-- 列表 -->
  45. <s-table
  46. class="sTable fixPagination"
  47. ref="table"
  48. :style="{ height: tableHeight+84.5+'px' }"
  49. size="small"
  50. :rowKey="(record) => record.wait_audit"
  51. :columns="columns"
  52. :data="loadData"
  53. :scroll="{ y: tableHeight }"
  54. :defaultLoadData="false"
  55. bordered>
  56. <!-- 商城状态-->
  57. <template slot="statusVal" slot-scope="text, record">
  58. <a-switch checked-children="已开启" un-checked-children="已关闭" v-model="record.statusFlag" @change="e=>handleStatus(e,record)"/>
  59. </template>
  60. <!-- 支付状态-->
  61. <template slot="payVal" slot-scope="text, record">
  62. <span v-if="record.payOpenFlag=='wait_audit'">{{ payStatus(record.payOpenFlag) }}</span>
  63. <a-button size="small" type="link" v-if="record.payOpenFlag=='wait_open'" @click="e=>handlePayStatus(e,record)">申请开通</a-button>
  64. <div v-if="record.payOpenFlag=='pay_opened'||record.payOpenFlag=='pay_close'">
  65. <a-switch checked-children="已开启" un-checked-children="已关闭" v-model="record.payFlag" @change="e=>handlePayStatus(e,record)"/>
  66. </div>
  67. </template>
  68. </s-table>
  69. </a-spin>
  70. </a-card>
  71. </template>
  72. <script>
  73. // 组件
  74. import { STable, VSelect } from '@/components'
  75. // 接口
  76. import { findMallParamList, updateMallParam, updatePayOpenParam } from '@/api/dealerBizParam'
  77. export default {
  78. components: { STable, VSelect },
  79. data () {
  80. return {
  81. spinning: false,
  82. tableHeight: 0, // 表格高度
  83. disabled: false, // 查询、重置按钮是否可操作
  84. // 查询条件
  85. queryParam: {
  86. dealerName: undefined, // 经销商名称
  87. delearSn: undefined,
  88. openFlag: undefined, // 商城状态
  89. payOpenFlag: undefined// 支付状态
  90. },
  91. // 表头
  92. columns: [
  93. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  94. { title: '经销商名称', dataIndex: 'dealerName', width: '30%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  95. { title: '商城状态时间', dataIndex: 'updateDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  96. { title: '商城状态', dataIndex: 'paramValue', width: '15%', align: 'center', scopedSlots: { customRender: 'statusVal' } },
  97. { title: '支付状态时间', dataIndex: 'payOpenActDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  98. { title: '支付状态', dataIndex: 'payOpenFlag', width: '15%', align: 'center', scopedSlots: { customRender: 'payVal' } }
  99. ],
  100. // 加载数据方法 必须为 Promise 对象
  101. loadData: parameter => {
  102. this.disabled = true
  103. this.spinning = true
  104. return findMallParamList(Object.assign(parameter, this.queryParam)).then(res => {
  105. let data
  106. if (res.status == 200) {
  107. data = res.data
  108. const no = (data.pageNo - 1) * data.pageSize
  109. for (var i = 0; i < data.list.length; i++) {
  110. data.list[i].no = no + i + 1
  111. data.list[i].statusFlag = data.list[i].paramValue == '1'
  112. data.list[i].payFlag = data.list[i].payOpenFlag == 'pay_opened'
  113. }
  114. this.disabled = false
  115. }
  116. this.spinning = false
  117. return data
  118. })
  119. },
  120. payStatusList: [
  121. { code: 'pay_opened', dispName: '已开通' },
  122. { code: 'wait_open', dispName: '待开通' },
  123. { code: 'wait_audit', dispName: '审核中' },
  124. { code: 'pay_close', dispName: '已关闭' }
  125. ]
  126. }
  127. },
  128. methods: {
  129. payStatus (val) {
  130. const row = this.payStatusList.find(item => item.code == val)
  131. return row ? row.dispName : '--'
  132. },
  133. custChange (val) {
  134. if (val) {
  135. this.queryParam.delearSn = val.key
  136. this.queryParam.dealerName = val.label.match(/[\u4e00-\u9fff]+/g).join('')
  137. } else {
  138. this.queryParam.delearSn = undefined
  139. this.queryParam.dealerName = undefined
  140. }
  141. },
  142. // 修改商城状态
  143. handleStatus (val, row) {
  144. const _this = this
  145. _this.spinning = true
  146. updateMallParam({
  147. tenantId: row.tenantId,
  148. paramValue: row.paramValue == '0' ? '1' : '0'
  149. }).then(res => {
  150. if (res.status == 200) {
  151. _this.$message.success(res.message)
  152. _this.$refs.table.refresh()
  153. _this.spinning = false
  154. } else {
  155. _this.spinning = false
  156. }
  157. })
  158. },
  159. // 修改支付开通状态
  160. handlePayStatus (val, row) {
  161. const _this = this
  162. _this.spinning = true
  163. updatePayOpenParam({
  164. tenantId: row.tenantId,
  165. paramValue: row.payOpenFlag == 'wait_open' ? 'wait_audit' : (row.payOpenFlag == 'pay_close' ? 'pay_opened' : 'pay_close')
  166. }).then(res => {
  167. if (res.status == 200) {
  168. _this.$message.success(res.message)
  169. _this.$refs.table.refresh()
  170. _this.spinning = false
  171. } else {
  172. _this.spinning = false
  173. }
  174. })
  175. },
  176. // 重置
  177. resetSearchForm () {
  178. this.queryParam.dealerName = undefined
  179. this.queryParam.delearSn = undefined
  180. this.queryParam.openFlag = undefined
  181. this.queryParam.payOpenFlag = undefined
  182. this.$refs.table.refresh(true)
  183. },
  184. setTableH () {
  185. const tableSearchH = this.$refs.tableSearch.offsetHeight
  186. this.tableHeight = window.innerHeight - tableSearchH - 420
  187. },
  188. pageInit () {
  189. const _this = this
  190. this.$nextTick(() => { // 页面渲染完成后的回调
  191. _this.setTableH()
  192. _this.resetSearchForm()
  193. })
  194. }
  195. },
  196. mounted () {
  197. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  198. this.pageInit()
  199. }
  200. },
  201. watch: {
  202. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  203. this.setTableH()
  204. }
  205. },
  206. activated () {
  207. // 如果是新页签打开,则重置当前页面
  208. if (this.$store.state.app.isNewTab) {
  209. this.pageInit()
  210. }
  211. // 仅刷新列表,不重置页面
  212. if (this.$store.state.app.updateList) {
  213. this.setTableH()
  214. this.$refs.table.refresh()
  215. }
  216. }
  217. }
  218. </script>