Skip to content

Commit 76ccc54

Browse files
author
puhui999
committed
fix: 修复 spu 详情查看错误,同步 mall seckill 组件 name 配置方式
1 parent 5d613e6 commit 76ccc54

File tree

6 files changed

+20
-30
lines changed

6 files changed

+20
-30
lines changed

src/views/mall/product/spu/addForm.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ const { delView } = useTagsViewStore() // 视图操作
5555
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
5656
const activeName = ref('basicInfo') // Tag 激活的窗口
5757
const isDetail = ref(false) // 是否查看详情
58-
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>() // 商品信息Ref
59-
const descriptionRef = ref<ComponentRef<typeof DescriptionForm>>() // 商品详情Ref
60-
const otherSettingsRef = ref<ComponentRef<typeof OtherSettingsForm>>() // 其他设置Ref
58+
const basicInfoRef = ref() // 商品信息Ref
59+
const descriptionRef = ref() // 商品详情Ref
60+
const otherSettingsRef = ref() // 其他设置Ref
6161
// spu 表单数据
6262
const formData = ref<ProductSpuApi.Spu>({
6363
name: '', // 商品名称
@@ -98,7 +98,7 @@ const formData = ref<ProductSpuApi.Spu>({
9898
9999
/** 获得详情 */
100100
const getDetail = async () => {
101-
if ('productSpuDetail' === name) {
101+
if ('ProductSpuDetail' === name) {
102102
isDetail.value = true
103103
}
104104
const id = params.spuId as number

src/views/mall/product/spu/components/BasicInfoForm.vue

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ import { checkSelectedNode, defaultProps, handleTree, treeToString } from '@/uti
176176
import { createImageViewer } from '@/components/ImageViewer'
177177
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
178178
import { UploadImg, UploadImgs } from '@/components/UploadFile'
179-
import { ProductAttributes, ProductPropertyAddForm, SkuList } from './index'
179+
import { getPropertyList, ProductAttributes, ProductPropertyAddForm, SkuList } from './index'
180180
import { basicInfoSchema } from './spu.data'
181181
import type { Spu } from '@/api/mall/product/spu'
182182
import * as ProductCategoryApi from '@/api/mall/product/category'
@@ -242,7 +242,7 @@ const rules = reactive({
242242
introduction: [required],
243243
picUrl: [required],
244244
sliderPicUrls: [required],
245-
// deliveryTemplateId: [required],
245+
deliveryTemplateId: [required],
246246
brandId: [required],
247247
specType: [required],
248248
subCommissionType: [required]
@@ -261,26 +261,7 @@ watch(
261261
formData.sliderPicUrls = data['sliderPicUrls']?.map((item) => ({
262262
url: item
263263
}))
264-
// 只有是多规格才处理
265-
if (!formData.specType) {
266-
return
267-
}
268-
// 直接拿返回的 skus 属性逆向生成出 propertyList
269-
const properties = []
270-
formData.skus?.forEach((sku) => {
271-
sku.properties?.forEach(({ propertyId, propertyName, valueId, valueName }) => {
272-
// 添加属性
273-
if (!properties?.some((item) => item.id === propertyId)) {
274-
properties.push({ id: propertyId, name: propertyName, values: [] })
275-
}
276-
// 添加属性值
277-
const index = properties?.findIndex((item) => item.id === propertyId)
278-
if (!properties[index].values?.some((value) => value.id === valueId)) {
279-
properties[index].values?.push({ id: valueId, name: valueName })
280-
}
281-
})
282-
})
283-
propertyList.value = properties
264+
propertyList.value = getPropertyList(data)
284265
},
285266
{
286267
immediate: true

src/views/mall/promotion/seckill/activity/SeckillActivityForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
<!-- TODO @puhui999:这个组件是不是 SpuSelect,不需要带 sku 或者 Form 呀 -->
2323
<SpuAndSkuSelectForm ref="spuAndSkuSelectForm" @confirm="selectSpu" />
2424
</template>
25-
<script lang="ts" name="PromotionSeckillActivityForm" setup>
25+
<script lang="ts" setup>
2626
import { SpuAndSkuList, SpuAndSkuSelectForm } from './components'
2727
import { allSchemas, rules } from './seckillActivity.data'
2828
import { Spu } from '@/api/mall/product/spu'
2929
3030
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
3131
32+
defineOptions({ name: 'PromotionSeckillActivityForm' })
33+
3234
const { t } = useI18n() // 国际化
3335
const message = useMessage() // 消息弹窗
3436

src/views/mall/promotion/seckill/activity/components/SpuAndSkuList.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<el-table-column align="center" label="库存" min-width="90" prop="stock" />
4747
</el-table>
4848
</template>
49-
<script lang="ts" name="SpuAndSkuList" setup>
49+
<script lang="ts" setup>
5050
// TODO 后续计划重新封装作为活动商品配置通用组件;可以等其他活动做到的时候,在统一处理 SPU 选择组件哈
5151
import { formatToFraction } from '@/utils'
5252
import { createImageViewer } from '@/components/ImageViewer'
@@ -59,6 +59,9 @@ import {
5959
SkuList
6060
} from '@/views/mall/product/spu/components'
6161
import { SeckillProductVO, SpuExtension } from '@/api/mall/promotion/seckill/seckillActivity'
62+
63+
defineOptions({ name: 'PromotionSpuAndSkuList' })
64+
6265
const message = useMessage() // 消息弹窗
6366
6467
// TODO @puhui999:是不是改成传递一个 spu 就好啦?

src/views/mall/promotion/seckill/activity/components/SpuAndSkuSelectForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
</Dialog>
111111
</template>
112112

113-
<script lang="ts" name="SeckillActivitySpuAndSkuSelect" setup>
113+
<script lang="ts" setup>
114114
import { getPropertyList, Properties, SkuList } from '@/views/mall/product/spu/components'
115115
import { ElTable } from 'element-plus'
116116
import { dateFormatter } from '@/utils/formatTime'
@@ -122,6 +122,8 @@ import * as ProductCategoryApi from '@/api/mall/product/category'
122122
import * as ProductSpuApi from '@/api/mall/product/spu'
123123
import { propTypes } from '@/utils/propTypes'
124124
125+
defineOptions({ name: 'PromotionSpuAndSkuSelect' })
126+
125127
const props = defineProps({
126128
// 默认不需要(不需要的情况下只返回 spu,需要的情况下返回 选中的 spu 和 sku 列表)
127129
// 其它活动需要选择商品和商品属性导入此组件即可,需添加组件属性 :isSelectSku='true'

src/views/mall/promotion/seckill/activity/index.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@
5353
<!-- 表单弹窗:添加/修改 -->
5454
<SeckillActivityForm ref="formRef" @success="getList" />
5555
</template>
56-
<script lang="ts" name="PromotionSeckillActivity" setup>
56+
<script lang="ts" setup>
5757
import { allSchemas } from './seckillActivity.data'
5858
import * as SeckillActivityApi from '@/api/mall/promotion/seckill/seckillActivity'
5959
import SeckillActivityForm from './SeckillActivityForm.vue'
6060
61+
defineOptions({ name: 'PromotionSeckillActivity' })
62+
6163
// tableObject:表格的属性对象,可获得分页大小、条数等属性
6264
// tableMethods:表格的操作对象,可进行获得分页、删除记录等操作
6365
// 详细可见:https://doc.iocoder.cn/vue3/crud-schema/

0 commit comments

Comments
 (0)