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] =?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()