From c75e31aab5eaa5b9024405f0e6e0cf3b2a8c5222 Mon Sep 17 00:00:00 2001 From: zhongwenkai <3478244299@qq.com> Date: Thu, 16 Jul 2026 12:01:18 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6?= =?UTF-8?q?-=E4=BF=AE=E5=A4=8D=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95ID?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mes/deviceline/index.ts | 4 +-- src/api/mes/devicetype/index.ts | 4 +-- .../mes/deviceledger/DeviceLedgerForm.vue | 20 ++++++------- .../mes/deviceledger/detail/editIndex.vue | 14 ++++----- src/views/mes/deviceledger/detail/index.vue | 12 ++++---- src/views/mes/deviceledger/index.vue | 30 +++++++++---------- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/api/mes/deviceline/index.ts b/src/api/mes/deviceline/index.ts index 4c45fbe8..f3078663 100644 --- a/src/api/mes/deviceline/index.ts +++ b/src/api/mes/deviceline/index.ts @@ -1,14 +1,14 @@ import request from '@/config/axios' export interface DeviceLineVO { - id: number + id: string | number code: string isCode?: boolean qrcodeUrl?: string name: string remark: string sort: number - parentId: number + parentId: string | number parentChain: string createTime?: string } diff --git a/src/api/mes/devicetype/index.ts b/src/api/mes/devicetype/index.ts index 0fe53b72..7a0b02e9 100644 --- a/src/api/mes/devicetype/index.ts +++ b/src/api/mes/devicetype/index.ts @@ -2,12 +2,12 @@ import request from '@/config/axios' // 设备类型 VO export interface DeviceTypeVO { - id: number // id + id: string | number // id code: string // 编码 name: string // 名称 remark: string // 备注 sort: number // 排序 - parentId?: number + parentId?: string | number parentChain?: string createTime?: string } diff --git a/src/views/mes/deviceledger/DeviceLedgerForm.vue b/src/views/mes/deviceledger/DeviceLedgerForm.vue index 9847f9b0..fe481c2d 100644 --- a/src/views/mes/deviceledger/DeviceLedgerForm.vue +++ b/src/views/mes/deviceledger/DeviceLedgerForm.vue @@ -909,8 +909,8 @@ const initFormData = () => ({ deviceSpec: undefined, isScheduled: 0, ratedCapacity: undefined, - deviceType: undefined as number | undefined, - deviceLine: undefined as number | undefined, + deviceType: undefined as string | undefined, + deviceLine: undefined as string | undefined, supplier: undefined, workshop: undefined, deviceLocation: undefined, @@ -926,7 +926,7 @@ const initFormData = () => ({ qrcodeUrl: undefined, templateJson: undefined, sort: undefined, - dvId: undefined as number | undefined + dvId: undefined as string | undefined }) const formData = ref({ @@ -1274,9 +1274,9 @@ const ensureOptionsLoaded = async () => { /** 鎵撳紑寮圭獥 */ const open = async ( type: string, - id?: number, - defaultDeviceTypeId?: number, - defaultDeviceLineId?: number + id?: string, + defaultDeviceTypeId?: string, + defaultDeviceLineId?: string ) => { dialogTitle.value = t('action.' + type) formType.value = type @@ -1304,8 +1304,8 @@ const open = async ( isScheduled: normalizeNumberish((detail as any)?.isScheduled ?? (detail as any)?.isScheduled) ?? 0, ratedCapacity: normalizeNumberish((detail as any)?.ratedCapacity), - deviceType: normalizeNumberish((detail as any)?.deviceType), - deviceLine: normalizeNumberish((detail as any)?.deviceLine), + deviceType: (detail as any)?.deviceType ?? undefined, + deviceLine: (detail as any)?.deviceLine ?? undefined, deviceManagerIds: parseIdsValue((detail as any)?.deviceManager), productionDate: normalizeYmd((detail as any)?.productionDate), outgoingTime: normalizeYmd((detail as any)?.outgoingTime), @@ -1553,8 +1553,8 @@ const submitForm = async () => { ...(formData.value as any), isScheduled: normalizeNumberish((formData.value as any).isScheduled) ?? 0, ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity), - deviceType: normalizeNumberish(formData.value.deviceType), - deviceLine: normalizeNumberish((formData.value as any).deviceLine), + deviceType: (formData.value as any).deviceType ?? undefined, + deviceLine: (formData.value as any).deviceLine ?? undefined, productionDate: normalizeYmd(formData.value.productionDate), outgoingTime: normalizeYmd((formData.value as any).outgoingTime), factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate), diff --git a/src/views/mes/deviceledger/detail/editIndex.vue b/src/views/mes/deviceledger/detail/editIndex.vue index c889d3c4..0f7c3a2d 100644 --- a/src/views/mes/deviceledger/detail/editIndex.vue +++ b/src/views/mes/deviceledger/detail/editIndex.vue @@ -847,7 +847,7 @@ const { delView } = useTagsViewStore() const { currentRoute } = useRouter() const router = useRouter() const appStore = useAppStore() -const deviceId = computed(() => Number(route.params.id)) +const deviceId = computed(() => String(route.params.id || '')) const detailLoading = ref(false) const tableLoading = ref(false) const detailData = ref() @@ -1185,8 +1185,8 @@ const initFormData = () => ({ deviceSpec: undefined, isScheduled: 0, ratedCapacity: undefined, - deviceType: undefined as number | undefined, - deviceLine: undefined as number | undefined, + deviceType: undefined as string | undefined, + deviceLine: undefined as string | undefined, supplier: undefined, workshop: undefined, deviceLocation: undefined, @@ -1633,8 +1633,8 @@ const bindFormData = async (detail: DeviceLedgerVO) => { isCode: (detail as any)?.isCode ?? false, isScheduled: normalizeNumberish((detail as any)?.isScheduled) ?? 0, ratedCapacity: normalizeNumberish((detail as any)?.ratedCapacity), - deviceType: normalizeNumberish((detail as any)?.deviceType), - deviceLine: normalizeNumberish((detail as any)?.deviceLine), + deviceType: (detail as any)?.deviceType ?? undefined, + deviceLine: (detail as any)?.deviceLine ?? undefined, deviceManagerIds: parseIdsValue((detail as any)?.deviceManager), productionDate: normalizeYmd((detail as any)?.productionDate), outgoingTime: normalizeYmd((detail as any)?.outgoingTime), @@ -1675,8 +1675,8 @@ const buildSubmitData = () => { ...(formData.value as any), isScheduled: normalizeNumberish((formData.value as any).isScheduled) ?? 0, ratedCapacity: normalizeNumberish((formData.value as any).ratedCapacity), - deviceType: normalizeNumberish(formData.value.deviceType), - deviceLine: normalizeNumberish((formData.value as any).deviceLine), + deviceType: (formData.value as any).deviceType ?? undefined, + deviceLine: (formData.value as any).deviceLine ?? undefined, productionDate: normalizeYmd(formData.value.productionDate), outgoingTime: normalizeYmd((formData.value as any).outgoingTime), factoryEntryDate: normalizeYmd(formData.value.factoryEntryDate), diff --git a/src/views/mes/deviceledger/detail/index.vue b/src/views/mes/deviceledger/detail/index.vue index 29df7293..7f61f08b 100644 --- a/src/views/mes/deviceledger/detail/index.vue +++ b/src/views/mes/deviceledger/detail/index.vue @@ -517,28 +517,28 @@ type DeviceLedgerDetailVO = DeviceLedgerVO & { outgoingTime?: string | number | Date } -const deviceId = computed(() => Number(route.params.id)) +const deviceId = computed(() => String(route.params.id || '')) const detailLoading = ref(false) const tableLoading = ref(false) const detailData = ref() const detailActiveTab = ref('check') -const deviceTypeNameMap = ref>({}) +const deviceTypeNameMap = ref>({}) const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => { - const map: Record = {} + const map: Record = {} const stack = [...nodes] while (stack.length) { const node = stack.pop()! - if (typeof node.id === 'number') map[node.id] = node.name + if (node.id != null) map[String(node.id)] = node.name if (Array.isArray(node.children) && node.children.length) stack.push(...node.children) } deviceTypeNameMap.value = map } const getDeviceTypeName = (value: any) => { - const id = typeof value === 'number' ? value : Number(value) - if (!Number.isNaN(id) && deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id] + const id = String(value ?? '') + if (deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id] return value ?? '' } diff --git a/src/views/mes/deviceledger/index.vue b/src/views/mes/deviceledger/index.vue index f20e3f65..21e70e6a 100644 --- a/src/views/mes/deviceledger/index.vue +++ b/src/views/mes/deviceledger/index.vue @@ -350,7 +350,7 @@ > @@ -677,7 +677,7 @@ const { t } = useI18n() // 国际化 const loading = ref(true) // 列表的加载中 const list = ref([]) // 列表的数据 const total = ref(0) // 列表的总页数 -const selectedDeviceLineId = ref(undefined) +const selectedDeviceLineId = ref(undefined) const queryParams = reactive({ pageNo: 1, pageSize: 10, @@ -687,8 +687,8 @@ const queryParams = reactive({ deviceBrand: undefined, sn: undefined, outgoingTime: undefined, - deviceType: undefined as number | undefined, - deviceLine: undefined as number | undefined + deviceType: undefined as string | undefined, + deviceLine: undefined as string | undefined }) const queryFormRef = ref() // 搜索的表单 const exportLoading = ref(false) @@ -705,7 +705,7 @@ const updatePlanTableMaxHeight = async () => { const availableHeight = window.innerHeight - tableTop - paginationHeight - pageBottomGap planTableMaxHeight.value = Math.min(window.innerHeight, Math.max(240, Math.floor(availableHeight))) } -const selectedIds = ref([]) +const selectedIds = ref([]) const handleSelectionChange = (rows: any[]) => { selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? [] } @@ -735,15 +735,15 @@ const typeTreeProps = { label: 'name', children: 'children' } const treeSelectProps = { label: 'name', children: 'children' } const typeTreeExpandedKeys = ref([]) const deviceTypeTree = ref([]) -const deviceTypeNameMap = ref>({}) +const deviceTypeNameMap = ref>({}) const ALL_TYPE_NODE_ID = -1 const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => { - const map: Record = {} + const map: Record = {} const stack = [...nodes] while (stack.length) { const node = stack.pop()! - if (typeof node.id === 'number') map[node.id] = node.name + if (node.id != null) map[String(node.id)] = node.name if (Array.isArray(node.children) && node.children.length) stack.push(...node.children) } deviceTypeNameMap.value = map @@ -809,7 +809,7 @@ const treeFormLoading = ref(false) const treeFormMode = ref<'create' | 'update'>('create') const treeFormRef = ref() const treeFormData = ref({ - id: undefined as number | undefined, + id: undefined as string | undefined, code: '', isCode: true, name: '', @@ -973,8 +973,8 @@ const buildTreeQrcodePrintData = () => { } const getDeviceTypeName = (value: any) => { - const id = typeof value === 'number' ? value : Number(value) - if (!Number.isNaN(id) && deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id] + const id = String(value ?? '') + if (deviceTypeNameMap.value[id]) return deviceTypeNameMap.value[id] return value ?? '' } @@ -1012,7 +1012,7 @@ const handleDetail = (id: number) => { router.push({ name: 'MesDeviceLedgerDetail', params: { id } }) } -const handleEditDetail = (id: number) => { +const handleEditDetail = (id: string) => { router.push({ name: 'MesDeviceLedgerEditDetail', params: { id } }) } /** 查询列表 */ @@ -1054,18 +1054,18 @@ const resetQuery = () => { /** 添加/修改操作 */ const formRef = ref() const formVisible = ref(false) -const openForm = async (type: string, id?: number) => { +const openForm = async (type: string, id?: string) => { formVisible.value = true await nextTick() formRef.value.open(type, id, queryParams.deviceType, selectedDeviceLineId.value) } /** 删除按钮操作 */ -const buildIdsParam = (ids: number | number[]) => { +const buildIdsParam = (ids: string | string[]) => { return Array.isArray(ids) ? ids.join(',') : String(ids) } -const handleDelete = async (ids: number | number[]) => { +const handleDelete = async (ids: string | string[]) => { try { // 删除的二次确认 await message.delConfirm() From ec337f1921fc83545bcf7d7c3da9f23a028fcc92 Mon Sep 17 00:00:00 2001 From: zhongwenkai <3478244299@qq.com> Date: Thu, 16 Jul 2026 14:29:54 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=9A=84=E4=BB=BB=E5=8A=A1=E8=AE=A1=E5=88=92=E5=92=8C=E7=BB=B4?= =?UTF-8?q?=E4=BF=AE=E5=B7=A5=E5=8D=95-=E4=BF=AE=E5=A4=8D=E9=9B=AA?= =?UTF-8?q?=E8=8A=B1=E7=AE=97=E6=B3=95ID=E7=B2=BE=E5=BA=A6=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mes/dvrepair/DvRepairForm.vue | 24 +++++++++---------- .../mes/taskManagement/TaskManagementForm.vue | 9 ++++--- src/views/mes/taskManagement/index.vue | 4 ++-- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/views/mes/dvrepair/DvRepairForm.vue b/src/views/mes/dvrepair/DvRepairForm.vue index 1cdf6dfb..26646a92 100644 --- a/src/views/mes/dvrepair/DvRepairForm.vue +++ b/src/views/mes/dvrepair/DvRepairForm.vue @@ -506,7 +506,7 @@ defineOptions({ name: 'DvRepairForm' }) type RepairFormType = 'create' | 'update' | 'repair' | 'detail' | '' interface DvRepairFormData extends Partial { - deviceId?: number + deviceId?: string componentId?: number isShutdown?: boolean isCode?: boolean @@ -607,13 +607,13 @@ const showComponentSelect = computed(() => formData.value.machineryTypeId === 2) const selectedDeviceText = computed(() => { const deviceId = formData.value.deviceId - if (typeof deviceId !== 'number') return '' - const option = deviceOptions.value.find((item) => item.value === deviceId) + if (deviceId == null || deviceId === '') return '' + const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId)) return option?.label || `ID:${deviceId}` }) const deviceLoading = ref(false) -const deviceOptions = ref<{ label: string; value: number; raw?: DeviceLedgerVO }[]>([]) +const deviceOptions = ref<{ label: string; value: string | number; raw?: DeviceLedgerVO }[]>([]) const deviceOptionsLoaded = ref(false) const deviceDialogVisible = ref(false) @@ -697,7 +697,7 @@ const toComponentOption = (item: any) => { return { label, value: id } } -const loadComponentOptionsByDeviceId = async (deviceId: number) => { +const loadComponentOptionsByDeviceId = async (deviceId: string) => { componentLoading.value = true try { const data = await RepairItemsApi.getComponentList(deviceId) @@ -810,7 +810,7 @@ const confirmDeviceSelection = (row?: DeviceLedgerVO) => { return } - const id = Number(selected.id) + const id = String(selected.id) const label = `${selected.deviceCode ?? ''} ${selected.deviceName ?? ''}`.trim() deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: id, raw: selected }) formData.value.deviceId = id @@ -854,12 +854,12 @@ watch( if (isHydrating.value) return formData.value.componentId = undefined componentOptions.value = [] - if (typeof deviceId !== 'number') { + if (deviceId == null || deviceId === '') { setLineRows([]) return } - const option = deviceOptions.value.find((item) => item.value === deviceId) + const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId)) if (option?.raw) { formData.value.machineryCode = option.raw.deviceCode formData.value.machineryName = option.raw.deviceName @@ -883,7 +883,7 @@ watch( if (isHydrating.value) return if (formData.value.machineryTypeId !== 2) return const deviceId = formData.value.deviceId - if (typeof deviceId !== 'number' || typeof componentId !== 'number') { + if (deviceId == null || deviceId === '' || typeof componentId !== 'number') { setLineRows([]) return } @@ -1103,14 +1103,14 @@ const open = async (type: string, id?: number) => { formData.value.machineryTypeId = Number.isNaN(typeId) ? formData.value.machineryTypeId : typeId const deviceId = formData.value.deviceId - const resolvedDeviceId = typeof deviceId === 'number' ? deviceId : formData.value.machineryId - if (typeof resolvedDeviceId === 'number') { + const resolvedDeviceId = (deviceId != null && deviceId !== '') ? deviceId : formData.value.machineryId + if (resolvedDeviceId != null && resolvedDeviceId !== '') { formData.value.deviceId = resolvedDeviceId const label = `${formData.value.machineryCode ?? ''} ${formData.value.machineryName ?? ''}`.trim() || `ID:${resolvedDeviceId}` deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: resolvedDeviceId }) } - if (formData.value.machineryTypeId === 2 && typeof formData.value.deviceId === 'number') { + if (formData.value.machineryTypeId === 2 && formData.value.deviceId != null && formData.value.deviceId !== '') { await loadComponentOptionsByDeviceId(formData.value.deviceId) const componentId = typeof formData.value.componentId === 'number' ? formData.value.componentId diff --git a/src/views/mes/taskManagement/TaskManagementForm.vue b/src/views/mes/taskManagement/TaskManagementForm.vue index 45c48e2c..d3941cb8 100644 --- a/src/views/mes/taskManagement/TaskManagementForm.vue +++ b/src/views/mes/taskManagement/TaskManagementForm.vue @@ -416,7 +416,7 @@ const formData = ref({ name: undefined as string | undefined, taskType: undefined as number | undefined, deviceList: [] as string[], - projectForm: undefined as number | undefined, + projectForm: undefined as string | undefined, dateRange: [] as string[], cronExpression: undefined as string | undefined, operableUsers: [] as string[], @@ -492,8 +492,7 @@ const open = async (type: string, row?: TaskManagementVO) => { formData.value.deviceList = parseIdsValue((row as any).deviceList) const projectFormIds = parseIdsValue((row as any).projectForm) if (projectFormIds.length) { - const n = Number(projectFormIds[0]) - formData.value.projectForm = Number.isFinite(n) ? n : undefined + formData.value.projectForm = projectFormIds[0] || undefined const projectFormName = String((row as any).projectFormName ?? '').trim() if (formData.value.projectForm !== undefined && projectFormName) { planSelectionCache.value[String(formData.value.projectForm)] = { @@ -664,8 +663,8 @@ const confirmPlanSelection = (row?: PlanOption) => { return } - const id = Number(selected.id) - formData.value.projectForm = Number.isFinite(id) ? id : undefined + const id = String(selected.id) + formData.value.projectForm = id || undefined cachePlanRows([selected]) planDialogVisible.value = false formRef.value?.clearValidate?.('projectForm') diff --git a/src/views/mes/taskManagement/index.vue b/src/views/mes/taskManagement/index.vue index bef425f5..b9a19b8d 100644 --- a/src/views/mes/taskManagement/index.vue +++ b/src/views/mes/taskManagement/index.vue @@ -301,7 +301,7 @@ type PlanOption = { } const planOptions = ref([]) -const deviceOptions = ref<{ id: number; label: string; raw?: DeviceLedgerVO }[]>([]) +const deviceOptions = ref<{ id: string | number; label: string; raw?: DeviceLedgerVO }[]>([]) const users = ref([]) const queryParams = reactive({ @@ -339,7 +339,7 @@ const ensureDeviceOptionsLoaded = async () => { const deviceRes = await DeviceLedgerApi.getDeviceLedgerList() const rows = (Array.isArray(deviceRes) ? deviceRes : deviceRes?.list ?? deviceRes?.data ?? []) as DeviceLedgerVO[] deviceOptions.value = rows - .filter((item) => typeof item?.id === 'number') + .filter((item) => item?.id != null) .map((item) => ({ id: item.id, label: `${item.deviceCode ?? ''} ${item.deviceName ?? ''}`.trim() || String(item.id),