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