22
22
</el-radio-group >
23
23
</el-form-item >
24
24
<el-form-item
25
- label =" 商品"
26
25
v-if =" formData.productScope === PromotionProductScopeEnum.SPU.scope"
26
+ label =" 商品"
27
27
prop =" productSpuIds"
28
28
>
29
29
<div class =" flex flex-wrap items-center gap-1" >
30
- <div class = " select-box spu-pic " v-for =" (spu, index) in productSpus" :key =" spu.id" >
30
+ <div v-for =" (spu, index) in productSpus" :key =" spu.id" class = " select-box spu-pic " >
31
31
<el-image :src =" spu.picUrl" />
32
- <Icon icon =" ep:circle-close-filled" class = " del-icon " @click =" handleRemoveSpu(index)" />
32
+ <Icon class = " del- icon" icon =" ep:circle-close-filled" @click =" handleRemoveSpu(index)" />
33
33
</div >
34
34
<div class =" select-box" @click =" openSpuTableSelect" >
35
35
<Icon icon =" ep:plus" />
36
36
</div >
37
37
</div >
38
38
</el-form-item >
39
39
<el-form-item
40
- label =" 分类"
41
40
v-if =" formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
41
+ label =" 分类"
42
42
prop =" productCategoryIds"
43
43
>
44
44
<ProductCategorySelect v-model =" formData.productCategoryIds" />
61
61
>
62
62
<el-input-number
63
63
v-model =" formData.discountPrice"
64
- placeholder =" 请输入优惠金额,单位:元"
65
- class =" mr-2 !w-400px"
66
- :precision =" 2"
67
64
:min =" 0"
65
+ :precision =" 2"
66
+ class =" mr-2 !w-400px"
67
+ placeholder =" 请输入优惠金额,单位:元"
68
68
/>
69
69
元
70
70
</el-form-item >
75
75
>
76
76
<el-input-number
77
77
v-model =" formData.discountPercent"
78
- placeholder =" 优惠券折扣不能小于 1 折,且不可大于 9.9 折"
79
- class =" mr-2 !w-400px"
80
- :precision =" 1"
81
- :min =" 1"
82
78
:max =" 9.9"
79
+ :min =" 1"
80
+ :precision =" 1"
81
+ class =" mr-2 !w-400px"
82
+ placeholder =" 优惠券折扣不能小于 1 折,且不可大于 9.9 折"
83
83
/>
84
84
折
85
85
</el-form-item >
90
90
>
91
91
<el-input-number
92
92
v-model =" formData.discountLimitPrice"
93
- placeholder =" 请输入最多优惠"
94
- class =" mr-2 !w-400px"
95
- :precision =" 2"
96
93
:min =" 0"
94
+ :precision =" 2"
95
+ class =" mr-2 !w-400px"
96
+ placeholder =" 请输入最多优惠"
97
97
/>
98
98
元
99
99
</el-form-item >
100
100
<el-form-item label =" 满多少元可以使用" prop =" usePrice" >
101
101
<el-input-number
102
102
v-model =" formData.usePrice"
103
- placeholder =" 无门槛请设为 0"
104
- class =" mr-2 !w-400px"
105
- :precision =" 2"
106
103
:min =" 0"
104
+ :precision =" 2"
105
+ class =" mr-2 !w-400px"
106
+ placeholder =" 无门槛请设为 0"
107
107
/>
108
108
元
109
109
</el-form-item >
116
116
<el-form-item v-if =" formData.takeType === 1" label =" 发放数量" prop =" totalCount" >
117
117
<el-input-number
118
118
v-model =" formData.totalCount"
119
- placeholder =" 发放数量,没有之后不能领取或发放,-1 为不限制"
120
- class =" mr-2 !w-400px"
121
- :precision =" 0"
122
119
:min =" -1"
120
+ :precision =" 0"
121
+ class =" mr-2 !w-400px"
122
+ placeholder =" 发放数量,没有之后不能领取或发放,-1 为不限制"
123
123
/>
124
124
张
125
125
</el-form-item >
126
126
<el-form-item v-if =" formData.takeType === 1" label =" 每人限领个数" prop =" takeLimitCount" >
127
127
<el-input-number
128
128
v-model =" formData.takeLimitCount"
129
- placeholder =" 设置为 -1 时,可无限领取"
130
- class =" mr-2 !w-400px"
131
- :precision =" 0"
132
129
:min =" -1"
130
+ :precision =" 0"
131
+ class =" mr-2 !w-400px"
132
+ placeholder =" 设置为 -1 时,可无限领取"
133
133
/>
134
134
张
135
135
</el-form-item >
151
151
>
152
152
<el-date-picker
153
153
v-model =" formData.validTimes"
154
+ :default-time =" [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]"
154
155
style =" width : 240px "
155
- value-format =" x"
156
156
type =" datetimerange"
157
- :default-time = " [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)] "
157
+ value-format = " x "
158
158
/>
159
159
</el-form-item >
160
160
<el-form-item
165
165
第
166
166
<el-input-number
167
167
v-model =" formData.fixedStartTerm"
168
- placeholder =" 0 为今天生效"
169
- class =" mx-2"
170
- :precision =" 0"
171
168
:min =" 0"
169
+ :precision =" 0"
170
+ class =" mx-2"
171
+ placeholder =" 0 为今天生效"
172
172
/>
173
173
至
174
174
<el-input-number
175
175
v-model =" formData.fixedEndTerm"
176
- placeholder =" 请输入结束天数"
177
- class =" mx-2"
178
- :precision =" 0"
179
176
:min =" 0"
177
+ :precision =" 0"
178
+ class =" mx-2"
179
+ placeholder =" 请输入结束天数"
180
180
/>
181
181
天有效
182
182
</el-form-item >
@@ -199,6 +199,7 @@ import {
199
199
} from ' @/utils/constants'
200
200
import SpuTableSelect from ' @/views/mall/product/spu/components/SpuTableSelect.vue'
201
201
import ProductCategorySelect from ' @/views/mall/product/category/components/ProductCategorySelect.vue'
202
+ import { convertToInteger , formatToFraction } from ' @/utils'
202
203
203
204
defineOptions ({ name: ' CouponTemplateForm' })
204
205
@@ -265,12 +266,11 @@ const open = async (type: string, id?: number) => {
265
266
const data = await CouponTemplateApi .getCouponTemplate (id )
266
267
formData .value = {
267
268
... data ,
268
- discountPrice: data .discountPrice !== undefined ? data . discountPrice / 100.0 : undefined ,
269
+ discountPrice: formatToFraction ( data .discountPrice ) ,
269
270
discountPercent:
270
271
data .discountPercent !== undefined ? data .discountPercent / 10.0 : undefined ,
271
- discountLimitPrice:
272
- data .discountLimitPrice !== undefined ? data .discountLimitPrice / 100.0 : undefined ,
273
- usePrice: data .usePrice !== undefined ? data .usePrice / 100.0 : undefined ,
272
+ discountLimitPrice: formatToFraction (data .discountLimitPrice ),
273
+ usePrice: formatToFraction (data .usePrice ),
274
274
validTimes: [data .validStartTime , data .validEndTime ]
275
275
}
276
276
// 获得商品范围
@@ -294,17 +294,13 @@ const submitForm = async () => {
294
294
try {
295
295
const data = {
296
296
... formData .value ,
297
- discountPrice:
298
- formData .value .discountPrice !== undefined ? formData .value .discountPrice * 100 : undefined ,
297
+ discountPrice: convertToInteger (formData .value .discountPrice ),
299
298
discountPercent:
300
299
formData .value .discountPercent !== undefined
301
300
? formData .value .discountPercent * 10
302
301
: undefined ,
303
- discountLimitPrice:
304
- formData .value .discountLimitPrice !== undefined
305
- ? formData .value .discountLimitPrice * 100
306
- : undefined ,
307
- usePrice: formData .value .usePrice !== undefined ? formData .value .usePrice * 100 : undefined ,
302
+ discountLimitPrice: convertToInteger (formData .value .discountLimitPrice ),
303
+ usePrice: convertToInteger (formData .value .usePrice ),
308
304
validStartTime:
309
305
formData .value .validTimes && formData .value .validTimes .length === 2
310
306
? formData .value .validTimes [0 ]
@@ -385,6 +381,7 @@ const getProductScope = async () => {
385
381
break
386
382
}
387
383
}
384
+
388
385
/** 设置商品范围 */
389
386
function setProductScopeValues(data : CouponTemplateApi .CouponTemplateVO ) {
390
387
switch (formData .value .productScope ) {
@@ -420,7 +417,7 @@ const handleRemoveSpu = (index: number) => {
420
417
}
421
418
</script >
422
419
423
- <style scoped lang="scss">
420
+ <style lang="scss" scoped >
424
421
.select-box {
425
422
display : flex ;
426
423
width : 60px ;
0 commit comments