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
5f557c7b
authored
Sep 02, 2023
by
owen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promotion: 优惠券模板 productSpuIds 改成 productScopeValues
parent
a68acb09
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
18 deletions
+40
-18
src/api/mall/promotion/coupon/couponTemplate.ts
+1
-1
src/views/mall/product/category/components/ProductCategorySelect.vue
+3
-3
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
+36
-14
No files found.
src/api/mall/promotion/coupon/couponTemplate.ts
View file @
5f557c7b
...
@@ -9,7 +9,7 @@ export interface CouponTemplateVO {
...
@@ -9,7 +9,7 @@ export interface CouponTemplateVO {
takeType
:
number
takeType
:
number
usePrice
:
number
usePrice
:
number
productScope
:
number
productScope
:
number
productS
puId
s
:
number
[]
productS
copeValue
s
:
number
[]
validityType
:
number
validityType
:
number
validStartTime
:
Date
validStartTime
:
Date
validEndTime
:
Date
validEndTime
:
Date
...
...
src/views/mall/product/category/components/ProductCategorySelect.vue
View file @
5f557c7b
...
@@ -13,21 +13,21 @@
...
@@ -13,21 +13,21 @@
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
defaultProps
,
handleTree
}
from
'@/utils/tree'
import
{
defaultProps
,
handleTree
}
from
'@/utils/tree'
import
*
as
ProductCategoryApi
from
'@/api/mall/product/category'
import
*
as
ProductCategoryApi
from
'@/api/mall/product/category'
import
{
oneOf
}
from
'vue-types'
import
{
oneOf
Type
}
from
'vue-types'
import
{
propTypes
}
from
'@/utils/propTypes'
import
{
propTypes
}
from
'@/utils/propTypes'
/** 商品分类选择组件 */
/** 商品分类选择组件 */
defineOptions
({
name
:
'ProductCategorySelect'
})
defineOptions
({
name
:
'ProductCategorySelect'
})
const
props
=
defineProps
({
const
props
=
defineProps
({
value
:
oneOf
([
propTypes
.
number
,
propTypes
.
array
.
def
([])]).
isRequired
,
// 选中的ID
modelValue
:
oneOfType
([
propTypes
.
number
.
def
(
undefined
),
propTypes
.
array
.
def
([])]).
def
(
undefined
)
,
// 选中的ID
multiple
:
propTypes
.
bool
.
def
(
false
)
// 是否多选
multiple
:
propTypes
.
bool
.
def
(
false
)
// 是否多选
})
})
/** 选中的分类 ID */
/** 选中的分类 ID */
const
selectCategoryId
=
computed
({
const
selectCategoryId
=
computed
({
get
:
()
=>
{
get
:
()
=>
{
return
props
.
v
alue
return
props
.
modelV
alue
},
},
set
:
(
val
:
number
|
number
[])
=>
{
set
:
(
val
:
number
|
number
[])
=>
{
emit
(
'update:modelValue'
,
val
)
emit
(
'update:modelValue'
,
val
)
...
...
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
View file @
5f557c7b
...
@@ -36,7 +36,6 @@
...
@@ -36,7 +36,6 @@
</div>
</div>
</div>
</div>
</el-form-item>
</el-form-item>
<!-- TODO 疯狂:要不把 productSpuIds 改成 productScopeValues,更通用?另外,改完后,涉及到优惠劵的匹配逻辑,要补充分类相关的逻辑,例如说获得匹配的优惠劵列表之类的,包括使用卷的时候; -->
<el-form-item
<el-form-item
label=
"分类"
label=
"分类"
v-if=
"formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
v-if=
"formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
...
@@ -228,8 +227,9 @@ const formData = ref({
...
@@ -228,8 +227,9 @@ const formData = ref({
fixedStartTerm
:
undefined
,
fixedStartTerm
:
undefined
,
fixedEndTerm
:
undefined
,
fixedEndTerm
:
undefined
,
productScope
:
PromotionProductScopeEnum
.
ALL
.
scope
,
productScope
:
PromotionProductScopeEnum
.
ALL
.
scope
,
productSpuIds
:
[],
productScopeValues
:
[],
// 商品范围:值为 品类编号列表 或 商品编号列表 ,用于提交
productCategoryIds
:
[]
productCategoryIds
:
[],
// 仅用于表单,不提交
productSpuIds
:
[]
// 仅用于表单,不提交
})
})
const
formRules
=
reactive
({
const
formRules
=
reactive
({
name
:
[{
required
:
true
,
message
:
'优惠券名称不能为空'
,
trigger
:
'blur'
}],
name
:
[{
required
:
true
,
message
:
'优惠券名称不能为空'
,
trigger
:
'blur'
}],
...
@@ -246,8 +246,8 @@ const formRules = reactive({
...
@@ -246,8 +246,8 @@ const formRules = reactive({
fixedStartTerm
:
[{
required
:
true
,
message
:
'开始领取天数不能为空'
,
trigger
:
'blur'
}],
fixedStartTerm
:
[{
required
:
true
,
message
:
'开始领取天数不能为空'
,
trigger
:
'blur'
}],
fixedEndTerm
:
[{
required
:
true
,
message
:
'开始领取天数不能为空'
,
trigger
:
'blur'
}],
fixedEndTerm
:
[{
required
:
true
,
message
:
'开始领取天数不能为空'
,
trigger
:
'blur'
}],
productScope
:
[{
required
:
true
,
message
:
'商品范围不能为空'
,
trigger
:
'blur'
}],
productScope
:
[{
required
:
true
,
message
:
'商品范围不能为空'
,
trigger
:
'blur'
}],
productSpuIds
:
[{
required
:
true
,
message
:
'商品
范围
不能为空'
,
trigger
:
'blur'
}],
productSpuIds
:
[{
required
:
true
,
message
:
'商品不能为空'
,
trigger
:
'blur'
}],
productCategoryIds
:
[{
required
:
true
,
message
:
'分类
范围
不能为空'
,
trigger
:
'blur'
}]
productCategoryIds
:
[{
required
:
true
,
message
:
'分类不能为空'
,
trigger
:
'blur'
}]
})
})
const
formRef
=
ref
()
// 表单 Ref
const
formRef
=
ref
()
// 表单 Ref
const
productSpus
=
ref
<
ProductSpuApi
.
Spu
[]
>
([])
// 商品列表
const
productSpus
=
ref
<
ProductSpuApi
.
Spu
[]
>
([])
// 商品列表
...
@@ -313,12 +313,10 @@ const submitForm = async () => {
...
@@ -313,12 +313,10 @@ const submitForm = async () => {
formData
.
value
.
validTimes
&&
formData
.
value
.
validTimes
.
length
===
2
formData
.
value
.
validTimes
&&
formData
.
value
.
validTimes
.
length
===
2
?
formData
.
value
.
validTimes
[
1
]
?
formData
.
value
.
validTimes
[
1
]
:
undefined
:
undefined
}
as
CouponTemplateApi
.
CouponTemplateVO
}
as
unknown
as
CouponTemplateApi
.
CouponTemplateVO
if
(
formData
.
value
.
productCategoryIds
?.
length
>
0
)
{
// 设置商品范围
// 改个名字?加个字段?
setProductScopeValues
(
data
)
data
.
productSpuIds
=
formData
.
value
.
productCategoryIds
}
if
(
formType
.
value
===
'create'
)
{
if
(
formType
.
value
===
'create'
)
{
await
CouponTemplateApi
.
createCouponTemplate
(
data
)
await
CouponTemplateApi
.
createCouponTemplate
(
data
)
...
@@ -355,6 +353,7 @@ const resetForm = () => {
...
@@ -355,6 +353,7 @@ const resetForm = () => {
fixedStartTerm
:
undefined
,
fixedStartTerm
:
undefined
,
fixedEndTerm
:
undefined
,
fixedEndTerm
:
undefined
,
productScope
:
PromotionProductScopeEnum
.
ALL
.
scope
,
productScope
:
PromotionProductScopeEnum
.
ALL
.
scope
,
productScopeValues
:
[],
productSpuIds
:
[],
productSpuIds
:
[],
productCategoryIds
:
[]
productCategoryIds
:
[]
}
}
...
@@ -366,13 +365,36 @@ const resetForm = () => {
...
@@ -366,13 +365,36 @@ const resetForm = () => {
const
getProductScope
=
async
()
=>
{
const
getProductScope
=
async
()
=>
{
switch
(
formData
.
value
.
productScope
)
{
switch
(
formData
.
value
.
productScope
)
{
case
PromotionProductScopeEnum
.
SPU
.
scope
:
case
PromotionProductScopeEnum
.
SPU
.
scope
:
// 设置商品编号
formData
.
value
.
productSpuIds
=
formData
.
value
.
productScopeValues
// 获得商品列表
// 获得商品列表
productSpus
.
value
=
await
ProductSpuApi
.
getSpuDetailList
(
formData
.
value
.
productSpuIds
)
productSpus
.
value
=
await
ProductSpuApi
.
getSpuDetailList
(
formData
.
value
.
productScopeValues
)
break
case
PromotionProductScopeEnum
.
CATEGORY
.
scope
:
await
nextTick
(()
=>
{
let
productCategoryIds
=
formData
.
value
.
productScopeValues
if
(
Array
.
isArray
(
productCategoryIds
)
&&
productCategoryIds
.
length
>
0
)
{
// 单选时使用数组不能反显
productCategoryIds
=
productCategoryIds
[
0
]
}
// 设置品类编号
formData
.
value
.
productCategoryIds
=
productCategoryIds
})
break
default
:
break
}
}
/** 设置商品范围 */
function
setProductScopeValues
(
data
:
CouponTemplateApi
.
CouponTemplateVO
)
{
switch
(
formData
.
value
.
productScope
)
{
case
PromotionProductScopeEnum
.
SPU
.
scope
:
data
.
productScopeValues
=
formData
.
value
.
productSpuIds
break
break
case
PromotionProductScopeEnum
.
CATEGORY
.
scope
:
case
PromotionProductScopeEnum
.
CATEGORY
.
scope
:
// TODO @疯狂:貌似分类不会选中。
data
.
productScopeValues
=
Array
.
isArray
(
formData
.
value
.
productCategoryIds
)
formData
.
value
.
productCategoryIds
=
formData
.
value
.
productSpu
Ids
?
formData
.
value
.
productCategory
Ids
formData
.
value
.
productSpuIds
=
[
]
:
[
formData
.
value
.
productCategoryIds
]
break
break
default
:
default
:
break
break
...
...
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