@@ -30,8 +30,8 @@ import { SpuAndSkuList, SpuProperty, SpuSelect } from '../../components'
30
30
import { allSchemas , rules } from ' ./seckillActivity.data'
31
31
32
32
import * as SeckillActivityApi from ' @/api/mall/promotion/seckill/seckillActivity'
33
- import { getPropertyList , RuleConfig } from ' @/views/mall/product/spu/components'
34
33
import * as ProductSpuApi from ' @/api/mall/product/spu'
34
+ import { getPropertyList , RuleConfig } from ' @/views/mall/product/spu/components'
35
35
36
36
defineOptions ({ name: ' PromotionSeckillActivityForm' })
37
37
@@ -62,7 +62,7 @@ const open = async (type: string, id?: number) => {
62
62
dialogVisible .value = true
63
63
dialogTitle .value = t (' action.' + type )
64
64
formType .value = type
65
- resetForm ()
65
+ await resetForm ()
66
66
// 修改时,设置数据 TODO 没测试估计有问题
67
67
if (id ) {
68
68
formLoading .value = true
@@ -89,34 +89,30 @@ const selectSpu = (spuIds: number[]) => {
89
89
*/
90
90
const getSpuDetails = async (spuIds : number []) => {
91
91
const spuProperties: SpuProperty <SeckillActivityApi .SpuExtension >[] = []
92
+ const res = (await ProductSpuApi .getSpuDetailList (spuIds )) as SeckillActivityApi .SpuExtension []
92
93
spuList .value = []
93
- // TODO puhui999: 考虑后端添加通过 spuIds 批量获取
94
- for (const spuId of spuIds ) {
95
- // 获取 SPU 详情
96
- const res = (await ProductSpuApi .getSpu (spuId )) as SeckillActivityApi .SpuExtension
97
- if (! res ) {
98
- continue
99
- }
100
- spuList .value .push (res )
94
+ res ?.forEach ((spu ) => {
101
95
// 初始化每个 sku 秒杀配置
102
- res .skus ?.forEach ((sku ) => {
96
+ spu .skus ?.forEach ((sku ) => {
103
97
const config: SeckillActivityApi .SeckillProductVO = {
104
- spuId ,
98
+ spuId: spu . id ! ,
105
99
skuId: sku .id ! ,
106
100
stock: 0 ,
107
101
seckillPrice: 0
108
102
}
109
103
sku .productConfig = config
110
104
})
111
- spuProperties .push ({ spuId , spuDetail: res , propertyList: getPropertyList (res ) })
112
- }
105
+ spuProperties .push ({ spuId: spu .id ! , spuDetail: spu , propertyList: getPropertyList (spu ) })
106
+ })
107
+ spuList .value .push (... res )
113
108
spuPropertyList .value = spuProperties
114
109
}
115
110
116
111
/** 重置表单 */
117
- const resetForm = () => {
112
+ const resetForm = async () => {
118
113
spuList .value = []
119
114
spuPropertyList .value = []
115
+ await nextTick ()
120
116
formRef .value .getElFormRef ().resetFields ()
121
117
}
122
118
/** 提交表单 */
0 commit comments