6ee6b0b7
杨鑫
'最新'
|
1
2
3
|
<template>
<div class="addCoupon">
<!-- 新增优惠券 -->
|
ab818baa
杨鑫
'1'
|
4
5
|
<div class="addCouponBox" style="padding-right: 30px;">
<TitleWithCircle title="基本信息" style="margin-bottom: 20px;"/>
|
6ee6b0b7
杨鑫
'最新'
|
6
7
8
|
<div style="padding-bottom: 15px;padding-right: 30px;padding-left: 80px;font-weight: bold;">
所需金额:{{ changecouponfrom() }} 元
</div>
|
8cb5c17e
杨鑫
'最新1'
|
9
|
|
6ee6b0b7
杨鑫
'最新'
|
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>
|
ab818baa
杨鑫
'1'
|
18
|
<el-form-item v-if="couponfrom.couponType === '1'" class="inputW" label="优惠内容" prop="maxDiscountAmount">
|
6ee6b0b7
杨鑫
'最新'
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
订单满 <el-input-number v-model="couponfrom.maxDiscountAmount" :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" /> 元
</el-form-item>
<el-form-item v-else class="inputW discount" label="优惠内容" prop="discountContent">
<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>
打 <el-input-number v-model="couponfrom.discountContent" :controls="false" :min="0" :max="9.9" :precision="1" :step="0.1" /> 折
<label>输入值要大于0 小于10,可保留一位小数</label>
</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="可用商品类别:">
|
ab818baa
杨鑫
'1'
|
34
|
<el-radio-group v-model="couponfrom.useCategory" @change="changeType">
|
6ee6b0b7
杨鑫
'最新'
|
35
|
<el-radio :label="1" >全部</el-radio>
|
8cb5c17e
杨鑫
'最新1'
|
36
|
<el-radio :label="2" >选择类别</el-radio>
|
6ee6b0b7
杨鑫
'最新'
|
37
38
|
</el-radio-group>
</el-form-item>
|
ab818baa
杨鑫
'1'
|
39
40
|
<el-form-item label="选择商品类别:" v-if="couponfrom.useCategory === 2">
<el-select style="width: 100%;" multiple v-model="useCategory" placeholder="请选择" filterable @change="changeuseCategory">
|
6ee6b0b7
杨鑫
'最新'
|
41
42
43
44
45
46
47
48
49
|
<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="使用范围:">
|
ab818baa
杨鑫
'1'
|
50
|
<el-radio-group v-model="couponfrom.usedMerchants" >
|
6ee6b0b7
杨鑫
'最新'
|
51
52
|
<el-radio :label="1" >全平台</el-radio>
<!-- <el-radio :label="2" >自营</el-radio> -->
|
8cb5c17e
杨鑫
'最新1'
|
53
|
<el-radio :label="3" >部分商家</el-radio>
|
6ee6b0b7
杨鑫
'最新'
|
54
55
|
</el-radio-group>
</el-form-item>
|
ab818baa
杨鑫
'1'
|
56
|
<el-form-item label="选择商家:" v-if="couponfrom.usedMerchants === 3">
|
8cb5c17e
杨鑫
'最新1'
|
57
58
59
60
61
|
<el-select
style="width: 100%;"
multiple
v-model="usedMerchants"
placeholder="请选择"
|
6ee6b0b7
杨鑫
'最新'
|
62
|
filterable
|
ab818baa
杨鑫
'1'
|
63
|
@change="changeusedMerchants"
|
6ee6b0b7
杨鑫
'最新'
|
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
>
<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>
|
ab818baa
杨鑫
'1'
|
84
|
<el-form-item class="timeDataBox" label="用券时间" prop="startTime">
|
6ee6b0b7
杨鑫
'最新'
|
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
<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">
<el-input v-model="couponfrom.totalCoupons" type="number" oninput="value=value.replace(/[^\d]/g,'')" />张 <span v-if="coupoobj.symon && changecouponfrom()!=0">(最大:{{ (coupoobj.symon/changecouponfrom()).toFixed(0) }} 张)</span>
</el-form-item>
<el-form-item label="备注">
|
ab818baa
杨鑫
'1'
|
99
|
<el-input maxlength="200" show-word-limit rows="4" v-model="couponfrom.remark" placeholder="请输入备注" type="textarea" />
|
6ee6b0b7
杨鑫
'最新'
|
100
101
102
103
104
|
</el-form-item>
</el-form>
</div>
</div>
</template>
|
8cb5c17e
杨鑫
'最新1'
|
105
|
|
6ee6b0b7
杨鑫
'最新'
|
106
107
|
<script>
import { commdityClassGetAll } from '@/api/renovation';
|
ab818baa
杨鑫
'1'
|
108
|
import TitleWithCircle from '@/components/top/index';
|
6ee6b0b7
杨鑫
'最新'
|
109
110
111
112
|
import {
businessListGetAll,
} from '@/api/business'
export default {
|
ab818baa
杨鑫
'1'
|
113
114
115
|
components: {
TitleWithCircle
},
|
6ee6b0b7
杨鑫
'最新'
|
116
117
118
119
120
121
122
123
124
125
126
127
|
name: 'AddCoupon',
props: {
couponfrom: {
type: Object,
default: {},
},
coupoobj: {
type: Object,
default: {
symon:0
},
|
6ee6b0b7
杨鑫
'最新'
|
128
129
130
|
},
},
data() {
|
ab818baa
杨鑫
'1'
|
131
132
133
134
135
136
137
138
139
140
|
var moneyContent = (rule, value, callback) => {
if(!this.couponfrom.maxDiscountAmount) {
return callback(new Error('请输入优惠内容'));
}
if(!this.couponfrom.discountContent) {
return callback(new Error('请输入优惠内容'));
}
if(this.couponfrom.couponType == '1') {
if(Number(this.couponfrom.discountContent) >= Number(this.couponfrom.maxDiscountAmount)) {
return callback(new Error('请满减金额大于优惠金额'));
|
8cb5c17e
杨鑫
'最新1'
|
141
142
|
}
}
|
ab818baa
杨鑫
'1'
|
143
144
|
callback();
}
|
6ee6b0b7
杨鑫
'最新'
|
145
146
|
return {
monys:0,
|
ab818baa
杨鑫
'1'
|
147
|
usedMerchants:null,
|
6ee6b0b7
杨鑫
'最新'
|
148
149
150
|
pointsRequired:0,
dateInfo: null,
isThreshold: true,
|
ab818baa
杨鑫
'1'
|
151
|
useCategory:null,
|
6ee6b0b7
杨鑫
'最新'
|
152
153
154
155
156
157
158
|
useCategory2:1,
classList:[],
shopList:[],
couponRules: {
couponName: [
{ required: true, message: '请输入优惠券名称', trigger: 'blur' }
],
|
ab818baa
杨鑫
'1'
|
159
160
|
maxDiscountAmount: [ { validator: moneyContent, trigger: 'blur' }],
startTime: [{required: true, message: '请选择时间', trigger: 'blur'}],
|
6ee6b0b7
杨鑫
'最新'
|
161
162
163
164
165
166
167
168
169
|
totalCoupons: [{ required: true, message: '请输入数量', trigger: 'blur' }]
},
}
},
watch: {
'couponfrom.couponType'(val) {
this.couponfrom.maxDiscountAmount = 0
this.couponfrom.discountContent = 0
},
|
ab818baa
杨鑫
'1'
|
170
|
'couponfrom.useCategory'(val) {
|
6ee6b0b7
杨鑫
'最新'
|
171
|
if(val == '1') {
|
ab818baa
杨鑫
'1'
|
172
|
this.useCategory = null
|
6ee6b0b7
杨鑫
'最新'
|
173
|
} else {
|
8cb5c17e
杨鑫
'最新1'
|
174
|
}
|
6ee6b0b7
杨鑫
'最新'
|
175
|
},
|
ab818baa
杨鑫
'1'
|
176
177
|
'couponfrom.usedMerchants'(val) {
this.usedMerchants = null
|
6ee6b0b7
杨鑫
'最新'
|
178
179
|
},
pointsRequired(val) {
|
ab818baa
杨鑫
'1'
|
180
|
this.couponfrom.pointsRequired = 0
|
6ee6b0b7
杨鑫
'最新'
|
181
182
183
184
185
186
|
},
},
mounted() {
this.getAll()
},
methods: {
|
ab818baa
杨鑫
'1'
|
187
188
189
190
191
192
|
changeuseCategory(e){
this.$emit('changevalue','useCategorylist',e)
},
changeusedMerchants(e){
this.$emit('changevalue','usedMerchantslist',e)
},
|
6ee6b0b7
杨鑫
'最新'
|
193
194
195
196
197
198
199
200
201
|
changeDate(e){
console.error(e)
if(e && e.length>0) {
this.couponfrom.startTime = e[0]
this.couponfrom.endTime = e[0]
} else {
this.couponfrom.startTime = ''
this.couponfrom.endTime = ''
}
|
8cb5c17e
杨鑫
'最新1'
|
202
|
|
6ee6b0b7
杨鑫
'最新'
|
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
},
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
|
b7023175
杨鑫
'最新'
|
227
|
|
6ee6b0b7
杨鑫
'最新'
|
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
|
},
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;
}
}
|
8cb5c17e
杨鑫
'最新1'
|
306
|
|
6ee6b0b7
杨鑫
'最新'
|
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
|
</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;
}
|
8cb5c17e
杨鑫
'最新1'
|
357
|
|
6ee6b0b7
杨鑫
'最新'
|
358
|
</style>
|