feat:备件信息-二维码模板回显

main
黄伟杰 2 days ago
parent ae6ef128ee
commit 2d20ec5344

@ -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"
/>
</el-form-item>
@ -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,

Loading…
Cancel
Save