fix(雪花ID): 全项目修复雪花算法ID精度丢失问题

main
zhongwenkai 1 day ago
parent f3fac8d655
commit 6c723087c0

@ -151,14 +151,14 @@ const typeTreeData = ref<DeviceTypeTreeVO[]>([])
const brandTreeData = ref<MoldBrandTreeVO[]>([])
const typeTreeProps = { label: 'name', children: 'children' }
const typeTreeExpandedKeys = ref<number[]>([0])
const deviceTypeNameMap = ref<Record<number, string>>({})
const deviceTypeNameMap = ref<Record<string, string>>({})
const buildDeviceTypeNameMap = (nodes: DeviceTypeTreeVO[]) => {
const map: Record<number, string> = {}
const map: Record<string, string> = {}
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

@ -607,7 +607,7 @@ const formRef = ref([]) // 表单 Ref
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const defaultWarehouse = ref<WarehouseVO>(undefined) //
const warehouseAreaMap = ref<Record<number, WarehouseAreaVO[]>>({})
const warehouseAreaMap = ref<Record<string, WarehouseAreaVO[]>>({})
const stockInCategoryTypeMap: Record<string, number> = {
产品入库: 1,
物料入库: 2,

@ -515,7 +515,7 @@ const formRef = ref([]) // 表单 Ref
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const defaultWarehouse = ref<WarehouseVO>(undefined) //
const warehouseAreaMap = ref<Record<number, WarehouseAreaVO[]>>({})
const warehouseAreaMap = ref<Record<string, WarehouseAreaVO[]>>({})
const resolveStockOutCategoryType = (outType?: string) => {
if (!outType) return undefined
if (outType.includes('产品')) return 1

@ -567,7 +567,7 @@ const open = async (type: string, row?: PalletVO, defaults?: Partial<PalletVO>)
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)
}
}

@ -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) => ({

@ -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<number | undefined>(undefined)
attributeDeviceId.value = Number(id)
const attributeDeviceId = ref<string | undefined>(undefined)
attributeDeviceId.value = String(id)
const deviceAlarmDialogVisible = ref(false)
const deviceAlarmList = ref<any[]>([])
const deviceAlarmTotal = ref(0)

@ -1855,7 +1855,7 @@ const handleCreateRuleSubmit = async () => {
createRuleFormLoading.value = false
}
}
const connectLoadingMap = reactive<Record<number, boolean>>({})
const connectLoadingMap = reactive<Record<string, boolean>>({})
const getRowConnectValue = (row: any) => {
return row?.isConnect ?? row?.status

@ -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',

@ -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()

@ -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

@ -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',

@ -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 = () => {

@ -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)
}

@ -124,8 +124,8 @@ const dictStore = useDictStoreWithOut()
const dictReady = ref(false)
//
const expandLoadingMap = ref<Record<number, boolean>>({})
const expandDataMap = ref<Record<number, any[]>>({})
const expandLoadingMap = ref<Record<string, boolean>>({})
const expandDataMap = ref<Record<string, any[]>>({})
/** 查询列表 */
const getList = async () => {

@ -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<number[]>([])
const moldIds= ref<number[]>([])
const ids = ref<string[]>([])
const moldIds= ref<string[]>([])
const itemList = ref<DeviceLedgerVO[]>([])
const moldItemList = ref<MoldVO[]>([])
const deviceSelectDialogRef = ref<InstanceType<typeof TableSelectDialog> | null>(null)
@ -706,7 +706,7 @@ const downMoldLoading = ref(false)
const downMoldTarget = ref<any>(null)
const downMoldFormRef = ref()
const downMoldForm = reactive({
moldIds: [] as number[],
moldIds: [] as string[],
operatorId: undefined as number | undefined,
operateTime: '',
remark: ''

@ -125,8 +125,8 @@ const dictStore = useDictStoreWithOut()
const dictReady = ref(false)
//
const expandLoadingMap = ref<Record<number, boolean>>({})
const expandDataMap = ref<Record<number, any[]>>({})
const expandLoadingMap = ref<Record<string, boolean>>({})
const expandDataMap = ref<Record<string, any[]>>({})
/** 查询列表 */
const getList = async () => {

@ -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
}

@ -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}`
}

@ -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<number | string> => {
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)

@ -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<TaskVO | null>(null)
const activeTabName = ref('basicInfo')

@ -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}`

@ -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
})

@ -299,8 +299,8 @@ const queryParams = reactive({
const taskList = ref<any[]>([])
const detailList = ref<any[]>([])
const currentTask = ref<any>()
const allDetailsMap = ref<Record<number, any[]>>({}) // store details per taskId
const taskDetailRequestMap = new Map<number, Promise<any[]>>()
const allDetailsMap = ref<Record<string, any[]>>({}) // store details per taskId
const taskDetailRequestMap = new Map<string, Promise<any[]>>()
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<string, any>) => {
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)
}
}

@ -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 () => {

@ -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)

@ -119,14 +119,12 @@ const parseIds = (value: any): Array<number | string> => {
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<DvSubjectVO[]>([])
@ -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 = () => {

@ -460,7 +460,7 @@ import { useUserStore } from '@/store/modules/user'
defineOptions({ name: 'MoldRepairForm' })
interface MoldRepairFormData extends Partial<MoldRepairVO> {
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 })

@ -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 }]
}

@ -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')

@ -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

@ -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 = []

Loading…
Cancel
Save