mirror of
				https://gitee.com/hhyykk/ipms-sjy-ui.git
				synced 2025-10-30 01:38:44 +08:00 
			
		
		
		
	fix: 移动copyValueToTarget方法到utils/index中
This commit is contained in:
		| @@ -155,3 +155,21 @@ export const fileSizeFormatter = (row, column, cellValue) => { | |||||||
|   const sizeStr = size.toFixed(2) //保留的小数位数 |   const sizeStr = size.toFixed(2) //保留的小数位数 | ||||||
|   return sizeStr + ' ' + unitArr[index] |   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) | ||||||
|  | } | ||||||
|   | |||||||
| @@ -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) |  | ||||||
| } |  | ||||||
| @@ -14,9 +14,9 @@ | |||||||
|             :data="categoryList" |             :data="categoryList" | ||||||
|             :props="defaultProps" |             :props="defaultProps" | ||||||
|             check-strictly |             check-strictly | ||||||
|  |             class="w-1/1" | ||||||
|             node-key="id" |             node-key="id" | ||||||
|             placeholder="请选择商品分类" |             placeholder="请选择商品分类" | ||||||
|             class="w-1/1" |  | ||||||
|           /> |           /> | ||||||
|         </el-form-item> |         </el-form-item> | ||||||
|       </el-col> |       </el-col> | ||||||
| @@ -27,7 +27,7 @@ | |||||||
|       </el-col> |       </el-col> | ||||||
|       <el-col :span="12"> |       <el-col :span="12"> | ||||||
|         <el-form-item label="单位" prop="unit"> |         <el-form-item label="单位" prop="unit"> | ||||||
|           <el-select v-model="formData.unit" placeholder="请选择单位" class="w-1/1"> |           <el-select v-model="formData.unit" class="w-1/1" placeholder="请选择单位"> | ||||||
|             <el-option |             <el-option | ||||||
|               v-for="dict in getIntDictOptions(DICT_TYPE.PRODUCT_UNIT)" |               v-for="dict in getIntDictOptions(DICT_TYPE.PRODUCT_UNIT)" | ||||||
|               :key="dict.value" |               :key="dict.value" | ||||||
| @@ -59,7 +59,7 @@ | |||||||
|       </el-col> |       </el-col> | ||||||
|       <el-col :span="12"> |       <el-col :span="12"> | ||||||
|         <el-form-item label="运费模板" prop="deliveryTemplateId"> |         <el-form-item label="运费模板" prop="deliveryTemplateId"> | ||||||
|           <el-select v-model="formData.deliveryTemplateId" placeholder="请选择" class="w-1/1"> |           <el-select v-model="formData.deliveryTemplateId" class="w-1/1" placeholder="请选择"> | ||||||
|             <el-option v-for="item in []" :key="item.id" :label="item.name" :value="item.id" /> |             <el-option v-for="item in []" :key="item.id" :label="item.name" :value="item.id" /> | ||||||
|           </el-select> |           </el-select> | ||||||
|         </el-form-item> |         </el-form-item> | ||||||
| @@ -112,10 +112,11 @@ import { defaultProps, handleTree } from '@/utils/tree' | |||||||
| import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | ||||||
| import type { SpuType } from '@/api/mall/product/management/type/spuType' | import type { SpuType } from '@/api/mall/product/management/type/spuType' | ||||||
| import { UploadImg, UploadImgs } from '@/components/UploadFile' | import { UploadImg, UploadImgs } from '@/components/UploadFile' | ||||||
| import { copyValueToTarget } from '@/utils/object' | import { copyValueToTarget } from '@/utils' | ||||||
| import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index' | import { ProductAttributes, ProductAttributesAddForm, SkuList } from './index' | ||||||
| import * as ProductCategoryApi from '@/api/mall/product/category' | import * as ProductCategoryApi from '@/api/mall/product/category' | ||||||
| import { propTypes } from '@/utils/propTypes' | import { propTypes } from '@/utils/propTypes' | ||||||
|  |  | ||||||
| const message = useMessage() // 消息弹窗 | const message = useMessage() // 消息弹窗 | ||||||
|  |  | ||||||
| const props = defineProps({ | const props = defineProps({ | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| import type { SpuType } from '@/api/mall/product/management/type/spuType' | import type { SpuType } from '@/api/mall/product/management/type/spuType' | ||||||
| import { Editor } from '@/components/Editor' | import { Editor } from '@/components/Editor' | ||||||
| import { PropType } from 'vue' | import { PropType } from 'vue' | ||||||
| import { copyValueToTarget } from '@/utils/object' | import { copyValueToTarget } from '@/utils' | ||||||
| import { propTypes } from '@/utils/propTypes' | import { propTypes } from '@/utils/propTypes' | ||||||
|  |  | ||||||
| const message = useMessage() // 消息弹窗 | const message = useMessage() // 消息弹窗 | ||||||
|   | |||||||
| @@ -53,8 +53,9 @@ | |||||||
| <script lang="ts" name="OtherSettingsForm" setup> | <script lang="ts" name="OtherSettingsForm" setup> | ||||||
| import type { SpuType } from '@/api/mall/product/management/type/spuType' | import type { SpuType } from '@/api/mall/product/management/type/spuType' | ||||||
| import { PropType } from 'vue' | import { PropType } from 'vue' | ||||||
| import { copyValueToTarget } from '@/utils/object' | import { copyValueToTarget } from '@/utils' | ||||||
| import { propTypes } from '@/utils/propTypes' | import { propTypes } from '@/utils/propTypes' | ||||||
|  |  | ||||||
| const message = useMessage() // 消息弹窗 | const message = useMessage() // 消息弹窗 | ||||||
|  |  | ||||||
| const props = defineProps({ | const props = defineProps({ | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ | |||||||
|         </template> |         </template> | ||||||
|       </el-table-column> |       </el-table-column> | ||||||
|     </template> |     </template> | ||||||
|     <!-- TODO @puhui999: controls-position="right" 可以去掉哈,不然太长了,手动输入更方便 --> |     <!-- TODO @puhui999: controls-position=" " 可以去掉哈,不然太长了,手动输入更方便 --> | ||||||
|     <el-table-column align="center" label="商品条码" min-width="168"> |     <el-table-column align="center" label="商品条码" min-width="168"> | ||||||
|       <template #default="{ row }"> |       <template #default="{ row }"> | ||||||
|         <el-input v-model="row.barCode" class="w-100%" /> |         <el-input v-model="row.barCode" class="w-100%" /> | ||||||
| @@ -110,7 +110,7 @@ import { PropType } from 'vue' | |||||||
| import { SpuType } from '@/api/mall/product/management/type/spuType' | import { SpuType } from '@/api/mall/product/management/type/spuType' | ||||||
| import { propTypes } from '@/utils/propTypes' | import { propTypes } from '@/utils/propTypes' | ||||||
| import { SkuType } from '@/api/mall/product/management/type/skuType' | import { SkuType } from '@/api/mall/product/management/type/skuType' | ||||||
| import { copyValueToTarget } from '@/utils/object' | import { copyValueToTarget } from '@/utils' | ||||||
|  |  | ||||||
| const props = defineProps({ | const props = defineProps({ | ||||||
|   propFormData: { |   propFormData: { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999