style:托盘管理-二维码打印回显

main
黄伟杰 5 days ago
parent d96ee185fc
commit 5c66c52cd4

@ -15,6 +15,7 @@ export interface PalletVO {
productId?: number | string
productCount?: number | string
qrcode?: string
templateJson?: string | any
purchaseDate?: string
useDate?: string
remark?: string

@ -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<PalletVO>({
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<PalletVO>)
}
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

Loading…
Cancel
Save