Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
01d78429
authored
Oct 20, 2023
by
puhui999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SPU: 完善优惠卷选择
parent
18df708b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
22 deletions
+43
-22
src/api/mall/product/spu.ts
+2
-1
src/views/mall/product/spu/form/OtherSettingsForm.vue
+37
-18
src/views/mall/product/spu/form/index.vue
+3
-2
src/views/mall/product/spu/form/spu.data.ts
+1
-1
No files found.
src/api/mall/product/spu.ts
View file @
01d78429
...
@@ -60,7 +60,8 @@ export interface Spu {
...
@@ -60,7 +60,8 @@ export interface Spu {
stock
?:
number
// 商品库存
stock
?:
number
// 商品库存
createTime
?:
Date
// 商品创建时间
createTime
?:
Date
// 商品创建时间
status
?:
number
// 商品状态
status
?:
number
// 商品状态
giveCouponTemplate
?:
GiveCouponTemplate
[]
activityOrders
:
number
[]
// 活动排序
giveCouponTemplates
:
GiveCouponTemplate
[]
// 优惠卷
}
}
// 获得 Spu 列表
// 获得 Spu 列表
...
...
src/views/mall/product/spu/form/OtherSettingsForm.vue
View file @
01d78429
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
<!-- TODO @puhui999:tag展示暂时不考虑排序;支持拖动排序 -->
<!-- TODO @puhui999:tag展示暂时不考虑排序;支持拖动排序 -->
<el-form-item
label=
"活动优先级"
>
<el-form-item
label=
"活动优先级"
>
<el-tag
<el-tag
v-for=
"type in
getIntDictOptions(DICT_TYPE.PROMOTION_TYPE_ENUM)
"
v-for=
"type in
promotionTypes
"
:key=
"type.value as number"
:key=
"type.value as number"
:type=
"type.colorType"
:type=
"type.colorType"
class=
"mr-[10px]"
class=
"mr-[10px]"
...
@@ -55,7 +55,11 @@
...
@@ -55,7 +55,11 @@
</el-col>
</el-col>
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
<el-form-item
label=
"赠送优惠劵"
>
<el-form-item
label=
"赠送优惠劵"
>
<el-tag
v-for=
"coupon in couponTemplateList"
:key=
"coupon.id as number"
class=
"mr-[10px]"
>
<el-tag
v-for=
"coupon in formData.giveCouponTemplates"
:key=
"coupon.id as number"
class=
"mr-[10px]"
>
{{
coupon
.
name
}}
{{
coupon
.
name
}}
</el-tag>
</el-tag>
<el-button
@
click=
"openCouponSelect"
>
选择优惠券
</el-button>
<el-button
@
click=
"openCouponSelect"
>
选择优惠券
</el-button>
...
@@ -67,35 +71,49 @@
...
@@ -67,35 +71,49 @@
<!-- 情况二:详情 -->
<!-- 情况二:详情 -->
<Descriptions
v-if=
"isDetail"
:data=
"formData"
:schema=
"allSchemas.detailSchema"
>
<Descriptions
v-if=
"isDetail"
:data=
"formData"
:schema=
"allSchemas.detailSchema"
>
<template
#
recommendHot=
"
{ row }">
<template
#
recommendHot=
"
{ row }">
{{
row
.
recommendHot
?
'是'
:
'否'
}}
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"row.recommendHot"
/>
</
template
>
</
template
>
<
template
#
recommendBenefit=
"{ row }"
>
<
template
#
recommendBenefit=
"{ row }"
>
{{
row
.
recommendBenefit
?
'是'
:
'否'
}}
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"row.recommendBenefit"
/>
</
template
>
</
template
>
<
template
#
recommendBest=
"{ row }"
>
<
template
#
recommendBest=
"{ row }"
>
{{
row
.
recommendBest
?
'是'
:
'否'
}}
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"row.recommendBest"
/>
</
template
>
</
template
>
<
template
#
recommendNew=
"{ row }"
>
<
template
#
recommendNew=
"{ row }"
>
{{
row
.
recommendNew
?
'是'
:
'否'
}}
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"row.recommendNew"
/>
</
template
>
</
template
>
<
template
#
recommendGood=
"{ row }"
>
<
template
#
recommendGood=
"{ row }"
>
{{
row
.
recommendGood
?
'是'
:
'否'
}}
<dict-tag
:type=
"DICT_TYPE.INFRA_BOOLEAN_STRING"
:value=
"row.recommendGood"
/>
</
template
>
<
template
#
activityOrders=
"{ row }"
>
<el-tag
v-for=
"activityType in row.activityOrders"
:key=
"activityType"
:type=
"promotionTypes.find((item) => item.value === activityType)?.colorType"
class=
"mr-[10px]"
>
{{
promotionTypes
.
find
((
item
)
=>
item
.
value
===
activityType
)?.
label
}}
</el-tag>
</
template
>
</
template
>
<
template
#
activityOrders
>
<
template
#
giveCouponTemplates=
"{ row }"
>
<el-tag
v-for=
"coupon in couponTemplateList"
:key=
"coupon.id as number"
class=
"mr-[10px]"
>
<el-tag
v-for=
"coupon in row.giveCouponTemplates"
:key=
"coupon.id as number"
class=
"mr-[10px]"
>
{{
coupon
.
name
}}
{{
coupon
.
name
}}
</el-tag>
</el-tag>
</
template
>
</
template
>
</Descriptions>
</Descriptions>
<CouponSelect
ref=
"couponSelectRef"
v-model:multiple-selection=
"
couponTemplateList
"
/>
<CouponSelect
ref=
"couponSelectRef"
v-model:multiple-selection=
"
formData.giveCouponTemplates
"
/>
</template>
</template>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
type
{
GiveCouponTemplate
,
Spu
}
from
'@/api/mall/product/spu'
import
type
{
Spu
}
from
'@/api/mall/product/spu'
import
{
PropType
}
from
'vue'
import
{
PropType
}
from
'vue'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
copyValueToTarget
}
from
'@/utils'
import
{
copyValueToTarget
}
from
'@/utils'
import
{
otherSettingsSchema
}
from
'./spu.data'
import
{
otherSettingsSchema
}
from
'./spu.data'
import
{
DICT_TYPE
,
getIntDictOptions
}
from
'@/utils/dict'
import
{
DICT_TYPE
,
DictDataType
,
getIntDictOptions
}
from
'@/utils/dict'
import
CouponSelect
from
'./CouponSelect.vue'
import
CouponSelect
from
'./CouponSelect.vue'
defineOptions
({
name
:
'OtherSettingsForm'
})
defineOptions
({
name
:
'OtherSettingsForm'
})
...
@@ -112,12 +130,16 @@ const props = defineProps({
...
@@ -112,12 +130,16 @@ const props = defineProps({
activeName
:
propTypes
.
string
.
def
(
''
),
activeName
:
propTypes
.
string
.
def
(
''
),
isDetail
:
propTypes
.
bool
.
def
(
false
)
// 是否作为详情组件
isDetail
:
propTypes
.
bool
.
def
(
false
)
// 是否作为详情组件
})
})
// 优惠卷
const
couponSelectRef
=
ref
()
// 优惠卷模版选择 Ref
const
couponSelectRef
=
ref
()
// 优惠卷模版选择 Ref
const
couponTemplateList
=
ref
<
GiveCouponTemplate
[]
>
([])
// 选择的优惠卷
const
openCouponSelect
=
()
=>
{
const
openCouponSelect
=
()
=>
{
couponSelectRef
.
value
?.
open
()
couponSelectRef
.
value
?.
open
()
}
}
// 活动优先级处理
const
promotionTypes
=
ref
<
DictDataType
[]
>
(
getIntDictOptions
(
DICT_TYPE
.
PROMOTION_TYPE_ENUM
))
const
otherSettingsFormRef
=
ref
()
// 表单Ref
const
otherSettingsFormRef
=
ref
()
// 表单Ref
// 表单数据
// 表单数据
const
formData
=
ref
<
Spu
>
({
const
formData
=
ref
<
Spu
>
({
...
@@ -129,7 +151,8 @@ const formData = ref<Spu>({
...
@@ -129,7 +151,8 @@ const formData = ref<Spu>({
recommendBest
:
false
,
// 是否精品
recommendBest
:
false
,
// 是否精品
recommendNew
:
false
,
// 是否新品
recommendNew
:
false
,
// 是否新品
recommendGood
:
false
,
// 是否优品
recommendGood
:
false
,
// 是否优品
giveCouponTemplate
:
[]
// 赠送的优惠券
activityOrders
:
[],
// 活动排序
giveCouponTemplates
:
[]
// 赠送的优惠券
})
})
// 表单规则
// 表单规则
const
rules
=
reactive
({
const
rules
=
reactive
({
...
@@ -163,9 +186,6 @@ watch(
...
@@ -163,9 +186,6 @@ watch(
return
return
}
}
copyValueToTarget
(
formData
.
value
,
data
)
copyValueToTarget
(
formData
.
value
,
data
)
if
(
data
.
giveCouponTemplate
)
{
couponTemplateList
.
value
=
data
.
giveCouponTemplate
}
recommendOptions
.
forEach
(({
value
})
=>
{
recommendOptions
.
forEach
(({
value
})
=>
{
if
(
formData
.
value
[
value
]
&&
!
checkboxGroup
.
value
.
includes
(
value
))
{
if
(
formData
.
value
[
value
]
&&
!
checkboxGroup
.
value
.
includes
(
value
))
{
checkboxGroup
.
value
.
push
(
value
)
checkboxGroup
.
value
.
push
(
value
)
...
@@ -192,7 +212,6 @@ const validate = async () => {
...
@@ -192,7 +212,6 @@ const validate = async () => {
throw
new
Error
(
'商品其他设置未完善!!'
)
throw
new
Error
(
'商品其他设置未完善!!'
)
}
else
{
}
else
{
// 校验通过更新数据
// 校验通过更新数据
formData
.
value
.
giveCouponTemplate
=
couponTemplateList
.
value
Object
.
assign
(
props
.
propFormData
,
formData
.
value
)
Object
.
assign
(
props
.
propFormData
,
formData
.
value
)
}
}
})
})
...
...
src/views/mall/product/spu/form/index.vue
View file @
01d78429
...
@@ -95,7 +95,8 @@ const formData = ref<ProductSpuApi.Spu>({
...
@@ -95,7 +95,8 @@ const formData = ref<ProductSpuApi.Spu>({
recommendBest
:
false
,
// 是否精品
recommendBest
:
false
,
// 是否精品
recommendNew
:
false
,
// 是否新品
recommendNew
:
false
,
// 是否新品
recommendGood
:
false
,
// 是否优品
recommendGood
:
false
,
// 是否优品
giveCouponTemplate
:
[]
// 赠送的优惠券
activityOrders
:
[],
// 活动排序
giveCouponTemplates
:
[]
// 赠送的优惠券
})
})
/** 获得详情 */
/** 获得详情 */
...
@@ -109,7 +110,7 @@ const getDetail = async () => {
...
@@ -109,7 +110,7 @@ const getDetail = async () => {
try
{
try
{
const
res
=
(
await
ProductSpuApi
.
getSpu
(
id
))
as
ProductSpuApi
.
Spu
const
res
=
(
await
ProductSpuApi
.
getSpu
(
id
))
as
ProductSpuApi
.
Spu
res
.
skus
?.
forEach
((
item
)
=>
{
res
.
skus
?.
forEach
((
item
)
=>
{
if
(
isDetail
.
value
===
true
)
{
if
(
isDetail
.
value
)
{
item
.
price
=
floatToFixed2
(
item
.
price
)
item
.
price
=
floatToFixed2
(
item
.
price
)
item
.
marketPrice
=
floatToFixed2
(
item
.
marketPrice
)
item
.
marketPrice
=
floatToFixed2
(
item
.
marketPrice
)
item
.
costPrice
=
floatToFixed2
(
item
.
costPrice
)
item
.
costPrice
=
floatToFixed2
(
item
.
costPrice
)
...
...
src/views/mall/product/spu/form/spu.data.ts
View file @
01d78429
...
@@ -96,7 +96,7 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
...
@@ -96,7 +96,7 @@ export const otherSettingsSchema = reactive<CrudSchema[]>([
},
},
{
{
label
:
'赠送的优惠劵'
,
label
:
'赠送的优惠劵'
,
field
:
'giveCouponTemplate'
field
:
'giveCouponTemplate
s
'
},
},
{
{
label
:
'活动显示排序'
,
label
:
'活动显示排序'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment