44
44
<!-- TODO @puhui999:tag展示暂时不考虑排序;支持拖动排序 -->
45
45
<el-form-item label =" 活动优先级" >
46
46
<el-tag
47
- v-for =" type in getIntDictOptions(DICT_TYPE.PROMOTION_TYPE_ENUM) "
47
+ v-for =" type in promotionTypes "
48
48
:key =" type.value as number"
49
49
:type =" type.colorType"
50
50
class =" mr-[10px]"
55
55
</el-col >
56
56
<el-col :span =" 24" >
57
57
<el-form-item label =" 赠送优惠劵" >
58
- <el-tag v-for =" coupon in couponTemplateList" :key =" coupon.id as number" class =" mr-[10px]" >
58
+ <el-tag
59
+ v-for =" coupon in formData.giveCouponTemplates"
60
+ :key =" coupon.id as number"
61
+ class =" mr-[10px]"
62
+ >
59
63
{{ coupon.name }}
60
64
</el-tag >
61
65
<el-button @click =" openCouponSelect" >选择优惠券</el-button >
67
71
<!-- 情况二:详情 -->
68
72
<Descriptions v-if =" isDetail" :data =" formData" :schema =" allSchemas.detailSchema" >
69
73
<template #recommendHot =" { row } " >
70
- {{ row.recommendHot ? '是' : '否' }}
74
+ < dict-tag :type = " DICT_TYPE.INFRA_BOOLEAN_STRING " :value = " row.recommendHot" />
71
75
</template >
72
76
<template #recommendBenefit =" { row } " >
73
- {{ row.recommendBenefit ? '是' : '否' }}
77
+ < dict-tag :type = " DICT_TYPE.INFRA_BOOLEAN_STRING " :value = " row.recommendBenefit" />
74
78
</template >
75
79
<template #recommendBest =" { row } " >
76
- {{ row.recommendBest ? '是' : '否' }}
80
+ < dict-tag :type = " DICT_TYPE.INFRA_BOOLEAN_STRING " :value = " row.recommendBest" />
77
81
</template >
78
82
<template #recommendNew =" { row } " >
79
- {{ row.recommendNew ? '是' : '否' }}
83
+ < dict-tag :type = " DICT_TYPE.INFRA_BOOLEAN_STRING " :value = " row.recommendNew" />
80
84
</template >
81
85
<template #recommendGood =" { row } " >
82
- {{ row.recommendGood ? '是' : '否' }}
86
+ <dict-tag :type =" DICT_TYPE.INFRA_BOOLEAN_STRING" :value =" row.recommendGood" />
87
+ </template >
88
+ <template #activityOrders =" { row } " >
89
+ <el-tag
90
+ v-for =" activityType in row.activityOrders"
91
+ :key =" activityType"
92
+ :type =" promotionTypes.find((item) => item.value === activityType)?.colorType"
93
+ class =" mr-[10px]"
94
+ >
95
+ {{ promotionTypes.find((item) => item.value === activityType)?.label }}
96
+ </el-tag >
83
97
</template >
84
- <template #activityOrders >
85
- <el-tag v-for =" coupon in couponTemplateList" :key =" coupon.id as number" class =" mr-[10px]" >
98
+ <template #giveCouponTemplates =" { row } " >
99
+ <el-tag
100
+ v-for =" coupon in row.giveCouponTemplates"
101
+ :key =" coupon.id as number"
102
+ class =" mr-[10px]"
103
+ >
86
104
{{ coupon.name }}
87
105
</el-tag >
88
106
</template >
89
107
</Descriptions >
90
- <CouponSelect ref =" couponSelectRef" v-model:multiple-selection =" couponTemplateList " />
108
+ <CouponSelect ref =" couponSelectRef" v-model:multiple-selection =" formData.giveCouponTemplates " />
91
109
</template >
92
110
<script lang="ts" setup>
93
- import type { GiveCouponTemplate , Spu } from ' @/api/mall/product/spu'
111
+ import type { Spu } from ' @/api/mall/product/spu'
94
112
import { PropType } from ' vue'
95
113
import { propTypes } from ' @/utils/propTypes'
96
114
import { copyValueToTarget } from ' @/utils'
97
115
import { otherSettingsSchema } from ' ./spu.data'
98
- import { DICT_TYPE , getIntDictOptions } from ' @/utils/dict'
116
+ import { DICT_TYPE , DictDataType , getIntDictOptions } from ' @/utils/dict'
99
117
import CouponSelect from ' ./CouponSelect.vue'
100
118
101
119
defineOptions ({ name: ' OtherSettingsForm' })
@@ -112,12 +130,16 @@ const props = defineProps({
112
130
activeName: propTypes .string .def (' ' ),
113
131
isDetail: propTypes .bool .def (false ) // 是否作为详情组件
114
132
})
133
+
134
+ // 优惠卷
115
135
const couponSelectRef = ref () // 优惠卷模版选择 Ref
116
- const couponTemplateList = ref <GiveCouponTemplate []>([]) // 选择的优惠卷
117
136
const openCouponSelect = () => {
118
137
couponSelectRef .value ?.open ()
119
138
}
120
139
140
+ // 活动优先级处理
141
+ const promotionTypes = ref <DictDataType []>(getIntDictOptions (DICT_TYPE .PROMOTION_TYPE_ENUM ))
142
+
121
143
const otherSettingsFormRef = ref () // 表单Ref
122
144
// 表单数据
123
145
const formData = ref <Spu >({
@@ -129,7 +151,8 @@ const formData = ref<Spu>({
129
151
recommendBest: false , // 是否精品
130
152
recommendNew: false , // 是否新品
131
153
recommendGood: false , // 是否优品
132
- giveCouponTemplate: [] // 赠送的优惠券
154
+ activityOrders: [], // 活动排序
155
+ giveCouponTemplates: [] // 赠送的优惠券
133
156
})
134
157
// 表单规则
135
158
const rules = reactive ({
@@ -163,9 +186,6 @@ watch(
163
186
return
164
187
}
165
188
copyValueToTarget (formData .value , data )
166
- if (data .giveCouponTemplate ) {
167
- couponTemplateList .value = data .giveCouponTemplate
168
- }
169
189
recommendOptions .forEach (({ value }) => {
170
190
if (formData .value [value ] && ! checkboxGroup .value .includes (value )) {
171
191
checkboxGroup .value .push (value )
@@ -192,7 +212,6 @@ const validate = async () => {
192
212
throw new Error (' 商品其他设置未完善!!' )
193
213
} else {
194
214
// 校验通过更新数据
195
- formData .value .giveCouponTemplate = couponTemplateList .value
196
215
Object .assign (props .propFormData , formData .value )
197
216
}
198
217
})
0 commit comments