From 5c66c52cd4f176a285cacb12144a7056a79432df Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 1 Jul 2026 14:47:51 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E6=89=98=E7=9B=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86-=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/erp/stock/pallet/index.ts | 1 + src/views/erp/stock/pallet/PalletForm.vue | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/api/erp/stock/pallet/index.ts b/src/api/erp/stock/pallet/index.ts index 4322d8b0..17edb1a0 100644 --- a/src/api/erp/stock/pallet/index.ts +++ b/src/api/erp/stock/pallet/index.ts @@ -15,6 +15,7 @@ export interface PalletVO { productId?: number | string productCount?: number | string qrcode?: string + templateJson?: string | any purchaseDate?: string useDate?: string remark?: string diff --git a/src/views/erp/stock/pallet/PalletForm.vue b/src/views/erp/stock/pallet/PalletForm.vue index 4c9d3999..9a7a6404 100644 --- a/src/views/erp/stock/pallet/PalletForm.vue +++ b/src/views/erp/stock/pallet/PalletForm.vue @@ -193,6 +193,7 @@ :refresh-url="getQrcodeRefreshUrl()" :refresh-disabled="!formData.id || !formData.code" :refresh-confirm-text="t('ErpStock.Pallet.qrcodeRefreshConfirm')" + :template-json="formData.templateJson" :print-data="buildPrintData()" @refresh-success="handleQrcodeRefreshSuccess" /> @@ -508,6 +509,7 @@ const formData = ref({ productId: undefined, productCount: undefined, qrcode: undefined, + templateJson: undefined, purchaseDate: undefined, useDate: undefined, remark: undefined @@ -556,8 +558,9 @@ const open = async (type: string, row?: PalletVO, defaults?: Partial) } await hydrateSelectedProduct() } - if (type === 'update' && row) { - await applyPalletDetail(row) + if (type === 'update' && row?.id) { + const data = await PalletApi.getPallet(Number(row.id)) + await applyPalletDetail(data) } } defineExpose({ open }) @@ -569,6 +572,7 @@ const submitForm = async () => { try { const data = { ...formData.value } delete data.qrcode + delete data.templateJson data.specification = buildSpecification() if (data.isCode) { data.code = undefined @@ -608,6 +612,7 @@ const buildPrintData = () => { specification: buildSpecification() || formData.value.specification, warehouseId: formData.value.warehouseId, areaId: formData.value.areaId, + qrcode: formData.value.qrcode, qrcodeUrl: formData.value.qrcode } } @@ -617,10 +622,21 @@ const getQrcodeRefreshUrl = () => { return `/erp/pallet/regenerate-code?id=${formData.value.id}&code=${encodeURIComponent(String(formData.value.code))}` } +const parseTemplateJson = (templateJson: PalletVO['templateJson']) => { + if (!templateJson || typeof templateJson !== 'string') return templateJson + try { + return JSON.parse(templateJson) + } catch { + return undefined + } +} + const applyPalletDetail = async (data: PalletVO) => { + const templateJson = data?.templateJson formData.value = { ...formData.value, ...data, + templateJson: parseTemplateJson(templateJson), isCode: false } parseSpecification(formData.value.specification) @@ -839,6 +855,7 @@ const resetForm = () => { productId: undefined, productCount: undefined, qrcode: undefined, + templateJson: undefined, purchaseDate: undefined, useDate: undefined, remark: undefined