fix: 设备台账-修复雪花算法ID精度丢失问题

main
zhongwenkai 8 hours ago
parent b5d7ac1fd8
commit c75e31aab5

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

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

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

@ -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<DeviceLedgerVO | undefined>()
@ -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),

@ -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<DeviceLedgerDetailVO | undefined>()
const detailActiveTab = ref('check')
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
}
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 ?? ''
}

@ -350,7 +350,7 @@
>
<template #default="scope">
<el-tag effect="light">
{{ getDeviceTypeName(scope.row.deviceTypeName ?? scope.row.deviceType) }}
{{ getDeviceTypeName(scope.row.typeName ?? scope.row.deviceType) }}
</el-tag>
</template>
</el-table-column>
@ -677,7 +677,7 @@ const { t } = useI18n() // 国际化
const loading = ref(true) //
const list = ref<DeviceLedgerVO[]>([]) //
const total = ref(0) //
const selectedDeviceLineId = ref<number | undefined>(undefined)
const selectedDeviceLineId = ref<string | undefined>(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<number[]>([])
const selectedIds = ref<string[]>([])
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<number[]>([])
const deviceTypeTree = ref<DeviceTypeTreeVO[]>([])
const deviceTypeNameMap = ref<Record<number, string>>({})
const deviceTypeNameMap = ref<Record<string, string>>({})
const ALL_TYPE_NODE_ID = -1
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
@ -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()

Loading…
Cancel
Save