Merge remote-tracking branch 'origin/main'

main
liutao 8 hours ago
commit 0fead876fe

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

@ -506,7 +506,7 @@ defineOptions({ name: 'DvRepairForm' })
type RepairFormType = 'create' | 'update' | 'repair' | 'detail' | ''
interface DvRepairFormData extends Partial<DvRepairVO> {
deviceId?: number
deviceId?: string
componentId?: number
isShutdown?: boolean
isCode?: boolean
@ -607,13 +607,13 @@ const showComponentSelect = computed(() => formData.value.machineryTypeId === 2)
const selectedDeviceText = computed(() => {
const deviceId = formData.value.deviceId
if (typeof deviceId !== 'number') return ''
const option = deviceOptions.value.find((item) => item.value === deviceId)
if (deviceId == null || deviceId === '') return ''
const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId))
return option?.label || `ID:${deviceId}`
})
const deviceLoading = ref(false)
const deviceOptions = ref<{ label: string; value: number; raw?: DeviceLedgerVO }[]>([])
const deviceOptions = ref<{ label: string; value: string | number; raw?: DeviceLedgerVO }[]>([])
const deviceOptionsLoaded = ref(false)
const deviceDialogVisible = ref(false)
@ -697,7 +697,7 @@ const toComponentOption = (item: any) => {
return { label, value: id }
}
const loadComponentOptionsByDeviceId = async (deviceId: number) => {
const loadComponentOptionsByDeviceId = async (deviceId: string) => {
componentLoading.value = true
try {
const data = await RepairItemsApi.getComponentList(deviceId)
@ -810,7 +810,7 @@ const confirmDeviceSelection = (row?: DeviceLedgerVO) => {
return
}
const id = Number(selected.id)
const id = String(selected.id)
const label = `${selected.deviceCode ?? ''} ${selected.deviceName ?? ''}`.trim()
deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: id, raw: selected })
formData.value.deviceId = id
@ -854,12 +854,12 @@ watch(
if (isHydrating.value) return
formData.value.componentId = undefined
componentOptions.value = []
if (typeof deviceId !== 'number') {
if (deviceId == null || deviceId === '') {
setLineRows([])
return
}
const option = deviceOptions.value.find((item) => item.value === deviceId)
const option = deviceOptions.value.find((item) => String(item.value) === String(deviceId))
if (option?.raw) {
formData.value.machineryCode = option.raw.deviceCode
formData.value.machineryName = option.raw.deviceName
@ -883,7 +883,7 @@ watch(
if (isHydrating.value) return
if (formData.value.machineryTypeId !== 2) return
const deviceId = formData.value.deviceId
if (typeof deviceId !== 'number' || typeof componentId !== 'number') {
if (deviceId == null || deviceId === '' || typeof componentId !== 'number') {
setLineRows([])
return
}
@ -1103,14 +1103,14 @@ const open = async (type: string, id?: number) => {
formData.value.machineryTypeId = Number.isNaN(typeId) ? formData.value.machineryTypeId : typeId
const deviceId = formData.value.deviceId
const resolvedDeviceId = typeof deviceId === 'number' ? deviceId : formData.value.machineryId
if (typeof resolvedDeviceId === 'number') {
const resolvedDeviceId = (deviceId != null && deviceId !== '') ? deviceId : formData.value.machineryId
if (resolvedDeviceId != null && resolvedDeviceId !== '') {
formData.value.deviceId = resolvedDeviceId
const label = `${formData.value.machineryCode ?? ''} ${formData.value.machineryName ?? ''}`.trim() || `ID:${resolvedDeviceId}`
deviceOptions.value = upsertDeviceOption(deviceOptions.value, { label, value: resolvedDeviceId })
}
if (formData.value.machineryTypeId === 2 && typeof formData.value.deviceId === 'number') {
if (formData.value.machineryTypeId === 2 && formData.value.deviceId != null && formData.value.deviceId !== '') {
await loadComponentOptionsByDeviceId(formData.value.deviceId)
const componentId = typeof formData.value.componentId === 'number'
? formData.value.componentId

@ -416,7 +416,7 @@ const formData = ref({
name: undefined as string | undefined,
taskType: undefined as number | undefined,
deviceList: [] as string[],
projectForm: undefined as number | undefined,
projectForm: undefined as string | undefined,
dateRange: [] as string[],
cronExpression: undefined as string | undefined,
operableUsers: [] as string[],
@ -492,8 +492,7 @@ const open = async (type: string, row?: TaskManagementVO) => {
formData.value.deviceList = parseIdsValue((row as any).deviceList)
const projectFormIds = parseIdsValue((row as any).projectForm)
if (projectFormIds.length) {
const n = Number(projectFormIds[0])
formData.value.projectForm = Number.isFinite(n) ? n : undefined
formData.value.projectForm = projectFormIds[0] || undefined
const projectFormName = String((row as any).projectFormName ?? '').trim()
if (formData.value.projectForm !== undefined && projectFormName) {
planSelectionCache.value[String(formData.value.projectForm)] = {
@ -664,8 +663,8 @@ const confirmPlanSelection = (row?: PlanOption) => {
return
}
const id = Number(selected.id)
formData.value.projectForm = Number.isFinite(id) ? id : undefined
const id = String(selected.id)
formData.value.projectForm = id || undefined
cachePlanRows([selected])
planDialogVisible.value = false
formRef.value?.clearValidate?.('projectForm')

@ -301,7 +301,7 @@ type PlanOption = {
}
const planOptions = ref<PlanOption[]>([])
const deviceOptions = ref<{ id: number; label: string; raw?: DeviceLedgerVO }[]>([])
const deviceOptions = ref<{ id: string | number; label: string; raw?: DeviceLedgerVO }[]>([])
const users = ref<UserVO[]>([])
const queryParams = reactive({
@ -339,7 +339,7 @@ const ensureDeviceOptionsLoaded = async () => {
const deviceRes = await DeviceLedgerApi.getDeviceLedgerList()
const rows = (Array.isArray(deviceRes) ? deviceRes : deviceRes?.list ?? deviceRes?.data ?? []) as DeviceLedgerVO[]
deviceOptions.value = rows
.filter((item) => typeof item?.id === 'number')
.filter((item) => item?.id != null)
.map((item) => ({
id: item.id,
label: `${item.deviceCode ?? ''} ${item.deviceName ?? ''}`.trim() || String(item.id),

Loading…
Cancel
Save