From 6c723087c0e708d816de2037a7be4411f838a0d4 Mon Sep 17 00:00:00 2001 From: zhongwenkai <3478244299@qq.com> Date: Thu, 16 Jul 2026 17:45:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=9B=AA=E8=8A=B1ID):=20=E5=85=A8=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E4=BF=AE=E5=A4=8D=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95?= =?UTF-8?q?ID=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/views/erp/moldlist/index.vue | 6 +-- .../stock/in/components/StockInItemForm.vue | 2 +- .../stock/out/components/StockOutItemForm.vue | 2 +- src/views/erp/stock/pallet/PalletForm.vue | 2 +- src/views/formula/formulaConfig/index.vue | 2 +- src/views/iot/device/DevicePoint.vue | 4 +- src/views/iot/device/index.vue | 2 +- src/views/iot/runoverview/index.vue | 8 ++-- src/views/mes/criticalComponent/index.vue | 2 +- src/views/mes/dvrepair/DvRepairForm.vue | 4 +- src/views/mes/energyOverview/index.vue | 8 ++-- .../mes/energydevice/EnergyDeviceForm.vue | 10 ++--- src/views/mes/energydevice/index.vue | 2 +- .../moldget/components/StockOutItemForm.vue | 4 +- src/views/mes/moldoperate/MoldOperateForm.vue | 40 +++++++++---------- .../moldreturn/components/StockInItemForm.vue | 4 +- src/views/mes/plan/PlanForm.vue | 10 ++--- src/views/mes/plan/index.vue | 6 +-- .../planMaintenance/PlanMaintenanceForm.vue | 6 +-- .../mes/productionReport/detail/index.vue | 2 +- src/views/mes/repairItems/RepairItemsForm.vue | 24 +++++------ src/views/mes/taskManagement/index.vue | 2 +- .../components/TaskScheduleDialog.vue | 20 +++++----- src/views/mes/workOrderManagement/index.vue | 2 +- src/views/mes/zjschema/ZjSchemaForm.vue | 2 +- .../inspectionPlan/InspectionPlanForm.vue | 16 ++++---- src/views/mold/moldrepair/MoldRepairForm.vue | 25 ++++++------ .../mold/repairItems/MoldRepairItemsForm.vue | 8 ++-- .../TaskConfigurationForm.vue | 12 +++--- src/views/mold/workOrderInquiry/index.vue | 2 +- src/views/report/dashboardList/index.vue | 8 ++-- 31 files changed, 117 insertions(+), 130 deletions(-) diff --git a/src/views/erp/moldlist/index.vue b/src/views/erp/moldlist/index.vue index 01773251..67423104 100644 --- a/src/views/erp/moldlist/index.vue +++ b/src/views/erp/moldlist/index.vue @@ -151,14 +151,14 @@ const typeTreeData = ref([]) const brandTreeData = ref([]) const typeTreeProps = { label: 'name', children: 'children' } const typeTreeExpandedKeys = ref([0]) -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 diff --git a/src/views/erp/stock/in/components/StockInItemForm.vue b/src/views/erp/stock/in/components/StockInItemForm.vue index e641c3fa..facf3aff 100644 --- a/src/views/erp/stock/in/components/StockInItemForm.vue +++ b/src/views/erp/stock/in/components/StockInItemForm.vue @@ -607,7 +607,7 @@ const formRef = ref([]) // 表单 Ref const productList = ref([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 const defaultWarehouse = ref(undefined) // 默认仓库 -const warehouseAreaMap = ref>({}) +const warehouseAreaMap = ref>({}) const stockInCategoryTypeMap: Record = { 产品入库: 1, 物料入库: 2, diff --git a/src/views/erp/stock/out/components/StockOutItemForm.vue b/src/views/erp/stock/out/components/StockOutItemForm.vue index 3e4d4bcd..8afdffa5 100644 --- a/src/views/erp/stock/out/components/StockOutItemForm.vue +++ b/src/views/erp/stock/out/components/StockOutItemForm.vue @@ -515,7 +515,7 @@ const formRef = ref([]) // 表单 Ref const productList = ref([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 const defaultWarehouse = ref(undefined) // 默认仓库 -const warehouseAreaMap = ref>({}) +const warehouseAreaMap = ref>({}) const resolveStockOutCategoryType = (outType?: string) => { if (!outType) return undefined if (outType.includes('产品')) return 1 diff --git a/src/views/erp/stock/pallet/PalletForm.vue b/src/views/erp/stock/pallet/PalletForm.vue index de5ebee9..c4cbe272 100644 --- a/src/views/erp/stock/pallet/PalletForm.vue +++ b/src/views/erp/stock/pallet/PalletForm.vue @@ -567,7 +567,7 @@ const open = async (type: string, row?: PalletVO, defaults?: Partial) await hydrateSelectedProduct() } if (type === 'update' && row?.id) { - const data = await PalletApi.getPallet(Number(row.id)) + const data = await PalletApi.getPallet(String(row.id)) await applyPalletDetail(data) } } diff --git a/src/views/formula/formulaConfig/index.vue b/src/views/formula/formulaConfig/index.vue index 02b8f5c4..abb0f111 100644 --- a/src/views/formula/formulaConfig/index.vue +++ b/src/views/formula/formulaConfig/index.vue @@ -750,7 +750,7 @@ const openConfigDialog = async (recipeId: number | string) => { const selectedKeys = (selectedList ?? []) .map((item: any) => (item.attributeId !== undefined ? item.attributeId : item.id)) .map((id: any) => normalizeKey(id)) - .filter((id: any) => typeof id === 'number') + .filter((id: any) => id != null && id !== '') configSelectedKeys.value = selectedKeys configSelectedItems.value = (selectedList ?? []) .map((item: any) => ({ diff --git a/src/views/iot/device/DevicePoint.vue b/src/views/iot/device/DevicePoint.vue index 634f56fb..2bf3527f 100644 --- a/src/views/iot/device/DevicePoint.vue +++ b/src/views/iot/device/DevicePoint.vue @@ -510,8 +510,8 @@ const id = route.query.id; // 类型是 string | string[],需转换 const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 const attributeDeviceName = ref(route.query.name as string); -const attributeDeviceId = ref(undefined) -attributeDeviceId.value = Number(id) +const attributeDeviceId = ref(undefined) +attributeDeviceId.value = String(id) const deviceAlarmDialogVisible = ref(false) const deviceAlarmList = ref([]) const deviceAlarmTotal = ref(0) diff --git a/src/views/iot/device/index.vue b/src/views/iot/device/index.vue index d60e9ffe..20e3280a 100644 --- a/src/views/iot/device/index.vue +++ b/src/views/iot/device/index.vue @@ -1855,7 +1855,7 @@ const handleCreateRuleSubmit = async () => { createRuleFormLoading.value = false } } -const connectLoadingMap = reactive>({}) +const connectLoadingMap = reactive>({}) const getRowConnectValue = (row: any) => { return row?.isConnect ?? row?.status diff --git a/src/views/iot/runoverview/index.vue b/src/views/iot/runoverview/index.vue index 718d1906..f0613ea4 100644 --- a/src/views/iot/runoverview/index.vue +++ b/src/views/iot/runoverview/index.vue @@ -141,13 +141,11 @@ const normalizeDeviceParameterAnalysisTree = ( nodes: DeviceParameterAnalysisNodeVO[] = [] ): OrganizationTreeOption[] => { const normalizeNode = (node: DeviceParameterAnalysisNodeVO): any => { - const rawId = Number(node?.id) || node?.id + const rawId = node?.id const parentId = node?.parentId == null || node?.parentId === '' ? 0 - : typeof node.parentId === 'number' - ? node.parentId - : Number(node.parentId) || 0 + : node.parentId return { ...node, @@ -200,7 +198,7 @@ const normalizeDeviceParameterAnalysisTree = ( return { id: `org-${node.id}`, name: node.name, - parentId: node.parentId != null && Number(node.parentId) > 0 ? `org-${node.parentId}` : node.parentId, + parentId: node.parentId != null && node.parentId !== '' && node.parentId !== 0 ? `org-${node.parentId}` : node.parentId, lineId: String(node.id), filterId: String(node.id), nodeType: 'org', diff --git a/src/views/mes/criticalComponent/index.vue b/src/views/mes/criticalComponent/index.vue index 0259cb84..db1fc8c6 100644 --- a/src/views/mes/criticalComponent/index.vue +++ b/src/views/mes/criticalComponent/index.vue @@ -293,7 +293,7 @@ const resetQuery = () => { } const handleSelectionChange = (rows: CriticalComponentVO[]) => { - selectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number') + selectedIds.value = rows.map((r) => r.id).filter((id): id is string => id != null && id !== '') } const formRef = ref() diff --git a/src/views/mes/dvrepair/DvRepairForm.vue b/src/views/mes/dvrepair/DvRepairForm.vue index 26646a92..8386317e 100644 --- a/src/views/mes/dvrepair/DvRepairForm.vue +++ b/src/views/mes/dvrepair/DvRepairForm.vue @@ -1054,7 +1054,7 @@ const setLineRows = (rows: any[]) => { dvRepairLineFormRef.value?.setData(rows) } -const prefillLinesByDeviceOrComponent = async (params: { deviceId: number; componentId?: number; deviceType: number }) => { +const prefillLinesByDeviceOrComponent = async (params: { deviceId: string; componentId?: number; deviceType: number }) => { if (formType.value !== 'create') return const data = await RepairItemsApi.getDeviceOrComponentList(params) const list = normalizeDeviceOrComponentList(data) @@ -1178,7 +1178,7 @@ const submitForm = async () => { if (formType.value === 'repair') { data.status = '1' } - if (typeof formData.value.deviceId === 'number') { + if (formData.value.deviceId != null && formData.value.deviceId !== '') { data.machineryId = formData.value.deviceId } data.deviceId = formData.value.deviceId diff --git a/src/views/mes/energyOverview/index.vue b/src/views/mes/energyOverview/index.vue index a7a64660..6a64d589 100644 --- a/src/views/mes/energyOverview/index.vue +++ b/src/views/mes/energyOverview/index.vue @@ -550,13 +550,11 @@ const normalizeDeviceParameterAnalysisTree = ( nodes: DeviceParameterAnalysisNodeVO[] = [] ): OrganizationTreeOption[] => { const normalizeNode = (node: DeviceParameterAnalysisNodeVO): any => { - const rawId = Number(node?.id) || node?.id + const rawId = node?.id const parentId = node?.parentId == null || node?.parentId === '' ? 0 - : typeof node.parentId === 'number' - ? node.parentId - : Number(node.parentId) || 0 + : node.parentId return { ...node, @@ -609,7 +607,7 @@ const normalizeDeviceParameterAnalysisTree = ( return { id: `org-${node.id}`, name: node.name, - parentId: node.parentId != null && Number(node.parentId) > 0 ? `org-${node.parentId}` : node.parentId, + parentId: node.parentId != null && node.parentId !== '' && node.parentId !== 0 ? `org-${node.parentId}` : node.parentId, lineId: String(node.id), filterId: String(node.id), nodeType: 'org', diff --git a/src/views/mes/energydevice/EnergyDeviceForm.vue b/src/views/mes/energydevice/EnergyDeviceForm.vue index c1771b4d..c7b33814 100644 --- a/src/views/mes/energydevice/EnergyDeviceForm.vue +++ b/src/views/mes/energydevice/EnergyDeviceForm.vue @@ -514,12 +514,10 @@ const handlePointSelected = (index: number, val: any) => { return } const [deviceIdStr, pointIdStr] = val.split(':') - const deviceId = Number(deviceIdStr) - const pointId = Number(pointIdStr) - formData.value.operationRulesVOList[index].deviceId = Number.isNaN(deviceId) - ? undefined - : deviceId - formData.value.operationRulesVOList[index].pointId = Number.isNaN(pointId) ? undefined : pointId + const deviceId = deviceIdStr || undefined + const pointId = pointIdStr || undefined + formData.value.operationRulesVOList[index].deviceId = deviceId + formData.value.operationRulesVOList[index].pointId = pointId } const addRule = () => { diff --git a/src/views/mes/energydevice/index.vue b/src/views/mes/energydevice/index.vue index 8b3eaa55..8d296de3 100644 --- a/src/views/mes/energydevice/index.vue +++ b/src/views/mes/energydevice/index.vue @@ -293,7 +293,7 @@ onBeforeUnmount(() => { /** 添加/修改操作 */ const newRecordFormRef = ref() -const newRecordForm = (id: number, deviceType: string) => { +const newRecordForm = (id: string, deviceType: string) => { //type: string, id?: number, deviceId: number, deviceType: string newRecordFormRef.value.open("create", null, id, deviceType) } diff --git a/src/views/mes/moldget/components/StockOutItemForm.vue b/src/views/mes/moldget/components/StockOutItemForm.vue index b7450af3..5b145318 100644 --- a/src/views/mes/moldget/components/StockOutItemForm.vue +++ b/src/views/mes/moldget/components/StockOutItemForm.vue @@ -124,8 +124,8 @@ const dictStore = useDictStoreWithOut() const dictReady = ref(false) // 展开行相关 -const expandLoadingMap = ref>({}) -const expandDataMap = ref>({}) +const expandLoadingMap = ref>({}) +const expandDataMap = ref>({}) /** 查询列表 */ const getList = async () => { diff --git a/src/views/mes/moldoperate/MoldOperateForm.vue b/src/views/mes/moldoperate/MoldOperateForm.vue index 4d0734b6..ddc91258 100644 --- a/src/views/mes/moldoperate/MoldOperateForm.vue +++ b/src/views/mes/moldoperate/MoldOperateForm.vue @@ -195,9 +195,9 @@ const formType = ref('') // 表单的类型:create - 新增;update - 修改 type MoldOperateFormData = { id: number | undefined operateType: string | number | undefined - moldId: number | undefined - deviceId: number | undefined - lineId: number | undefined + moldId: string | undefined + deviceId: string | undefined + lineId: string | undefined operateTime: string | undefined operatorId: number | undefined remark: string | undefined @@ -249,10 +249,10 @@ const open = async (type: string, id?: number) => { ...data, } if (formData.value.deviceId != null) { - ids.value = [Number(formData.value.deviceId)].filter((v) => Number.isFinite(v)) + ids.value = [String(formData.value.deviceId)] } if (formData.value.moldId != null) { - moldIds.value = [Number(formData.value.moldId)].filter((v) => Number.isFinite(v)) + moldIds.value = [String(formData.value.moldId)] } } finally { initializingOperateType.value = false @@ -382,7 +382,7 @@ const ensureLineOptionsLoaded = async () => { } // 设备更改 -const deviceChange = async (deviceId:number) => { +const deviceChange = async (deviceId: string) => { if (String(formData.value.operateType) === '2' && deviceId) { formData.value.moldId = undefined as any } @@ -469,13 +469,13 @@ const deviceMoldLoaded = ref(false) const resolveTopCategoryName = (deviceLineId: string | number | undefined): string => { if (deviceLineId == null || deviceLineId === '') return '' if (!deviceLineTree.value.length) return '' - const targetId = Number(deviceLineId) - const containsId = (nodes: any[] | undefined, id: number): boolean => { + const targetId = String(deviceLineId) + const containsId = (nodes: any[] | undefined, id: string): boolean => { if (!nodes) return false - return nodes.some((n) => n.id === id || containsId(n.children, id)) + return nodes.some((n) => String(n.id) === id || containsId(n.children, id)) } for (const root of deviceLineTree.value) { - if (root.id === targetId || containsId(root.children, targetId)) { + if (String(root.id) === targetId || containsId(root.children, targetId)) { return root.name } } @@ -552,7 +552,7 @@ const handleDeviceSelectConfirm = async (payload: { ids: (number | string)[]; ro const row = payload.rows[0] if (row) { selectedDeviceRows.value = [row] - const deviceId = Number(row.id) + const deviceId = String(row.id) formData.value.deviceId = deviceId ids.value = [deviceId] // 选择设备后调详情接口获取完整的 deviceLine 字段(分页接口不返回该字段) @@ -566,15 +566,15 @@ const handleDeviceSelectConfirm = async (payload: { ids: (number | string)[]; ro displayTopCategory.value = detail?.topCategoryName || '' // fallback: 用产线树(DeviceLineTree)匹配,找到根节点名称 if (!displayTopCategory.value && detail?.deviceLine != null && deviceLineTree.value.length) { - const lineId = Number(detail.deviceLine) + const lineId = String(detail.deviceLine) console.log('fallback 匹配: deviceLine=', lineId, '产线树根数=', deviceLineTree.value.length) // 检查每个顶层节点是否包含目标节点(自身或后代),返回根节点名称 - const containsId = (nodes: DeviceLineTreeVO[] | undefined, id: number): boolean => { + const containsId = (nodes: DeviceLineTreeVO[] | undefined, id: string): boolean => { if (!nodes) return false - return nodes.some((n) => n.id === id || containsId(n.children, id)) + return nodes.some((n) => String(n.id) === id || containsId(n.children, id)) } for (const root of deviceLineTree.value) { - if (root.id === lineId || containsId(root.children, lineId)) { + if (String(root.id) === lineId || containsId(root.children, lineId)) { displayTopCategory.value = root.name console.log('产线匹配成功:', root.name) break @@ -600,8 +600,8 @@ const handleMoldSelectConfirm = (payload: { ids: (number | string)[]; rows: any[ const row = payload.rows[0] if (row) { selectedMoldRows.value = [row] - formData.value.moldId = Number(row.id) - moldIds.value = [Number(row.id)] + formData.value.moldId = String(row.id) + moldIds.value = [String(row.id)] } else { selectedMoldRows.value = [] formData.value.moldId = undefined @@ -648,8 +648,8 @@ const mergedMoldQueryParams = computed(() => { const status = String(formData.value.operateType) === '1' ? 1 : String(formData.value.operateType) === '2' ? 0 : undefined return { ...searchMoldParams, ...(status !== undefined ? { status } : {}) } }) -const ids = ref([]) -const moldIds= ref([]) +const ids = ref([]) +const moldIds= ref([]) const itemList = ref([]) const moldItemList = ref([]) const deviceSelectDialogRef = ref | null>(null) @@ -706,7 +706,7 @@ const downMoldLoading = ref(false) const downMoldTarget = ref(null) const downMoldFormRef = ref() const downMoldForm = reactive({ - moldIds: [] as number[], + moldIds: [] as string[], operatorId: undefined as number | undefined, operateTime: '', remark: '' diff --git a/src/views/mes/moldreturn/components/StockInItemForm.vue b/src/views/mes/moldreturn/components/StockInItemForm.vue index 76ac7936..99a93030 100644 --- a/src/views/mes/moldreturn/components/StockInItemForm.vue +++ b/src/views/mes/moldreturn/components/StockInItemForm.vue @@ -125,8 +125,8 @@ const dictStore = useDictStoreWithOut() const dictReady = ref(false) // 展开行相关 -const expandLoadingMap = ref>({}) -const expandDataMap = ref>({}) +const expandLoadingMap = ref>({}) +const expandDataMap = ref>({}) /** 查询列表 */ const getList = async () => { diff --git a/src/views/mes/plan/PlanForm.vue b/src/views/mes/plan/PlanForm.vue index e0e9b44a..fa22750f 100644 --- a/src/views/mes/plan/PlanForm.vue +++ b/src/views/mes/plan/PlanForm.vue @@ -281,7 +281,7 @@ const validatePlanEndTime = (_rule: any, value: any, callback: (error?: Error) = const getSelectedTaskDetailUnplanned = () => { const detail = taskDetailList.value.find( - (item: any) => Number(item.id) === Number(formData.value.taskDetailId) + (item: any) => String(item.id) === String(formData.value.taskDetailId) ) as any if (!detail) return undefined const total = Number(detail.number) @@ -359,7 +359,7 @@ const openDeviceSelectDialog = (row: PlanProcessRouteItemVO) => { const rows = row.deviceId ? [ { - id: Number(row.deviceId), + id: String(row.deviceId), deviceName: row.deviceName } ] @@ -370,8 +370,8 @@ const openDeviceSelectDialog = (row: PlanProcessRouteItemVO) => { const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => { const row = payload.rows?.[0] if (!row || !activeRouteItemRow.value) return - const deviceId = Number(row.id) - if (!Number.isFinite(deviceId)) return + const deviceId = String(row.id) + if (!deviceId) return activeRouteItemRow.value.deviceId = deviceId activeRouteItemRow.value.deviceName = row.deviceName || row.name || row.code || `ID:${deviceId}` } @@ -382,7 +382,7 @@ const clearRouteItemDevice = (row: PlanProcessRouteItemVO) => { } const syncFinishDateByTaskDetail = () => { - const detail = taskDetailList.value.find((item: any) => Number(item.id) === Number(formData.value.taskDetailId)) as any + const detail = taskDetailList.value.find((item: any) => String(item.id) === String(formData.value.taskDetailId)) as any formData.value.finishDate = detail?.finishDate || detail?.deliveryDate || undefined formData.value.deliveryDate = detail?.deliveryDate || formData.value.deliveryDate } diff --git a/src/views/mes/plan/index.vue b/src/views/mes/plan/index.vue index fd125278..ba3cef6d 100644 --- a/src/views/mes/plan/index.vue +++ b/src/views/mes/plan/index.vue @@ -596,7 +596,7 @@ const openLineDeviceSelectDialog = (row: LineChangeRouteItem) => { const rows = row.selectedDeviceId ? [ { - id: Number(row.selectedDeviceId), + id: String(row.selectedDeviceId), deviceName: row.selectedDeviceName } ] @@ -607,8 +607,8 @@ const openLineDeviceSelectDialog = (row: LineChangeRouteItem) => { const handleLineDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => { const row = payload.rows?.[0] if (!row || !activeLineChangeItem.value) return - const deviceId = Number(row.id) - if (!Number.isFinite(deviceId)) return + const deviceId = String(row.id) + if (!deviceId) return activeLineChangeItem.value.selectedDeviceId = deviceId activeLineChangeItem.value.selectedDeviceName = row.deviceName || row.name || row.code || `ID:${deviceId}` } diff --git a/src/views/mes/planMaintenance/PlanMaintenanceForm.vue b/src/views/mes/planMaintenance/PlanMaintenanceForm.vue index 1f37f140..455beb22 100644 --- a/src/views/mes/planMaintenance/PlanMaintenanceForm.vue +++ b/src/views/mes/planMaintenance/PlanMaintenanceForm.vue @@ -160,7 +160,7 @@ const ensureSubjectOptionsLoaded = async () => { const code = item.subjectCode ? String(item.subjectCode) : '' const name = item.subjectName ? String(item.subjectName) : '' const label = code && name ? `${code}-${name}` : name || code || String(item.id) - return { label, value: Number(item.id) } + return { label, value: String(item.id) } }) } @@ -175,11 +175,9 @@ const parseIds = (value: any): Array => { return raw .map((v) => { - if (typeof v === 'number') return v + if (typeof v === 'number') return String(v) const s = String(v).trim() if (!s) return undefined - const n = Number(s) - if (Number.isFinite(n) && String(n) === s) return n return s }) .filter((v): v is number | string => v !== undefined) diff --git a/src/views/mes/productionReport/detail/index.vue b/src/views/mes/productionReport/detail/index.vue index d3fe5bbc..4c6be527 100644 --- a/src/views/mes/productionReport/detail/index.vue +++ b/src/views/mes/productionReport/detail/index.vue @@ -75,7 +75,7 @@ const route = useRoute() const { delView } = useTagsViewStore() const { currentRoute } = useRouter() -const taskId = computed(() => Number(route.params.id)) +const taskId = computed(() => String(route.params.id || '')) const detailLoading = ref(false) const detailData = ref(null) const activeTabName = ref('basicInfo') diff --git a/src/views/mes/repairItems/RepairItemsForm.vue b/src/views/mes/repairItems/RepairItemsForm.vue index 09f51f49..aa0a109c 100644 --- a/src/views/mes/repairItems/RepairItemsForm.vue +++ b/src/views/mes/repairItems/RepairItemsForm.vue @@ -116,7 +116,7 @@ const formData = ref({ subjectCode: undefined as string | undefined, subjectName: undefined as string | undefined, deviceType: undefined as number | undefined, - deviceId: undefined as number | number[] | undefined, + deviceId: undefined as string | string[] | undefined, componentId: undefined as number | undefined, inspectionMethod: undefined as string | undefined, valueType: undefined as string | undefined, @@ -150,7 +150,7 @@ const handleDeviceSearch = async (keyword: string) => { }) const rows = (data?.list ?? []) as DeviceLedgerVO[] deviceOptions.value = rows - .filter((r) => typeof r?.id === 'number') + .filter((r) => r?.id != null) .map((r) => ({ label: `${r.deviceCode ?? ''} ${r.deviceName ?? ''}`.trim(), value: r.id })) } finally { deviceLoading.value = false @@ -158,7 +158,7 @@ const handleDeviceSearch = async (keyword: string) => { } const toComponentOption = (item: any) => { - const id = typeof item?.id === 'number' ? item.id : Number(item?.id) + const id = item?.id != null ? String(item.id) : undefined if (Number.isNaN(id)) return undefined const code = item?.code ?? item?.componentCode ?? item?.subjectCode const name = item?.name ?? item?.componentName ?? item?.subjectName @@ -166,7 +166,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) @@ -198,8 +198,8 @@ watch( if (formData.value.deviceType !== 2) return formData.value.componentId = undefined componentOptions.value = [] - const selectedId = typeof deviceId === 'number' ? deviceId : undefined - if (typeof selectedId !== 'number') return + const selectedId = (deviceId != null && deviceId !== '') ? deviceId : undefined + if (selectedId == null || selectedId === '') return await loadComponentOptionsByDeviceId(selectedId) } ) @@ -261,12 +261,12 @@ const open = async (type: string, row?: any) => { if (type === 'update' && row) { const parseDeviceIds = (input: unknown) => { if (input === undefined || input === null || input === '') return [] - if (Array.isArray(input)) return input.map((v) => Number(v)).filter((v) => !Number.isNaN(v)) - if (typeof input === 'number') return [input] + if (Array.isArray(input)) return input.map((v) => String(v)).filter((v) => v !== '') + if (typeof input === 'number') return [String(input)] return String(input) .split(',') - .map((v) => Number(v.trim())) - .filter((v) => !Number.isNaN(v)) + .map((v) => String(v.trim())) + .filter((v) => v !== '') } const deviceIds = parseDeviceIds(row.deviceId) formData.value = { @@ -295,11 +295,11 @@ const open = async (type: string, row?: any) => { const label = nameParts[idx] ? String(nameParts[idx]) : `ID:${id}` deviceOptions.value = upsertOption(deviceOptions.value, { label, value: id }) }) - } else if (typeof formData.value.deviceId === 'number') { + } else if (formData.value.deviceId != null && formData.value.deviceId !== '') { const label = row.deviceName ? String(row.deviceName) : `ID:${formData.value.deviceId}` deviceOptions.value = upsertOption(deviceOptions.value, { label, value: formData.value.deviceId }) } - if (formData.value.deviceType === 2 && typeof formData.value.deviceId === 'number') { + if (formData.value.deviceType === 2 && formData.value.deviceId != null && formData.value.deviceId !== '') { await loadComponentOptionsByDeviceId(formData.value.deviceId) if (typeof formData.value.componentId === 'number') { const label = row.componentName ? String(row.componentName) : `ID:${formData.value.componentId}` diff --git a/src/views/mes/taskManagement/index.vue b/src/views/mes/taskManagement/index.vue index b9a19b8d..bc1bb27a 100644 --- a/src/views/mes/taskManagement/index.vue +++ b/src/views/mes/taskManagement/index.vue @@ -310,7 +310,7 @@ const queryParams = reactive({ name: undefined as string | undefined, taskType: undefined as number | undefined, projectForm: [] as string[], - deviceIds: [] as number[], + deviceIds: [] as string[], operator: undefined as string | undefined, taskTime: undefined as string | undefined }) diff --git a/src/views/mes/tasksummary/components/TaskScheduleDialog.vue b/src/views/mes/tasksummary/components/TaskScheduleDialog.vue index e06b122f..e0e24bd4 100644 --- a/src/views/mes/tasksummary/components/TaskScheduleDialog.vue +++ b/src/views/mes/tasksummary/components/TaskScheduleDialog.vue @@ -299,8 +299,8 @@ const queryParams = reactive({ const taskList = ref([]) const detailList = ref([]) const currentTask = ref() -const allDetailsMap = ref>({}) // store details per taskId -const taskDetailRequestMap = new Map>() +const allDetailsMap = ref>({}) // store details per taskId +const taskDetailRequestMap = new Map>() const currentDetailRequestId = ref(0) const taskTableBusy = computed(() => taskLoading.value || taskSelectionLoading.value) @@ -365,8 +365,8 @@ const toDeviceRows = (devices: { id: number; name: string }[]) => { name: item.name })) } -const buildRelationIdList = (list: { id: number; name: string }[]) => { - return list.map((item) => Number(item.id)).filter((id) => Number.isFinite(id)) +const buildRelationIdList = (list: { id: string; name: string }[]) => { + return list.map((item) => String(item.id)).filter((id) => id !== '') } const fetchDeviceLedgerPage = (params: Record) => { return DeviceLedgerApi.getDeviceLedgerPage({ @@ -642,15 +642,15 @@ const openDeviceRelationDialog = async (row: any) => { } const openDeviceSelectDialog = () => { const rows = selectedDeviceRows.value.length - ? selectedDeviceRows.value.map((item) => ({ ...item, id: Number(item.id) })) + ? selectedDeviceRows.value.map((item) => ({ ...item, id: String(item.id) })) : toDeviceRows(deviceRelationForm.devices) deviceSelectDialogRef.value?.open(rows) } const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => { deviceRelationForm.devices = payload.rows .map((item) => { - const id = Number(item.id) - if (!Number.isFinite(id)) return undefined + const id = String(item.id) + if (!id) return undefined return { id, name: item.deviceName || item.name || item.code || `${t('ProductionPlan.TaskSummary.deviceColumnName')}ID:${id}` @@ -660,10 +660,10 @@ const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: an selectedDeviceRows.value = payload.rows } const refreshDetailListAfterDeviceSaved = async () => { - const taskId = Number(currentDeviceRelationRow.value?.taskId) - if (!Number.isFinite(taskId)) return + const taskId = String(currentDeviceRelationRow.value?.taskId ?? '') + if (!taskId) return delete allDetailsMap.value[taskId] - if (Number(currentTask.value?.id) === taskId && currentTask.value) { + if (String(currentTask.value?.id) === taskId && currentTask.value) { await handleCurrentTaskChange(currentTask.value) } } diff --git a/src/views/mes/workOrderManagement/index.vue b/src/views/mes/workOrderManagement/index.vue index 7f07b66d..f65fce3b 100644 --- a/src/views/mes/workOrderManagement/index.vue +++ b/src/views/mes/workOrderManagement/index.vue @@ -337,7 +337,7 @@ const handleSelectionChange = (rows: TicketManagementVO[]) => { selectedRows.value = rows selectedIds.value = rows .map((r) => r.id) - .filter((id): id is number => typeof id === 'number') + .filter((id): id is string => id != null && id !== '') } const handleBatchCancel = async () => { diff --git a/src/views/mes/zjschema/ZjSchemaForm.vue b/src/views/mes/zjschema/ZjSchemaForm.vue index c7fff0e5..fdd17f38 100644 --- a/src/views/mes/zjschema/ZjSchemaForm.vue +++ b/src/views/mes/zjschema/ZjSchemaForm.vue @@ -758,7 +758,7 @@ const resetProductQuery = () => { } const handleSelectionChange = (rows: ZjItemVO[]) => { - selectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number') + selectedIds.value = rows.map((r) => r.id).filter((id): id is string => id != null && id !== '') // 获取当前页所有行的 id const currentPageIds = rows.map(item => item.id) diff --git a/src/views/mold/inspectionPlan/InspectionPlanForm.vue b/src/views/mold/inspectionPlan/InspectionPlanForm.vue index 840a941f..26834dfb 100644 --- a/src/views/mold/inspectionPlan/InspectionPlanForm.vue +++ b/src/views/mold/inspectionPlan/InspectionPlanForm.vue @@ -119,14 +119,12 @@ const parseIds = (value: any): Array => { return raw .map((v) => { - if (typeof v === 'number') return v + if (typeof v === 'number') return String(v) const s = String(v).trim() if (!s) return undefined - const n = Number(s) - if (Number.isFinite(n) && String(n) === s) return n return s }) - .filter((v): v is number | string => v !== undefined) + .filter((v): v is string => v !== undefined) } const ids = ref([]) const itemList = ref([]) @@ -188,23 +186,23 @@ const openCriticalComponentDialog = async () => { deviceSelectDialogRef.value?.open([], { defaultSelectedKeys: initIds }) - ids.value=initIds.map((id) => Number(id)) + ids.value=initIds.map((id) => String(id)) } const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => { formData.value.subjectIds = payload.rows .map((item) => { - const id = Number(item.id) - if (!Number.isFinite(id)) return undefined + const id = String(item.id) + if (!id) return undefined return { id, name: item.subjectName || item.name || item.code || `设备ID:${id}` } }) - .filter((item): item is { id: number; name: string } => Boolean(item)) + .filter((item): item is { id: string; name: string } => Boolean(item)) selectedDeviceRows.value = payload.rows formData.value.subjectIds = payload.ids.join(',') - ids.value = payload.ids.map((id) => Number(id)) + ids.value = payload.ids.map((id) => String(id)) } const handleSearch = () => { diff --git a/src/views/mold/moldrepair/MoldRepairForm.vue b/src/views/mold/moldrepair/MoldRepairForm.vue index 42ff02a1..5ee5aaf9 100644 --- a/src/views/mold/moldrepair/MoldRepairForm.vue +++ b/src/views/mold/moldrepair/MoldRepairForm.vue @@ -460,7 +460,7 @@ import { useUserStore } from '@/store/modules/user' defineOptions({ name: 'MoldRepairForm' }) interface MoldRepairFormData extends Partial { - moldId?: number + moldId?: string shutdown?: boolean isCode?: boolean faultLevel?: string @@ -562,8 +562,8 @@ const moldOptionsLoaded = ref(false) const selectedMoldText = computed(() => { const moldId = formData.value.moldId - if (typeof moldId !== 'number') return '' - const option = moldOptions.value.find((o) => o.value === moldId) + if (moldId == null || moldId === '') return '' + const option = moldOptions.value.find((o) => String(o.value) === String(moldId)) return option?.label || `ID:${moldId}` }) @@ -605,7 +605,7 @@ const upsertMoldOption = ( } const toMoldOption = (item: any) => { - const id = typeof item?.id === 'number' ? item.id : Number(item?.id) + const id = item?.id != null ? String(item.id) : undefined if (Number.isNaN(id)) return undefined const code = item?.code ?? item?.moldCode const name = item?.name ?? item?.moldName @@ -681,7 +681,7 @@ const confirmMoldSelection = (row?: MoldVO) => { return } - const id = Number(selected.id) + const id = String(selected.id) const label = `${selected.code ?? ''} ${selected.name ?? ''}`.trim() moldOptions.value = upsertMoldOption(moldOptions.value, { label, value: id, raw: selected }) formData.value.moldId = id @@ -702,7 +702,7 @@ watch( () => formData.value.moldId, (moldId) => { if (isHydrating.value) return - if (typeof moldId !== 'number') { + if (moldId == null || moldId === '') { formData.value.moldCode = undefined formData.value.moldName = undefined formData.value.machinerySpec = undefined @@ -912,17 +912,16 @@ const open = async (type: string, id?: number) => { ;(formData.value as any).moldName = (formData.value as any).moldName ?? (formData.value as any).machineryName const rawMoldId = (formData.value as any).moldId const rawMachineryId = (formData.value as any).machineryId - const resolvedMoldId = - typeof rawMoldId === 'number' - ? rawMoldId - : typeof rawMachineryId === 'number' - ? rawMachineryId - : Number(rawMachineryId) + const resolvedMoldId = (rawMoldId != null && rawMoldId !== '') + ? rawMoldId + : (rawMachineryId != null && rawMachineryId !== '') + ? rawMachineryId + : undefined delete (formData.value as any).machineryId delete (formData.value as any).machineryCode delete (formData.value as any).machineryName - if (typeof resolvedMoldId === 'number' && !Number.isNaN(resolvedMoldId)) { + if (resolvedMoldId != null && resolvedMoldId !== '') { formData.value.moldId = resolvedMoldId const label = `${formData.value.moldCode ?? ''} ${formData.value.moldName ?? ''}`.trim() || `ID:${resolvedMoldId}` moldOptions.value = upsertMoldOption(moldOptions.value, { label, value: resolvedMoldId }) diff --git a/src/views/mold/repairItems/MoldRepairItemsForm.vue b/src/views/mold/repairItems/MoldRepairItemsForm.vue index 50f446d4..1216691f 100644 --- a/src/views/mold/repairItems/MoldRepairItemsForm.vue +++ b/src/views/mold/repairItems/MoldRepairItemsForm.vue @@ -74,7 +74,7 @@ const formData = ref({ id: undefined as number | undefined, subjectCode: undefined as string | undefined, subjectName: undefined as string | undefined, - moldId: undefined as number | undefined, + moldId: undefined as string | undefined, projectContent: undefined as string | undefined, isEnable: undefined as string | undefined }) @@ -91,7 +91,7 @@ const handleDeviceSearch = async (keyword: string) => { }) const rows = (data?.list ?? []) as MoldVO[] deviceOptions.value = rows - .filter((r) => typeof r?.id === 'number') + .filter((r) => r?.id != null) .map((r) => ({ label: `${r.code ?? ''} ${r.name ?? ''}`.trim(), value: r.id })) } finally { deviceLoading.value = false @@ -126,12 +126,12 @@ const open = async (type: string, row?: any) => { id: row.id, subjectCode: row.subjectCode, subjectName: row.subjectName, - moldId: row.moldId !== undefined && row.moldId !== null ? Number(row.moldId) : undefined, + moldId: row.moldId !== undefined && row.moldId !== null ? String(row.moldId) : undefined, projectContent: row.projectContent, isEnable: row.isEnable !== undefined && row.isEnable !== null ? String(row.isEnable) : undefined } - if (typeof formData.value.moldId === 'number') { + if (formData.value.moldId != null && formData.value.moldId !== '') { const label = row.moldName ? String(row.moldName) : `ID:${formData.value.moldId}` deviceOptions.value = [{ label, value: formData.value.moldId }] } diff --git a/src/views/mold/taskConfiguration/TaskConfigurationForm.vue b/src/views/mold/taskConfiguration/TaskConfigurationForm.vue index 8538a63a..fa4b81af 100644 --- a/src/views/mold/taskConfiguration/TaskConfigurationForm.vue +++ b/src/views/mold/taskConfiguration/TaskConfigurationForm.vue @@ -410,7 +410,7 @@ const formData = ref({ name: undefined as string | undefined, taskType: undefined as number | undefined, moldList: [] as string[], - projectForm: undefined as number | undefined, + projectForm: undefined as string | undefined, dateRange: [] as string[], cronExpression: undefined as string | undefined, operableUsers: [] as string[], @@ -455,8 +455,7 @@ const open = async (type: string, row?: TaskManagementVO) => { formData.value.moldList = parseIdsValue((row as any).moldList) 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)] = { @@ -474,9 +473,8 @@ const open = async (type: string, row?: TaskManagementVO) => { return found?.id }) .filter((id) => id !== undefined && id !== null) - .map((id) => Number(id)) const firstId = mapped[0] - formData.value.projectForm = typeof firstId === 'number' && Number.isFinite(firstId) ? firstId : undefined + formData.value.projectForm = firstId || undefined } formData.value.dateRange = [row.startDate, row.endDate].filter(Boolean) as string[] formData.value.cronExpression = row.cronExpression @@ -639,8 +637,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/mold/workOrderInquiry/index.vue b/src/views/mold/workOrderInquiry/index.vue index 8fc1eabb..d77b72cc 100644 --- a/src/views/mold/workOrderInquiry/index.vue +++ b/src/views/mold/workOrderInquiry/index.vue @@ -254,7 +254,7 @@ const handleSelectionChange = (rows: TicketManagementVO[]) => { selectedRows.value = rows selectedIds.value = rows .map((r) => r.id) - .filter((id): id is number => typeof id === 'number') + .filter((id): id is string => id != null && id !== '') } const isUnworkedTicket = (row?: TicketManagementVO) => String(row?.jobStatus ?? '') === UNWORKED_JOB_STATUS diff --git a/src/views/report/dashboardList/index.vue b/src/views/report/dashboardList/index.vue index 61010def..50903335 100644 --- a/src/views/report/dashboardList/index.vue +++ b/src/views/report/dashboardList/index.vue @@ -309,9 +309,9 @@ const normalizeDeviceIdsList = (val: any): { deviceId: number; attributesIds: nu if (Array.isArray(val)) { return val .map((v: any) => ({ - deviceId: Number(v?.deviceId), + deviceId: String(v?.deviceId), attributesIds: Array.isArray(v?.attributesIds) - ? v.attributesIds.map((id: any) => Number(id)).filter((id: number) => !Number.isNaN(id)) + ? v.attributesIds.map((id: any) => String(id)).filter((id: string) => id !== '') : [] })) .filter((v) => v.deviceId && !Number.isNaN(v.deviceId)) @@ -397,8 +397,8 @@ const submitDialog = async () => { return } createForm.deviceIdsList = groups.map((g) => ({ - deviceId: Number(g.deviceId), - attributesIds: g.attributesIds.map((id: any) => Number(id)) + deviceId: String(g.deviceId), + attributesIds: g.attributesIds.map((id: any) => String(id)) })) } else { createForm.deviceIdsList = []