style:设备运行概览-筛选入参修改

main
黄伟杰 5 days ago
parent a90a2f1997
commit 4011bd8f39

@ -10,6 +10,7 @@ export interface DeviceLedgerVO {
deviceName: string // 设备名称
iotDeviceCode?: string // 物联设备编码
iotDeviceName?: string // 物联设备名称
dvId?: string | number // 物联设备 ID
deviceStatus: number // 设备状态 (0-正常, 1-停用, 2-维修, 3-报废)
deviceBrand: string // 设备品牌
sn?: string // 序列号
@ -60,8 +61,8 @@ export const DeviceLedgerApi = {
return await request.get({ url: `/mes/device-ledger/page`, params })
},
getDeviceLedgerList: async () => {
return await request.get({ url: `/mes/device-ledger/list` })
getDeviceLedgerList: async (params?: any) => {
return await request.get({ url: `/mes/device-ledger/list`, params })
},
getDeviceLedgerListByNoUsed: async () => {

@ -74,6 +74,6 @@ export const OrganizationApi = {
},
deviceParameterAnalysis: async (params: { keyword?: string, showDevices?: number }) => {
return await request.get({ url: `/mes/organization/deviceParameterAnalysis`, params })
return await request.get({ url: `/mes/device-line/deviceParameterAnalysis`, params })
}
}

@ -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) => {

Loading…
Cancel
Save