style: 备件出库关联设备选择优化

master
zhongwenkai 15 hours ago
parent 47c9c3941c
commit 4bb71a72fc

@ -186,6 +186,7 @@ function setPurpose(value) {
selectedMaintainOrder.value = null
repairOrderOptions.value = []
maintainOrderOptions.value = []
if (value === 'repair') loadRepairDeviceIds()
if (value === 'maintain') loadMaintainDeviceIds()
}
@ -196,10 +197,12 @@ const selectedRepairOrder = ref(null)
const maintainOrderOptions = ref([])
const selectedMaintainOrder = ref(null)
const maintainDeviceIds = ref(new Set())
const repairDeviceIds = ref(new Set())
const deviceLoading = ref(false)
const filteredDeviceOptions = computed(() => {
if (selectedPurpose.value === 'maintain') return deviceOptions.value.filter(d => maintainDeviceIds.value.has(d.value))
if (selectedPurpose.value === 'repair') return deviceOptions.value.filter(d => repairDeviceIds.value.has(d.value))
return deviceOptions.value
})
const currentOrder = computed(() => selectedPurpose.value === 'repair' ? selectedRepairOrder.value : selectedMaintainOrder.value)
@ -390,6 +393,28 @@ async function loadMaintainDeviceIds() {
} catch (e) { console.error('loadMaintainDeviceIds error', e) }
finally { deviceLoading.value = false }
}
async function loadRepairDeviceIds() {
deviceLoading.value = true
try {
// 100
const allRecords = []
for (let page = 1; page <= 5; page++) {
const res = await getDvRepairPage({ pageNo: page, pageSize: 100 })
const data = res && res.data !== undefined ? res.data : res
const records = Array.isArray(data) ? data : (data?.list || data?.records || [])
allRecords.push(...records)
if (records.length < 100) break
}
const deviceCodes = new Set(allRecords.map(r => r.machineryCode || r.deviceCode || r.deviceName).filter(Boolean))
const ids = new Set()
for (const d of deviceOptions.value) {
if (deviceCodes.has(d.deviceCode) || deviceCodes.has(d.label) || deviceCodes.has(d.deviceName)) ids.add(d.value)
}
repairDeviceIds.value = ids
console.log('[loadRepairDeviceIds] 维修单设备编码:', [...deviceCodes], '匹配到的设备数:', ids.size)
} catch (e) { console.error('loadRepairDeviceIds error', e) }
finally { deviceLoading.value = false }
}
async function loadDevices() {
try {
const res = await getDeviceLedgerList({ pageNo: 1, pageSize: 100 })
@ -525,7 +550,8 @@ onShow(async () => {
} catch (e) { console.error('获取备件详情失败:', e) }
}
}
loadDevices()
await loadDevices()
loadRepairDeviceIds()
loadWarehouses()
})

Loading…
Cancel
Save