From c254222b5f28d450a208d563083ed9a3dbffeff3 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sat, 20 May 2023 12:05:18 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=81=97=E7=95=99?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 38545e89c6b6cb98f7a70d69583110338b02d499) --- src/views/mall/product/spu/addForm.vue | 22 +--------- .../product/spu/components/BasicInfoForm.vue | 40 +++++++++++++------ .../spu/components/ProductAttributes.vue | 36 ++++++++++++----- .../components/ProductAttributesAddForm.vue | 23 +++++++++-- .../mall/product/spu/components/SkuList.vue | 6 +-- 5 files changed, 76 insertions(+), 51 deletions(-) diff --git a/src/views/mall/product/spu/addForm.vue b/src/views/mall/product/spu/addForm.vue index e081387d..bc0941cd 100644 --- a/src/views/mall/product/spu/addForm.vue +++ b/src/views/mall/product/spu/addForm.vue @@ -37,7 +37,6 @@ import { useTagsViewStore } from '@/store/modules/tagsView' import { BasicInfoForm, DescriptionForm, OtherSettingsForm } from './components' // 业务api import * as ProductSpuApi from '@/api/mall/product/spu' -import * as PropertyApi from '@/api/mall/product/property' import { convertToInteger, formatToFraction } from '@/utils' const { t } = useI18n() // 国际化 @@ -105,25 +104,6 @@ const getDetail = async () => { item.subCommissionSecondPrice = formatToFraction(item.subCommissionSecondPrice) }) formData.value = res - // 只有是多规格才处理 - if (res.specType) { - // TODO @puhui999:可以直接拿 propertyName 拼接处规格 id + 属性,可以看下商品 uniapp 详情的做法 - // fix: 考虑到 sku 数量和通过属性算出来的sku不一致的情况 - const propertyIds = [] - res.skus.forEach((sku) => - sku.properties - ?.map((property) => property.propertyId) - .forEach((propertyId) => { - if (propertyIds.indexOf(propertyId) === -1) { - propertyIds.push(propertyId) - } - }) - ) - const properties = await PropertyApi.getPropertyListAndValue({ propertyIds }) - await nextTick() - // 回显商品属性 - basicInfoRef.value.addAttribute(properties) - } } finally { formLoading.value = false } @@ -141,7 +121,7 @@ const submitForm = async () => { await unref(descriptionRef)?.validate() await unref(otherSettingsRef)?.validate() const deepCopyFormData = cloneDeep(unref(formData.value)) // 深拷贝一份 fix:这样最终 server 端不满足,不需要恢复, - // TODO 兜底处理 sku 空数据详见 SkuList TODO + // TODO 兜底处理 sku 空数据 formData.value.skus.forEach((sku) => { // 因为是空数据这里判断一下商品条码是否为空就行 if (sku.barCode === '') { diff --git a/src/views/mall/product/spu/components/BasicInfoForm.vue b/src/views/mall/product/spu/components/BasicInfoForm.vue index d2c7bbe1..eac3de9c 100644 --- a/src/views/mall/product/spu/components/BasicInfoForm.vue +++ b/src/views/mall/product/spu/components/BasicInfoForm.vue @@ -98,14 +98,14 @@ 添加规格 - + @@ -114,7 +114,7 @@ - +