From 538d1e0b6cc997e701a6c7cc22b6550ddf21cd42 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 30 Apr 2023 02:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E7=AE=A1=E7=90=86:=20fix:?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=95=86=E5=93=81=E5=B1=9E=E6=80=A7=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=94=9F=E6=88=90=E8=A1=A8=E6=A0=BC=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/product/management/type/spuType.ts | 1 - .../management/components/BasicInfoForm.vue | 39 +++--- .../components/ProductAttributes.vue | 4 +- .../components/ProductAttributesAddForm.vue | 3 + .../management/components/SkuList/index.vue | 129 ++++++++++++++++-- 5 files changed, 140 insertions(+), 36 deletions(-) diff --git a/src/api/mall/product/management/type/spuType.ts b/src/api/mall/product/management/type/spuType.ts index f51bc526..5d9b65ef 100644 --- a/src/api/mall/product/management/type/spuType.ts +++ b/src/api/mall/product/management/type/spuType.ts @@ -9,7 +9,6 @@ export interface SpuType { sliderPicUrls?: string[] // 商品轮播图 introduction?: string // 商品简介 deliveryTemplateId?: number // 运费模版 - selectRule?: string // 选择规格 TODO 暂时定义 specType?: boolean // 商品规格 subCommissionType?: boolean // 分销类型 skus?: SkuType[] // sku数组 diff --git a/src/views/mall/product/management/components/BasicInfoForm.vue b/src/views/mall/product/management/components/BasicInfoForm.vue index 90f7c0df..d06a787d 100644 --- a/src/views/mall/product/management/components/BasicInfoForm.vue +++ b/src/views/mall/product/management/components/BasicInfoForm.vue @@ -60,7 +60,7 @@ - + 单规格 多规格 @@ -76,12 +76,17 @@ - - 添加规格 + + 添加规格 + + + + - + @@ -110,14 +115,8 @@ const props = defineProps({ }) const AttributesAddFormRef = ref() // 添加商品属性表单 const ProductManagementBasicInfoRef = ref() // 表单Ref -// 属性列表 -const attributeList = ref([ - { - id: 1, - name: '颜色', - values: [{ id: 1, name: '白色' }] - } -]) +const attributeList = ref([]) // 商品属性列表 +/** 添加商品属性 */ const addAttribute = (property: any) => { attributeList.value.push(property) } @@ -176,10 +175,10 @@ const rules = reactive({ unit: [required], introduction: [required], picUrl: [required], - sliderPicUrls: [required] + sliderPicUrls: [required], // deliveryTemplateId: [required], - // specType: [required], - // subCommissionType: [required], + specType: [required], + subCommissionType: [required] }) /** * 将传进来的值赋值给formData @@ -215,10 +214,7 @@ const validate = async () => { }) } defineExpose({ validate }) -// 选择规格 -const changeSpecType = (specType) => { - console.log(specType) -} + // 分销类型 const changeSubCommissionType = () => { // 默认为零,类型切换后也要重置为零 @@ -227,10 +223,7 @@ const changeSubCommissionType = () => { item.subCommissionSecondPrice = 0 } } -// 选择属性确认 -// const confirm = () => {} -// 添加规格 -// const addRule = () => {} + const categoryList = ref() // 分类树 onMounted(async () => { // 获得分类树 diff --git a/src/views/mall/product/management/components/ProductAttributes.vue b/src/views/mall/product/management/components/ProductAttributes.vue index 120ffd36..ea9b311a 100644 --- a/src/views/mall/product/management/components/ProductAttributes.vue +++ b/src/views/mall/product/management/components/ProductAttributes.vue @@ -49,10 +49,10 @@ const inputVisible = computed(() => (index) => { if (attributeIndex.value === index) return true }) const InputRef = ref() //标签输入框Ref -const attributeList = ref([]) +const attributeList = ref([]) // 商品属性列表 const props = defineProps({ attributeData: { - type: Object, + type: Array, default: () => {} } }) diff --git a/src/views/mall/product/management/components/ProductAttributesAddForm.vue b/src/views/mall/product/management/components/ProductAttributesAddForm.vue index f498b7dd..bd715dde 100644 --- a/src/views/mall/product/management/components/ProductAttributesAddForm.vue +++ b/src/views/mall/product/management/components/ProductAttributesAddForm.vue @@ -62,6 +62,9 @@ const submitForm = async () => { const propertyId = await PropertyApi.createProperty(data) emit('success', { id: propertyId, ...formData.value, values: [] }) } else { + if (res[0].values === null) { + res[0].values = [] + } emit('success', res[0]) // 因为只用一个 } message.success(t('common.createSuccess')) diff --git a/src/views/mall/product/management/components/SkuList/index.vue b/src/views/mall/product/management/components/SkuList/index.vue index fd148126..a3ecd9dd 100644 --- a/src/views/mall/product/management/components/SkuList/index.vue +++ b/src/views/mall/product/management/components/SkuList/index.vue @@ -1,10 +1,21 @@