From 10e1b2576174562a9f6bcbd6f6c528be95951483 Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 10 Jun 2026 16:48:36 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=89=A9=E6=96=99=E6=A1=A3?= =?UTF-8?q?=E6=A1=88-=E8=AF=A6=E6=83=85=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/locales/en.ts | 3 +- src/locales/zh-CN.ts | 3 +- src/views/erp/product/product/ProductForm.vue | 76 ++- src/views/erp/product/product/index.vue | 432 +++++++++++++++++- 4 files changed, 488 insertions(+), 26 deletions(-) diff --git a/src/locales/en.ts b/src/locales/en.ts index 137822f3..809338d2 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -2107,7 +2107,8 @@ export default { dialogPurchaseCycleLabel: 'Purchase Cycle (Days)', dialogBrandLabel: 'Brand', dialogBrandPlaceholder: 'Please enter brand', - categoryTree: 'Category Tree', + images: 'Image', + categoryTree: 'Material Category', addCategory: 'Add Category', refreshTree: 'Refresh' }, diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 81a71459..4c654aae 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -3275,7 +3275,8 @@ export default { dialogPurchaseCycleLabel: '采购周期(天)', dialogBrandLabel: '品牌', dialogBrandPlaceholder: '请输入品牌', - categoryTree: '产品分类树', + images: '图片', + categoryTree: '物料分类', addCategory: '新增分类', refreshTree: '刷新' }, diff --git a/src/views/erp/product/product/ProductForm.vue b/src/views/erp/product/product/ProductForm.vue index 9f016714..06247569 100644 --- a/src/views/erp/product/product/ProductForm.vue +++ b/src/views/erp/product/product/ProductForm.vue @@ -179,24 +179,34 @@ - - +
+ + + + + + +
+
+ + + - + @@ -447,6 +457,7 @@ const formData = ref({ fragileFlag: undefined as number | undefined, purchaseCycle: undefined as number | undefined, brand: undefined as string | undefined, + images: undefined as string | undefined, sparePartLevel: undefined as number | undefined }) const selectedDeviceRows = ref([]) @@ -922,8 +933,8 @@ const open = async (type: string, id?: number) => { sparePartLevel: productData.sparePartLevel != null ? Number(productData.sparePartLevel) : undefined, devices, molds, - packagingSchemes: (productData as any).packagingSchemes || [], - suppliers: (productData as any).suppliers || [] + packagingSchemes: normalizeDefaultStatus((productData as any).packagingSchemes, (productData as any).defaultPackagingSchemeId, 'packagingSchemeId'), + suppliers: normalizeDefaultStatus((productData as any).suppliers, (productData as any).defaultSupplierId, 'supplierId') } selectedDeviceRows.value = toDeviceRows(devices) selectedMoldRows.value = toMoldRows(molds) @@ -1005,6 +1016,24 @@ const buildRelationIdListString = (list: { id: number; name: string }[]) => { return list.map((item) => Number(item.id)).filter((id) => Number.isFinite(id)) } +const getDefaultPackagingSchemeId = () => { + const defaultItem = formData.value.packagingSchemes?.find((item) => item.defaultStatus === 1) + return defaultItem?.packagingSchemeId ?? undefined +} + +const getDefaultSupplierId = () => { + const defaultItem = formData.value.suppliers?.find((item) => item.defaultStatus === 1) + return defaultItem?.supplierId ?? undefined +} + +const normalizeDefaultStatus = (list: any[] | undefined, defaultId: number | undefined, idKey: string) => { + if (!list?.length) return [] + return list.map((item: any) => ({ + ...item, + defaultStatus: defaultId != null && item[idKey] === defaultId ? 1 : 0 + })) +} + const submitForm = async () => { await formRef.value.validate() formLoading.value = true @@ -1014,7 +1043,9 @@ const submitForm = async () => { const data = { ...formData.value, deviceIds: buildRelationIdListString(relationDevices), - moldIds: buildRelationIdListString(relationMolds) + moldIds: buildRelationIdListString(relationMolds), + defaultPackagingSchemeId: formData.value.categoryType === 1 ? getDefaultPackagingSchemeId() : undefined, + defaultSupplierId: (formData.value.categoryType === 2 || formData.value.categoryType === 3) ? getDefaultSupplierId() : undefined } as unknown as ProductVO delete (data as any).devices delete (data as any).molds @@ -1115,6 +1146,15 @@ watch( border-top: 1px solid #ebeef5; } +.image-form-item { + margin-bottom: 28px; + + :deep(.el-form-item__content) { + min-height: 150px; + align-items: flex-start; + } +} + @media (max-width: 768px) { .dv-repair-panel__header { padding: 14px 16px; diff --git a/src/views/erp/product/product/index.vue b/src/views/erp/product/product/index.vue index ca9ab690..54c225ea 100644 --- a/src/views/erp/product/product/index.vue +++ b/src/views/erp/product/product/index.vue @@ -80,10 +80,16 @@ - - +
+ + + + + - + - + + + + +
+ @@ -126,7 +303,7 @@