From 2d20ec5344d1dbe4571414ff3b45a3f18bd09667 Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 13 May 2026 15:52:11 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A4=87=E4=BB=B6=E4=BF=A1?= =?UTF-8?q?=E6=81=AF-=E4=BA=8C=E7=BB=B4=E7=A0=81=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E5=9B=9E=E6=98=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../erp/component/product/ProductForm.vue | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/views/erp/component/product/ProductForm.vue b/src/views/erp/component/product/ProductForm.vue index 435319f1..6ee2127b 100644 --- a/src/views/erp/component/product/ProductForm.vue +++ b/src/views/erp/component/product/ProductForm.vue @@ -118,6 +118,8 @@ :refresh-url="getQrcodeRefreshUrl()" :refresh-disabled="!formData.id || !formData.barCode" refresh-confirm-text="确认刷新该备件二维码吗?" + :template-json="formData.templateJson" + :print-data="buildPrintData()" @refresh-success="handleQrcodeRefreshSuccess" /> @@ -158,6 +160,7 @@ const formData = ref({ barCode: undefined, isCode: undefined, qrcodeUrl: undefined, + templateJson: undefined, categoryId: undefined, unitId: undefined, status: undefined, @@ -201,7 +204,15 @@ const open = async (type: string, id?: number) => { if (id) { formLoading.value = true try { - formData.value = await ProductApi.getProduct(id) + const productData = await ProductApi.getProduct(id) + const templateJson = productData?.templateJson + const parsedTemplateJson = typeof templateJson === 'string' + ? JSON.parse(templateJson) + : templateJson + formData.value = { + ...productData, + templateJson: parsedTemplateJson + } } finally { formLoading.value = false } @@ -223,6 +234,20 @@ const getQrcodeRefreshUrl = () => { return `/erp/product/regenerate-code?id=${formData.value.id}&code=${encodeURIComponent(String(formData.value.barCode))}` } +const buildPrintData = () => { + return { + id: formData.value.id, + barCode: formData.value.barCode, + name: formData.value.name, + standard: formData.value.standard, + unitId: formData.value.unitId, + safetyNumber: formData.value.safetyNumber, + status: formData.value.status, + remark: formData.value.remark, + qrcodeUrl: formData.value.qrcodeUrl + } +} + const handleQrcodeRefreshSuccess = async (data: any) => { if (!formData.value.id) return if (data?.qrcodeUrl) { @@ -267,6 +292,7 @@ const resetForm = () => { barCode: undefined, isCode: true, qrcodeUrl: undefined, + templateJson: undefined, categoryId: undefined, unitId: undefined, status: CommonStatusEnum.ENABLE,