|
|
|
|
@ -874,15 +874,15 @@ const updateActionBarRectAfterLayout = () => {
|
|
|
|
|
}
|
|
|
|
|
const criticalComponentDialogVisible = ref(false)
|
|
|
|
|
const beijianDialogVisible = ref(false)
|
|
|
|
|
const criticalComponentDraft = ref<number[]>([])
|
|
|
|
|
const beijianDraft = ref<number[]>([])
|
|
|
|
|
const criticalComponentDraft = ref<(number | string)[]>([])
|
|
|
|
|
const beijianDraft = ref<(number | string)[]>([])
|
|
|
|
|
const list = ref<CriticalComponentVO[]>([])
|
|
|
|
|
const bjList = ref<ProductVO[]>([])
|
|
|
|
|
const loading = ref(true)
|
|
|
|
|
const total = ref(0)
|
|
|
|
|
const bjTotal = ref(0)
|
|
|
|
|
const selectedIds = ref<number[]>([])
|
|
|
|
|
const bjSelectedIds = ref<number[]>([])
|
|
|
|
|
const selectedIds = ref<(number | string)[]>([])
|
|
|
|
|
const bjSelectedIds = ref<(number | string)[]>([])
|
|
|
|
|
// 琛ㄦ牸寮曠敤
|
|
|
|
|
const multipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
|
|
const bjMultipleTableRef = ref<InstanceType<typeof ElTable>>()
|
|
|
|
|
@ -896,13 +896,13 @@ const iotDeviceTotal = ref(0)
|
|
|
|
|
const iotDeviceSelectedLabel = ref('')
|
|
|
|
|
const iotDeviceDraftId = ref<string | undefined>()
|
|
|
|
|
const iotDeviceDraftRow = ref<DeviceVO | undefined>()
|
|
|
|
|
const parseIdsValue = (value: any): number[] => {
|
|
|
|
|
const parseIdsValue = (value: any): (number | string)[] => {
|
|
|
|
|
if (!value) return []
|
|
|
|
|
if (Array.isArray(value)) return value.map((v) => Number(v)).filter((v) => !Number.isNaN(v))
|
|
|
|
|
if (Array.isArray(value)) return value.map((v) => String(v)).filter((v) => v !== '')
|
|
|
|
|
return String(value)
|
|
|
|
|
.split(',')
|
|
|
|
|
.map((v) => Number(v.trim()))
|
|
|
|
|
.filter((v) => !Number.isNaN(v))
|
|
|
|
|
.map((v) => String(v.trim()))
|
|
|
|
|
.filter((v) => v !== '')
|
|
|
|
|
}
|
|
|
|
|
const selectedRows = ref<any[]>([]) // 瀛樺偍鎵€鏈夐€変腑鐨勮
|
|
|
|
|
const bjSelectedRows = ref<any[]>([]) // 瀛樺偍鎵€鏈夐€変腑鐨勮
|
|
|
|
|
@ -951,12 +951,12 @@ const bjResetQuery = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 !== undefined && id !== null && id !== '')
|
|
|
|
|
// 鑾峰彇褰撳墠椤垫墍鏈夎锟?id
|
|
|
|
|
const currentPageIds = rows.map((item) => item.id)
|
|
|
|
|
const currentPageIds = rows.map((item) => String(item.id))
|
|
|
|
|
|
|
|
|
|
// 浠庡凡閫変腑鐨勬暟缁勪腑绉婚櫎褰撳墠椤电殑鏁版嵁
|
|
|
|
|
selectedRows.value = selectedRows.value.filter((item) => !currentPageIds.includes(item.id))
|
|
|
|
|
selectedRows.value = selectedRows.value.filter((item) => !currentPageIds.includes(String(item.id)))
|
|
|
|
|
// 娣诲姞褰撳墠椤垫柊閫変腑鐨勬暟锟? selectedRows.value.push(...rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -967,21 +967,16 @@ const handleSelect = (selection: any[], row: any) => {
|
|
|
|
|
const isSelected = selection.includes(row)
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// console.log(`锟?琛岃閫変腑: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
ids.value.push(row.id)
|
|
|
|
|
ids.value.push(String(row.id))
|
|
|
|
|
} else {
|
|
|
|
|
ids.value = ids.value.filter((item) => item !== row.id)
|
|
|
|
|
ids.value = ids.value.filter((item) => String(item) !== String(row.id))
|
|
|
|
|
// console.log(`锟?琛岃鍙栨秷閫変腑: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
}
|
|
|
|
|
// 鏇存柊褰撳墠閫変腑鐘讹拷? currentSelectedRows.value = selection
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const handleSelectAll = (selection) => {
|
|
|
|
|
ids.value = selection?.map((row) => row.id).filter((id) => id !== undefined) ?? []
|
|
|
|
|
|
|
|
|
|
/* let newVar = selection?.map((row) => row.id).filter((id) => id !== undefined) ?? [];
|
|
|
|
|
newVar.forEach(row => {
|
|
|
|
|
ids.value.push(row)
|
|
|
|
|
})*/
|
|
|
|
|
ids.value = selection?.map((row) => String(row.id)).filter((id) => id !== '') ?? []
|
|
|
|
|
}
|
|
|
|
|
const confirmCriticalComponentDialog = () => {
|
|
|
|
|
//let ids = selectedRows.value.map(item => item.id);
|
|
|
|
|
@ -993,12 +988,12 @@ const confirmCriticalComponentDialog = () => {
|
|
|
|
|
//multipleTableRef.value.clearSelection()
|
|
|
|
|
}
|
|
|
|
|
const filterValidSelectedIds = (selectedIds: any[], options: SelectionOption[]) => {
|
|
|
|
|
const validIds = new Set(options.map((item) => item.value))
|
|
|
|
|
const validIds = new Set(options.map((item) => String(item.value)))
|
|
|
|
|
return Array.from(
|
|
|
|
|
new Set(
|
|
|
|
|
(selectedIds ?? [])
|
|
|
|
|
.map((id) => normalizeNumberish(id))
|
|
|
|
|
.filter((id): id is number => id !== undefined && validIds.has(id))
|
|
|
|
|
.map((id) => (id === undefined || id === null || id === '' ? undefined : String(id)))
|
|
|
|
|
.filter((id): id is string => id !== undefined && validIds.has(id))
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
@ -1012,12 +1007,12 @@ const confirmBeijianDialog = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bjHandleSelectionChange = (rows: CriticalComponentVO[]) => {
|
|
|
|
|
bjSelectedIds.value = rows.map((r) => r.id).filter((id): id is number => typeof id === 'number')
|
|
|
|
|
bjSelectedIds.value = rows.map((r) => r.id).filter((id) => id !== undefined && id !== null && id !== '')
|
|
|
|
|
// 鑾峰彇褰撳墠椤垫墍鏈夎锟?id
|
|
|
|
|
const currentPageIds = rows.map((item) => item.id)
|
|
|
|
|
const currentPageIds = rows.map((item) => String(item.id))
|
|
|
|
|
|
|
|
|
|
// 浠庡凡閫変腑鐨勬暟缁勪腑绉婚櫎褰撳墠椤电殑鏁版嵁
|
|
|
|
|
bjSelectedRows.value = bjSelectedRows.value.filter((item) => !currentPageIds.includes(item.id))
|
|
|
|
|
bjSelectedRows.value = bjSelectedRows.value.filter((item) => !currentPageIds.includes(String(item.id)))
|
|
|
|
|
// 娣诲姞褰撳墠椤垫柊閫変腑鐨勬暟锟? bjSelectedRows.value.push(...rows)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1028,16 +1023,16 @@ const bjHandleSelect = (selection: any[], row: any) => {
|
|
|
|
|
const isSelected = selection.includes(row)
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// console.log(`锟?琛岃閫変腑: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
bjIds.value.push(row.id)
|
|
|
|
|
bjIds.value.push(String(row.id))
|
|
|
|
|
} else {
|
|
|
|
|
bjIds.value = bjIds.value.filter((item) => item !== row.id)
|
|
|
|
|
bjIds.value = bjIds.value.filter((item) => String(item) !== String(row.id))
|
|
|
|
|
// console.log(`锟?琛岃鍙栨秷閫変腑: ID=${row.id}, Name=${row.name}`)
|
|
|
|
|
}
|
|
|
|
|
// 鏇存柊褰撳墠閫変腑鐘讹拷? bjCurrentSelectedRows.value = selection
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bjHandleSelectAll = (selection) => {
|
|
|
|
|
bjIds.value = selection?.map((row) => row.id).filter((id) => id !== undefined) ?? []
|
|
|
|
|
bjIds.value = selection?.map((row) => String(row.id)).filter((id) => id !== '') ?? []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getList = async () => {
|
|
|
|
|
@ -1075,7 +1070,7 @@ const toggleSelection = () => {
|
|
|
|
|
|
|
|
|
|
// 閬嶅巻褰撳墠椤电殑鏁版嵁
|
|
|
|
|
list.value.forEach((row) => {
|
|
|
|
|
const isSelected = selectedRows.value.some((item) => item.id === row.id)
|
|
|
|
|
const isSelected = selectedRows.value.some((item) => String(item.id) === String(row.id))
|
|
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 濡傛灉搴旇閫変腑锛屽氨閫変腑
|
|
|
|
|
@ -1092,7 +1087,7 @@ const bjToggleSelection = () => {
|
|
|
|
|
|
|
|
|
|
// 閬嶅巻褰撳墠椤电殑鏁版嵁
|
|
|
|
|
bjList.value.forEach((row) => {
|
|
|
|
|
const isSelected = bjSelectedRows.value.some((item) => item.id === row.id)
|
|
|
|
|
const isSelected = bjSelectedRows.value.some((item) => String(item.id) === String(row.id))
|
|
|
|
|
|
|
|
|
|
if (isSelected) {
|
|
|
|
|
// 濡傛灉搴旇閫変腑锛屽氨閫変腑
|
|
|
|
|
@ -1104,19 +1099,19 @@ const bjToggleSelection = () => {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
const selectedDeviceRows = ref<any[]>([])
|
|
|
|
|
const ids = ref<number[]>([])
|
|
|
|
|
const bjIds = ref<number[]>([])
|
|
|
|
|
const ids = ref<(number | string)[]>([])
|
|
|
|
|
const bjIds = ref<(number | string)[]>([])
|
|
|
|
|
const openCriticalComponentDialog = () => {
|
|
|
|
|
queryParams.name = ''
|
|
|
|
|
queryParams.description = ''
|
|
|
|
|
queryParams.code = ''
|
|
|
|
|
const rows = selectedDeviceRows.value.map((item) => ({ ...item, id: Number(item.id) }))
|
|
|
|
|
const rows = selectedDeviceRows.value.map((item) => ({ ...item, id: String(item.id) }))
|
|
|
|
|
criticalComponentSelectDialogRef.value?.open(rows)
|
|
|
|
|
let initIds =
|
|
|
|
|
formData.value.componentIds != undefined
|
|
|
|
|
? formData.value.componentIds.toString().split(',')
|
|
|
|
|
: []
|
|
|
|
|
ids.value = initIds.map((id) => Number(id))
|
|
|
|
|
ids.value = initIds.map((id) => String(id)).filter((id) => id !== '')
|
|
|
|
|
}
|
|
|
|
|
const openBeijianDialog = () => {
|
|
|
|
|
beijianDraft.value = [...(formData.value.beijianIds ?? [])]
|
|
|
|
|
@ -1131,7 +1126,7 @@ const setDefaultSelections = () => {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
if (!multipleTableRef.value) return
|
|
|
|
|
multipleTableRef.value.clearSelection()
|
|
|
|
|
const rawSubjectIds = toRaw(formData.value.componentIds)
|
|
|
|
|
const rawSubjectIds = (toRaw(formData.value.componentIds) ?? []).map((v) => String(v))
|
|
|
|
|
if (rawSubjectIds.length != 0) {
|
|
|
|
|
let row = {
|
|
|
|
|
id: undefined
|
|
|
|
|
@ -1140,7 +1135,7 @@ const setDefaultSelections = () => {
|
|
|
|
|
}
|
|
|
|
|
// 閬嶅巻鏁版嵁锛屾壘鍒伴渶瑕侀€変腑鐨勮
|
|
|
|
|
list.value.forEach((row) => {
|
|
|
|
|
if (rawSubjectIds.includes(row.id)) {
|
|
|
|
|
if (rawSubjectIds.includes(String(row.id))) {
|
|
|
|
|
multipleTableRef.value!.toggleRowSelection(row, true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
@ -1199,14 +1194,14 @@ const initFormData = () => ({
|
|
|
|
|
workshop: undefined,
|
|
|
|
|
deviceLocation: undefined,
|
|
|
|
|
systemOrg: undefined,
|
|
|
|
|
deviceManagerIds: [] as number[],
|
|
|
|
|
deviceManagerIds: [] as (number | string)[],
|
|
|
|
|
productionDate: undefined,
|
|
|
|
|
factoryEntryDate: undefined,
|
|
|
|
|
sn: undefined,
|
|
|
|
|
outgoingTime: undefined,
|
|
|
|
|
remark: undefined,
|
|
|
|
|
componentIds: [] as number[],
|
|
|
|
|
beijianIds: [] as number[],
|
|
|
|
|
componentIds: [] as (number | string)[],
|
|
|
|
|
beijianIds: [] as (number | string)[],
|
|
|
|
|
fileUrl: '',
|
|
|
|
|
qrcodeUrl: undefined,
|
|
|
|
|
templateJson: undefined,
|
|
|
|
|
@ -1302,29 +1297,31 @@ const findDeviceTypeName = (id: string | number): string | undefined => {
|
|
|
|
|
return undefined
|
|
|
|
|
}
|
|
|
|
|
const users = ref<UserVO[]>([])
|
|
|
|
|
type SelectionOption = { label: string; value: number }
|
|
|
|
|
type SelectionOption = { label: string; value: number | string }
|
|
|
|
|
const criticalComponentOptions = ref<SelectionOption[]>([])
|
|
|
|
|
const beijianOptions = ref<SelectionOption[]>([])
|
|
|
|
|
const savedCriticalComponentOptions = ref<SelectionOption[]>([])
|
|
|
|
|
const savedBeijianOptions = ref<SelectionOption[]>([])
|
|
|
|
|
const editableCriticalComponentRows = ref<any[]>([])
|
|
|
|
|
const getCriticalComponentId = (item: any): number | undefined =>
|
|
|
|
|
normalizeNumberish(
|
|
|
|
|
const getCriticalComponentId = (item: any): string | undefined => {
|
|
|
|
|
const raw =
|
|
|
|
|
item?.componentId ??
|
|
|
|
|
item?.criticalComponentId ??
|
|
|
|
|
item?.criticalId ??
|
|
|
|
|
item?.criticalComponent?.id ??
|
|
|
|
|
item?.component?.id ??
|
|
|
|
|
item?.id
|
|
|
|
|
)
|
|
|
|
|
item?.criticalComponentId ??
|
|
|
|
|
item?.criticalId ??
|
|
|
|
|
item?.criticalComponent?.id ??
|
|
|
|
|
item?.component?.id ??
|
|
|
|
|
item?.id
|
|
|
|
|
if (raw === undefined || raw === null || raw === '') return undefined
|
|
|
|
|
return String(raw)
|
|
|
|
|
}
|
|
|
|
|
const buildCriticalComponentOptions = (items: any[] = []): SelectionOption[] =>
|
|
|
|
|
(items ?? [])
|
|
|
|
|
.map((item: any) => {
|
|
|
|
|
const id = normalizeNumberish(item?.id)
|
|
|
|
|
if (id === undefined) return undefined
|
|
|
|
|
if (item?.id === undefined || item?.id === null || item?.id === '') return undefined
|
|
|
|
|
const id = String(item.id)
|
|
|
|
|
const code = item.code ? String(item.code) : ''
|
|
|
|
|
const name = item.name ? String(item.name) : ''
|
|
|
|
|
const label = code && name ? `${code}-${name}` : name || code || String(id)
|
|
|
|
|
const label = code && name ? `${code}-${name}` : name || code || id
|
|
|
|
|
return { label, value: id }
|
|
|
|
|
})
|
|
|
|
|
.filter((item): item is SelectionOption => Boolean(item))
|
|
|
|
|
@ -1332,24 +1329,24 @@ const buildCriticalComponentOptions = (items: any[] = []): SelectionOption[] =>
|
|
|
|
|
const buildBeijianOptions = (items: any[] = []): SelectionOption[] =>
|
|
|
|
|
(items ?? [])
|
|
|
|
|
.map((item: any) => {
|
|
|
|
|
const id = normalizeNumberish(item?.id)
|
|
|
|
|
if (id === undefined) return undefined
|
|
|
|
|
if (item?.id === undefined || item?.id === null || item?.id === '') return undefined
|
|
|
|
|
const id = String(item.id)
|
|
|
|
|
const code = item.barCode ? String(item.barCode) : ''
|
|
|
|
|
const name = item.name ? String(item.name) : ''
|
|
|
|
|
const label = code && name ? `${code}-${name}` : name || code || String(id)
|
|
|
|
|
const label = code && name ? `${code}-${name}` : name || code || id
|
|
|
|
|
return { label, value: id }
|
|
|
|
|
})
|
|
|
|
|
.filter((item): item is SelectionOption => Boolean(item))
|
|
|
|
|
|
|
|
|
|
const mergeSelectionOptions = (...groups: SelectionOption[][]): SelectionOption[] => {
|
|
|
|
|
const optionMap = new Map<number, SelectionOption>()
|
|
|
|
|
groups.flat().forEach((item) => optionMap.set(item.value, item))
|
|
|
|
|
const optionMap = new Map<string, SelectionOption>()
|
|
|
|
|
groups.flat().forEach((item) => optionMap.set(String(item.value), item))
|
|
|
|
|
return Array.from(optionMap.values())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const formatSelectedSummary = (ids: number[], options: SelectionOption[]) => {
|
|
|
|
|
const optionMap = new Map<number, string>(options.map((item) => [item.value, item.label]))
|
|
|
|
|
const labels = ids.map((id) => optionMap.get(id)).filter((v): v is string => Boolean(v))
|
|
|
|
|
const formatSelectedSummary = (ids: (number | string)[], options: SelectionOption[]) => {
|
|
|
|
|
const optionMap = new Map<string, string>(options.map((item) => [String(item.value), item.label]))
|
|
|
|
|
const labels = ids.map((id) => optionMap.get(String(id))).filter((v): v is string => Boolean(v))
|
|
|
|
|
if (!labels.length) return ''
|
|
|
|
|
if (labels.length <= 3) return labels.join(', ')
|
|
|
|
|
return `${labels.slice(0, 3).join(', ')}...${labels.length}`
|
|
|
|
|
@ -1365,8 +1362,8 @@ const criticalComponentDisplay = computed(() =>
|
|
|
|
|
if (!list.value.length) {
|
|
|
|
|
return formData.value.machineId ? String(formData.value.machineId) : ''
|
|
|
|
|
}
|
|
|
|
|
const map = new Map(list.value.map((item) => [item.id, item.name]))
|
|
|
|
|
const names = ids.value.map((id) => map.get(id)).filter((name) => name)
|
|
|
|
|
const map = new Map(list.value.map((item) => [String(item.id), item.name]))
|
|
|
|
|
const names = ids.value.map((id) => map.get(String(id))).filter((name) => name)
|
|
|
|
|
return names.join(',')
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
@ -1385,17 +1382,17 @@ const buildCriticalComponentTableRows = () => {
|
|
|
|
|
return detailList.map((item: any) => ({ ...item, count: normalizeNumberish(item?.count) ?? 0 }))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedIds = new Set<number>(
|
|
|
|
|
const selectedIds = new Set<string>(
|
|
|
|
|
(formData.value.componentIds ?? [])
|
|
|
|
|
.map((id: any) => Number(id))
|
|
|
|
|
.filter((id: number) => !Number.isNaN(id))
|
|
|
|
|
.map((id: any) => String(id))
|
|
|
|
|
.filter((id: string) => id !== '')
|
|
|
|
|
)
|
|
|
|
|
if (!selectedIds.size) return []
|
|
|
|
|
|
|
|
|
|
const optionMap = new Map<number, any>()
|
|
|
|
|
const optionMap = new Map<string, any>()
|
|
|
|
|
;[...criticalComponentOptions.value, ...savedCriticalComponentOptions.value].forEach(
|
|
|
|
|
(item: any) => {
|
|
|
|
|
optionMap.set(Number(item.value), item)
|
|
|
|
|
optionMap.set(String(item.value), item)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
@ -1693,7 +1690,7 @@ const buildSubmitData = () => {
|
|
|
|
|
const componentRows = editableCriticalComponentRows.value
|
|
|
|
|
.map((row: any) => ({
|
|
|
|
|
...row,
|
|
|
|
|
id: normalizeNumberish(row?.id),
|
|
|
|
|
id: row?.id != null && row?.id !== '' ? String(row.id) : undefined,
|
|
|
|
|
count: normalizeNumberish(row?.count) ?? 0
|
|
|
|
|
}))
|
|
|
|
|
.filter((row: any) => row.id !== undefined)
|
|
|
|
|
@ -1798,7 +1795,7 @@ const setBJDefaultSelections = () => {
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
if (!bjMultipleTableRef.value) return
|
|
|
|
|
bjMultipleTableRef.value.clearSelection()
|
|
|
|
|
const rawSubjectIds = toRaw(formData.value.beijianIds)
|
|
|
|
|
const rawSubjectIds = (toRaw(formData.value.beijianIds) ?? []).map((v) => String(v))
|
|
|
|
|
if (rawSubjectIds.length != 0) {
|
|
|
|
|
let row = {
|
|
|
|
|
id: undefined
|
|
|
|
|
@ -1807,7 +1804,7 @@ const setBJDefaultSelections = () => {
|
|
|
|
|
}
|
|
|
|
|
// 閬嶅巻鏁版嵁锛屾壘鍒伴渶瑕侀€変腑鐨勮
|
|
|
|
|
bjList.value.forEach((row) => {
|
|
|
|
|
if (rawSubjectIds.includes(row.id)) {
|
|
|
|
|
if (rawSubjectIds.includes(String(row.id))) {
|
|
|
|
|
bjMultipleTableRef.value!.toggleRowSelection(row, true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
@ -1872,22 +1869,22 @@ const handleCriticalComponentSelectConfirm = (payload: {
|
|
|
|
|
}) => {
|
|
|
|
|
formData.value.devices = payload.rows
|
|
|
|
|
.map((item) => {
|
|
|
|
|
const id = Number(item.id)
|
|
|
|
|
if (!Number.isFinite(id)) return undefined
|
|
|
|
|
if (item?.id === undefined || item?.id === null || item?.id === '') return undefined
|
|
|
|
|
const id = String(item.id)
|
|
|
|
|
return {
|
|
|
|
|
id,
|
|
|
|
|
name: item.deviceName || 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.componentIds = payload.ids.join(',')
|
|
|
|
|
ids.value = payload.ids.map((id) => Number(id))
|
|
|
|
|
ids.value = payload.ids.map((id) => String(id)).filter((id) => id !== '')
|
|
|
|
|
appendSelectedCriticalComponentRows(ids.value)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const buildCriticalComponentRowById = (id: number) => {
|
|
|
|
|
const row = selectedRows.value.find((item: any) => normalizeNumberish(item.id) === id)
|
|
|
|
|
const buildCriticalComponentRowById = (id: string) => {
|
|
|
|
|
const row = selectedRows.value.find((item: any) => String(item.id) === String(id))
|
|
|
|
|
if (row) {
|
|
|
|
|
return {
|
|
|
|
|
...row,
|
|
|
|
|
@ -1899,7 +1896,7 @@ const buildCriticalComponentRowById = (id: number) => {
|
|
|
|
|
const option = mergeSelectionOptions(
|
|
|
|
|
savedCriticalComponentOptions.value,
|
|
|
|
|
criticalComponentOptions.value
|
|
|
|
|
).find((item) => item.value === id)
|
|
|
|
|
).find((item) => String(item.value) === String(id))
|
|
|
|
|
const label = option?.label ?? String(id)
|
|
|
|
|
const [code, ...nameParts] = label.split('-')
|
|
|
|
|
return {
|
|
|
|
|
@ -1913,21 +1910,21 @@ const buildCriticalComponentRowById = (id: number) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const appendSelectedCriticalComponentRows = (selectedIds: number[]) => {
|
|
|
|
|
const appendSelectedCriticalComponentRows = (selectedIds: (number | string)[]) => {
|
|
|
|
|
const existingIds = new Set(
|
|
|
|
|
editableCriticalComponentRows.value
|
|
|
|
|
.map((row: any) => getCriticalComponentId(row))
|
|
|
|
|
.filter((id): id is number => id !== undefined)
|
|
|
|
|
.filter((id): id is string => id !== undefined)
|
|
|
|
|
)
|
|
|
|
|
const rowsToAppend = selectedIds
|
|
|
|
|
.filter((id) => !existingIds.has(id))
|
|
|
|
|
.map((id) => buildCriticalComponentRowById(id))
|
|
|
|
|
.filter((id) => !existingIds.has(String(id)))
|
|
|
|
|
.map((id) => buildCriticalComponentRowById(String(id)))
|
|
|
|
|
if (rowsToAppend.length) {
|
|
|
|
|
editableCriticalComponentRows.value = [...editableCriticalComponentRows.value, ...rowsToAppend]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
|
|
|
|
|
const buildIdsParam = (ids: number | number[]) => {
|
|
|
|
|
const buildIdsParam = (ids: number | string | (number | string)[]) => {
|
|
|
|
|
return Array.isArray(ids) ? ids.join(',') : String(ids)
|
|
|
|
|
}
|
|
|
|
|
const handleDelete = async (id: string) => {
|
|
|
|
|
@ -1935,7 +1932,7 @@ const handleDelete = async (id: string) => {
|
|
|
|
|
// 鍒犻櫎鐨勪簩娆$‘璁?
|
|
|
|
|
await message.delConfirm()
|
|
|
|
|
editableCriticalComponentRows.value = editableCriticalComponentRows.value.filter(
|
|
|
|
|
(item: any) => item.id !== id
|
|
|
|
|
(item: any) => String(item.id) !== String(id)
|
|
|
|
|
)
|
|
|
|
|
await DeviceLedgerApi.deleteDeviceCriticalComponent(id)
|
|
|
|
|
message.success(t('common.delSuccess'))
|
|
|
|
|
|