From 4bbe313ef87f7fe3140db3da891421d2648b134d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Thu, 2 Apr 2026 22:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(mes):=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增设备台账导入功能,支持从 Excel 文件批量导入设备信息。实现了导入模板的生成和导入结果的反馈,包括成功创建和更新的设备编码,以及导入失败的原因提示。同时,更新了设备类型和车间的校验逻辑,确保数据的有效性和完整性。 --- src/views/mes/dv/machinery/MachineryForm.vue | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/views/mes/dv/machinery/MachineryForm.vue b/src/views/mes/dv/machinery/MachineryForm.vue index 7f5827c5b..97407992f 100644 --- a/src/views/mes/dv/machinery/MachineryForm.vue +++ b/src/views/mes/dv/machinery/MachineryForm.vue @@ -75,6 +75,7 @@ placeholder="请选择最近点检时间" value-format="x" class="!w-1/1" + disabled /> @@ -86,6 +87,7 @@ placeholder="请选择最近保养时间" value-format="x" class="!w-1/1" + disabled /> @@ -124,9 +126,11 @@ import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' import { DvMachineryApi, DvMachineryVO } from '@/api/mes/dv/machinery' import { DvMachineryTypeApi } from '@/api/mes/dv/machinery/type' +import { WmBarcodeApi } from '@/api/mes/wm/barcode' import MdWorkshopSelect from '@/views/mes/md/workstation/components/MdWorkshopSelect.vue' +import Barcode from '@/views/mes/wm/barcode/components/Barcode.vue' import { defaultProps, handleTree } from '@/utils/tree' -import { MesDvMachineryStatusEnum } from '@/views/mes/utils/constants' +import { MesDvMachineryStatusEnum, BarcodeBizTypeEnum } from '@/views/mes/utils/constants' import { generateRandomStr } from '@/utils' defineOptions({ name: 'MachineryForm' }) @@ -161,9 +165,13 @@ const formRules = reactive({ }) const formRef = ref() // 表单 Ref const machineryTypeTree = ref([]) // 设备类型树 +const barcodeContent = ref('') // 条码内容 +const barcodeFormat = ref(0) // 条码格式 /** 生成设备编码 */ const generateCode = () => { + // TODO @AI:这里接上编码规则; + // TODO @AI:导入接口,增加一个用户手动填写 code;不用后端生成; formData.value.code = 'M' + generateRandomStr(12) } @@ -181,6 +189,19 @@ const open = async (type: string, id?: number) => { formLoading.value = true try { formData.value = await DvMachineryApi.getMachinery(id) + // 加载条码数据 + try { + const barcode = await WmBarcodeApi.getBarcodeByBusiness( + BarcodeBizTypeEnum.MACHINERY, + id + ) + if (barcode) { + barcodeContent.value = barcode.content || '' + barcodeFormat.value = barcode.format || 0 + } + } catch { + // 条码加载失败不阻塞表单 + } } finally { formLoading.value = false } @@ -227,6 +248,8 @@ const resetForm = () => { lastMaintenTime: undefined, remark: undefined } + barcodeContent.value = '' + barcodeFormat.value = 0 formRef.value?.resetFields() }