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
Unverified
Commit
24349110
authored
Aug 26, 2024
by
芋道源码
Committed by
Gitee
Aug 26, 2024
Browse files
Options
Browse Files
Download
Plain Diff
!529 【修改】修改限时折扣的一些问题
Merge pull request !529 from 痴货/dev
parents
1911ed99
a06a5096
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
31 deletions
+84
-31
src/views/mall/promotion/components/SpuAndSkuList.vue
+27
-0
src/views/mall/promotion/discountActivity/DiscountActivityForm.vue
+46
-9
src/views/mall/promotion/discountActivity/discountActivity.data.ts
+0
-11
src/views/mall/promotion/discountActivity/index.vue
+11
-11
No files found.
src/views/mall/promotion/components/SpuAndSkuList.vue
View file @
24349110
...
...
@@ -29,6 +29,17 @@
</el-table-column>
<el-table-column
align=
"center"
label=
"销量"
min-width=
"90"
prop=
"salesCount"
/>
<el-table-column
align=
"center"
label=
"库存"
min-width=
"90"
prop=
"stock"
/>
<el-table-column
v-if=
"spuData.length > 1 && isDelete"
align=
"center"
label=
"操作"
min-width=
"90"
>
<
template
#
default=
"scope"
>
<el-button
type=
"primary"
link
@
click=
"deleteSpu(scope.row.id)"
>
删除
</el-button>
</
template
>
</el-table-column>
</el-table>
</template>
<
script
generic=
"T extends Spu"
lang=
"ts"
setup
>
...
...
@@ -40,10 +51,13 @@ import { SpuProperty } from '@/views/mall/promotion/components/index'
defineOptions
({
name
:
'PromotionSpuAndSkuList'
})
const
message
=
useMessage
()
// 消息弹窗
const
props
=
defineProps
<
{
spuList
:
T
[]
ruleConfig
:
RuleConfig
[]
spuPropertyListP
:
SpuProperty
<
T
>
[]
isDelete
?:
boolean
//spu是否可以多选
}
>
()
const
spuData
=
ref
<
Spu
[]
>
([])
// spu 详情数据列表
...
...
@@ -77,6 +91,19 @@ const imagePreview = (imgUrl: string) => {
})
}
// 删除时的触发事件
const
emits
=
defineEmits
<
{
(
e
:
'delete'
,
spuId
:
number
):
void
}
>
()
/** 多选时可以删除spu **/
const
deleteSpu
=
async
(
spuId
:
number
)
=>
{
await
message
.
confirm
(
'是否删除商品编号为'
+
spuId
+
'的数据?'
)
let
index
=
spuData
.
value
.
findIndex
((
item
)
=>
item
.
id
==
spuId
)
spuData
.
value
.
splice
(
index
,
1
);
emits
(
'delete'
,
spuId
)
}
/**
* 将传进来的值赋值给 skuList
*/
...
...
src/views/mall/promotion/discountActivity/DiscountActivityForm.vue
View file @
24349110
...
...
@@ -19,6 +19,8 @@
:rule-config=
"ruleConfig"
:spu-list=
"spuList"
:spu-property-list-p=
"spuPropertyList"
:isDelete=
"true"
@
delete=
"deleteSpu"
>
<el-table-column
align=
"center"
label=
"优惠金额"
min-width=
"168"
>
<template
#
default=
"
{ row: sku }">
...
...
@@ -47,6 +49,7 @@ import { cloneDeep } from 'lodash-es'
import
*
as
DiscountActivityApi
from
'@/api/mall/promotion/discount/discountActivity'
import
*
as
ProductSpuApi
from
'@/api/mall/product/spu'
import
{
getPropertyList
,
RuleConfig
}
from
'@/views/mall/product/spu/components'
import
{
formatToFraction
}
from
"@/utils"
;
defineOptions
({
name
:
'PromotionDiscountActivityForm'
})
...
...
@@ -65,8 +68,8 @@ const spuAndSkuListRef = ref() // sku 限时折扣 配置组件Ref
const
ruleConfig
:
RuleConfig
[]
=
[]
const
spuList
=
ref
<
DiscountActivityApi
.
SpuExtension
[]
>
([])
// 选择的 spu
const
spuPropertyList
=
ref
<
SpuProperty
<
DiscountActivityApi
.
SpuExtension
>
[]
>
([])
const
spuIds
=
ref
<
number
[]
>
([]);
const
selectSpu
=
(
spuId
:
number
,
skuIds
:
number
[])
=>
{
formRef
.
value
.
setValues
({
spuId
})
getSpuDetails
(
spuId
,
skuIds
)
}
/**
...
...
@@ -75,14 +78,22 @@ const selectSpu = (spuId: number, skuIds: number[]) => {
const
getSpuDetails
=
async
(
spuId
:
number
,
skuIds
:
number
[]
|
undefined
,
products
?:
DiscountActivityApi
.
DiscountProductVO
[]
products
?:
DiscountActivityApi
.
DiscountProductVO
[],
type
?:
string
)
=>
{
const
spuProperties
:
SpuProperty
<
DiscountActivityApi
.
SpuExtension
>
[]
=
[]
//如果已经包含spu则跳过
if
(
spuIds
.
value
.
includes
(
spuId
)){
if
(
type
!==
"load"
){
message
.
error
(
"数据重复选择!"
)
}
return
;
}
spuIds
.
value
.
push
(
spuId
)
const
res
=
(
await
ProductSpuApi
.
getSpuDetailList
([
spuId
]))
as
DiscountActivityApi
.
SpuExtension
[]
if
(
res
.
length
==
0
)
{
return
}
spuList
.
value
=
[]
//
spuList.value = []
// 因为只能选择一个
const
spu
=
res
[
0
]
const
selectSkus
=
...
...
@@ -100,15 +111,19 @@ const getSpuDetails = async (
config
=
product
||
config
}
sku
.
productConfig
=
config
sku
.
price
=
formatToFraction
(
sku
.
price
)
sku
.
marketPrice
=
formatToFraction
(
sku
.
marketPrice
)
sku
.
costPrice
=
formatToFraction
(
sku
.
costPrice
)
sku
.
firstBrokeragePrice
=
formatToFraction
(
sku
.
firstBrokeragePrice
)
sku
.
secondBrokeragePrice
=
formatToFraction
(
sku
.
secondBrokeragePrice
)
})
spu
.
skus
=
selectSkus
as
DiscountActivityApi
.
SkuExtension
[]
spuPropert
ies
.
push
({
spuPropert
yList
.
value
.
push
({
spuId
:
spu
.
id
!
,
spuDetail
:
spu
,
propertyList
:
getPropertyList
(
spu
)
})
spuList
.
value
.
push
(
spu
)
spuPropertyList
.
value
=
spuProperties
}
// ================= end =================
...
...
@@ -126,8 +141,10 @@ const open = async (type: string, id?: number) => {
const
data
=
(
await
DiscountActivityApi
.
getDiscountActivity
(
id
))
as
DiscountActivityApi
.
DiscountActivityVO
const
supId
=
data
.
products
[
0
].
spuId
await
getSpuDetails
(
supId
!
,
data
.
products
?.
map
((
sku
)
=>
sku
.
skuId
),
data
.
products
)
for
(
let
productsKey
in
data
.
products
)
{
const
supId
=
data
.
products
[
productsKey
].
spuId
await
getSpuDetails
(
supId
!
,
data
.
products
?.
map
((
sku
)
=>
sku
.
skuId
),
data
.
products
,
"load"
)
}
formRef
.
value
.
setValues
(
data
)
}
finally
{
formLoading
.
value
=
false
...
...
@@ -149,9 +166,20 @@ const submitForm = async () => {
const
data
=
formRef
.
value
.
formModel
as
DiscountActivityApi
.
DiscountActivityVO
// 获取 折扣商品配置
const
products
=
cloneDeep
(
spuAndSkuListRef
.
value
.
getSkuConfigs
(
'productConfig'
))
let
timp
=
false
;
products
.
forEach
((
item
:
DiscountActivityApi
.
DiscountProductVO
)
=>
{
item
.
discountType
=
data
[
'discountType'
]
if
(
item
.
discountPrice
!=
null
&&
item
.
discountPrice
>
0
){
item
.
discountType
=
1
}
else
if
(
item
.
discountPercent
!=
null
&&
item
.
discountPercent
>
0
){
item
.
discountType
=
2
}
else
{
timp
=
true
}
})
if
(
timp
){
message
.
error
(
"优惠金额和折扣百分比需要填写一个"
);
return
;
}
data
.
products
=
products
// 真正提交
if
(
formType
.
value
===
'create'
)
{
...
...
@@ -173,7 +201,16 @@ const submitForm = async () => {
const
resetForm
=
async
()
=>
{
spuList
.
value
=
[]
spuPropertyList
.
value
=
[]
spuIds
.
value
=
[]
await
nextTick
()
formRef
.
value
.
getElFormRef
().
resetFields
()
}
/**
* 删除spu
*/
const
deleteSpu
=
(
spuId
:
number
)
=>
{
spuIds
.
value
.
splice
(
spuIds
.
value
.
findIndex
((
item
)
=>
item
==
spuId
),
1
)
spuPropertyList
.
value
.
splice
(
spuPropertyList
.
value
.
findIndex
((
item
)
=>
item
.
spuId
==
spuId
),
1
)
}
</
script
>
src/views/mall/promotion/discountActivity/discountActivity.data.ts
View file @
24349110
...
...
@@ -73,17 +73,6 @@ const crudSchemas = reactive<CrudSchema[]>([
}
},
{
label
:
'优惠类型'
,
field
:
'discountType'
,
dictType
:
DICT_TYPE
.
PROMOTION_DISCOUNT_TYPE
,
dictClass
:
'number'
,
isSearch
:
true
,
form
:
{
component
:
'Radio'
,
value
:
1
}
},
{
label
:
'活动商品'
,
field
:
'spuId'
,
isTable
:
true
,
...
...
src/views/mall/promotion/discountActivity/index.vue
View file @
24349110
...
...
@@ -70,17 +70,17 @@
~
{{
formatDate
(
scope
.
row
.
endTime
,
'YYYY-MM-DD'
)
}}
</
template
>
</el-table-column>
<el-table-column
label=
"商品图片"
prop=
"spuName"
min-width=
"80"
>
<
template
#
default=
"scope"
>
<el-image
:src=
"scope.row.picUrl"
class=
"h-40px w-40px"
:preview-src-list=
"[scope.row.picUrl]"
preview-teleported
/
>
</
template
>
</el-table-column
>
<el-table-column
label=
"商品标题"
prop=
"spuName"
min-width=
"300"
/
>
<!-- <el-table-column label="商品图片" prop="spuName" min-width="80">--
>
<!-- <template #default="scope">--
>
<!-- <el-image-->
<!-- :src="scope.row.picUrl"-->
<!-- class="h-40px w-40px"-->
<!-- :preview-src-list="[scope.row.picUrl]"-->
<!-- preview-teleported-->
<!-- />--
>
<!-- </template>--
>
<!-- </el-table-column>--
>
<!-- <el-table-column label="商品标题" prop="spuName" min-width="300" />--
>
<el-table-column
label=
"活动状态"
align=
"center"
prop=
"status"
min-width=
"100"
>
<
template
#
default=
"scope"
>
<dict-tag
:type=
"DICT_TYPE.COMMON_STATUS"
:value=
"scope.row.status"
/>
...
...
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