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 diff --git a/src/views/iot/device/components/DeviceAttributeList.vue b/src/views/iot/device/components/DeviceAttributeList.vue index a8a7b9ba..bc29675f 100644 --- a/src/views/iot/device/components/DeviceAttributeList.vue +++ b/src/views/iot/device/components/DeviceAttributeList.vue @@ -220,7 +220,7 @@ const total = ref(0) // 列表的总页数 const queryParams = reactive({ pageNo: 1, pageSize: 10, - deviceId: undefined as unknown, + deviceId: undefined as number | undefined, attributeCode: undefined, attributeName: undefined, attributeType: undefined @@ -263,6 +263,8 @@ watch( return } queryParams.deviceId = val + selectedIds.value = [] + tableRef.value?.clearSelection?.() handleQuery() }, { immediate: true, deep: true } @@ -350,10 +352,16 @@ const handleImport = () => { /** 导出按钮操作 */ const handleExport = async () => { + if (!props.deviceId) { + message.error(t('DataCollection.Device.messageSelectDeviceRequired')) + return + } try { await message.exportConfirm() exportLoading.value = true - const params: any = {} + const params: any = { + deviceId: props.deviceId + } if (selectedIds.value.length) { params.ids = selectedIds.value.join(',') } diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index c2d5bab0..9e16f431 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -148,6 +148,7 @@ @@ -272,6 +273,7 @@