recordList.vue
14.9 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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<template>
<div class="marketing record-list">
<div class="m-b-10">
<el-button :size="size" type="default" class="default-blue-btn color-transparent" @click="openDialog">核销优惠券</el-button>
</div>
<div class="container">
<GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
<div class="flex m-b-10 w-100-percent">
<span class="table-title"></span>
<el-button :size="size" class="default-blue-btn" type="default" @click="handleExport">全部导出</el-button>
</div>
<GLTable ref="memberRecordRef" v-if="isReload" :noDataImg="url" @setTableFinishFun="setTableFinishFun" :searchForm="tableSearchForm" :tableParams="tableParams" :getListApi="getListApi" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn">
<template slot="discountType" slot-scope="scope">
<img :src="require(`@/assets/coupon/icon-${attrToIcon[scope.scope.discountType]}.png`)" />
</template>
<template slot="packageName" slot-scope="scope">
<span v-if="$isGroupUp">{{ scope.scope.packageId ? scope.scope.packageName : scope.scope.directionalGiftId ? scope.scope.directionalGiftName : '-' }}</span>
<div v-else>
<p v-if="scope.scope.receiveWay != 7">{{ packageNameTxtObj[scope.scope.receiveWay] }}</p>
<p v-else>{{ scope.scope.merchantType == 1 ? '通过自店礼包赠送' : '通过集团礼包赠送' }}</p>
<p v-if="scope.scope.receiveWay == 7 && scope.scope.receiveMethod" class="txt-grey text-10">指定{{ scope.scope.receiveMethod == 1 ? '手机号' : '车架号' }}:{{ scope.scope.receiveNumber }}</p>
</div>
</template>
<span slot="orderCodeHtml" slot-scope="scope">
<span class="cursor-pointer" @click="couponNameHandleDetail(scope.scope)" v-if="scope.scope.directionalGiftId">{{ scope.scope.directionalGiftName }}</span>
<span class="cursor-pointer" @click="orderCodeHandleDetail(scope.scope)" v-else>{{ scope.scope.orderCode }}</span>
</span>
</GLTable>
<GLDialog mode="mid" :visible.sync="isDialogVisible" @onCancel="handleClose" @onOk="handleConfirm">
<div slot="title">优惠券核销(请确保用户到店后核销,避免引起不必要问题)</div>
<div class="gl-form-page m-t-20">
<el-form :rules="rules" ref="ruleForm" :model="ruleForm" :label-width="defaultLabelWidth">
<el-form-item size="small" label="核销码:" prop="verficationCode">
<el-input size="small" v-model.trim="ruleForm.verficationCode" maxlength="50" placeholder="请输入核销码"></el-input>
</el-form-item>
</el-form>
</div>
</GLDialog>
</div>
</div>
</template>
<script>
// import { getRecordListApi, getVerificationCode, verificationExportApi } from '@/api/modules/record'
import url from '@/assets/empty.png'
import { dateFormat } from '@/utils/index.js'
import { exportFn } from '@/common/constant'
export default {
name: 'recordList',
data() {
return {
ruleForm: {
verficationCode: ''
},
isDialogVisible: false,
rules: {
verficationCode: [{ required: true, message: '请输入核销码', trigger: 'blur' }]
},
url: url,
isReload: true,
size: 'small',
searchForm: {
grantMerchantId: '',
verificationMerchantId: '',
couponName: '',
userReq: '',
verificationOperator: '',
orderCode: '',
packageId: '',
discountType: '',
discountTypes: [2, 3, 4, 7]
},
tableSearchForm: {
discountType: '',
verificationMerchantId: ''
},
// 搜索
searchFormData: [
{
label: '发放门店',
name: 'grantMerchantId',
labelWidth: 56,
type: 'select',
optionList: [],
optionId: 'merchantNo',
optionLabel: 'merchantName',
optionsName: 'merchantList'
},
{
label: '核销门店',
name: 'verificationMerchantId',
labelWidth: 56,
type: 'select',
optionList: [],
optionId: 'merchantNo',
optionLabel: 'merchantName',
optionsName: 'merchantList'
},
// {
// label: '核销门店',
// name: 'verificationMerchantName',
// type: 'input',
// isHide: false,
// maxlength: 50
// },
{
label: '券名称',
name: 'couponName',
type: 'input',
maxlength: 50
},
{
label: '券类型',
name: 'discountType',
labelWidth: 56,
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName',
optionsName: 'discountTypeList'
},
{
label: '核销人',
name: 'verificationOperator',
type: 'input',
isHide: false,
labelWidth: 56,
maxlength: 50
},
{
label: '用户信息',
name: 'userReq',
type: 'input',
labelWidth: 42,
placeholder: '请输入用户昵称或手机号',
maxlength: 50
},
{
label: '核销码',
name: 'verificationCode',
type: 'input',
labelWidth: 56,
maxlength: 50
},
{
label: '核销日期',
name: 'daterange',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
},
{
label: '券来源',
name: 'packageId',
labelWidth: 56,
type: 'select',
optionList: [],
optionId: 'id',
optionLabel: 'packageName',
optionsName: 'packageList'
}
],
// 表格组件
getListApi: this.$apis.couponManage.getVerificationListApi,
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
// 表格参数
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '领取用户',
prop: 'userName',
width: 220,
formatter: cellValue => {
return cellValue.userName == cellValue.phone ? cellValue.userName : cellValue.userName + ' ' + cellValue.phone
}
},
{
label: '券类型',
name: 'discountType',
width: '100',
addHtml: 'discountType'
},
{
label: '券名称',
prop: 'couponName',
width: 200,
line: 2
},
{
label: '剩余核销次数',
prop: 'residueAmount',
width: 120,
formatter: cellValue => {
return cellValue.residueAmount || cellValue.residueAmount == 0 ? cellValue.residueAmount : '不限制次数'
}
},
{
label: '发放门店',
width: 200,
prop: 'grantMerchantName'
},
{
label: '核销门店',
width: 200,
prop: 'verificationMerchantName'
},
{
label: '核销人',
width: 120,
prop: 'verificationOperator'
},
{
label: '券来源',
prop: 'packageName',
addHtml: 'packageName',
width: 240
},
{
label: '核销码',
prop: 'verificationCode',
width: 200
},
{
label: '核销日期',
prop: 'verificationTime',
width: 200,
formatter: cellValue => {
return dateFormat(cellValue.verificationTime)
}
}
]
},
attrToIcon: {
2: 'discount',
3: 'cash',
4: 'exchange',
7: 'service'
},
packageNameTxtObj: {
'': '-',
1: '营销活动',
2: '营销活动',
3: '会员服务套餐',
4: '营销活动',
5: '关联商品购买',
6: '通过集团套餐赠送',
7: '通过定向礼包赠送'
},
baseData: {
discountTypeList: [
{
confId: '2',
confName: '折扣券'
},
{
confId: '3',
confName: '代金券'
},
{
confId: '4',
confName: '兑换券'
},
{
confId: '7',
confName: '服务券'
}
],
packageList: [],
merchantList: []
}
}
},
created() {
if (this.$isGroupUp) {
this.getPackageList()
} else {
this.showOrHideAttr('searchFormData', '券来源', true)
}
},
mounted() {
this.getSuperMerchant()
this.getOptionsList('searchFormData')
},
methods: {
showOrHideAttr(formName, label, isHide) {
let idx = this[formName].findIndex(item => item.label == label)
this[formName][idx].isHide = isHide
},
deleteAttr(labelList) {
labelList.forEach(i => {
let idx = this.tableParams.tableColumns.findIndex(item => item.label == i)
this.tableParams.tableColumns.splice(idx, 1)
})
},
getPackageList() {
this.$apis.couponManage.getPackageListApi({ pageNum: 1, pageSize: 9999 }).then(res => {
this.baseData.packageList = res.list
this.getOptionsList('searchFormData', true, 'packageId')
})
},
getSuperMerchant() {
var isFactory = this.$globalState.session.accountLevel == 1
var { merchantId } = this.$globalState?.session || ''
if (isFactory) {
this.getMerchant(merchantId)
return true
}
this.$apis.common.getSuperMerchantApi({ merchantId: merchantId }).then(res => {
merchantId = res
this.getMerchant(merchantId)
})
},
getMerchant(merchantId) {
const param = {
supMerchantNo: merchantId,
merchantAccountLevel: 4
}
this.$apis.groupGiftBag.getMerchantListApi(param).then(res => {
this.baseData.merchantList = res || []
this.getOptionsList('searchFormData')
})
},
// 跳转到礼包领取详情页
couponNameHandleDetail(row) {
// console.log('row', row)
this.$router.push({
path: '/giftBag/giftDetail',
query: {
id: row.directionalGiftId
}
})
},
// 跳转到订单详情页
orderCodeHandleDetail(row) {
this.$router.push({
path: '/memberCenter/orderDetail',
query: {
id: row.id,
detail: row
}
})
},
dateFormatFun(date) {
return dateFormat(date)
},
getOptionsList(formName, hasAll = true, refreshSigle) {
if (refreshSigle) {
var item = this[formName].find(k => k.name == refreshSigle)
var index = this[formName].findIndex(k => k.name == refreshSigle)
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
} else {
this[formName].forEach((item, index) => {
if (item.type === 'select' && this.baseData[item.optionsName].length) {
this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
const temp = {}
temp[this[formName][index].optionId] = ''
temp[this[formName][index].optionLabel] = '全部'
this[formName][index].optionList.unshift(temp)
}
}
})
}
},
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
if (params.daterange) {
params.verificationTimeStart = new Date(this.searchForm.daterange[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.verificationTimeEnd = new Date(this.searchForm.daterange[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
} else {
if (params.beginTime) delete params.beginTime && delete params.endTime
}
delete params.daterange
if (params.discountType) {
params.discountTypes = [params.discountType]
}
return params
},
beforeSearchFn() {
return new Promise((resolve, reject) => {
this.tableSearchForm = this.getParams()
resolve()
})
},
setTableFinishFun() {
//接收到的数据为空
if (!this.$refs.memberRecordRef.data.length) {
this.$refs.memberRecordRef.setTableHeightFun()
}
},
handleShareClose() {
this.isShareVisible = !this.isShareVisible
},
handleDetail(row) {
this.$router.push({
name: 'ServicesLiveRoomLiveControl',
params: {
id: row.id
}
})
},
openDialog() {
this.isDialogVisible = true
},
handleClose() {
this.isDialogVisible = !this.isDialogVisible
this.$refs.ruleForm.resetFields()
},
handleConfirm() {
// getRecordListApi
this.$refs['ruleForm'].validate(valid => {
if (!valid) {
return
}
let params = {}
params.verficationCode = this.ruleForm.verficationCode
// params.discountTypes=[7]
this.$apis.record.getVerificationCode(params).then(res => {
if (res) {
this.handleClose()
this.handleSearch()
}
})
})
},
// 1-新增;2-编辑
handleEdit(addOrEdit, row) {
this.$router.push({
name: 'ServicesLiveRoomEditLiveRoom',
params: {
addOrEdit: addOrEdit,
id: row ? row.id : '-1'
}
})
},
handleExport(row) {
var params = this.getParams()
this.$apis.couponManage.verificationExportApi(params).then(res => {
exportFn(res)
})
},
handleSearch() {
this.$refs.memberRecordRef.refreshTable()
},
handleReset() {
this.isReload = false
this.searchForm = {
grantMerchantId: '',
verificationMerchantId: '',
couponName: '',
userReq: '',
verificationOperator: '',
orderCode: '',
packageId: '',
discountType: '',
discountTypes: [2, 3, 4, 7]
}
this.$nextTick(() => {
this.isReload = true
})
}
}
}
</script>
<style lang="scss" scoped>
</style>