receiveDetail.vue
14.7 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
485
486
<!-- 领取详情 -->
<template>
<div class="marketing pro-group">
<div class="edit-container">
<div class="marketing edit-box">
<div class="container edit-container m-b-20">
<p class="edit-title">优惠券信息</p>
<el-form class="flex-wrap" label-width="120px">
<el-form-item class="info-item" v-for="(item, index) in couponFormData" :key="index" :label="item.label + ':'">
<div v-if="item.name == 'discountType' && coupon[item.name]">
<img style="vertical-align: middle;" :src="require(`@/assets/coupon/icon-${attrToIcon[coupon[item.name]]}.png`)" />
</div>
<div v-else-if="item.formatter">{{ item.formatter() }}</div>
<div v-else>{{ coupon[item.name] }}</div>
</el-form-item>
</el-form>
</div>
</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="exportExcel">全部导出</el-button>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="receiveList" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
<div slot="userStatus" slot-scope="scope">
<p>
<span :class="['table-circle', 'm-r-8', scope.scope.userStatus == 1 ? 'back-green' : scope.scope.userStatus == 2 ? 'back-red' : 'back-grey']"></span>
<span>{{ baseData.userStatusList.find(item => item.confId == scope.scope.userStatus).confName }}</span>
</p>
<p v-if="scope.scope.userStatus == 4">{{ scope.scope.cancelReason }}</p>
</div>
<div class="table-btns" slot="auth-button" slot-scope="scope">
<GLTableButton :buttonList="tableButtonList" :buttonItem="scope.scope" :buttonNum="3"></GLTableButton>
</div>
</GLTable>
<!-- 表格区域 end -->
</div>
</div>
<!-- 作废 -->
<GLDialog title="作废确认" mode="small" :visible.sync="isCancelVisible" @onOk="handleCancelConfirm" @onCancel="handleCancelClose">
<div class="small-content">
<p>请先和客户沟通在确认,避免引起客诉,作废后客户将不可使用该礼包下所有优惠卷</p>
<el-form ref="cancelRef" label-width="80px" :rules="cancelRules" :model="cancelForm">
<el-form-item label="作废原因" prop="cancelReason" class="m-t-20">
<el-input style="width: 410px;" :size="size" type="textarea" v-model.trim="cancelForm.cancelReason" placeholder="请输入作废原因" maxlength="50" rows="3" show-word-limit></el-input>
</el-form-item>
</el-form>
</div>
</GLDialog>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
export default {
name: 'receiveDetail',
data() {
return {
size: 'small',
url: url,
// 作废
isCancelVisible: false,
cancelForm: {
userCouponId: '',
cancelReason: ''
},
cancelRules: {
cancelReason: [{ required: true, message: '请输入作废原因', trigger: 'change' }]
},
coupon: {
couponName: '',
stock: '',
getAmount: '',
overdueAmount: ''
},
effective: '',
useB: '',
attrToIcon: {
2: 'discount',
3: 'cash',
4: 'exchange',
7: 'service'
},
// 优惠券信息
couponFormData: [
{
label: '券名称',
name: 'couponName'
},
{
label: '券类型',
name: 'discountType'
},
{
label: '有效期',
name: 'effectiveTxt'
},
// {
// label: '适用范围',
// name: 'scopeApplicationTxt'
// },
{
label: '发行库存',
name: 'limitStockFlag',
formatter: () => {
switch (this.coupon.limitStockFlag) {
case 1:
return this.coupon.stock
case 2:
return '无库存限制'
default:
return '-'
}
}
},
{
label: '已领取',
name: 'getAmount'
},
{
label: '已使用',
name: 'usedAmount'
}
],
// 表格按钮
tableButtonList: [
{
type: 'el-button',
name: '作废',
attrs: {
type: 'text',
disabled: (row, condition) => {
var isDisabled = [2, 3, 4].includes(row.userStatus)
if (+row.userStatus == 2 && this.coupon.discountType == 7) {
isDisabled = false
}
return isDisabled
}
},
listeners: {
click: this.handleCancel
}
}
],
// 表格
searchForm: {
userInfo: '',
wechatUserFlag: '',
userStatus: '',
daterange: ''
},
tableSearchForm: {},
// 搜索
searchFormData: [
{
label: '用户信息',
name: 'userInfo',
type: 'input',
maxlength: 50
},
{
label: '是否加企微',
name: 'wechatUserFlag',
type: 'select',
optionList: [],
optionId: 'statusId',
optionLabel: 'statusName',
optionsName: 'wechatUserFlagList'
},
{
label: '使用状态',
name: 'userStatus',
type: 'select',
optionList: [],
optionId: 'confId',
optionLabel: 'confName',
optionsName: 'userStatusList'
},
{
label: '领取日期',
name: 'daterange',
type: 'datePicker',
isClear: true,
pickerOptions: 'beforeRangePickerOptions'
}
],
// 表格
getListApi: this.$apis.couponManage.getListReceiveRecordApi,
tableParams: {
listName: 'list',
tableOption: true,
tableColumns: [
{
label: '领取用户',
prop: 'userName',
formatter: cellValue => {
return cellValue.userName == cellValue.phone ? cellValue.userName : cellValue.userName + ' ' + cellValue.phone
}
},
{
label: '是否已加企微',
prop: 'wechatUserFlag',
formatter: cellValue => {
return this.baseData.wechatUserFlagList.find(item => item.statusId == cellValue.wechatUserFlag).statusName
}
},
{
label: '使用状态',
prop: 'userStatus',
addHtml: 'userStatus'
// formatter: cellValue => {
// return this.baseData.userStatusList.find(item => +item.confId == cellValue.userStatus).confName
// }
},
{
label: '领取日期',
prop: 'createdDate',
formatter: cellValue => {
return dayjs(cellValue.createdDate).format('YYYY-MM-DD HH:mm:ss')
}
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
baseData: {
userStatusList: [
{
confId: '1',
confName: '未使用'
},
{
confId: '2',
confName: '已使用'
},
{
confId: '3',
confName: '已失效'
},
{
confId: '4',
confName: '已作废'
}
],
wechatUserFlagList: [
{
statusId: '2',
statusName: '是'
},
{
statusId: '1',
statusName: '否'
}
]
},
exportLoading: false
}
},
components: {},
created() {
// if (!this.$isGroupUp) {
// let idx = this.couponFormData.findIndex(item => item.label == '适用范围')
// this.couponFormData.splice(idx, 1)
// }
},
mounted() {
this.getOptionsList('searchFormData')
this.getInfo(this.$route.params.id)
},
methods: {
getParams() {
var params = JSON.parse(JSON.stringify(this.searchForm))
params.couponId = this.$route.params.id
if (params.daterange) {
params.receiveTimeBegin = new Date(this.searchForm.daterange[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
params.receiveTimeEnd = 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
return params
},
beforeSearchFn() {
return new Promise(resolve => {
this.tableSearchForm = this.getParams()
resolve()
})
},
getInfo(couponId) {
var params = {}
params.couponId = couponId
this.$apis.couponManage.getCouponDetailApi(params).then(res => {
this.coupon = res
this.effective = ''
this.useB = ''
var coupon = res
//有效期
if (coupon.effectiveType == 1) {
//固定天数,领取后计算
// this.effective = coupon.effectiveDays + '天'
this.coupon.effectiveTxt = coupon.effectiveDays + '天'
} else if (coupon.effectiveType == 2) {
//时间段
this.coupon.effectiveTxt = coupon.effectiveStartTime + ' - ' + coupon.effectiveEndTime
} else if (coupon.effectiveType == 3) {
//永久有效
this.coupon.effectiveTxt = '永久有效'
}
if (coupon.discountType == 3) {
//代金券
//使用限制
if (coupon.useBarriers == 1) {
//无限制
this.useB = '无限制'
} else if (coupon.useBarriers == 2) {
//满减
this.useB = '满' + coupon.full + '元可用'
}
}
if (coupon.discountType == 7) {
//服务券
//使用限制
if (coupon.useType == 0) {
//无限制
this.useB = '无限制'
} else if (coupon.useType == 1) {
//有效期内可使用次数
this.useB = '有效期内可使用' + coupon.useAmount + '次'
} else if (coupon.useType == 2) {
//有效期内多少天内可使用次数
this.useB = '有效期内' + coupon.useLimitDays + '天可使用' + coupon.usedAmount + '次'
}
}
// 适用范围
// if (this.$isGroupUp) {
// this.coupon.scopeApplicationTxt =
// {
// 1: '旗下所有店通用',
// 2: '旗下品牌店通用'
// }[coupon.scopeApplication] || '-'
// }
})
},
handleCancel(row) {
this.cancelForm.userCouponId = row.id
this.cancelVisibleChange()
},
cancelVisibleChange() {
this.$refs.cancelRef && this.$refs.cancelRef.clearValidate()
this.isCancelVisible = !this.isCancelVisible
},
handleCancelClose() {
this.cancelVisibleChange()
this.cancelForm = {
userCouponId: '',
cancelReason: ''
}
},
handleCancelConfirm() {
this.$refs.cancelRef.validate(valid => {
if (valid) {
this.$apis.couponManage.couponUserCancelApi(this.cancelForm).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleCancelClose()
this.handleSearch()
}
})
}
})
},
/**导出excel */
exportExcel() {
this.exportLoading = true
var params = this.getParams()
this.$apis.couponManage.exportReceiveRecordApi(params).then(res => {
this.exportLoading = false
window.location.href = res
})
},
//返回
goback() {
this.$router.push('/couponManage/index')
},
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)
}
}
})
}
},
handleSearch() {
this.$refs.receiveList.refreshTable()
},
handleReset() {
this.searchForm = {
userInfo: '',
wechatUserFlag: '',
userStatus: '',
daterange: ''
}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.receiveList.data.length ? (this.$refs.receiveList.tableHeightValues = '') : this.$refs.receiveList.setTableHeightFun()
}
}
}
</script>
<style scoped>
.modal-title span {
font-size: 12px;
font-weight: 400;
}
.icon-green {
background-color: rgba(3, 153, 69, 0.2);
border: 1px solid rgba(3, 153, 69, 0.2);
}
.icon-tips {
border-radius: 2px;
font-size: 12px;
color: #333;
line-height: 30px;
padding: 0 10px 0 30px;
position: relative;
}
.icon-tips span {
margin-right: 10px;
}
.icon-tips i {
font-style: normal;
color: #ff3f3f;
margin: 0 3px;
}
.icon-tips img {
position: absolute;
top: 8px;
left: 10px;
}
.info-item {
box-sizing: border-box;
width: 33.33%;
}
</style>