首页判断被检设备下绑定监测点
This commit is contained in:
@@ -192,7 +192,7 @@ import { useAuthStore } from '@/stores/modules/auth'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { documentedPqDev } from '@/api/device/report'
|
||||
import { ResultEnum } from '@/enums/httpEnum'
|
||||
|
||||
import {getPqMonList} from '@/api/device/monitor/index.ts'
|
||||
|
||||
const checkStore = useCheckStore()
|
||||
let devNum = 0//当前选取的被检设备数量
|
||||
@@ -665,7 +665,7 @@ function refreshStatusList() {
|
||||
* 通道配对功能处理函数(比对模式专用)
|
||||
* 校验选中设备的一致性,然后打开通道配对弹窗
|
||||
*/
|
||||
const handleTest2 = () => {
|
||||
const handleTest2 = async () => {
|
||||
// 检查是否选择了设备
|
||||
if (devNum == 0) {
|
||||
ElMessageBox.confirm(
|
||||
@@ -729,7 +729,67 @@ const handleTest2 = () => {
|
||||
return
|
||||
}
|
||||
|
||||
deviceConnectionPopupRef.value?.open(channelsSelection.value, pqStandardDevList.value,props.id)
|
||||
const devBindMonList = await getPqMonList({devIds: channelsSelection.value.map(d => d.id)})
|
||||
|
||||
// 创建一个映射来存储每个设备的监测点信息(支持多个监测点)
|
||||
const deviceMonitoringMap = new Map<string, any[]>()
|
||||
devBindMonList.data.forEach((item: any) => {
|
||||
if (deviceMonitoringMap.has(item.devId)) {
|
||||
// 如果设备已存在,添加新的监测点信息
|
||||
deviceMonitoringMap.get(item.devId)?.push(item)
|
||||
} else {
|
||||
// 如果设备不存在,创建新的数组存储监测点信息
|
||||
deviceMonitoringMap.set(item.devId, [item])
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// 过滤出至少有一个监测点的设备
|
||||
const filteredChannelsSelection = channelsSelection.value.filter(device => {
|
||||
return deviceMonitoringMap.has(device.id)
|
||||
})
|
||||
|
||||
// 如果没有设备有监测点,则提示并返回
|
||||
if (filteredChannelsSelection.length === 0) {
|
||||
ElMessageBox.confirm(
|
||||
'所选设备均无监测点,请检查设备配置',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
},
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否有设备被过滤掉
|
||||
const devicesWithoutMonitoring = channelsSelection.value.filter(device => {
|
||||
return !deviceMonitoringMap.has(device.id)
|
||||
})
|
||||
|
||||
// 提示完全没有监测点的设备
|
||||
if (devicesWithoutMonitoring.length > 0) {
|
||||
const deviceNames = devicesWithoutMonitoring.map(d => d.name).join(', ')
|
||||
ElMessage.warning(`以下设备没有监测点: ${deviceNames}`)
|
||||
}
|
||||
|
||||
// 检查监测点数量与通道数是否一致,并指出具体哪些通道未绑定
|
||||
const inconsistentPointDevices = filteredChannelsSelection.filter(device => {
|
||||
const monitoringInfoArray = deviceMonitoringMap.get(device.id)
|
||||
const pointCount = monitoringInfoArray ? monitoringInfoArray.length : 0
|
||||
// 只有当监测点数量与通道数不一致时才需要提示
|
||||
return pointCount !== device.devChns
|
||||
})
|
||||
|
||||
if (inconsistentPointDevices.length > 0) {
|
||||
const deviceNames = inconsistentPointDevices.map(d => d.name).join(', ')
|
||||
ElMessage.warning(`以下设备存在通道未绑定监测点: ${deviceNames}`)
|
||||
}
|
||||
|
||||
|
||||
// 只传递有监测点的设备
|
||||
deviceConnectionPopupRef.value?.open(filteredChannelsSelection, pqStandardDevList.value, props.id)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user