From 9ab51a137cd2eb699c7699f6a9da0be44272824b Mon Sep 17 00:00:00 2001 From: xingyu4j Date: Tue, 21 Oct 2025 17:55:23 +0800 Subject: [PATCH] fix: sku list --- .../mall/product/spu/modules/form-data.ts | 4 - .../views/mall/product/spu/modules/form.vue | 122 ++-- .../views/mall/product/spu/modules/index.ts | 4 +- .../spu/modules/product-attributes.vue | 24 +- .../spu/modules/product-property-add-form.vue | 2 +- .../mall/product/spu/modules/sku-list.vue | 606 +++++++++--------- .../product/spu/modules/sku-table-select.vue | 16 +- 7 files changed, 388 insertions(+), 390 deletions(-) diff --git a/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts b/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts index 3ad1cd4ff..8596a610d 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts +++ b/apps/web-antd/src/views/mall/product/spu/modules/form-data.ts @@ -160,7 +160,6 @@ export function useSkuFormSchema( fieldName: 'singleSkuList', label: '', component: 'Input', - componentProps: {}, dependencies: { triggerFields: ['specType'], // 当 specType 为 false(单规格)时显示 @@ -172,7 +171,6 @@ export function useSkuFormSchema( fieldName: 'productAttributes', label: '商品属性', component: 'Input', - componentProps: {}, dependencies: { triggerFields: ['specType'], // 当 specType 为 true(多规格)时显示 @@ -184,7 +182,6 @@ export function useSkuFormSchema( fieldName: 'batchSkuList', label: '批量设置', component: 'Input', - componentProps: {}, dependencies: { triggerFields: ['specType'], // 当 specType 为 true(多规格)且 propertyList 有数据时显示,且非详情模式 @@ -197,7 +194,6 @@ export function useSkuFormSchema( fieldName: 'multiSkuList', label: '规格列表', component: 'Input', - componentProps: {}, dependencies: { triggerFields: ['specType'], // 当 specType 为 true(多规格)且 propertyList 有数据时显示 diff --git a/apps/web-antd/src/views/mall/product/spu/modules/form.vue b/apps/web-antd/src/views/mall/product/spu/modules/form.vue index e3b5e05de..9c24e85aa 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/form.vue +++ b/apps/web-antd/src/views/mall/product/spu/modules/form.vue @@ -313,67 +313,69 @@ onMounted(async () => { diff --git a/apps/web-antd/src/views/mall/product/spu/modules/index.ts b/apps/web-antd/src/views/mall/product/spu/modules/index.ts index a14d1838e..7c7c72d4d 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/index.ts +++ b/apps/web-antd/src/views/mall/product/spu/modules/index.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-non-null-assertion */ import type { MallSpuApi } from '#/api/mall/product/spu'; export interface PropertyAndValues { @@ -39,9 +40,7 @@ const getPropertyList = (spu: MallSpuApi.Spu): PropertyAndValues[] => { // 添加属性 if (!properties?.some((item) => item.id === propertyId)) { properties.push({ - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion id: propertyId!, - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion name: propertyName!, values: [], }); @@ -51,7 +50,6 @@ const getPropertyList = (spu: MallSpuApi.Spu): PropertyAndValues[] => { if ( !properties[index]?.values?.some((value) => value.id === valueId) ) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion properties[index]?.values?.push({ id: valueId!, name: valueName! }); } }, diff --git a/apps/web-antd/src/views/mall/product/spu/modules/product-attributes.vue b/apps/web-antd/src/views/mall/product/spu/modules/product-attributes.vue index 89786800f..efa59431d 100644 --- a/apps/web-antd/src/views/mall/product/spu/modules/product-attributes.vue +++ b/apps/web-antd/src/views/mall/product/spu/modules/product-attributes.vue @@ -48,7 +48,7 @@ interface InputRefItem { const inputRef = ref([]); // 标签输入框Ref /** 解决 ref 在 v-for 中的获取问题*/ -const setInputRef = (el: any) => { +function setInputRef(el: any) { if (el === null || el === undefined) return; // 如果不存在 id 相同的元素才添加 if ( @@ -58,7 +58,7 @@ const setInputRef = (el: any) => { ) { inputRef.value.push(el); } -}; +} const attributeList = ref([]); // 商品属性列表 const attributeOptions = ref([]); // 商品属性值下拉框 @@ -75,26 +75,26 @@ watch( ); /** 删除属性值*/ -const handleCloseValue = (index: number, valueIndex: number) => { +function handleCloseValue(index: number, valueIndex: number) { attributeList.value?.[index]?.values?.splice(valueIndex, 1); -}; +} /** 删除属性*/ -const handleCloseProperty = (index: number) => { +function handleCloseProperty(index: number) { attributeList.value?.splice(index, 1); emit('success', attributeList.value); -}; +} /** 显示输入框并获取焦点 */ -const showInput = async (index: number) => { +async function showInput(index: number) { attributeIndex.value = index; inputRef.value?.[index]?.focus(); // 获取属性下拉选项 await getAttributeOptions(attributeList.value?.[index]?.id!); -}; +} // 定义 success 事件,用于操作成功后的回调 -const handleInputConfirm = async (index: number, propertyId: number) => { +async function handleInputConfirm(index: number, propertyId: number) { // 从数组中取最后一个输入的值(tags 模式下 inputValue 是数组) const currentValue = inputValue.value?.[inputValue.value.length - 1]?.trim(); @@ -144,12 +144,12 @@ const handleInputConfirm = async (index: number, propertyId: number) => { } attributeIndex.value = null; inputValue.value = []; -}; +} /** 获取商品属性下拉选项 */ -const getAttributeOptions = async (propertyId: number) => { +async function getAttributeOptions(propertyId: number) { attributeOptions.value = await getPropertyValueSimpleList(propertyId); -}; +}