storeTargetList.vue
10.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<!-- 门店目标配置 -->
<template>
<d2-container class="store-target-list m-t-40">
<div class="header"
slot="header">
<d2-search ref="showSearch"
class="show-search"
:search-form="searchForm"
:label-width="'100px'"
:form-data="showFormData">
</d2-search>
<div class="up-btns">
<el-button :id="tableParams.btnId"
size="small"
type="primary">
查询
</el-button>
<el-button size="small"
@click="handleReset">
重置
</el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<auth-button category="Button"
style="{display: inline-block}"
:show-btn-ids="['9120701']" />
</d2-table-header>
<d2-table ref="storeTargetTable"
:has-num="false"
:search-form="searchForm"
:table-params="tableParams"
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
@setTableFinishFun="setTableFinishFun">
<template slot="sceneType"
slot-scope="scope">
<div v-if="scope.scope.sceneType == 1">精品升级</div>
<div v-if="scope.scope.sceneType == 0">会员权益/升级</div>
</template>
<template slot="partnerMerchantName"
slot-scope="scope">
<div v-for="item in scope.scope.serviceList"
:key="item.merchantId">{{ item.merchantName }}</div>
<div v-if="!scope.scope.serviceList.length">-</div>
</template>
<template slot="partnerMerchantId"
slot-scope="scope">
<div v-for="item in scope.scope.serviceList"
:key="item.merchantId">{{ item.merchantId }}</div>
<div v-if="!scope.scope.serviceList.length">-</div>
</template>
<div slot="auth-button"
slot-scope="scope">
<!-- 查看 -->
<span style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9120702']" />
</span>
<!-- 编辑 -->
<span style="margin-right: 10px;">
<auth-button :data="scope.scope"
:show-btn-ids="['9120703']" />
</span>
</div>
</d2-table>
</div>
</d2-container>
</template>
<script>
import { mapActions } from 'vuex'
import { getStoreTargetListApi } from '@api/inStoreTargetConfig'
import { Util } from '@/common/util'
export default {
name: "StoreTargetList",
data() {
return {
// 搜索框
showFormData: [{
label: '商户名称',
name: 'allMerchantName',
type: 'input',
placeholder: '请输入园区店/导流方/服务商名称',
isClear: true,
keyFn: this.keyDownGetList
}, {
label: '商户号',
name: 'allMerchantId',
type: 'input',
inputType: 'number',
placeholder: '请输入园区店/导流方/服务商商户号',
isClear: true,
keyFn: this.keyDownGetList
}, {
label: '场景名称',
name: 'sceneType',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confValue',
optionsName: 'sceneTypeList'
}, {
label: '配置状态',
name: 'configStatus',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confValue',
optionsName: 'configStatusList'
}],
getListApi: getStoreTargetListApi,
// 表格参数
tableParams: {
needUnique: true,
mutiSelectUniqueKey: 'uniqueVal',
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: 'list',
tableOption: {
width: '100'
},
tableColumns: [{
label: '序号',
prop: 'ownSerialNum',
type: 'ownSerialNum',
width: '60'
}, {
label: '流量方',
prop: 'merchantName',
width: '120'
}, {
label: '流量方商户号',
prop: 'merchantId',
width: '120'
}, {
label: '业务场景',
prop: 'sceneType',
addHtml: 'sceneType'
}, {
label: '关联园区店',
prop: 'yqMerchantName'
}, {
label: '关联园区店号',
prop: 'yqMerchantId'
}, {
label: '关联服务商',
prop: 'partnerMerchantName',
addHtml: 'partnerMerchantName'
}, {
label: '关联服务商商户号',
prop: 'partnerMerchantId',
addHtml: 'partnerMerchantId'
}, {
label: '配置状态',
prop: 'status',
width: '80',
className: (cellValue) => {
return {
Y: 'greenSpot',
N: 'yellowSpot'
}[cellValue.configStatus]
},
formatter: (cellValue) => {
return {
Y: '已配置',
N: '待配置'
}[cellValue.configStatus]
}
}, {
label: '创建时间',
prop: 'created',
width: '160',
formatter: (cellValue) => {
return cellValue.createdDate ? Util.dateFormate(cellValue.createdDate, 'YYYY-MM-DD HH:mm:ss') : ''
}
}, {
label: '更新时间',
prop: 'update',
width: '160',
formatter: (cellValue) => {
return cellValue.updatedDate ? Util.dateFormate(cellValue.updatedDate, 'YYYY-MM-DD HH:mm:ss') : ''
}
}, {
label: '操作人',
prop: 'updatedBy',
width: '80'
}]
},
// 查询条件
searchForm: {
allMerchantName: '',
allMerchantId: '',
sceneType: '',
configStatus: ''
},
baseData: {
sceneTypeList: [{
confId: 1,
confValue: '精品升级'
}, {
confId: 0,
confValue: '会员权益/升级'
}],
configStatusList: [{
confId: 'N',
confValue: '待配置'
}, {
confId: 'Y',
confValue: '已配置'
}]
},
spanArr1: [],
spanIndex1: 0,
spanArr2: [],
spanIndex2: 0,
spanArr3: [],
spanIndex3: 0
}
},
mounted() {
this.getBaseData()
},
methods: {
...mapActions({
get: 'd2admin/base/get',
close: 'd2admin/page/close'
}),
getBaseData() {
this.showFormData.forEach((item, index) => {
if (item.type === 'select') {
this.baseData[item.name + 'List'].unshift({
confId: '',
confValue: '全部'
})
this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
}
})
},
beforeSearchFn() {
return new Promise(resolve => {
resolve()
})
},
// 表格数据处理
setTableFinishFun(data) {
// this.merge(data)
},
// 合并表格
arraySpanMethod({ row, column, rowIndex, columnIndex }) {
const len = this.viewInfo?.tableData?.length
const t = 14
if (columnIndex === 0) {
// 第一列 序号
const _row_1 = this.spanArr1[rowIndex]
const _col_1 = _row_1 > 0 ? 1 : 0
return {
rowspan: _row_1,
colspan: _col_1
}
} else if (columnIndex === 1) {
// 第二列 流量方
const _row_2 = this.spanArr2[rowIndex]
const _col_2 = _row_2 > 0 ? 1 : 0
return {
rowspan: _row_2,
colspan: _col_2
}
// 第三列 流量方商户号
} else if (columnIndex === 2) {
const _row_3 = this.spanArr3[rowIndex]
const _col_3 = _row_3 > 0 ? 1 : 0
return {
rowspan: _row_3,
colspan: _col_3
}
} else if (columnIndex === t) {
const _row_4 = len
const _col_4 = 1
return {
rowspan: _row_4,
colspan: _col_4
}
} else if (rowIndex === len) {
return {
rowspan: 1,
colspan: 1
}
}
},
// 初始化合并行数组
mergeInit() {
this.spanArr1 = [] // 合并序号
this.spanIndex1 = 0 // 合并序号索引
this.spanArr2 = [] // 合并流量方
this.spanIndex2 = 0 // 合并流量方索引
this.spanArr3 = [] // 合并流量方商户号
this.spanIndex3 = 0 // 合并流量方商户号索引
},
// 合并表格
merge(data) {
this.mergeInit()
if (data.length > 0) {
for (var i = 0; i < data.length; i++) {
if (i === 0) {
// 第一行必须存在,以第一行为基准
this.spanArr1.push(1) // 合并序号
this.spanIndex1 = 0
this.spanArr2.push(1) // 合并流量方
this.spanIndex2 = 0
this.spanArr3.push(1) // 合并流量方商户号
this.spanIndex3 = 0
} else {
if (data[i].merchantId == data[i - 1].merchantId) {
this.spanArr1[this.spanIndex1] += 1
this.spanArr1.push(0)
this.spanArr2[this.spanIndex2] += 1
this.spanArr2.push(0)
this.spanArr3[this.spanIndex3] += 1
this.spanArr3.push(0)
} else {
this.spanArr1.push(1)
this.spanIndex1 = i
this.spanArr2.push(1)
this.spanIndex2 = i
this.spanArr3.push(1)
this.spanIndex3 = i
}
}
}
}
},
// 查看详情
handleStoreView(row) {
this.close({ tagName: '/inStoreGoalsConfig' })
this.$router.push({
path: '/inStoreConfigView',
query: row
})
},
// 新增配置
handleAdd() {
this.close({ tagName: '/inStoreGoalsConfig' })
const queryObj = { idEdit: false }
this.$router.push({
path: '/addInStoreConfig',
query: queryObj
})
},
// 编辑配置
handleStoreEdit(row) {
this.close({ tagName: '/inStoreGoalsConfig' })
const queryObj = { idEdit: true, ...row }
this.$router.push({
path: '/addInStoreConfig',
query: queryObj
})
},
// 重置
handleReset() {
this.searchForm = {
allMerchantName: '',
allMerchantId: '',
sceneType: '',
configStatus: ''
}
this.$refs.storeTargetTable.refreshTable(true, true)
}
}
}
</script>
<style lang="scss" scoped>
.m-t-40 {
margin-top: 40px;
}
</style>