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
ff8bde20
authored
Aug 12, 2023
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
商城:
1. 修复秒杀活动,修改商品的秒杀价格,会存在 *100 的问题
parent
9984de0d
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
31 deletions
+35
-31
src/hooks/web/useCrudSchemas.ts
+10
-0
src/views/mall/promotion/combination/index.vue
+0
-1
src/views/mall/promotion/seckill/activity/SeckillActivityForm.vue
+18
-16
src/views/mall/promotion/seckill/activity/index.vue
+7
-14
No files found.
src/hooks/web/useCrudSchemas.ts
View file @
ff8bde20
...
...
@@ -9,6 +9,7 @@ import { TableColumn } from '@/types/table'
import
{
DescriptionsSchema
}
from
'@/types/descriptions'
import
{
ComponentOptions
,
ComponentProps
}
from
'@/types/components'
import
{
DictTag
}
from
'@/components/DictTag'
import
{
cloneDeep
}
from
'lodash-es'
export
type
CrudSchema
=
Omit
<
TableColumn
,
'children'
>
&
{
isSearch
?:
boolean
// 是否在查询显示
...
...
@@ -306,3 +307,12 @@ const filterOptions = (options: Recordable, labelField?: string) => {
return
v
})
}
// 将 tableColumns 指定 fields 放到最前面
export
const
sortTableColumns
=
(
tableColumns
:
TableColumn
[],
field
:
string
)
=>
{
const
fieldIndex
=
tableColumns
.
findIndex
((
item
)
=>
item
.
field
===
field
)
const
fieldColumn
=
cloneDeep
(
tableColumns
[
fieldIndex
])
tableColumns
.
splice
(
fieldIndex
,
1
)
// 添加到开头
tableColumns
.
unshift
(
fieldColumn
)
}
src/views/mall/promotion/combination/index.vue
View file @
ff8bde20
...
...
@@ -98,7 +98,6 @@ const handleDelete = (id: number) => {
tableMethods
.
delList
(
id
,
false
)
}
// TODO @puhui999:要不还是使用原生的 element plus 做。感觉 crud schema 复杂界面,做起来麻烦
/** 初始化 **/
onMounted
(()
=>
{
/**
...
...
src/views/mall/promotion/seckill/activity/SeckillActivityForm.vue
View file @
ff8bde20
...
...
@@ -45,6 +45,7 @@
<
script
lang=
"ts"
setup
>
import
{
SpuAndSkuList
,
SpuProperty
,
SpuSelect
}
from
'../../components'
import
{
allSchemas
,
rules
}
from
'./seckillActivity.data'
import
{
cloneDeep
}
from
'lodash-es'
import
*
as
SeckillActivityApi
from
'@/api/mall/promotion/seckill/seckillActivity'
import
{
SeckillProductVO
}
from
'@/api/mall/promotion/seckill/seckillActivity'
...
...
@@ -70,13 +71,13 @@ const spuAndSkuListRef = ref() // sku 秒杀配置组件Ref
const
ruleConfig
:
RuleConfig
[]
=
[
{
name
:
'productConfig.stock'
,
rule
:
(
arg
)
=>
arg
>
1
,
message
:
'商品秒杀库存必须大于 1 !!!'
rule
:
(
arg
)
=>
arg
>
=
1
,
message
:
'商品秒杀库存必须大于
等于
1 !!!'
},
{
name
:
'productConfig.seckillPrice'
,
rule
:
(
arg
)
=>
arg
>
0.01
,
message
:
'商品秒杀价格必须大于 0.01 !!!'
rule
:
(
arg
)
=>
arg
>
=
0.01
,
message
:
'商品秒杀价格必须大于
等于
0.01 !!!'
}
]
const
spuList
=
ref
<
SeckillActivityApi
.
SpuExtension
[]
>
([])
// 选择的 spu
...
...
@@ -112,7 +113,6 @@ const getSpuDetails = async (
if
(
typeof
products
!==
'undefined'
)
{
const
product
=
products
.
find
((
item
)
=>
item
.
skuId
===
sku
.
id
)
if
(
product
)
{
// 分转元
product
.
seckillPrice
=
formatToFraction
(
product
.
seckillPrice
)
}
config
=
product
||
config
...
...
@@ -153,13 +153,6 @@ const open = async (type: string, id?: number) => {
}
defineExpose
({
open
})
// 提供 open 方法,用于打开弹窗
/** 重置表单 */
const
resetForm
=
async
()
=>
{
spuList
.
value
=
[]
spuPropertyList
.
value
=
[]
await
nextTick
()
formRef
.
value
.
getElFormRef
().
resetFields
()
}
/** 提交表单 */
const
emit
=
defineEmits
([
'success'
])
// 定义 success 事件,用于操作成功后的回调
const
submitForm
=
async
()
=>
{
...
...
@@ -170,14 +163,14 @@ const submitForm = async () => {
// 提交请求
formLoading
.
value
=
true
try
{
const
data
=
formRef
.
value
.
formModel
as
SeckillActivityApi
.
SeckillActivityVO
const
products
=
spuAndSkuListRef
.
value
.
getSkuConfigs
(
'productConfig'
)
// 获取秒杀商品配置
const
products
=
cloneDeep
(
spuAndSkuListRef
.
value
.
getSkuConfigs
(
'productConfig'
)
)
products
.
forEach
((
item
:
SeckillProductVO
)
=>
{
// 秒杀价格元转分
item
.
seckillPrice
=
convertToInteger
(
item
.
seckillPrice
)
})
// 获取秒杀商品配置
const
data
=
formRef
.
value
.
formModel
as
SeckillActivityApi
.
SeckillActivityVO
data
.
products
=
products
// 真正提交
if
(
formType
.
value
===
'create'
)
{
await
SeckillActivityApi
.
createSeckillActivity
(
data
)
message
.
success
(
t
(
'common.createSuccess'
))
...
...
@@ -192,6 +185,15 @@ const submitForm = async () => {
formLoading
.
value
=
false
}
}
/** 重置表单 */
const
resetForm
=
async
()
=>
{
spuList
.
value
=
[]
spuPropertyList
.
value
=
[]
await
nextTick
()
formRef
.
value
.
getElFormRef
().
resetFields
()
}
// TODO @puhui999:下面的 css 名字,是不是可以改下;demo-table-expand
</
script
>
<
style
lang=
"scss"
scoped
>
.demo-table-expand
{
...
...
src/views/mall/promotion/seckill/activity/index.vue
View file @
ff8bde20
...
...
@@ -10,8 +10,7 @@
type=
"primary"
@
click=
"openForm('create')"
>
<Icon
class=
"mr-5px"
icon=
"ep:plus"
/>
新增
<Icon
class=
"mr-5px"
icon=
"ep:plus"
/>
新增
</el-button>
</
template
>
</Search>
...
...
@@ -74,8 +73,8 @@ import { allSchemas } from './seckillActivity.data'
import
{
getSimpleSeckillConfigList
}
from
'@/api/mall/promotion/seckill/seckillConfig'
import
*
as
SeckillActivityApi
from
'@/api/mall/promotion/seckill/seckillActivity'
import
SeckillActivityForm
from
'./SeckillActivityForm.vue'
import
{
cloneDeep
}
from
'lodash-es'
import
{
createImageViewer
}
from
'@/components/ImageViewer'
import
{
sortTableColumns
}
from
'@/hooks/web/useCrudSchemas'
defineOptions
({
name
:
'PromotionSeckillActivity'
})
...
...
@@ -99,12 +98,14 @@ const openForm = (type: string, id?: number) => {
const
handleDelete
=
(
id
:
number
)
=>
{
tableMethods
.
delList
(
id
,
false
)
}
/** 商品图预览 */
const
imagePreview
=
(
imgUrl
:
string
)
=>
{
createImageViewer
({
urlList
:
[
imgUrl
]
})
}
const
configList
=
ref
([])
// 时段配置精简列表
const
convertSeckillConfigNames
=
computed
(
()
=>
(
row
)
=>
...
...
@@ -120,18 +121,10 @@ const expandChange = (row, expandedRows) => {
/** 初始化 **/
onMounted
(
async
()
=>
{
/*
TODO
后面准备封装成一个函数来操作 tableColumns 重新排列:比如说需求是表单上商品选择是在后面的而列表展示的时候需要调到位置。
封装效果支持批量操作,给出 field 和需要插入的位置,例:[{field:'spuId',index: 1}] 效果为把 field 为 spuId 的 column 移动到第一个位置
*/
// 处理一下表格列让商品往前
const
index
=
allSchemas
.
tableColumns
.
findIndex
((
item
)
=>
item
.
field
===
'spuId'
)
const
column
=
cloneDeep
(
allSchemas
.
tableColumns
[
index
])
allSchemas
.
tableColumns
.
splice
(
index
,
1
)
// 添加到开头
allSchemas
.
tableColumns
.
unshift
(
column
)
// 获得活动列表
sortTableColumns
(
allSchemas
.
tableColumns
,
'spuId'
)
await
getList
()
// 获得秒杀时间段
configList
.
value
=
await
getSimpleSeckillConfigList
()
})
</
script
>
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