writeOffDetail.vue
9.59 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
<!-- 核销详情 -->
<template>
<div class="marketing pro-group p-t-20">
<div class="container">
<div>
<glsx-combi-form ref="showSearch" :formObj="searchForm" :formData="searchFormData">
<span slot="footer" class="footer-btns">
<el-button :size="size" @click="handleReset">重置</el-button>
<el-button :size="size" type="primary" @click="handleSearch">查询</el-button>
<el-button :size="size" type="primary" @click="writeOff">优惠券核销</el-button>
<el-button :size="size" type="primary" @click="handleExport">导出</el-button>
<el-button :size="size" @click="goback">返回</el-button>
</span>
</glsx-combi-form>
</div>
<div class="list-tips">
<img class="tips-img" src="@/assets/icon-info.png" />
<span>
优惠券名称:
<span class="red-txt">{{ coupon.couponName }}</span>
</span>
<span style="margin-left:10px">
发行总量:
<span class="red-txt">{{ coupon.stock || 0 }} </span>
</span>
<span style="margin-left:10px">
核销总量:
<span class="red-txt">{{ coupon.usedAmount || 0 }} </span>
</span>
<span style="margin-left:10px">
有效期:
<span class="red-txt">{{ effective }} </span>
</span>
<span style="margin-left:10px">
使用限制:
<span class="red-txt">{{ useB }} </span>
</span>
</div>
<!-- 表格区域 开始 -->
<GLTable ref="writeOffList" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun"></GLTable>
<!-- 表格区域 end -->
</div>
<!-- 优惠券核销 -->
<glsx-dialog title="优惠券核销(请确保用户到店后核销,避免引起不必要问题)" :isVisible.sync="writeOffVisible" @confirmDialog="handleDownConfirm" @closeDialog="handleDownClose">
<el-form ref="writeOffRef" label-width="100px" :rules="writeOffRules" :model="writeOffForm">
<el-form-item label="核销码" prop="verficationCode">
<el-input :size="size" v-model="writeOffForm.verficationCode" placeholder="请输入核销码" style="width:300px;" maxlength="32"></el-input>
</el-form-item>
</el-form>
</glsx-dialog>
</div>
</template>
<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { exportFn } from '@/common/constant'
export default {
name: 'writeOffDetail',
data() {
return {
size: 'small',
url: url,
writeOffVisible: false,
coupon: {
couponName: '',
stock: '',
usedAmount: ''
},
effective: '',
useB: '',
writeOffForm: {
verficationCode: ''
},
writeOffRules: {
verficationCode: [{ required: true, message: '请输入核销码', trigger: 'change' }]
},
shareForm: {},
// 表格
searchForm: {
verificationCode: ''
},
tableSearchForm: {},
// 搜索
searchFormData: [
{
label: '核销码',
name: 'verificationCode',
type: 'input',
maxlength: 20
}
],
// 表格
getListApi: this.$apis.couponManage.getVerificationListApi,
tableParams: {
listName: 'list',
tableOption: false,
tableColumns: [
{
label: '核销码',
prop: 'verificationCode'
},
{
label: '手机号',
prop: 'phone'
},
{
label: '领取时间',
prop: 'receiveTime',
formatter: cellValue => {
return dayjs(cellValue.receiveTime).format('YYYY-MM-DD HH:mm:ss')
}
},
{
label: '核销时间',
prop: 'verificationTime',
formatter: cellValue => {
return dayjs(cellValue.verificationTime).format('YYYY-MM-DD HH:mm:ss')
}
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
baseData: {}
}
},
components: {},
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
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 + '天'
} else if (coupon.effectiveType == 2) {
//时间段
this.effective = coupon.effectiveStartTime + ' ~ ' + coupon.effectiveEndTime
} else if (coupon.effectiveType == 3) {
//无有效期
this.effective = '无有效期'
}
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.useAmount + '次'
}
}
})
},
writeOff() {
this.writeOffVisible = !this.writeOffVisible
},
//返回
goback() {
this.$router.push('/couponManage/index')
},
dwonVisibleChange() {
this.$refs.writeOffRef && this.$refs.writeOffRef.clearValidate()
this.writeOffVisible = !this.writeOffVisible
},
handleDownClose() {
this.dwonVisibleChange()
this.writeOffForm = {
verficationCode: ''
}
},
handleDownConfirm() {
this.$refs.writeOffRef.validate(valid => {
if (valid) {
this.$apis.couponManage.codeVerificationApi(this.writeOffForm).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
this.handleDownClose()
this.handleSearch()
}
})
}
})
},
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)
}
}
})
}
},
handleExport(row) {
var params = this.getParams()
this.$apis.couponManage.verificationExportApi(params).then(res => {
exportFn(res)
})
},
handleSearch() {
this.$refs.writeOffList.refreshTable()
},
handleReset() {
this.searchForm = {
verificationCode: ''
}
this.handleSearch()
},
setTableFinishFun() {
//接收到的数据为空
this.$refs.writeOffList.data.length ? (this.$refs.writeOffList.tableHeightValues = '') : this.$refs.writeOffList.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;
}
</style>