main
liutao 2 weeks ago
parent 5325880ecb
commit 2534340dda

@ -618,28 +618,6 @@ const setDefaultSelections = () => {
})
}
//
const setBJDefaultSelections = () => {
// DOM
nextTick(() => {
if (!bjMultipleTableRef.value) return
bjMultipleTableRef.value.clearSelection()
const rawSubjectIds = toRaw(formData.value.beijianIds)
if (rawSubjectIds.length != 0) {
let row = {
id: undefined
}
bjMultipleTableRef.value.toggleRowSelection(row, true)
}
//
bjList.value.forEach(row => {
let id = row.id;
if (rawSubjectIds.includes(row.id)) {
bjMultipleTableRef.value.toggleRowSelection(row, true)
}
})
})
}
const normalizeNumberish = (value: any): number | undefined => {
if (value === null || value === undefined || value === '') return undefined
if (typeof value === 'number') return Number.isFinite(value) ? value : undefined
@ -949,8 +927,78 @@ const getDetail = async () => {
}
}
// 1 data
watch(bjList, (newData, oldData) => {
//
if (newData.length > 0) {
//
setBJDefaultSelections()
}
}, { deep: true })
//const defaultSelectedIds = [144, 143,141]
//
const setBJDefaultSelections = () => {
// DOM
nextTick(() => {
if (!bjMultipleTableRef.value) return
bjMultipleTableRef.value.clearSelection()
const rawSubjectIds = toRaw(formData.value.beijianIds)
if (rawSubjectIds.length != 0) {
let row = {
id: undefined
}
bjMultipleTableRef.value.toggleRowSelection(row, true)
}
//
bjList.value.forEach(row => {
let id = row.id;
if (rawSubjectIds.includes(row.id)) {
bjMultipleTableRef.value.toggleRowSelection(row, true)
}
})
})
}
async function initForm() {
//
if (deviceId.value) {
formLoading.value = true
try {
const detail = await DeviceLedgerApi.getDeviceLedger(deviceId.value)
const templateJson = (detail as any)?.templateJson
const parsedTemplateJson = typeof templateJson === 'string'
? JSON.parse(templateJson)
: templateJson
formData.value = {
...initFormData(),
...(detail as any),
templateJson: parsedTemplateJson,
isCode: (detail as any)?.isCode ?? false,
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),
deviceManagerIds: parseIdsValue((detail as any)?.deviceManager),
productionDate: normalizeYmd((detail as any)?.productionDate),
factoryEntryDate: normalizeYmd((detail as any)?.factoryEntryDate),
componentIds: parseIdsValue((detail as any)?.componentId),
beijianIds: parseIdsValue((detail as any)?.beijianId),
qrcodeUrl: (detail as any)?.qrcodeUrl,
}
savedCriticalComponentOptions.value = buildCriticalComponentOptions((detail as any)?.componentList ?? [])
savedBeijianOptions.value = buildBeijianOptions((detail as any)?.beijianList ?? [])
} finally {
formLoading.value = false
}
}
}
onMounted(async () => {
await ensureOptionsLoaded()
initForm()
// await getDetail()
getList()

Loading…
Cancel
Save