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
4f7d6793
authored
Sep 02, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review:优惠劵逻辑
parent
190c6e38
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
49 deletions
+55
-49
src/utils/constants.ts
+3
-3
src/views/mall/product/category/components/ProductCategorySelect.vue
+2
-2
src/views/mall/promotion/coupon/components/CouponSendForm.vue
+8
-5
src/views/mall/promotion/coupon/formatter.ts
+1
-1
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
+37
-33
src/views/member/user/index.vue
+4
-5
No files found.
src/utils/constants.ts
View file @
4f7d6793
...
...
@@ -215,15 +215,15 @@ export const CouponTemplateValidityTypeEnum = {
export
const
PromotionProductScopeEnum
=
{
ALL
:
{
scope
:
1
,
name
:
'
全部商品参与
'
name
:
'
通用劵
'
},
SPU
:
{
scope
:
2
,
name
:
'
指定商品参与
'
name
:
'
商品劵
'
},
CATEGORY
:
{
scope
:
3
,
name
:
'
指定品类参与
'
name
:
'
品类劵
'
}
}
...
...
src/views/mall/product/category/components/ProductCategorySelect.vue
View file @
4f7d6793
...
...
@@ -24,7 +24,7 @@ const props = defineProps({
multiple
:
propTypes
.
bool
.
def
(
false
)
// 是否多选
})
/** 选中的分类ID */
/** 选中的分类
ID */
const
selectCategoryId
=
computed
({
get
:
()
=>
{
return
props
.
value
...
...
@@ -37,8 +37,8 @@ const selectCategoryId = computed({
/** 分类选择 */
const
emit
=
defineEmits
([
'update:modelValue'
])
/** 初始化 **/
const
categoryList
=
ref
([])
// 分类树
onMounted
(
async
()
=>
{
// 获得分类树
const
data
=
await
ProductCategoryApi
.
getCategoryList
({})
...
...
src/views/mall/promotion/coupon/components/CouponSend.vue
→
src/views/mall/promotion/coupon/components/CouponSend
Form
.vue
View file @
4f7d6793
<
template
>
<Dialog
v-model=
"dialogVisible"
:appendToBody=
"true"
title=
"发送优惠券"
width=
"70%"
>
<!-- 搜索工作栏 -->
<el-form
ref=
"queryFormRef"
:inline=
"true"
...
...
@@ -27,6 +28,8 @@
</el-button>
</el-form-item>
</el-form>
<!-- 列表 -->
<el-table
v-loading=
"loading"
:data=
"list"
show-overflow-tooltip
>
<el-table-column
align=
"center"
label=
"优惠券名称"
prop=
"name"
min-width=
"60"
/>
<el-table-column
...
...
@@ -41,7 +44,7 @@
label=
"最低消费"
prop=
"usePrice"
min-width=
"60"
:formatter=
"use
r
PriceFormat"
:formatter=
"usePriceFormat"
/>
<el-table-column
align=
"center"
...
...
@@ -72,6 +75,7 @@
</el-table-column>
</el-table>
<!-- 分页 -->
<!-- TODO 疯狂:可以看看,为啥弹窗没把分页包进去,可能和 footer 有关? -->
<Pagination
v-model:limit=
"queryParams.pageSize"
v-model:page=
"queryParams.pageNo"
...
...
@@ -80,18 +84,17 @@
/>
</Dialog>
</template>
<
script
lang=
"ts"
setup
>
import
*
as
CouponTemplateApi
from
'@/api/mall/promotion/coupon/couponTemplate'
import
*
as
CouponApi
from
'@/api/mall/promotion/coupon/coupon'
import
{
discountFormat
,
remainedCountFormat
,
use
r
PriceFormat
,
usePriceFormat
,
validityTypeFormat
}
from
'@/views/mall/promotion/coupon/formatter'
defineOptions
({
name
:
'PromotionCouponSend'
})
defineOptions
({
name
:
'PromotionCouponSend
Form
'
})
const
message
=
useMessage
()
// 消息弹窗
const
total
=
ref
(
0
)
// 列表的总页数
...
...
@@ -147,7 +150,7 @@ const handleSendCoupon = async (templateId: number) => {
try
{
sendLoading
.
value
=
true
await
CouponApi
.
sendCoupon
({
templateId
,
userIds
})
// 提示
message
.
success
(
'发送成功'
)
dialogVisible
.
value
=
false
}
finally
{
...
...
src/views/mall/promotion/coupon/formatter.ts
View file @
4f7d6793
...
...
@@ -39,6 +39,6 @@ export const remainedCountFormat = (row: CouponTemplateVO) => {
}
// 格式化【最低消费】
export
const
use
r
PriceFormat
=
(
row
:
CouponTemplateVO
)
=>
{
export
const
usePriceFormat
=
(
row
:
CouponTemplateVO
)
=>
{
return
`¥
${
floatToFixed2
(
row
.
usePrice
)}
`
}
src/views/mall/promotion/coupon/template/CouponTemplateForm.vue
View file @
4f7d6793
...
...
@@ -10,7 +10,41 @@
<el-form-item
label=
"优惠券名称"
prop=
"name"
>
<el-input
v-model=
"formData.name"
placeholder=
"请输入优惠券名称"
/>
</el-form-item>
<el-form-item
label=
"优惠券类型"
prop=
"discountType"
>
<el-form-item
label=
"优惠劵类型"
prop=
"productScope"
>
<el-radio-group
v-model=
"formData.productScope"
>
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.PROMOTION_PRODUCT_SCOPE)"
:key=
"dict.value"
:label=
"dict.value"
>
{{
dict
.
label
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
label=
"商品"
v-if=
"formData.productScope === PromotionProductScopeEnum.SPU.scope"
prop=
"productSpuIds"
>
<div
class=
"flex items-center gap-1 flex-wrap"
>
<div
class=
"select-box spu-pic"
v-for=
"(spu, index) in productSpus"
:key=
"spu.id"
>
<el-image
:src=
"spu.picUrl"
/>
<Icon
icon=
"ep:circle-close-filled"
class=
"del-icon"
@
click=
"handleRemoveSpu(index)"
/>
</div>
<div
class=
"select-box"
@
click=
"openSpuTableSelect"
>
<Icon
icon=
"ep:plus"
/>
</div>
</div>
</el-form-item>
<!-- TODO 疯狂:要不把 productSpuIds 改成 productScopeValues,更通用?另外,改完后,涉及到优惠劵的匹配逻辑,要补充分类相关的逻辑,例如说获得匹配的优惠劵列表之类的,包括使用卷的时候; -->
<el-form-item
label=
"分类"
v-if=
"formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
prop=
"productCategoryIds"
>
<ProductCategorySelect
v-model=
"formData.productCategoryIds"
/>
</el-form-item>
<el-form-item
label=
"优惠类型"
prop=
"discountType"
>
<el-radio-group
v-model=
"formData.discountType"
>
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.PROMOTION_DISCOUNT_TYPE)"
...
...
@@ -147,37 +181,6 @@
/>
天有效
</el-form-item>
<el-form-item
label=
"活动商品"
prop=
"productScope"
>
<el-radio-group
v-model=
"formData.productScope"
>
<el-radio
v-for=
"dict in getIntDictOptions(DICT_TYPE.PROMOTION_PRODUCT_SCOPE)"
:key=
"dict.value"
:label=
"dict.value"
>
{{
dict
.
label
}}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item
v-if=
"formData.productScope === PromotionProductScopeEnum.SPU.scope"
prop=
"productSpuIds"
>
<div
class=
"flex items-center gap-1 flex-wrap"
>
<div
class=
"select-box spu-pic"
v-for=
"(spu, index) in productSpus"
:key=
"spu.id"
>
<el-image
:src=
"spu.picUrl"
/>
<Icon
icon=
"ep:circle-close-filled"
class=
"del-icon"
@
click=
"handleRemoveSpu(index)"
/>
</div>
<div
class=
"select-box"
@
click=
"openSpuTableSelect"
>
<Icon
icon=
"ep:plus"
/>
</div>
</div>
</el-form-item>
<el-form-item
v-if=
"formData.productScope === PromotionProductScopeEnum.CATEGORY.scope"
prop=
"productCategoryIds"
>
<ProductCategorySelect
v-model=
"formData.productCategoryIds"
multiple
/>
</el-form-item>
</el-form>
<template
#
footer
>
<el-button
:disabled=
"formLoading"
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
...
...
@@ -367,6 +370,7 @@ const getProductScope = async () => {
productSpus
.
value
=
await
ProductSpuApi
.
getSpuDetailList
(
formData
.
value
.
productSpuIds
)
break
case
PromotionProductScopeEnum
.
CATEGORY
.
scope
:
// TODO @疯狂:貌似分类不会选中。
formData
.
value
.
productCategoryIds
=
formData
.
value
.
productSpuIds
formData
.
value
.
productSpuIds
=
[]
break
...
...
@@ -375,7 +379,7 @@ const getProductScope = async () => {
}
}
/** 活动商品
按钮 */
/** 活动商品
的
按钮 */
const
spuTableSelectRef
=
ref
()
const
openSpuTableSelect
=
()
=>
{
spuTableSelectRef
.
value
.
open
(
productSpus
.
value
)
...
...
src/views/member/user/index.vue
View file @
4f7d6793
...
...
@@ -154,7 +154,7 @@
<!-- 修改用户等级弹窗 -->
<UpdateLevelForm
ref=
"updateLevelFormRef"
@
success=
"getList"
/>
<!-- 发送优惠券弹窗 -->
<CouponSend
ref=
"couponSend
"
/>
<CouponSend
Form
ref=
"couponSendFormRef
"
/>
</template>
<
script
setup
lang=
"ts"
>
import
{
dateFormatter
}
from
'@/utils/formatTime'
...
...
@@ -164,7 +164,7 @@ import MemberTagSelect from '@/views/member/tag/components/MemberTagSelect.vue'
import
MemberLevelSelect
from
'@/views/member/level/components/MemberLevelSelect.vue'
import
MemberGroupSelect
from
'@/views/member/group/components/MemberGroupSelect.vue'
import
UpdateLevelForm
from
'@/views/member/user/UpdateLevelForm.vue'
import
CouponSend
from
'@/views/mall/promotion/coupon/components/CouponSend
.vue'
import
CouponSend
Form
from
'@/views/mall/promotion/coupon/components/CouponSendForm
.vue'
defineOptions
({
name
:
'MemberUser'
})
...
...
@@ -224,14 +224,13 @@ const handleSelectionChange = (rows: UserApi.UserVO[]) => {
}
/** 发送优惠券 */
const
couponSend
=
ref
()
const
couponSend
FormRef
=
ref
()
const
openCoupon
=
()
=>
{
if
(
selectedIds
.
value
.
length
===
0
)
{
message
.
warning
(
'请选择要发送优惠券的用户'
)
return
}
couponSend
.
value
.
open
(
selectedIds
.
value
)
couponSendFormRef
.
value
.
open
(
selectedIds
.
value
)
}
/** 初始化 **/
...
...
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