From 4cd4327bc86151c6ccd31cc32576f17ecf7e5905 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 24 May 2023 20:27:45 +0800 Subject: [PATCH] =?UTF-8?q?review=20+=20mall=EF=BC=9A=E5=95=86=E5=93=81?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 0fba3fd5033a451cfe2c33a1dc8a3d91c90ed9b3) --- build/vite/optimize.ts | 105 ++++++++++-------- src/api/mall/product/spu.ts | 2 + src/utils/index.ts | 1 + src/views/mall/product/spu/addForm.vue | 1 - .../product/spu/components/BasicInfoForm.vue | 17 ++- .../spu/components/OtherSettingsForm.vue | 13 +-- .../mall/product/spu/components/SkuList.vue | 50 ++++++--- src/views/mall/product/spu/index.vue | 65 +++-------- 8 files changed, 121 insertions(+), 133 deletions(-) diff --git a/build/vite/optimize.ts b/build/vite/optimize.ts index ed932a60..2c73f72b 100644 --- a/build/vite/optimize.ts +++ b/build/vite/optimize.ts @@ -37,38 +37,58 @@ const include = [ 'element-plus/es', 'element-plus/es/locale/lang/zh-cn', 'element-plus/es/locale/lang/en', - 'element-plus/es/components/backtop/style/index', - 'element-plus/es/components/form/style/index', - 'element-plus/es/components/radio-group/style/index', - 'element-plus/es/components/radio/style/index', - 'element-plus/es/components/checkbox/style/index', - 'element-plus/es/components/checkbox-group/style/index', - 'element-plus/es/components/switch/style/index', - 'element-plus/es/components/time-picker/style/index', - 'element-plus/es/components/date-picker/style/index', - 'element-plus/es/components/col/style/index', - 'element-plus/es/components/form-item/style/index', - 'element-plus/es/components/alert/style/index', - 'element-plus/es/components/breadcrumb/style/index', - 'element-plus/es/components/select/style/index', - 'element-plus/es/components/input/style/index', - 'element-plus/es/components/breadcrumb-item/style/index', - 'element-plus/es/components/tag/style/index', - 'element-plus/es/components/pagination/style/index', - 'element-plus/es/components/table/style/index', - 'element-plus/es/components/table-column/style/index', - 'element-plus/es/components/card/style/index', - 'element-plus/es/components/row/style/index', - 'element-plus/es/components/button/style/index', - 'element-plus/es/components/menu/style/index', - 'element-plus/es/components/sub-menu/style/index', - 'element-plus/es/components/menu-item/style/index', - 'element-plus/es/components/option/style/index', - 'element-plus/es/components/dropdown/style/index', - 'element-plus/es/components/dropdown-menu/style/index', - 'element-plus/es/components/dropdown-item/style/index', - 'element-plus/es/components/skeleton/style/index', - + 'element-plus/es/components/backtop/style/css', + 'element-plus/es/components/form/style/css', + 'element-plus/es/components/radio-group/style/css', + 'element-plus/es/components/radio/style/css', + 'element-plus/es/components/checkbox/style/css', + 'element-plus/es/components/checkbox-group/style/css', + 'element-plus/es/components/switch/style/css', + 'element-plus/es/components/time-picker/style/css', + 'element-plus/es/components/date-picker/style/css', + 'element-plus/es/components/descriptions/style/css', + 'element-plus/es/components/descriptions-item/style/css', + 'element-plus/es/components/link/style/css', + 'element-plus/es/components/tooltip/style/css', + 'element-plus/es/components/drawer/style/css', + 'element-plus/es/components/dialog/style/css', + 'element-plus/es/components/checkbox-button/style/css', + 'element-plus/es/components/option-group/style/css', + 'element-plus/es/components/radio-button/style/css', + 'element-plus/es/components/cascader/style/css', + 'element-plus/es/components/color-picker/style/css', + 'element-plus/es/components/input-number/style/css', + 'element-plus/es/components/rate/style/css', + 'element-plus/es/components/select-v2/style/css', + 'element-plus/es/components/tree-select/style/css', + 'element-plus/es/components/slider/style/css', + 'element-plus/es/components/time-select/style/css', + 'element-plus/es/components/autocomplete/style/css', + 'element-plus/es/components/image-viewer/style/css', + 'element-plus/es/components/upload/style/css', + 'element-plus/es/components/col/style/css', + 'element-plus/es/components/form-item/style/css', + 'element-plus/es/components/alert/style/css', + 'element-plus/es/components/breadcrumb/style/css', + 'element-plus/es/components/select/style/css', + 'element-plus/es/components/input/style/css', + 'element-plus/es/components/breadcrumb-item/style/css', + 'element-plus/es/components/tag/style/css', + 'element-plus/es/components/pagination/style/css', + 'element-plus/es/components/table/style/css', + 'element-plus/es/components/table-v2/style/css', + 'element-plus/es/components/table-column/style/css', + 'element-plus/es/components/card/style/css', + 'element-plus/es/components/row/style/css', + 'element-plus/es/components/button/style/css', + 'element-plus/es/components/menu/style/css', + 'element-plus/es/components/sub-menu/style/css', + 'element-plus/es/components/menu-item/style/css', + 'element-plus/es/components/option/style/css', + 'element-plus/es/components/dropdown/style/css', + 'element-plus/es/components/dropdown-menu/style/css', + 'element-plus/es/components/dropdown-item/style/css', + 'element-plus/es/components/skeleton/style/css', 'element-plus/es/components/skeleton/style/css', 'element-plus/es/components/backtop/style/css', 'element-plus/es/components/menu/style/css', @@ -82,20 +102,13 @@ const include = [ 'element-plus/es/components/breadcrumb/style/css', 'element-plus/es/components/breadcrumb-item/style/css', 'element-plus/es/components/image/style/css', - 'element-plus/es/components/tag/style/css', - 'element-plus/es/components/dialog/style/css', - 'element-plus/es/components/form/style/css', - 'element-plus/es/components/form-item/style/css', - 'element-plus/es/components/card/style/css', - 'element-plus/es/components/tooltip/style/css', - 'element-plus/es/components/radio-group/style/css', - 'element-plus/es/components/radio/style/css', - 'element-plus/es/components/input-number/style/css', - 'element-plus/es/components/tree-select/style/css', - 'element-plus/es/components/drawer/style/css', - 'element-plus/es/components/image-viewer/style/css', - 'element-plus/es/components/upload/style/css', - 'element-plus/es/components/switch/style/css' + 'element-plus/es/components/collapse-transition/style/css', + 'element-plus/es/components/timeline/style/css', + 'element-plus/es/components/timeline-item/style/css', + 'element-plus/es/components/collapse/style/css', + 'element-plus/es/components/collapse-item/style/css', + 'element-plus/es/components/button-group/style/css', + 'element-plus/es/components/text/style/css' ] const exclude = ['@iconify/json'] diff --git a/src/api/mall/product/spu.ts b/src/api/mall/product/spu.ts index 9c3f98bf..fd55e126 100644 --- a/src/api/mall/product/spu.ts +++ b/src/api/mall/product/spu.ts @@ -7,6 +7,7 @@ export interface Property { valueName?: string // 属性值名称 } +// TODO puhui999:是不是直接叫 Sku 更简洁一点哈。type 待后面,总感觉有个类型? export interface SkuType { id?: number // 商品 SKU 编号 spuId?: number // SPU 编号 @@ -24,6 +25,7 @@ export interface SkuType { salesCount?: number // 商品销量 } +// TODO puhui999:是不是直接叫 Spu 更简洁一点哈。type 待后面,总感觉有个类型? export interface SpuType { id?: number name?: string // 商品名称 diff --git a/src/utils/index.ts b/src/utils/index.ts index cf8ba38e..3d596a36 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -174,6 +174,7 @@ export const copyValueToTarget = (target, source) => { Object.assign(target, newObj) } +// TODO @puhui999:返回要带上 .00 哈.例如说 1.00 /** * 将一个整数转换为分数保留两位小数 * @param num diff --git a/src/views/mall/product/spu/addForm.vue b/src/views/mall/product/spu/addForm.vue index bc0941cd..18f9d0b6 100644 --- a/src/views/mall/product/spu/addForm.vue +++ b/src/views/mall/product/spu/addForm.vue @@ -146,7 +146,6 @@ const submitForm = async () => { const newSliderPicUrls = [] deepCopyFormData.sliderPicUrls.forEach((item) => { // 如果是前端选的图 - // TODO @puhui999:疑问哈,为啥会是 object 呀?fix typeof item === 'object' ? newSliderPicUrls.push(item.url) : newSliderPicUrls.push(item) }) deepCopyFormData.sliderPicUrls = newSliderPicUrls diff --git a/src/views/mall/product/spu/components/BasicInfoForm.vue b/src/views/mall/product/spu/components/BasicInfoForm.vue index eac3de9c..d800e332 100644 --- a/src/views/mall/product/spu/components/BasicInfoForm.vue +++ b/src/views/mall/product/spu/components/BasicInfoForm.vue @@ -96,7 +96,6 @@ - 添加规格 @@ -137,9 +136,8 @@ const props = defineProps({ }, activeName: propTypes.string.def('') }) -const attributesAddFormRef = ref() // 添加商品属性表单 TODO @puhui999:小写开头哈 fix -const productSpuBasicInfoRef = ref() // 表单Ref TODO @puhui999:小写开头哈 fix -// TODO @puhui999:attributeList 改成 propertyList,会更统一一点 fix +const attributesAddFormRef = ref() // 添加商品属性表单 +const productSpuBasicInfoRef = ref() // 表单 Ref const propertyList = ref([]) // 商品属性列表 const skuListRef = ref() // 商品属性列表Ref /** 调用 SkuList generateTableData 方法*/ @@ -180,17 +178,17 @@ const rules = reactive({ watch( () => props.propFormData, (data) => { - if (!data) return - // fix:三个表单组件监听赋值必须使用 copyValueToTarget 使用 formData.value = data 会监听非常多次 + if (!data) { + return + } copyValueToTarget(formData, data) - // fix: 多图上传组件需要一个包含url属性的对象才能正常回显 formData.sliderPicUrls = data['sliderPicUrls'].map((item) => ({ url: item })) + // TODO @puhui999:if return,减少嵌套层级 // 只有是多规格才处理 if (formData.specType) { - // TODO @puhui999:可以直接拿 propertyName 拼接处规格 id + 属性,可以看下商品 uniapp 详情的做法 - // fix: 直接拿返回的 skus 属性逆向生成出 propertyList + // 直接拿返回的 skus 属性逆向生成出 propertyList const properties = [] formData.skus.forEach((sku) => { sku.properties.forEach(({ propertyId, propertyName, valueId, valueName }) => { @@ -209,7 +207,6 @@ watch( } }, { - // fix: 去掉深度监听只有对象引用发生改变的时候才执行,解决改一动多的问题 immediate: true } ) diff --git a/src/views/mall/product/spu/components/OtherSettingsForm.vue b/src/views/mall/product/spu/components/OtherSettingsForm.vue index 8189f9c7..48608b7b 100644 --- a/src/views/mall/product/spu/components/OtherSettingsForm.vue +++ b/src/views/mall/product/spu/components/OtherSettingsForm.vue @@ -1,7 +1,6 @@ - -