diff --git a/src/api/mes/criticalComponent/index.ts b/src/api/mes/criticalComponent/index.ts index e249417e..38255d36 100644 --- a/src/api/mes/criticalComponent/index.ts +++ b/src/api/mes/criticalComponent/index.ts @@ -9,6 +9,7 @@ export interface CriticalComponentVO { count?: number remark?: string qrcodeUrl?: string + templateJson?: string | any createTime?: string images?: string } diff --git a/src/views/mes/criticalComponent/CriticalComponentForm.vue b/src/views/mes/criticalComponent/CriticalComponentForm.vue index 5b1dc87c..6bf29149 100644 --- a/src/views/mes/criticalComponent/CriticalComponentForm.vue +++ b/src/views/mes/criticalComponent/CriticalComponentForm.vue @@ -72,6 +72,8 @@ :refresh-url="getQrcodeRefreshUrl()" :refresh-disabled="!formData.id || !formData.code" refresh-confirm-text="确认刷新该关键件二维码吗?" + :template-json="formData.templateJson" + :print-data="buildPrintData()" @refresh-success="handleQrcodeRefreshSuccess" /> @@ -123,6 +125,7 @@ const formData = ref>({ count: undefined, remark: undefined, qrcodeUrl: undefined, + templateJson: undefined, images: undefined }) @@ -152,7 +155,9 @@ const resetForm = () => { description: undefined, count: undefined, remark: undefined, - qrcodeUrl: undefined + qrcodeUrl: undefined, + templateJson: undefined, + images: undefined } formRef.value?.resetFields?.() } @@ -169,6 +174,18 @@ const getQrcodeRefreshUrl = () => { return `/mes/critical-component/regenerate-code?id=${formData.value.id}&code=${encodeURIComponent(String(formData.value.code))}` } +const buildPrintData = () => { + return { + id: formData.value.id, + code: formData.value.code, + name: formData.value.name, + description: formData.value.description, + count: formData.value.count, + remark: formData.value.remark, + qrcodeUrl: formData.value.qrcodeUrl + } +} + const handleQrcodeRefreshSuccess = async (data: any) => { if (!formData.value.id) return if (data?.qrcodeUrl) { @@ -189,6 +206,10 @@ const open = async (type: 'create' | 'update', id?: number) => { formLoading.value = true try { const detail = await CriticalComponentApi.getCriticalComponent(id) + const templateJson = detail?.templateJson + const parsedTemplateJson = typeof templateJson === 'string' + ? JSON.parse(templateJson) + : templateJson formData.value = { id: detail?.id, code: detail?.code, @@ -199,6 +220,7 @@ const open = async (type: 'create' | 'update', id?: number) => { count: detail?.count, remark: detail?.remark, qrcodeUrl: detail?.qrcodeUrl, + templateJson: parsedTemplateJson, images: detail?.images } } finally {