|
|
|
|
@ -76,6 +76,7 @@ const fullscreenTargetRef = ref()
|
|
|
|
|
const { isFullscreen, toggle: toggleFullscreen } = useFullscreen(fullscreenTargetRef)
|
|
|
|
|
const deviceLedgerList = ref<DeviceLedgerVO[]>([])
|
|
|
|
|
const groupOptions = ref<OrganizationTreeOption[]>([])
|
|
|
|
|
let deviceLedgerRequestSeq = 0
|
|
|
|
|
|
|
|
|
|
const createDateRangeByQuickKey = (key: QuickRangeKey): [string, string] => {
|
|
|
|
|
const format = 'YYYY-MM-DD HH:mm:ss'
|
|
|
|
|
@ -143,7 +144,7 @@ const collectGroupIds = (groupId?: string) => {
|
|
|
|
|
return ids
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const hasIotDeviceCode = (item: DeviceLedgerVO) => String(item.iotDeviceCode ?? '').trim() !== ''
|
|
|
|
|
const hasIotDeviceId = (item: DeviceLedgerVO) => String(item.dvId ?? '').trim() !== ''
|
|
|
|
|
|
|
|
|
|
const getDeviceOptionLabel = (item: DeviceLedgerVO) => {
|
|
|
|
|
const deviceName = String(item.deviceName ?? '').trim()
|
|
|
|
|
@ -156,11 +157,11 @@ const collectDeviceOptionsByGroup = (groupId?: string) => {
|
|
|
|
|
const groupIds = collectGroupIds(groupId)
|
|
|
|
|
deviceLedgerList.value.forEach((item) => {
|
|
|
|
|
if (groupIds && !groupIds.has(String(item.deviceLine ?? ''))) return
|
|
|
|
|
const deviceCode = String(item.iotDeviceCode ?? '').trim()
|
|
|
|
|
if (!deviceCode || deviceMap.has(deviceCode)) return
|
|
|
|
|
deviceMap.set(deviceCode, {
|
|
|
|
|
const deviceId = String(item.dvId ?? '').trim()
|
|
|
|
|
if (!deviceId || deviceMap.has(deviceId)) return
|
|
|
|
|
deviceMap.set(deviceId, {
|
|
|
|
|
label: getDeviceOptionLabel(item),
|
|
|
|
|
value: deviceCode
|
|
|
|
|
value: deviceId
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
return Array.from(deviceMap.values())
|
|
|
|
|
@ -244,14 +245,27 @@ watch(pageNo, () => {
|
|
|
|
|
void refreshData()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const getDeviceLedgerOptions = async (groupId?: string) => {
|
|
|
|
|
const requestSeq = ++deviceLedgerRequestSeq
|
|
|
|
|
const ledgerList = await DeviceLedgerApi.getDeviceLedgerList({
|
|
|
|
|
deviceLine: groupId || undefined
|
|
|
|
|
})
|
|
|
|
|
if (requestSeq !== deviceLedgerRequestSeq) return
|
|
|
|
|
deviceLedgerList.value = Array.isArray(ledgerList) ? ledgerList.filter(hasIotDeviceId) : []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getFilterOptions = async () => {
|
|
|
|
|
const [deviceLineTree, ledgerList] = await Promise.all([
|
|
|
|
|
DeviceLineApi.getDeviceLineTree(),
|
|
|
|
|
DeviceLedgerApi.getDeviceLedgerList()
|
|
|
|
|
])
|
|
|
|
|
const deviceLineTree = await DeviceLineApi.getDeviceLineTree()
|
|
|
|
|
groupOptions.value = normalizeDeviceLineTree(Array.isArray(deviceLineTree) ? deviceLineTree : [])
|
|
|
|
|
deviceLedgerList.value = Array.isArray(ledgerList) ? ledgerList.filter(hasIotDeviceCode) : []
|
|
|
|
|
await getDeviceLedgerOptions(queryParams.value.groupId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
watch(
|
|
|
|
|
() => queryParams.value.groupId,
|
|
|
|
|
(groupId) => {
|
|
|
|
|
void getDeviceLedgerOptions(groupId)
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
watch(
|
|
|
|
|
deviceOptions,
|
|
|
|
|
(options) => {
|
|
|
|
|
|