diff --git a/src/utils/index.ts b/src/utils/index.ts index e016c1e2..d74bbe99 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 6612da74..00000000 --- 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 249a3830..222623a5 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 0a7f522b..2a32e1af 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 c0fc5122..fb4facd7 100644 --- a/src/views/mall/product/spu/components/OtherSettingsForm.vue +++ b/src/views/mall/product/spu/components/OtherSettingsForm.vue @@ -53,8 +53,9 @@