084351b6
李宇
1
|
1
2
3
|
<template>
<div class="addCoupon">
<!-- 新增优惠券 -->
|
b1d468f9
李宇
1
|
4
5
|
<div class="addCouponBox" style="padding-right: 30px;">
<TitleWithCircle title="基本信息" style="margin-bottom: 20px;"/>
|
084351b6
李宇
1
|
6
7
8
|
<div style="padding-bottom: 15px;padding-right: 30px;padding-left: 80px;font-weight: bold;">
所需金额:{{ changecouponfrom() }} 元
</div>
|
8550d958
杨鑫
'最新'
|
9
|
|
084351b6
李宇
1
|
10
11
12
13
14
15
16
17
|
<el-form ref="ruleForm" class="formBox" :model="couponfrom" label-width="150px" :rules="couponRules">
<el-form-item label="优惠券名称" prop="couponName">
<el-input v-model="couponfrom.couponName" placeholder="请输入优惠券名称" onblur="value=value.replace(/(^\s*)|(\s*$)/g, '')" />
</el-form-item>
<el-form-item label="优惠券类型">
<el-radio v-model="couponfrom.couponType" label="1">满减券</el-radio>
<el-radio v-model="couponfrom.couponType" label="2">折扣券</el-radio>
</el-form-item>
|
8db25941
李宇
2
|
18
19
|
<el-form-item v-if="couponfrom.couponType === '1'" class="inputW" label="优惠内容" prop="usageThreshold">
订单满 <el-input-number v-model="couponfrom.usageThreshold" :controls="false" :min="0" :precision="2" :step="0.01" /> 元 减 <el-input-number v-model="couponfrom.discountContent" :controls="false" :min="0" :precision="2" :step="0.01" /> 元
|
084351b6
李宇
1
|
20
21
|
</el-form-item>
<el-form-item v-else class="inputW discount" label="优惠内容" prop="discountContent">
|
8550d958
杨鑫
'最新'
|
22
|
|
8db25941
李宇
2
|
23
|
打 <el-input-number v-model="couponfrom.discountContent" :controls="false" :min="0" :max="9.9" :precision="1" :step="0.1" /> 折
|
084351b6
李宇
1
|
24
25
26
27
|
<span v-if="couponfrom.couponType === '2'" style="margin-right: 10px;">
最高优惠金额
<el-input-number v-model="couponfrom.maxDiscountAmount" :controls="false" :min="0" :precision="2" :step="0.01" /> 元
</span>
|
8db25941
李宇
2
|
28
|
<label>折数输入值要大于0 小于10,可保留一位小数</label>
|
8550d958
杨鑫
'最新'
|
29
|
|
084351b6
李宇
1
|
30
31
32
33
34
|
</el-form-item>
<!-- <el-form-item v-if="couponfrom.couponType === '2'" class="inputW" label="最高优惠金额" prop="maxDiscountAmount">
<el-input-number v-model="couponfrom.maxDiscountAmount" :controls="false" :min="0" :precision="2" :step="0.01" /> 元
</el-form-item> -->
<el-form-item label="可用商品类别:">
|
b1d468f9
李宇
1
|
35
|
<el-radio-group v-model="couponfrom.useCategory" @change="changeType">
|
084351b6
李宇
1
|
36
|
<el-radio :label="1" >全部</el-radio>
|
8550d958
杨鑫
'最新'
|
37
|
<el-radio :label="2" >选择类别</el-radio>
|
084351b6
李宇
1
|
38
39
|
</el-radio-group>
</el-form-item>
|
b1d468f9
李宇
1
|
40
41
|
<el-form-item label="选择商品类别:" v-if="couponfrom.useCategory === 2">
<el-select style="width: 100%;" multiple v-model="useCategory" placeholder="请选择" filterable @change="changeuseCategory">
|
084351b6
李宇
1
|
42
43
44
45
46
47
48
49
50
|
<el-option
v-for="item in classList"
:key="item.classifyId"
:label="item.classifyName"
:value="item.classifyId"
/>
</el-select>
</el-form-item>
<el-form-item label="使用范围:">
|
b1d468f9
李宇
1
|
51
|
<el-radio-group v-model="couponfrom.usedMerchants" >
|
084351b6
李宇
1
|
52
53
|
<el-radio :label="1" >全平台</el-radio>
<!-- <el-radio :label="2" >自营</el-radio> -->
|
8550d958
杨鑫
'最新'
|
54
|
<el-radio :label="3" >部分商家</el-radio>
|
084351b6
李宇
1
|
55
56
|
</el-radio-group>
</el-form-item>
|
b1d468f9
李宇
1
|
57
|
<el-form-item label="选择商家:" v-if="couponfrom.usedMerchants === 3">
|
8550d958
杨鑫
'最新'
|
58
59
60
61
62
|
<el-select
style="width: 100%;"
multiple
v-model="usedMerchants"
placeholder="请选择"
|
084351b6
李宇
1
|
63
|
filterable
|
b1d468f9
李宇
1
|
64
|
@change="changeusedMerchants"
|
084351b6
李宇
1
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
>
<el-option
v-for="item in shopList"
:key="item.shopId"
:label="item.shopName"
:value="item.shopId"
/>
</el-select>
</el-form-item>
<div style="display: flex;">
<el-form-item label="是否开启积分兑换:">
<el-radio-group v-model="pointsRequired">
<el-radio :label="1" >是</el-radio>
<el-radio :label="0" >否</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="pointsRequired" label="所需积分:">
<el-input v-model="couponfrom.pointsRequired" type="number" style="width: 150px" /> 分
</el-form-item>
</div>
|
8db25941
李宇
2
|
85
86
87
88
89
90
|
<el-form-item label="是否重复领用:">
<el-radio-group v-model="couponfrom.receiveAgain">
<el-radio :label="1" >是</el-radio>
<el-radio :label="0" >否</el-radio>
</el-radio-group>
</el-form-item>
|
b1d468f9
李宇
1
|
91
|
<el-form-item class="timeDataBox" label="用券时间" prop="startTime">
|
084351b6
李宇
1
|
92
93
94
95
96
97
98
99
100
101
102
|
<el-date-picker
v-model="dateInfo"
type="datetimerange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd HH:mm:ss"
@change="changeDate"
/>
</el-form-item>
<el-form-item class="boxWidth" label="数量" prop="totalCoupons">
|
8db25941
李宇
2
|
103
104
|
<el-input-number v-model="couponfrom.totalCoupons" :controls="false" :min="1" :max="changemax" :precision="0" :step="1" /> 张 <span >(最大:{{ changemax}} 张)</span>
<!-- <el-input v-model="couponfrom.totalCoupons" :controls="false" type="number" :min="1" oninput="value=value.replace(/[^\d]/g,'')" />张 <span v-if="coupoobj.symon && changecouponfrom()!=0">(最大:{{ (coupoobj.symon/changecouponfrom()).toFixed(0) }} 张)</span> -->
|
084351b6
李宇
1
|
105
106
|
</el-form-item>
<el-form-item label="备注">
|
b1d468f9
李宇
1
|
107
|
<el-input maxlength="200" show-word-limit rows="4" v-model="couponfrom.remark" placeholder="请输入备注" type="textarea" />
|
084351b6
李宇
1
|
108
109
110
111
112
|
</el-form-item>
</el-form>
</div>
</div>
</template>
|
8550d958
杨鑫
'最新'
|
113
|
|
084351b6
李宇
1
|
114
115
|
<script>
import { commdityClassGetAll } from '@/api/renovation';
|
b1d468f9
李宇
1
|
116
|
import TitleWithCircle from '@/components/top/index';
|
084351b6
李宇
1
|
117
118
119
120
|
import {
businessListGetAll,
} from '@/api/business'
export default {
|
b1d468f9
李宇
1
|
121
122
123
|
components: {
TitleWithCircle
},
|
084351b6
李宇
1
|
124
125
126
127
128
129
130
131
132
133
134
135
|
name: 'AddCoupon',
props: {
couponfrom: {
type: Object,
default: {},
},
coupoobj: {
type: Object,
default: {
symon:0
},
|
084351b6
李宇
1
|
136
137
138
|
},
},
data() {
|
8db25941
李宇
2
|
139
140
141
142
|
var moneyContentusageThreshold = (rule, value, callback) => {
if(!this.couponfrom.usageThreshold) {
return callback(new Error('请输入优惠门槛'));
|
b1d468f9
李宇
1
|
143
144
145
146
147
|
}
if(!this.couponfrom.discountContent) {
return callback(new Error('请输入优惠内容'));
}
if(this.couponfrom.couponType == '1') {
|
8db25941
李宇
2
|
148
|
if(Number(this.couponfrom.discountContent) >= Number(this.couponfrom.usageThreshold)) {
|
b1d468f9
李宇
1
|
149
|
return callback(new Error('请满减金额大于优惠金额'));
|
8550d958
杨鑫
'最新'
|
150
151
|
}
}
|
b1d468f9
李宇
1
|
152
153
|
callback();
}
|
8db25941
李宇
2
|
154
155
156
157
158
159
160
|
var moneyContentdiscountContent = (rule, value, callback) => {
if(!this.couponfrom.discountContent) {
return callback(new Error('请输入优惠内容'));
}
if(!this.couponfrom.maxDiscountAmount) {
return callback(new Error('请输入最高优惠'));
}
|
8550d958
杨鑫
'最新'
|
161
|
|
8db25941
李宇
2
|
162
163
|
callback();
}
|
084351b6
李宇
1
|
164
|
return {
|
8db25941
李宇
2
|
165
|
changemax:9999,
|
084351b6
李宇
1
|
166
|
monys:0,
|
b1d468f9
李宇
1
|
167
|
usedMerchants:null,
|
084351b6
李宇
1
|
168
169
170
|
pointsRequired:0,
dateInfo: null,
isThreshold: true,
|
b1d468f9
李宇
1
|
171
|
useCategory:null,
|
084351b6
李宇
1
|
172
173
174
175
176
177
178
|
useCategory2:1,
classList:[],
shopList:[],
couponRules: {
couponName: [
{ required: true, message: '请输入优惠券名称', trigger: 'blur' }
],
|
8db25941
李宇
2
|
179
180
|
usageThreshold: [ { validator: moneyContentusageThreshold, trigger: 'blur' }],
discountContent: [ { validator: moneyContentdiscountContent, trigger: 'blur' }],
|
b1d468f9
李宇
1
|
181
|
startTime: [{required: true, message: '请选择时间', trigger: 'blur'}],
|
084351b6
李宇
1
|
182
183
184
185
186
|
totalCoupons: [{ required: true, message: '请输入数量', trigger: 'blur' }]
},
}
},
watch: {
|
8db25941
李宇
2
|
187
188
189
190
191
192
193
194
195
|
'couponfrom.discountContent'(val) {
this.setchangemax()
},
'couponfrom.usageThreshold'(val) {
this.setchangemax()
},
'couponfrom.maxDiscountAmount'(val) {
this.setchangemax()
},
|
084351b6
李宇
1
|
196
197
198
199
|
'couponfrom.couponType'(val) {
this.couponfrom.maxDiscountAmount = 0
this.couponfrom.discountContent = 0
},
|
b1d468f9
李宇
1
|
200
|
'couponfrom.useCategory'(val) {
|
084351b6
李宇
1
|
201
|
if(val == '1') {
|
b1d468f9
李宇
1
|
202
|
this.useCategory = null
|
084351b6
李宇
1
|
203
|
} else {
|
8550d958
杨鑫
'最新'
|
204
|
}
|
084351b6
李宇
1
|
205
|
},
|
b1d468f9
李宇
1
|
206
207
|
'couponfrom.usedMerchants'(val) {
this.usedMerchants = null
|
084351b6
李宇
1
|
208
209
|
},
pointsRequired(val) {
|
b1d468f9
李宇
1
|
210
|
this.couponfrom.pointsRequired = 0
|
084351b6
李宇
1
|
211
212
213
214
215
216
|
},
},
mounted() {
this.getAll()
},
methods: {
|
8db25941
李宇
2
|
217
218
|
setchangemax(){
if(this.coupoobj.symon && this.changecouponfrom()!=0) {
|
93c8bac5
李宇
1
|
219
|
this.changemax = Number(((Number(this.coupoobj.symon)/100)/this.changecouponfrom()).toFixed(0))
|
8db25941
李宇
2
|
220
221
222
223
|
} else {
this.changemax = 999999
}
},
|
b1d468f9
李宇
1
|
224
225
226
227
228
229
|
changeuseCategory(e){
this.$emit('changevalue','useCategorylist',e)
},
changeusedMerchants(e){
this.$emit('changevalue','usedMerchantslist',e)
},
|
084351b6
李宇
1
|
230
231
232
233
|
changeDate(e){
console.error(e)
if(e && e.length>0) {
this.couponfrom.startTime = e[0]
|
93c8bac5
李宇
1
|
234
|
this.couponfrom.endTime = e[1]
|
084351b6
李宇
1
|
235
236
237
238
|
} else {
this.couponfrom.startTime = ''
this.couponfrom.endTime = ''
}
|
8550d958
杨鑫
'最新'
|
239
|
|
084351b6
李宇
1
|
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
|
},
changecouponfrom() {
let num = 0
if(this.couponfrom.couponType == '1') {
num = (this.couponfrom.discountContent?Number(this.couponfrom.discountContent):0) * (this.couponfrom.totalCoupons?Number(this.couponfrom.totalCoupons):0)
} else if(this.couponfrom.couponType == '2') {
num = (this.couponfrom.maxDiscountAmount?Number(this.couponfrom.maxDiscountAmount):0) * (this.couponfrom.totalCoupons?Number(this.couponfrom.totalCoupons):0)
}
console.log(num)
return num
},
// 获取类别
async getAll () {
const res = await commdityClassGetAll({
page: 1,
pageSize: 100
})
this.classList = res.data.list
const res1 = await businessListGetAll ({
page: 1,
pageSize: 400
})
this.shopList = res1.data.list
},
changeThreshold(val) { // 输入框值改变
if (val) {
this.couponfrom.threshold = 0
}
},
changeType () {
}
}
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
@import url("../../styles/elDialog.scss");
.addCoupon {
background: #FFFFFF;
.dialog-footer {
// margin-left: 300px;
}
.formBox {
.flexBox {
display: flex;
}
.applyType {
span {
width: 100px;
height: 30px;
line-height: 30px;
background: #3F9B6A;
color: #FFFFFF;
text-align: center;
display: inline-block;
font-size: 14px;
margin-right: 30px;
border-radius: 4px;
cursor: pointer;
position: relative;
i {
position: absolute;
right: -10px;
top: -10px;
width: 25px;
height: 25px;
line-height: 25px;
background: #FFFFFF;
border-radius: 50%;
border: 1px solid #3F9B6A;
text-align: center;
color: #3F9B6A;
font-style: normal;
font-size: 12px;
}
}
}
}
.footBtnBox {
width: 100%;
display: flex;
justify-content: center;
margin-top: 50px;
}
.dateBox {
display: flex;
align-items: center;
.description {
width: 59px;
text-align: center;
display: block;
font-size: 14px;
color: #999999;
}
}
.discount label {
color: #cccccc;
font-weight: 500;
padding-left: 30px;
}
}
|
8550d958
杨鑫
'最新'
|
342
|
|
084351b6
李宇
1
|
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
|
</style>
<style scoped>
.flexBox /deep/ .el-input {
width: 300px;
}
.inputW /deep/ .el-input, .el-input-number {
width: 100px;
/* margin: 0 8px; */
}
.inputW /deep/ .el-input .el-input__inner {
text-align: center;
}
.inputW /deep/ .el-form-item__error {
padding-left: 25px;
}
.inputW /deep/ .el-checkbox {
margin-left: 20px;
}
.inputW /deep/ .el-radio {
margin-left: 30px;
}
.boxWidth /deep/ .el-input {
width: 100px;
margin-right: 15px;
}
.boxWidth /deep/ .el-input .el-input__inner {
text-align: center;
}
.addCoupon /deep/ .el-button--primary {
background: #3F9B6A;
border-color: #3F9B6A;
}
.addCoupon /deep/ .el-dialog__header {
background-color: #3F9B6A;
}
.addCoupon /deep/ .el-dialog__headerbtn .el-dialog__close {
color: #FFFFFF;
}
.addCoupon .timeDataBox /deep/ .el-form-item__content {
display: flex;
align-items: center;
}
.addCoupon .timeDataBox /deep/ .el-form-item__label {}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input[type="number"]{
-moz-appearance: textfield;
}
|
8550d958
杨鑫
'最新'
|
393
|
|
084351b6
李宇
1
|
394
|
</style>
|