From 43e541f9449e3474379b8bd7903666f783454963 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Tue, 16 May 2023 10:12:10 +0800 Subject: [PATCH 01/18] =?UTF-8?q?fix:=20=E7=A7=BB=E5=8A=A8copyValueToTarge?= =?UTF-8?q?t=E6=96=B9=E6=B3=95=E5=88=B0utils/index=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.ts | 18 ++++++++++++++++++ src/utils/object.ts | 18 ------------------ .../product/spu/components/BasicInfoForm.vue | 9 +++++---- .../product/spu/components/DescriptionForm.vue | 2 +- .../spu/components/OtherSettingsForm.vue | 3 ++- .../mall/product/spu/components/SkuList.vue | 4 ++-- 6 files changed, 28 insertions(+), 26 deletions(-) delete mode 100644 src/utils/object.ts diff --git a/src/utils/index.ts b/src/utils/index.ts index e016c1e20..d74bbe99f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -155,3 +155,21 @@ export const fileSizeFormatter = (row, column, cellValue) => { const sizeStr = size.toFixed(2) //保留的小数位数 return sizeStr + ' ' + unitArr[index] } + +/** + * 将值复制到目标对象,且以目标对象属性为准,例:target: {a:1} source:{a:2,b:3} 结果为:{a:2} + * @param target 目标对象 + * @param source 源对象 + */ +export const copyValueToTarget = (target, source) => { + const newObj = Object.assign({}, target, source) + // 删除多余属性 + Object.keys(newObj).forEach((key) => { + // 如果不是target中的属性则删除 + if (Object.keys(target).indexOf(key) === -1) { + delete newObj[key] + } + }) + // 更新目标对象值 + Object.assign(target, newObj) +} diff --git a/src/utils/object.ts b/src/utils/object.ts deleted file mode 100644 index 6612da748..000000000 --- a/src/utils/object.ts +++ /dev/null @@ -1,18 +0,0 @@ -// TODO @puhui999:这个方法,可以考虑放到 index.js -/** - * 将值复制到目标对象,且以目标对象属性为准,例:target: {a:1} source:{a:2,b:3} 结果为:{a:2} - * @param target 目标对象 - * @param source 源对象 - */ -export const copyValueToTarget = (target, source) => { - const newObj = Object.assign({}, target, source) - // 删除多余属性 - Object.keys(newObj).forEach((key) => { - // 如果不是target中的属性则删除 - if (Object.keys(target).indexOf(key) === -1) { - delete newObj[key] - } - }) - // 更新目标对象值 - Object.assign(target, newObj) -} diff --git a/src/views/mall/product/spu/components/BasicInfoForm.vue b/src/views/mall/product/spu/components/BasicInfoForm.vue index 249a3830a..222623a54 100644 --- a/src/views/mall/product/spu/components/BasicInfoForm.vue +++ b/src/views/mall/product/spu/components/BasicInfoForm.vue @@ -14,9 +14,9 @@ :data="categoryList" :props="defaultProps" check-strictly + class="w-1/1" node-key="id" placeholder="请选择商品分类" - class="w-1/1" /> @@ -27,7 +27,7 @@ - + - + @@ -112,10 +112,11 @@ import { defaultProps, handleTree } from '@/utils/tree' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import type { SpuType } from '@/api/mall/product/management/type/spuType' import { UploadImg, UploadImgs } from '@/components/UploadFile' -import { copyValueToTarget } from '@/utils/object' +import { copyValueToTarget } from '@/utils' import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index' import * as ProductCategoryApi from '@/api/mall/product/category' import { propTypes } from '@/utils/propTypes' + const message = useMessage() // 消息弹窗 const props = defineProps({ diff --git a/src/views/mall/product/spu/components/DescriptionForm.vue b/src/views/mall/product/spu/components/DescriptionForm.vue index 0a7f522b7..2a32e1afa 100644 --- a/src/views/mall/product/spu/components/DescriptionForm.vue +++ b/src/views/mall/product/spu/components/DescriptionForm.vue @@ -10,7 +10,7 @@ import type { SpuType } from '@/api/mall/product/management/type/spuType' import { Editor } from '@/components/Editor' import { PropType } from 'vue' -import { copyValueToTarget } from '@/utils/object' +import { copyValueToTarget } from '@/utils' import { propTypes } from '@/utils/propTypes' const message = useMessage() // 消息弹窗 diff --git a/src/views/mall/product/spu/components/OtherSettingsForm.vue b/src/views/mall/product/spu/components/OtherSettingsForm.vue index c0fc51225..fb4facd79 100644 --- a/src/views/mall/product/spu/components/OtherSettingsForm.vue +++ b/src/views/mall/product/spu/components/OtherSettingsForm.vue @@ -53,8 +53,9 @@ + From 6ac8c78d570737194327958736adf05551ff4ac1 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Wed, 17 May 2023 01:37:21 +0800 Subject: [PATCH 04/18] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=B1=9E=E6=80=A7=E5=8E=BB=E6=8E=89=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/spu/components/ProductAttributesAddForm.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/views/mall/product/spu/components/ProductAttributesAddForm.vue b/src/views/mall/product/spu/components/ProductAttributesAddForm.vue index bd715dde6..002a14880 100644 --- a/src/views/mall/product/spu/components/ProductAttributesAddForm.vue +++ b/src/views/mall/product/spu/components/ProductAttributesAddForm.vue @@ -7,12 +7,9 @@ :rules="formRules" label-width="80px" > - + - - -