27 Commits

Author SHA1 Message Date
guanj
1c01fe5ae1 修改测试问题 2026-06-12 11:02:46 +08:00
guanj
1a09c31669 修改测试问题 2026-06-11 20:27:37 +08:00
guanj
bda7373133 优化暂态事件列表 2026-06-09 19:51:31 +08:00
guanj
03d302ded8 修改测试bug 2026-06-08 18:34:49 +08:00
guanj
4f907a80c4 优化项目 2026-06-04 19:06:36 +08:00
guanj
4f32f84132 修改项目树问题 绘制稳态治理分析页面 2026-06-04 09:08:37 +08:00
guanj
c2805d7e9e 联调电镀数据功能 2026-06-02 16:09:21 +08:00
guanj
7deafa6d69 联调电镀数据页面 2026-06-01 20:35:26 +08:00
guanj
c2f23aa957 修改测试问题 2026-05-28 20:36:49 +08:00
guanj
9466141bff 去除部门树接口 2026-05-28 15:10:40 +08:00
guanj
faac12615d 提交 2026-05-26 16:23:18 +08:00
guanj
8b80e0678f 提交代码 2026-04-25 15:22:28 +08:00
guanj
7abcdb3a6b 联调程序升级 2026-04-24 09:13:48 +08:00
guanj
c8a42948de 修改台账 2026-04-20 09:28:04 +08:00
guanj
99bc99a6fc 绘制稳态事件配置页面 2026-04-17 08:49:22 +08:00
guanj
01a28d88f3 修改台账 2026-04-15 19:29:36 +08:00
guanj
632a0104fb 调整台账录入页面 2026-04-15 13:44:28 +08:00
guanj
cfcbfc45d6 修改台账 2026-04-13 10:48:32 +08:00
guanj
2601068a55 1 2026-04-08 15:51:46 +08:00
guanj
3ffb11defa 调整台账 2026-04-03 14:47:36 +08:00
guanj
0b9aafc1b5 联调文件管理页面 2026-04-02 09:08:57 +08:00
guanj
762965b1e4 联调设备文件 2026-03-30 09:03:53 +08:00
guanj
a30379ab01 绘制 运维版本管理页面 2026-03-19 11:29:26 +08:00
dk
9f1fbf93cd 新增实时运维页面 2026-03-18 21:06:48 +08:00
dk
b5fc946ce2 测试修改提交 2026-03-17 14:32:14 +08:00
guanj
1171d37a86 添加工程树 2026-03-06 09:36:42 +08:00
guanj
3fdb41c468 修改测试bug 2026-02-04 09:35:24 +08:00
228 changed files with 19630 additions and 15578 deletions

2
.gitignore vendored
View File

@@ -23,3 +23,5 @@ dist-ssr
*.sln *.sln
*.sw? *.sw?
pnpm-lock.yaml pnpm-lock.yaml
#test

View File

@@ -12,7 +12,7 @@ import { provide, onMounted, ref } from 'vue'
// let buildUrl = 'wss://pqmcn.com:8087/mqtt'//102 // let buildUrl = 'wss://pqmcn.com:8087/mqtt'//102
// let buildUrl = 'ws://pqmcn.com:8073/mqtt' //27 // let buildUrl = 'ws://pqmcn.com:8073/mqtt' //27
let buildUrl = 'ws://192.168.1.103:8083/mqtt' //27 let buildUrl = 'ws://112.4.144.18:38083/mqtt' //27
// 从 Nginx 获取 MQTT URL // 从 Nginx 获取 MQTT URL
const fetchMqttUrl = async () => { const fetchMqttUrl = async () => {

View File

@@ -0,0 +1,42 @@
import createAxios from '@/utils/request'
/**
* 删除数据合理范围
**/
export const pqDelete = (data: any) => {
return createAxios({
url: '/algorithm-boot/pqReasonableRange/delete',
method: 'post',
params: data
})
}
/**
* 按条件获取数据合理范围
**/
export const getData = (data: any) => {
return createAxios({
url: '/algorithm-boot/pqReasonableRange/getData',
method: 'post',
data
})
}
/**
* 新增数据合理范围
**/
export const save = (data: any) => {
return createAxios({
url: '/algorithm-boot/pqReasonableRange/save',
method: 'post',
data
})
}
/**
* 更新数据合理范围
**/
export const update = (data: any) => {
return createAxios({
url: '/algorithm-boot/pqReasonableRange/update',
method: 'post',
data
})
}

View File

@@ -1,144 +1,153 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
// 装置基础数据和模板数据 // 设备基础数据和模板数据
export function getDeviceData(deviceId: string, type: string, lineId: string) { export function getDeviceData(deviceId: string, type: string, lineId: string) {
let form = new FormData() let form = new FormData()
form.append('deviceId', deviceId) form.append('deviceId', deviceId)
form.append('lineId', lineId) form.append('lineId', lineId)
form.append('type', type) form.append('type', type)
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/deviceData', url: '/cs-device-boot/EquipmentDelivery/deviceData',
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
data: form data: form
}) })
} }
//获取趋势数据、暂态数据、实时数据 //获取趋势数据、暂态数据、实时数据
export function getTabsDataByType(data: any) { export function getTabsDataByType(data: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/deviceDataByType', url: '/cs-device-boot/csGroup/deviceDataByType',
method: 'POST', method: 'POST',
data data
}) })
} }
/**** 获取基础实施数据 ****/ /**** 获取基础实施数据 ****/
export function getBasicRealData(id: any) { export function getBasicRealData(id: any) {
return createAxios({ return createAxios({
url: `/cs-harmonic-boot/realData/getBaseRealData?lineId=${id}`, url: `/cs-harmonic-boot/realData/getBaseRealData?lineId=${id}`,
method: 'POST' method: 'POST'
}) })
} }
/**** 获取谐波实时数据 ****/ /**** 获取谐波实时数据 ****/
export function getHarmRealData(id: any, target: any) { export function getHarmRealData(id: any, target: any) {
return createAxios({ return createAxios({
url: `/cs-harmonic-boot/realData/getHarmRealData?lineId=${id}&target=${target}`, url: `/cs-harmonic-boot/realData/getHarmRealData?lineId=${id}&target=${target}`,
method: 'POST' method: 'POST'
}) })
} }
/**** 获取国标限值 ****/ /**** 获取国标限值 ****/
export function getOverLimitData(id: any) { export function getOverLimitData(id: any) {
return createAxios({ return createAxios({
url: `/cs-device-boot/csline/getOverLimitData?id=${id}`, url: `/cs-device-boot/csline/getOverLimitData?id=${id}`,
method: 'POST' method: 'POST'
}) })
} }
//获取实时数据列表数据 //获取实时数据列表数据
export function getRealTimeTableList() { export function getRealTimeTableList() {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getGroupPortableStatistical', url: '/cs-device-boot/csGroup/getGroupPortableStatistical',
method: 'GET' method: 'GET'
}) })
} }
//离线数据导入 //离线数据导入
export function uploadOffLineDataFile(data: any) { export function uploadOffLineDataFile(data: any) {
return createAxios({ return createAxios({
headers: { headers: {
'Content-Type': 'multipart/form-data' 'Content-Type': 'multipart/form-data'
}, },
url: '/cs-device-boot/portableOfflLog/importEquipment', url: '/cs-device-boot/portableOfflLog/importEquipment',
method: 'POST', method: 'POST',
data data
}) })
} }
//查询实时数据中实时趋势中指标分组 //查询实时数据中实时趋势中指标分组
export function getDeviceTrendDataGroup() { export function getDeviceTrendDataGroup() {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getDeviceTrendDataGroup', url: '/cs-device-boot/csGroup/getDeviceTrendDataGroup',
method: 'GET' method: 'GET'
}) })
} }
//根据指标分组查询实时数据中实时趋势 //根据指标分组查询实时数据中实时趋势
export function getDeviceTrendData(query: any) { export function getDeviceTrendData(query: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getDeviceTrendData', url: '/cs-device-boot/csGroup/getDeviceTrendData',
method: 'GET', method: 'GET',
params: query params: query
}) })
} }
//查询实时数据-谐波频谱-稳态指标 //查询实时数据-谐波频谱-稳态指标
export function getGroupPortableStatistical() { export function getGroupPortableStatistical() {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getGroupPortableStatistical', url: '/cs-device-boot/csGroup/getGroupPortableStatistical',
method: 'GET' method: 'GET'
}) })
} }
//查询实时数据-谐波频谱 //查询实时数据-谐波频谱
export function getDeviceHarmonicSpectrumData(data: any) { export function getDeviceHarmonicSpectrumData(data: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getDeviceHarmonicSpectrumData', url: '/cs-device-boot/csGroup/getDeviceHarmonicSpectrumData',
method: 'POST', method: 'POST',
data: data data: data
}) })
} }
//获取指标类型-谐波频谱 //获取指标类型-谐波频谱
export function queryDictType(data?: any) { export function queryDictType(data?: any) {
return createAxios({ return createAxios({
url: '/system-boot/dictTree/queryDictType', url: '/system-boot/dictTree/queryDictType',
method: 'GET', method: 'GET',
params: data params: data
}) })
} }
//根据监测点id获取监测点详情 //根据监测点id获取监测点详情
export function getById(data?: any) { export function getById(data?: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csline/getById', url: '/cs-device-boot/csline/getById',
method: 'POST', method: 'POST',
params: data params: data
}) })
} }
//测试项日志修改 //测试项日志修改
export function updateRecordData(data?: any) { export function updateRecordData(data?: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/wlRecord/updateRecordData', url: '/cs-device-boot/wlRecord/updateRecordData',
method: 'POST', method: 'POST',
data data
}) })
} }
//模块数据 //模块数据
export function allModelData(data?: any) { export function allModelData(data?: any) {
return createAxios({ return createAxios({
url: '/cs-harmonic-boot/data/allModelData', url: '/cs-harmonic-boot/data/allModelData',
method: 'POST', method: 'POST',
data data
}) })
} }
//刷新状态 //刷新状态
export function getModuleState(data?: any) { export function getModuleState(data?: any) {
return createAxios({ return createAxios({
url: '/cs-harmonic-boot/data/getModuleState', url: '/cs-harmonic-boot/data/getModuleState',
method: 'POST', method: 'POST',
params: data params: data
}) })
} }
//获取运行取数
export function getRawData(data?: any) {
return createAxios({
url: '/cs-device-boot/pqsCommunicate/getRawData',
method: 'POST',
data
})
}

View File

@@ -1,4 +1,4 @@
import createAxios from "@/utils/request"; import createAxios from '@/utils/request'
//根据Id获取台账信息 //根据Id获取台账信息
export function getInfoById(id: any) { export function getInfoById(id: any) {
@@ -11,7 +11,6 @@ export function getInfoById(id: any) {
}) })
} }
//工程查询通过id获取 //工程查询通过id获取
export function getEngineerById(id: any) { export function getEngineerById(id: any) {
let form = new FormData() let form = new FormData()
@@ -23,7 +22,6 @@ export function getEngineerById(id: any) {
}) })
} }
//项目查询通过id获取 //项目查询通过id获取
export function getProjectById(id: any) { export function getProjectById(id: any) {
let form = new FormData() let form = new FormData()
@@ -53,7 +51,7 @@ export function getById(id: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csline/getById', url: '/cs-device-boot/csline/getById',
method: 'POST', method: 'POST',
data: form data: form
}) })
} }
@@ -75,13 +73,15 @@ export function addLedger(data: any) {
} }
//修改-删除项目 //修改-删除项目
export function deleteProject(id: any,name:any,area:any,description:any,status:any) { export function deleteProject(id: any, name: any, area: any, description: any, status: any, sort: any, topoIds: any) {
let form = new FormData() let form = new FormData()
form.append('id', id) form.append('id', id)
form.append('name', name) form.append('name', name)
form.append('area', area) form.append('area', area)
form.append('description', description) form.append('description', description)
form.append('status', status) form.append('status', status)
form.append('sort', sort)
form.append('topoIds', topoIds)
return createAxios({ return createAxios({
url: '/cs-device-boot/project/auditAppProject', url: '/cs-device-boot/project/auditAppProject',
method: 'post', method: 'post',
@@ -105,7 +105,7 @@ export const deleteLine = (id: any) => {
let form = new FormData() let form = new FormData()
form.append('id', id) form.append('id', id)
return createAxios({ return createAxios({
url: '/cs-device-boot/csline/delCldLine', url: '/cs-device-boot/csline/delCldLine',
method: 'POST', method: 'POST',
data: form data: form
}) })
@@ -120,7 +120,6 @@ export function updateEquipment(data: any) {
}) })
} }
//修改监测点 //修改监测点
export function updateLine(data: any) { export function updateLine(data: any) {
return createAxios({ return createAxios({
@@ -134,8 +133,7 @@ export function updateLine(data: any) {
export function pushLog() { export function pushLog() {
return createAxios({ return createAxios({
url: '/cs-device-boot/csTerminalLogs/pushCldInfo', url: '/cs-device-boot/csTerminalLogs/pushCldInfo',
method: 'post', method: 'post'
}) })
} }
@@ -143,7 +141,14 @@ export function pushLog() {
export function queryPushResult() { export function queryPushResult() {
return createAxios({ return createAxios({
url: '/cs-device-boot/csTerminalReply/queryData', url: '/cs-device-boot/csTerminalReply/queryData',
method: 'post', method: 'post'
}) })
} }
//查询升级日志
export function getByDevId(data: any) {
return createAxios({
url: '/cs-device-boot/csUpgradeLogs/getByDevId',
method: 'get',
params:data
})
}

View File

@@ -1,86 +1,86 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
// 查询分组 // 查询分组
export function getGroup(dataSet: string) { export function getGroup(dataSet: string) {
let form = new FormData() let form = new FormData()
form.append('dataSet', dataSet) form.append('dataSet', dataSet)
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/getGroup', url: '/cs-device-boot/csGroup/getGroup',
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
data: form data: form
}) })
} }
// 装置分组实时数据 // 设备分组实时数据
export function deviceHisData(data: any) { export function deviceHisData(data: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/deviceHistoryData', url: '/cs-device-boot/csGroup/deviceHistoryData',
method: 'POST', method: 'POST',
data: Object.assign( data: Object.assign(
{ {
endTime: '', endTime: '',
id: '', id: '',
lineId: '', lineId: '',
pageNum: 1, pageNum: 1,
pageSize: 20, pageSize: 20,
startTime: '' startTime: ''
}, },
data data
) )
}) })
} }
// 装置分组历史数据 // 设备分组历史数据
export function deviceRtData(data: any) { export function deviceRtData(data: any) {
let form = new FormData() let form = new FormData()
form.append('id', data.id) form.append('id', data.id)
form.append('lineId', data.lineId) form.append('lineId', data.lineId)
form.append('pageNum', data.pageNum) form.append('pageNum', data.pageNum)
form.append('pageSize', data.pageSize) form.append('pageSize', data.pageSize)
form.append('searchValue', data.searchValue) form.append('searchValue', data.searchValue)
form.append('dataLevel', data.dataLevel) form.append('dataLevel', data.dataLevel)
return createAxios({ return createAxios({
url: '/cs-device-boot/csGroup/deviceRtData', url: '/cs-device-boot/csGroup/deviceRtData',
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
data: form data: form
}) })
} }
// 装置分组历史数据 // 设备分组历史数据
export function realTimeData(data: any) { export function realTimeData(data: any) {
let form = new FormData() let form = new FormData()
form.append('id', data.id) form.append('id', data.id)
form.append('lineId', data.lineId) form.append('lineId', data.lineId)
form.append('pageNum', data.pageNum) form.append('pageNum', data.pageNum)
form.append('pageSize', data.pageSize) form.append('pageSize', data.pageSize)
form.append('searchValue', data.searchValue) form.append('searchValue', data.searchValue)
form.append('targetType', data.targetType) form.append('targetType', data.targetType)
form.append('dataLevel', data.dataLevel) form.append('dataLevel', data.dataLevel)
return createAxios({ return createAxios({
url: '/cs-harmonic-boot/data/realTimeData', url: '/cs-harmonic-boot/data/realTimeData',
method: 'POST', method: 'POST',
data data
}) })
} }
// 设备监控-》测试项数据 // 设备监控-》测试项数据
export function getTestData(data: any) { export function getTestData(data: any) {
return createAxios({ return createAxios({
url: '/cs-harmonic-boot/data/getTestData', url: '/cs-harmonic-boot/data/getTestData',
method: 'POST', method: 'POST',
data data
}) })
} }
// 设备监控-删除装置测试项 // 设备监控-删除设备测试项
export function deleteItem(data: any) { export function deleteItem(data: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/wlRecord/deleteItem', url: '/cs-device-boot/wlRecord/deleteItem',
method: 'POST', method: 'POST',
params: data params: data
}) })
} }

View File

@@ -1,18 +1,20 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
// 设备列表 // 设备列表
export function getDeviceTree() { export function getDeviceTree(params?: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csLedger/deviceTree', url: '/cs-device-boot/csLedger/deviceTree',
method: 'POST' method: 'POST',
params
}) })
} }
// 监测点列表 // 监测点列表
export function getLineTree() { export function getLineTree(params?: any) {
return createAxios({ return createAxios({
url: '/cs-device-boot/csLedger/lineTree', url: '/cs-device-boot/csLedger/lineTree',
method: 'POST' method: 'POST',
params
}) })
} }
// 监测点列表治理 // 监测点列表治理
@@ -23,7 +25,6 @@ export function objTree() {
}) })
} }
//云设备录入树 //云设备录入树
export function getCldTree() { export function getCldTree() {
return createAxios({ return createAxios({
@@ -38,4 +39,11 @@ export function lineTree() {
method: 'POST' method: 'POST'
}) })
} }
//APF报表树
export function getUserDevTree(data) {
return createAxios({
url: '/cs-harmonic-boot/pqSensitiveUser/getUserDevTree',
method: 'POST',
params: data
})
}

View File

@@ -79,4 +79,12 @@ export const addProject = (data: any) => {
data: data data: data
}) })
} }
// 修改项目
export const updateProjects = (data: any) => {
return request({
url: '/cs-device-boot/engineeringProjectRelation/updateProject',
method: 'post',
data: data
})
}

View File

@@ -1,93 +1,140 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
// 设备文件根目录查询 // 设备文件根目录查询
export function getDeviceRootPath(nDid) { export function getDeviceRootPath(nDid) {
return createAxios({ return createAxios({
url: '/cs-device-boot/deviceFile/askDeviceRootPath?nDid=' + nDid, url: '/cs-device-boot/deviceFile/askDeviceRootPath?nDid=' + nDid,
method: 'POST' method: 'POST'
}) })
} }
// 设备文件-目录信息询问 // 设备文件-目录信息询问
export function getFileServiceFileOrDir(data) { export function getFileServiceFileOrDir(data) {
return createAxios({ return createAxios({
url: `cs-device-boot/deviceFile/askDeviceFileOrDir?nDid=${data.nDid}&name=${data.name}&type=${data.type}`, url: `cs-device-boot/deviceFile/askDeviceFileOrDir?nDid=${data.nDid}&name=${data.name}&type=${data.type}`,
method: 'POST' method: 'POST'
}) })
} }
// 监测设备-目录信息询问
//设备文件下载 export function listDir(data) {
export function downLoadDeviceFile(data) { return createAxios({
return createAxios({ url: `/zl-event-boot/file/listDir`,
url: `/cs-device-boot/deviceFile/downloadFile?nDid=${data.nDid}&name=${data.name}&fileCheck=${data.fileCheck}&size=${data.size}`, method: 'POST',
method: 'POST' data: data
}) })
} }
// 下载文件
//获取下载文件的文件路径地址 export function downloadFileFromFrontr(data: any) {
export function downLoadDeviceFilePath(obj) { return createAxios({
let form = new FormData() url: `/zl-event-boot/file/downloadFileFromFront`,
form.append('name', obj.name) method: 'POST',
form.append('nDid', obj.nDid) data: data,
return createAxios({ responseType: 'blob'
url: `/cs-device-boot/deviceFile/getDownloadFilePath`, })
method: 'POST', }
headers: { // 删除文件
'Content-Type': 'application/x-www-form-urlencoded' export function deleteCld(data: any) {
}, return createAxios({
data: form url: `/zl-event-boot/file/delete`,
}) method: 'POST',
} data: data
//装置重启 })
export function reStartDevice(data) { }
return createAxios({ // 新建文件
url: `/cs-device-boot/EquipmentDelivery/rebootDevice?nDid=${data.nDid}`, export function mkdir(data: any) {
method: 'POST' return createAxios({
}) url: `/zl-event-boot/file/mkdir`,
} method: 'POST',
data: data
//上传文件至装置 })
export function uploadDeviceFile(data) { }
let form = new FormData() // 上传文件
form.append('file', data.file) export function uploadFileToFront(obj: any) {
form.append('filePath', data.filePath) let form = new FormData()
form.append('id', data.id) form.append('file', obj.file)
return createAxios({ form.append('devId', obj.devId)
url: `/access-boot/analyzeModel/uploadDevFile`, form.append('dirPath', obj.dirPath)
method: 'POST', return createAxios({
headers: { url: `/zl-event-boot/file/uploadFileToFront`,
'Content-Type': 'application/x-www-form-urlencoded' method: 'POST',
}, headers: {
data: form 'Content-Type': 'application/x-www-form-urlencoded'
}) },
} data: form
})
//新建文件夹目录 }
export function addDeviceDir(data) { //设备文件下载
let form = new FormData() export function downLoadDeviceFile(data) {
form.append('nDid', data.nDid) return createAxios({
form.append('path', data.path) url: `/cs-device-boot/deviceFile/downloadFile?nDid=${data.nDid}&name=${data.name}&fileCheck=${data.fileCheck}&size=${data.size}`,
return createAxios({ method: 'POST'
url: `/access-boot/askDeviceData/createFolder`, })
method: 'POST', }
headers: {
'Content-Type': 'application/x-www-form-urlencoded' //获取下载文件的文件路径地址
}, export function downLoadDeviceFilePath(obj) {
data: form let form = new FormData()
}) form.append('name', obj.name)
} form.append('nDid', obj.nDid)
return createAxios({
//删除文件/文件夹 url: `/cs-device-boot/deviceFile/getDownloadFilePath`,
export function delDeviceDir(data) { method: 'POST',
let form = new FormData() headers: {
form.append('nDid', data.nDid) 'Content-Type': 'application/x-www-form-urlencoded'
form.append('path', data.path) },
return createAxios({ data: form
url: `/access-boot/askDeviceData/deleteFolder`, })
method: 'POST', }
headers: { //设备重启
'Content-Type': 'application/x-www-form-urlencoded' export function reStartDevice(data) {
}, return createAxios({
data: form url: `/cs-device-boot/EquipmentDelivery/rebootDevice?nDid=${data.nDid}`,
}) method: 'POST'
} })
}
//上传文件至设备
export function uploadDeviceFile(data) {
let form = new FormData()
form.append('file', data.file)
form.append('filePath', data.filePath)
form.append('id', data.id)
return createAxios({
url: `/access-boot/analyzeModel/uploadDevFile`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: form
})
}
//新建文件夹目录
export function addDeviceDir(data) {
let form = new FormData()
form.append('nDid', data.nDid)
form.append('path', data.path)
return createAxios({
url: `/access-boot/askDeviceData/createFolder`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: form
})
}
//删除文件/文件夹
export function delDeviceDir(data) {
let form = new FormData()
form.append('nDid', data.nDid)
form.append('path', data.path)
return createAxios({
url: `/access-boot/askDeviceData/deleteFolder`,
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
data: form
})
}

View File

@@ -65,3 +65,35 @@ export function savePageIdWithUser(data: any) {
params: data params: data
}) })
} }
//新增稳态指标方案
export function save(data: any) {
return createAxios({
url: '/cs-harmonic-boot/csHarmonicPlan/save',
method: 'post',
data: data
})
}
//修改稳态指标方案
export function update(data: any) {
return createAxios({
url: '/cs-harmonic-boot/csHarmonicPlan/update',
method: 'post',
data: data
})
}
//新增稳态指标方案
export function deletePlan(data: any) {
return createAxios({
url: '/cs-harmonic-boot/csHarmonicPlan/delete',
method: 'post',
data: data
})
}
//根据ID查询稳态指标方案
export function getById(data: any) {
return createAxios({
url: '/cs-harmonic-boot/csHarmonicPlan/getById',
method: 'GET',
params: data
})
}

View File

@@ -8,7 +8,7 @@ export function getMakeUpData(data: any) {
}) })
} }
//查询装置目录-文件 //查询设备目录-文件
export function getAskDirOrFile(data: any) { export function getAskDirOrFile(data: any) {
return createAxios({ return createAxios({
url: `/cs-harmonic-boot/offlineDataUpload/askDirOrFile?fileType=${data.fileType}&nDid=${data.nDid}&path=${data.path}&prjName=${data.prjName}`, url: `/cs-harmonic-boot/offlineDataUpload/askDirOrFile?fileType=${data.fileType}&nDid=${data.nDid}&path=${data.path}&prjName=${data.prjName}`,

View File

@@ -1,30 +1,69 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
/** /**
* 查询app个人中心信息详情 * 查询app个人中心信息详情
* @param id * @param id
*/ */
export const queryAppInfo = (type: string) => { export const queryAppInfo = (type: string) => {
let form = new FormData() let form = new FormData()
form.append('type', type) form.append('type', type)
return createAxios({ return createAxios({
url: '/cs-system-boot/appinfo/queryAppInfoByType', url: '/cs-system-boot/appinfo/queryAppInfoByType',
method: 'post', method: 'post',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded' 'Content-Type': 'application/x-www-form-urlencoded'
}, },
data: form data: form
}) })
} }
/**
/** * 新增app基础信息
* 新增app基础信息 **/
**/ export const addAppInfo = (data: { type: string; content: string }) => {
export const addAppInfo = (data: { type: string, content: string }) => { return createAxios({
return createAxios({ url: '/cs-system-boot/appinfo/addAppInfo',
url: '/cs-system-boot/appinfo/addAppInfo', method: 'post',
method: 'post', data: data
data: data })
}) }
} /**
* 切换告警配置启用状态
**/
export const toggleActive = (data: any) => {
return createAxios({
url: '/cs-system-boot/csAlarmSet/toggleActive',
method: 'post',
params: data
})
}
/**
* 切换告警配置启用状态
**/
export const csDelete = (data: any) => {
return createAxios({
url: '/cs-system-boot/csAlarmSet/delete',
method: 'post',
params: data
})
}
/**
* 新增告警配置
**/
export const add = (data: any) => {
return createAxios({
url: '/cs-system-boot/csAlarmSet/add',
method: 'post',
data: data
})
}
/**
* 修改告警配置
**/
export const update = (data: any) => {
return createAxios({
url: '/cs-system-boot/csAlarmSet/update',
method: 'post',
data: data
})
}

View File

@@ -1,98 +1,121 @@
import createAxios from '@/utils/request' import createAxios from '@/utils/request'
// 新增出厂设备 // 新增出厂设备
export const addEquipmentDelivery = (data: any) => { export const addEquipmentDelivery = (data: any) => {
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/addEquipmentDelivery', url: '/cs-device-boot/EquipmentDelivery/addEquipmentDelivery',
method: 'POST', method: 'POST',
data: data data: data
}) })
} }
// 删除出厂设备 // 删除出厂设备
export const deleteEquipmentDelivery = (id: any) => { export const deleteEquipmentDelivery = (id: any) => {
let form = new FormData() let form = new FormData()
form.append('id', id) form.append('id', id)
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/AuditEquipmentDelivery', url: '/cs-device-boot/EquipmentDelivery/AuditEquipmentDelivery',
method: 'POST', method: 'POST',
data: form data: form
}) })
} }
// 恢复出厂设置 // 恢复出厂设置
export const resetEquipmentDelivery = (id: any) => { export const resetEquipmentDelivery = (id: any) => {
let form = new FormData() let form = new FormData()
form.append('nDid', id) form.append('nDid', id)
return createAxios({ return createAxios({
url: '/access-boot/device/resetFactory', url: '/access-boot/device/resetFactory',
method: 'POST', method: 'POST',
data: form data: form
}) })
} }
// 编辑出厂设备 // 编辑出厂设备
export const editEquipmentDelivery = (data: any) => { export const editEquipmentDelivery = (data: any) => {
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/updateEquipmentDelivery', url: '/cs-device-boot/EquipmentDelivery/updateEquipmentDelivery',
method: 'POST', method: 'POST',
data: data data
}) })
} }
// 上传拓扑图 // 上传拓扑图
export const uploadTopo = (file: any) => { export const uploadTopo = (file: any) => {
let form = new FormData() let form = new FormData()
form.append('file', file) form.append('file', file)
return createAxios({ return createAxios({
url: '/cs-device-boot/topologyTemplate/uploadImage', url: '/cs-device-boot/topologyTemplate/uploadImage',
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'multipart/form-data' 'Content-Type': 'multipart/form-data'
}, },
data: form data: form
}) })
} }
// 批量导入设备 // 批量导入设备
export const batchImportDevice = (file: any) => { export const batchImportDevice = (file: any) => {
let form = new FormData() let form = new FormData()
form.append('file', file) form.append('file', file)
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/importEquipment', url: '/cs-device-boot/EquipmentDelivery/importEquipment',
method: 'POST', method: 'POST',
responseType: 'blob', responseType: 'blob',
data: form data: form
}) })
} }
// 直连设备注册接入 // 直连设备注册接入
export const governDeviceRegister = (data: any) => { export const governDeviceRegister = (data: any) => {
return createAxios({ return createAxios({
url: `/access-boot/device/register?nDid=${data.nDid}&type=${data.type}`, url: `/access-boot/device/register?nDid=${data.nDid}&type=${data.type}`,
method: 'POST' method: 'POST'
}) })
} }
// 便携式设备注册 // 便携式设备注册
export const portableDeviceRegister = (params: any) => { export const portableDeviceRegister = (params: any) => {
return createAxios({ return createAxios({
url: `/access-boot/device/wlRegister`, url: `/access-boot/device/wlRegister`,
method: 'POST', method: 'POST',
params params
}) })
} }
// 便携式设备接入 // 便携式设备接入
export const portableDeviceAccess = (data: any) => { export const portableDeviceAccess = (data: any) => {
return createAxios({ return createAxios({
url: `/access-boot/device/wlAccess?nDid=${data.nDid}`, url: `/access-boot/device/wlAccess?nDid=${data.nDid}`,
method: 'POST', method: 'POST'
}) })
} }
// 下载模版 // 下载模版
export function getExcelTemplate() { export function getExcelTemplate() {
return createAxios({ return createAxios({
url: '/cs-device-boot/EquipmentDelivery/getExcelTemplate', url: '/cs-device-boot/EquipmentDelivery/getExcelTemplate',
method: 'get', method: 'get',
responseType: 'blob' responseType: 'blob'
}) })
} }
// 查询工程信息列表
export function engineeringProject() {
return createAxios({
url: '/cs-device-boot/engineeringProjectRelation/list',
method: 'post'
})
}
//监测设备接入
export function onlineRegister(data: any) {
return createAxios({
url: '/access-boot/device/onlineRegister',
method: 'post',
params: data
})
}
//重启设备
export function resetFactory(data: any) {
return createAxios({
url: '/access-boot/device/resetFactory',
method: 'post',
params: data
})
}

View File

@@ -27,3 +27,23 @@ export const removeUserDev = (data: any) => {
data: data data: data
}) })
} }
/**
* 短信配置
*/
export const addUserDevices = (data: any) => {
return createAxios({
url: '/cs-system-boot/appMsgSet/addUserDevices',
method: 'post',
data: data
})
}
/**
* 短信配置
*/
export const queryDeviceIdsByUserId = (data: any) => {
return createAxios({
url: '/cs-system-boot/appMsgSet/queryDeviceIdsByUserId',
method: 'post',
params: data
})
}

View File

@@ -94,3 +94,19 @@ export function codeDicTree(data: any) {
params: data params: data
}) })
} }
// 根据装置型号获取装置类型
export function findByDevTypeId(data: any) {
return createAxios({
url: '/cs-device-boot/edData/queryEdDataPage',
method: 'post',
data
})
}
// 装置升级
export function upgrade(params: any) {
return createAxios({
url: '/zl-event-boot/device/upgrade',
method: 'get',
params
})
}

View File

@@ -6,10 +6,10 @@
</el-row> </el-row>
<el-row class="ba-array-item" v-for="(item, idx) in state.value" :gutter="10" :key="idx"> <el-row class="ba-array-item" v-for="(item, idx) in state.value" :gutter="10" :key="idx">
<el-col :span="10"> <el-col :span="10">
<el-input v-model="item.key"></el-input> <el-input maxlength="32" show-word-limit v-model="item.key"></el-input>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
<el-input v-model="item.value"></el-input> <el-input maxlength="32" show-word-limit v-model="item.value"></el-input>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
<el-button @click="onDelArrayItem(idx)" size="small" icon="el-icon-Delete" circle /> <el-button @click="onDelArrayItem(idx)" size="small" icon="el-icon-Delete" circle />

View File

@@ -61,7 +61,7 @@
</transition> </transition>
</div> </div>
<template #reference> <template #reference>
<el-input <el-input maxlength="32" show-word-limit
v-model="state.inputValue" v-model="state.inputValue"
:size="size" :size="size"
:disabled="disabled" :disabled="disabled"

View File

@@ -1,38 +1,21 @@
<template> <template>
<div> <div>
<!--F47曲线 --> <!--F47曲线 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" :timeKeyList="prop.timeKey" @selectChange="selectChange"
ref="TableHeaderRef" datePicker v-if="fullscreen"></TableHeader>
:showReset="false"
:timeKeyList="prop.timeKey"
@selectChange="selectChange"
datePicker
v-if="fullscreen"
></TableHeader>
<el-descriptions class="mt2" direction="vertical" :column="4" border> <el-descriptions class="mt2" direction="vertical" :column="4" border>
<el-descriptions-item align="center" label="名称">{{ data.name }}</el-descriptions-item> <el-descriptions-item align="center" label="名称">{{ data.name }}</el-descriptions-item>
<el-descriptions-item align="center" label="事件总数">{{ data.gs }}</el-descriptions-item> <el-descriptions-item align="center" label="事件总数">{{ data.gs }}</el-descriptions-item>
<el-descriptions-item align="center" label="可容忍">{{ data.krr }}</el-descriptions-item> <el-descriptions-item align="center" label="可容忍">{{ data.krr }}</el-descriptions-item>
<el-descriptions-item align="center" label="不可容忍">{{ data.bkrr }}</el-descriptions-item> <el-descriptions-item align="center" label="不可容忍">{{ data.bkrr }}</el-descriptions-item>
</el-descriptions> </el-descriptions>
<my-echart <my-echart v-loading="tableStore.table.loading" ref="chartRef" class="tall" :options="echartList" :style="{
v-loading="tableStore.table.loading" width: prop.width,
ref="chartRef" height: `calc(${prop.height} - 80px - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
class="tall" }" @chart-click="handleChartClick" />
:options="echartList"
:style="{
width: prop.width,
height: `calc(${prop.height} - 80px - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}"
@chart-click="handleChartClick"
/>
<el-dialog v-model="isWaveCharts" v-if="isWaveCharts" draggable :title="dialogTitle" append-to-body width="70%"> <el-dialog v-model="isWaveCharts" v-if="isWaveCharts" draggable :title="dialogTitle" append-to-body width="70%">
<waveFormAnalysis <waveFormAnalysis v-loading="loading" ref="waveFormAnalysisRef" @handleHideCharts="isWaveCharts = false"
v-loading="loading" :wp="wp" />
ref="waveFormAnalysisRef"
@handleHideCharts="isWaveCharts = false"
:wp="wp"
/>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@@ -123,9 +106,9 @@ const tableStore: any = new TableStore({
text: `F47曲线` text: `F47曲线`
}, },
legend: { legend: {
data: ['可容忍事件', '不可容忍事件'], data: ['分割线', '可容忍事件', '不可容忍事件'],
itemWidth: 10, // itemWidth: 10,
itemHeight: 10, // itemHeight: 10,
itemGap: 15 itemGap: 15
}, },
tooltip: { tooltip: {
@@ -147,10 +130,16 @@ const tableStore: any = new TableStore({
backgroundColor: 'rgba(0,0,0,0.55)', backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0, borderWidth: 0,
formatter: function (a: any) { formatter: function (a: any) {
var relVal = '' var relVal = `<strong>${a.seriesName}</strong><br/>`
relVal = "<font style='color:" + "'>发生时间:" + a.value[2] + '</font><br/>'
relVal += "<font style='color:" + "'>持续时间:" + a.value[0] + 's</font><br/>' relVal += "<font style='color:" + "'>发生时间" + a.value[2] + '</font><br/>'
relVal += "<font style='color:" + "'>特征幅值:" + a.value[1].toFixed(2) + '%</font>' relVal += "<font style='color:" + "'>特征幅值" + Math.floor(a.value[1] * 100) / 100 + '%</font><br/>'
relVal += "<font style='color:" + "'>持续时间:" + a.value[0] + 's</font><br/>'
relVal += "<font style='color:" + "'>监测点名称:" + (a.value[4] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>设备名称:" + (a.value[5] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>项目名称:" + (a.value[6] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>工程名称:" + (a.value[7] || '/') + '</font>'
return relVal return relVal
} }
}, },
@@ -172,10 +161,10 @@ const tableStore: any = new TableStore({
// max: function (value: any) { // max: function (value: any) {
// return value.max + 20 // return value.max + 20
// }, // },
max: function (value) { // max: function (value) {
// 先取原始最大值+20再向上取整到最近的10的倍数确保刻度够用且规整 // // 先取原始最大值+20再向上取整到最近的10的倍数确保刻度够用且规整
return Math.ceil((value.max + 20) / 10) * 10 // return Math.ceil((value.max + 20) / 10) * 10
}, // },
// splitNumber: 10, // splitNumber: 10,
// interval: 10, // interval: 10,
// minInterval: 10, // minInterval: 10,
@@ -187,7 +176,7 @@ const tableStore: any = new TableStore({
dataZoom: null, dataZoom: null,
series: [ series: [
{ {
name: '边界线', name: '分割线',
type: 'line', type: 'line',
data: [ data: [
[0.05, 0], [0.05, 0],
@@ -200,6 +189,7 @@ const tableStore: any = new TableStore({
[1000, 80] [1000, 80]
], ],
showSymbol: false, showSymbol: false,
tooltips: { tooltips: {
show: false show: false
} }
@@ -214,18 +204,18 @@ const tableStore: any = new TableStore({
// [0.2, 10, '2023-01-01 10:00:00'], // [0.2, 10, '2023-01-01 10:00:00'],
// [0.4, 50, '2023-01-01 11:00:00'] // [0.4, 50, '2023-01-01 11:00:00']
// ], // ],
legendSymbol: 'circle', legendSymbol: 'circle'
tooltip: { // tooltip: {
show: true, // show: true,
trigger: 'item', // trigger: 'item',
formatter: function (params: any) { // formatter: function (params: any) {
return `<strong>可容忍事件</strong><br/> // return `<strong>可容忍事件</strong><br/>
持续时间: ${params.value[0]}s<br/> // 持续时间: ${params.value[0]}s<br/>
特征幅值: ${params.value[1].toFixed(2)}%<br/> // 特征幅值: ${params.value[1].toFixed(2)}%<br/>
发生时间: ${params.value[2] || 'N/A'}` // 发生时间: ${params.value[2] || 'N/A'}`
} // }
} // }
}, },
{ {
name: '不可容忍事件', name: '不可容忍事件',
@@ -284,8 +274,11 @@ function gongfunction(arr: any) {
let time = arr[i].time let time = arr[i].time
let eventId = arr[i].eventId let eventId = arr[i].eventId
let lineName = arr[i].lineName let lineName = arr[i].lineName
let equipmentName = arr[i].equipmentName
let projectName = arr[i].projectName
let engineeringName = arr[i].engineeringName
// let index =arr[i].eventDetailIndex; // let index =arr[i].eventDetailIndex;
point = [xx, yy, time, eventId, lineName] point = [xx, yy, time, eventId, lineName, equipmentName, projectName, engineeringName]
if (xx <= 0.003) { if (xx <= 0.003) {
let line = 0 let line = 0
@@ -460,7 +453,7 @@ const handleTolerableEventClick = async (row: any) => {
if (res != undefined) { if (res != undefined) {
boxoList.value = { boxoList.value = {
persistTime: row.value[0], //持续时间 persistTime: row.value[0], //持续时间
featureAmplitude: (row.value[1] / 100).toFixed(2), //残余电压 featureAmplitude: (row.value[1] / 100), //残余电压
startTime: row.value[2], //时间 startTime: row.value[2], //时间
lineName: row.value[4] //监测点名称 lineName: row.value[4] //监测点名称
} }
@@ -509,6 +502,6 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -0,0 +1,439 @@
<template>
<div>
<!--ITIC曲线 -->
<TableHeader ref="TableHeaderRef" :showReset="false" :timeKeyList="prop.timeKey" @selectChange="selectChange"
datePicker v-if="fullscreen"></TableHeader>
<el-descriptions class="mt2" direction="vertical" :column="4" border>
<el-descriptions-item align="center" label="名称">{{ data.name }}</el-descriptions-item>
<el-descriptions-item align="center" label="事件总数">{{ data.gs }}</el-descriptions-item>
<el-descriptions-item align="center" label="可容忍">{{ data.krr }}</el-descriptions-item>
<el-descriptions-item align="center" label="不可容忍">{{ data.bkrr }}</el-descriptions-item>
</el-descriptions>
<my-echart v-loading="tableStore.table.loading" ref="chartRef" class="tall" :options="echartList" :style="{
width: prop.width,
height: `calc(${prop.height} - 80px - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" @chart-click="handleChartClick" />
<el-dialog v-model="isWaveCharts" v-if="isWaveCharts" draggable :title="dialogTitle" append-to-body width="70%">
<waveFormAnalysis v-loading="loading" ref="waveFormAnalysisRef" @handleHideCharts="isWaveCharts = false"
:wp="wp" />
</el-dialog>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, computed, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import MyEchart from '@/components/echarts/MyEchart.vue'
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
import TableHeader from '@/components/table/header/index.vue'
import { analyseWave } from '@/api/common'
import { ElMessage } from 'element-plus'
import { getTime } from '@/utils/formatTime'
const prop = defineProps({
w: { type: [String, Number] },
h: { type: [String, Number] },
width: { type: [String, Number] },
height: { type: [String, Number] },
timeKey: { type: Array as () => string[] },
timeValue: { type: Object },
interval: { type: Number }
})
const TableHeaderRef = ref()
const headerHeight = ref(57)
const dialogTitle = ref('波形分析')
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
headerHeight.value = height
if (datePickerValue && datePickerValue.timeValue) {
// 更新时间参数
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
}
}
// 计算是否全屏展示
const fullscreen = computed(() => {
const w = Number(prop.w)
const h = Number(prop.h)
if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) {
// 执行相应逻辑
return true
} else {
return false
}
})
const echartList = ref()
const chartRef = ref()
// 波形
const isWaveCharts = ref(false)
const loading = ref(false)
const wp = ref({})
const boxoList: any = ref({})
const waveFormAnalysisRef: any = ref(null)
const data = reactive({
name: '事件个数',
gs: 0,
krr: 0,
bkrr: 0
})
const tableStore: any = new TableStore({
url: '/cs-harmonic-boot/csevent/f47Curve',
method: 'POST',
showPage: false,
column: [],
beforeSearchFun: () => {
setTime()
},
loadCallback: () => {
const gongData = gongfunction(tableStore.table.data)
data.gs = tableStore.table.data.length
data.krr = gongData.pointI.length
data.bkrr = gongData.pointIun.length
echartList.value = {
title: {
text: `ITIC曲线`
},
legend: {
data: ['上限', '下限', '可容忍事件', '不可容忍事件'],
// itemWidth: 10,
// itemHeight: 10,
itemGap: 15
},
tooltip: {
trigger: 'item',
show: true,
axisPointer: {
type: 'shadow',
label: {
color: '#fff',
fontSize: 16
}
},
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.55)',
borderWidth: 0,
formatter: function (a: any) {
var relVal = `<strong>${a.seriesName}</strong><br/>`
relVal += "<font style='color:" + "'>发生时间:" + a.value[2] + '</font><br/>'
relVal += "<font style='color:" + "'>特征幅值:" + Math.floor(a.value[1] * 100) / 100 + '%</font><br/>'
relVal += "<font style='color:" + "'>持续时间:" + a.value[0] + 's</font><br/>'
relVal += "<font style='color:" + "'>监测点名称:" + (a.value[4] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>设备名称:" + (a.value[5] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>项目名称:" + (a.value[6] || '/') + '</font><br/>'
relVal += "<font style='color:" + "'>工程名称:" + (a.value[7] || '/') + '</font>'
return relVal
}
},
xAxis: [
{
type: 'log',
min: 0.001,
max: 1000,
splitLine: {
show: false
},
name: 's'
}
],
yAxis: [
{
type: 'value',
splitNumber: 10,
minInterval: 3,
name: '%'
}
],
color: ['#FF8C00', '#00BFFF', 'green', 'red'],
options: {
dataZoom: null,
series: [
{
name: '上限',
type: 'line',
data: [
[0.001, 200],
[0.003, 140],
[0.003, 120],
[0.5, 120],
[0.5, 110],
[10, 110],
[1000, 110]
],
showSymbol: false,
tooltips: {
show: false
}
},
{
name: '下限',
type: 'line',
data: [
[0.02, 0],
[0.02, 70],
[0.5, 70],
[0.5, 80],
[10, 80],
[10, 90],
[1000, 90]
],
showSymbol: false,
tooltips: {
show: false
}
},
{
name: '可容忍事件',
type: 'scatter',
symbol: 'circle',
symbolSize: 8,
data: gongData.pointI,
legendSymbol: 'circle'
},
{
name: '不可容忍事件',
type: 'scatter',
symbol: 'circle',
symbolSize: 8,
data: gongData.pointIun,
legendSymbol: 'rect'
}
]
}
}
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
const setTime = () => {
const time = getTime(
(TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
prop.timeKey,
fullscreen.value
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
: prop.timeValue
)
if (Array.isArray(time)) {
tableStore.table.params.searchBeginTime = time[0]
tableStore.table.params.searchEndTime = time[1]
TableHeaderRef.value?.setInterval(time[2] - 0)
TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
} else {
console.warn('获取时间失败time 不是一个有效数组')
}
}
function gongfunction(arr: any) {
let standI = 0
let unstandI = 0
let pointIun: any[] = []
let pointI: any[] = []
const total = arr.length
if (total > 0) {
for (let i = 0; i < arr.length; i++) {
const xx = arr[i].persistTime
const yy = arr[i].eventValue
const time = arr[i].time
const eventId = arr[i].eventId
const lineName = arr[i].lineName
let equipmentName = arr[i].equipmentName
let projectName = arr[i].projectName
let engineeringName = arr[i].engineeringName
// let index =arr[i].eventDetailIndex;
const point = [xx, yy, time, eventId, lineName, equipmentName, projectName, engineeringName]
if (xx <= 0.003) {
const line = 230 - 30000 * xx
if (yy > line) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 0.02) {
if (yy > 120) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 0.5) {
if (yy > 120 || yy < 70) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else if (xx <= 10) {
if (yy > 110 || yy < 80) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
} else {
if (yy > 110 || yy < 90) {
unstandI++
pointIun.push({
value: point,
itemStyle: { normal: { color: 'red' } }
})
} else {
standI++
pointI.push({
value: point,
itemStyle: { normal: { color: 'green' } }
})
}
}
}
}
return {
standI,
unstandI,
pointI,
pointIun
}
}
onMounted(() => {
setTimeout(() => {
tableStore.index()
}, 100)
})
// 点击事件处理函数
const handleChartClick = (params: any) => {
if (params.seriesName === '可容忍事件') {
// 处理可容忍事件点击
dialogTitle.value = '可容忍事件波形分析'
handleTolerableEventClick(params)
} else if (params.seriesName === '不可容忍事件') {
dialogTitle.value = '不可容忍事件波形分析'
// 处理不可容忍事件点击
// ElMessage.info(`点击了不可容忍事件: 持续时间${params.value[0]}s, 幅值${params.value[1].toFixed(2)}%`)
handleTolerableEventClick(params)
}
}
// 可容忍事件点击处理函数
const handleTolerableEventClick = async (row: any) => {
loading.value = true
nextTick(() => {
if (waveFormAnalysisRef.value) {
//waveFormAnalysisRef.value.setHeight(false, 360)
// waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
}
})
const messageInstance = ElMessage.info(`正在加载,请稍等...`)
await analyseWave(row.value[3]) //eventId
.then(res => {
row.loading1 = false
if (res != undefined) {
boxoList.value = {
persistTime: row.value[0], //持续时间
featureAmplitude: (row.value[1] / 100), //残余电压
startTime: row.value[2], //时间
lineName: row.value[4] //监测点名称
}
boxoList.value.systemType = 'YPT'
wp.value = res.data
}
isWaveCharts.value = true
loading.value = false
})
.catch(() => {
messageInstance.close()
row.loading1 = false
loading.value = false
})
nextTick(() => {
waveFormAnalysisRef.value && waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
waveFormAnalysisRef.value && waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true)
})
}
// 不可容忍事件点击处理函数
const handleIntolerableEventClick = (params: any) => {
console.log('不可容忍事件详情:', params)
}
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
() => prop.timeValue,
(newVal, oldVal) => {
// 当外部时间值变化时,更新表格的时间参数
if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
tableStore.table.params.searchBeginTime = newVal[0]
tableStore.table.params.searchEndTime = newVal[1]
tableStore.index()
}
},
{
deep: true
}
)
const addMenu = () => { }
</script>
<style lang="scss" scoped></style>

View File

@@ -1,20 +1,10 @@
<template> <template>
<div> <div>
<!--暂降方向统计 --> <!--暂降方向统计 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" datePicker
ref="TableHeaderRef" :timeKeyList="prop.timeKey" v-if="fullscreen"></TableHeader>
:showReset="false" <my-echart v-loading="tableStore.table.loading" class="tall" :options="echartList"
@selectChange="selectChange" :style="{ width: prop.width, height: `calc(${prop.height} )` }" />
datePicker
:timeKeyList="prop.timeKey"
v-if="fullscreen"
></TableHeader>
<my-echart
v-loading="tableStore.table.loading"
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} )` }"
/>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -29,7 +19,7 @@ const prop = defineProps({
h: { type: [String, Number] }, h: { type: [String, Number] },
width: { type: [String, Number] }, width: { type: [String, Number] },
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number }
}) })
@@ -126,7 +116,11 @@ const tableStore: any = new TableStore({
title: [ title: [
{ {
text: '暂降方向统计', text: '暂降方向统计',
left: 'center' left: 'center',
textStyle: {
color: '#000',
fontSize: '15'
},
}, },
{ {
text: total + '次', text: total + '次',
@@ -205,6 +199,6 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -47,7 +47,6 @@ const init = () => {
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
formatter: (params: any) => { formatter: (params: any) => {
console.log('🚀 ~ init ~ params:', params)
if (!params || params.length === 0) return '' if (!params || params.length === 0) return ''
// 使用第一个项目的轴标签作为时间标题 // 使用第一个项目的轴标签作为时间标题
@@ -90,8 +89,6 @@ const initData = async (row: any) => {
let [min, max] = yMethod(res.data.map((item: any) => item.value.split(',')).flat()) let [min, max] = yMethod(res.data.map((item: any) => item.value.split(',')).flat())
// 从第一条数据中提取时间作为x轴数据 // 从第一条数据中提取时间作为x轴数据
const firstItem = res.data[0]
const xAxisData = firstItem.time.split(',')
// 定义相位颜色映射 // 定义相位颜色映射
const phaseColors: any = { const phaseColors: any = {
@@ -107,6 +104,7 @@ const initData = async (row: any) => {
return a.phasic.localeCompare(b.phasic) return a.phasic.localeCompare(b.phasic)
}) })
.map((item: any) => { .map((item: any) => {
const xAxisData = item.time.split(',')
const values = xAxisData.map((time: string, index: number) => { const values = xAxisData.map((time: string, index: number) => {
// 将传入的日期与时间拼接成完整的时间字符串 // 将传入的日期与时间拼接成完整的时间字符串
const fullTime = `${row.time} ${time}` const fullTime = `${row.time} ${time}`

View File

@@ -1,27 +1,15 @@
<template> <template>
<div> <div>
<!--指标越限程度 --> <!--指标越限程度 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" datePicker
ref="TableHeaderRef" :timeKeyList="prop.timeKey" v-if="fullscreen"></TableHeader>
:showReset="false" <my-echart class="tall" :options="echartList"
@selectChange="selectChange" :style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }" />
datePicker <Table ref="tableRef" @cell-click="cellClickEvent"
:timeKeyList="prop.timeKey" :height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`" isGroup></Table>
v-if="fullscreen"
></TableHeader>
<my-echart
class="tall"
:options="echartList"
:style="{ width: prop.width, height: `calc(${prop.height} / 2 )` }"
/>
<Table
ref="tableRef"
@cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`"
isGroup
></Table>
<!-- 指标日趋势图 --> <!-- 指标日趋势图 -->
<DailyTrendChart v-if="dialogTrendChart" ref="dailyTrendChartRef" @close="dialogTrendChart = false" /> <HarmonicRatio ref="harmonicRatioRef" v-if="dialogFlag" @close="onHarmonicRatioClose" :showIndex="false" />
<!-- <DailyTrendChart v-if="dialogTrendChart" ref="dailyTrendChartRef" @close="dialogTrendChart = false" /> -->
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -31,9 +19,10 @@ import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { getTimeOfTheMonth } from '@/utils/formatTime' import { getTimeOfTheMonth } from '@/utils/formatTime'
import { ElMessage, ElMessageBox } from 'element-plus'
import DailyTrendChart from '@/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue' import DailyTrendChart from '@/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import HarmonicRatio from '@/components/cockpit/overLimitStatistics/components/harmonicRatio.vue'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
h: { type: [String, Number] }, h: { type: [String, Number] },
@@ -47,7 +36,7 @@ const prop = defineProps({
const TableHeaderRef = ref() const TableHeaderRef = ref()
const headerHeight = ref(57) const headerHeight = ref(57)
const harmonicRatioRef: any = ref(null)
const dialogTrendChart = ref(false) const dialogTrendChart = ref(false)
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
@@ -92,74 +81,82 @@ const tableStore: any = new TableStore({
{ {
title: '指标名称', title: '指标名称',
field: 'name', field: 'name',
minWidth: '90' minWidth: 120
},
{
title: '越限最高监测点',
field: 'lineName',
minWidth: 120,
formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
title: '设备名称', field: 'devName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
title: '项目名称', field: 'projectName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
}, },
{ {
title: '越限最大值', title: '越限最大值',
field: 'maxValue', field: 'maxValue',
minWidth: '70', minWidth: 100,
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
const extentValue = const extentValue =
row.maxValue !== null && row.maxValue !== undefined && row.maxValue !== '' row.maxValue !== null && row.maxValue !== undefined && row.maxValue !== ''
? Math.floor(row.maxValue * 100) / 100 ? Math.floor(row.maxValue * 100) / 100
: '/' : '/'
return `<span style='cursor: pointer;text-decoration: underline;'>${extentValue}</span>` return extentValue=='/' ? '/' : `<span style='cursor: pointer;text-decoration: underline;'>${extentValue}</span>`
} }
}, },
{ {
title: '国标限值', title: '国标限值',
field: 'internationalValue', field: 'internationalValue',
minWidth: '60' minWidth: 100, formatter: (row: any) => {
return row.cellValue || '/'
}
}, },
{ {
title: '越限程度(%)', title: '越限程度(%)',
field: 'extent', field: 'extent',
minWidth: '70', minWidth: 100,
formatter: (row: any) => { formatter: (row: any) => {
return Math.floor(row.cellValue * 100) / 100 return row.cellValue? Math.floor(row.cellValue * 100) / 100 : '/'
} }
}, },
{ {
title: '越限时间', title: '越限时间',
field: 'time', field: 'time',
minWidth: '60', minWidth: 100,
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue || '/' return row.cellValue || '/'
} }
}, },
{
title: '越限最高监测点',
field: 'lineName',
minWidth: '90',
formatter: (row: any) => {
return row.cellValue || '/'
}
}
], ],
beforeSearchFun: () => { beforeSearchFun: () => {
setTime() setTime()
}, },
loadCallback: () => { loadCallback: () => {
// 定义 x 轴标签顺序 // 定义 x 轴标签顺序
const xAxisLabels = ['长时闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
// 根据指标名称顺序提取对应的 extent 数据
const chartData = xAxisLabels.map(label => {
// 在表格数据中查找对应指标名称的数据项
const item = tableStore.table.data.find((row: any) => row.name === label)
// 如果找到对应项,则返回 extent 值,否则返回 0并保留两位小数
const extentValue = item ? item.extent || 0 : 0
return Math.round(extentValue * 100) / 100
})
echartList.value = { echartList.value = {
title: { title: {
text: '指标越限严重度' text: '指标越限度'
}, },
xAxis: { xAxis: {
data: xAxisLabels data: tableStore.table.data.map((item: any) => item.name)
}, },
yAxis: { yAxis: {
@@ -174,8 +171,8 @@ const tableStore: any = new TableStore({
series: [ series: [
{ {
type: 'bar', type: 'bar',
name: '越限占比', name: '指标越限程度',
data: chartData, data: tableStore.table.data.map((item: any) => Math.floor(item.extent * 100) / 100),
barMaxWidth: 30 barMaxWidth: 30
} }
] ]
@@ -188,15 +185,32 @@ const tableRef = ref()
provide('tableRef', tableRef) provide('tableRef', tableRef)
provide('tableStore', tableStore) provide('tableStore', tableStore)
const codeMap = [
{ key: '闪变', code: 'flickerOvertime' },
{ key: '电压偏差', code: 'voltageDevOvertime' },
{ key: '三相', code: 'ubalanceOvertime' },
{ key: '谐波电压', code: 'uharm' },
{ key: '谐波电流', code: 'iharm' },
];
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
dialogTrendChart.value = true dialogTrendChart.value = true
if (column.field == 'maxValue' && row.lineId) { if (column.field == 'maxValue') {
nextTick(() => { if (row.lineId == null) {
dailyTrendChartRef.value.open(row) ElMessage.info('暂无越限监测点!')
}) } else {
nextTick(() => {
// dailyTrendChartRef.value.open(row)
dialogFlag.value = true
nextTick(() => {
const code = codeMap.find(item => row.name.includes(item.key))?.code || '';
harmonicRatioRef.value.openDialog(row, code, column.title.replace(/次/g, ""))
})
})
}
} }
} }
@@ -218,6 +232,14 @@ const setTime = () => {
console.warn('获取时间失败time 不是一个有效数组') console.warn('获取时间失败time 不是一个有效数组')
} }
} }
const dialogFlag = ref(false)
// 谐波弹窗关闭时的回调
const onHarmonicRatioClose = () => {
dialogFlag.value = false
// 重新打开指标越限详情弹窗
}
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
@@ -238,6 +260,6 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -1,75 +1,96 @@
<template> <template>
<div> <div class="device-control">
<!--治理效果报表 --> <!--治理效果报表 -->
<TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef" datePicker @selectChange="selectChange" v-if="fullscreen"> <div v-show="fullscreen">
<template v-slot:select> <!-- <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree> -->
<el-form-item label="模板策略"> <APFTree :height="flag ? 126 : 70" @node-click="handleNodeClick" template @init="handleNodeClick"></APFTree>
<el-select filterable v-model="tableStore.table.params.tempId" placeholder="请选择模板策略" clearable>
<el-option v-for="item in templateList" :key="item.id" :label="item.excelName" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="监测对象">
<el-select filterable v-model="tableStore.table.params.sensitiveUserId" placeholder="请选择监测对象" clearable>
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
</template>
<template v-slot:operation>
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出</el-button>
</template>
</TableHeader>
<div style="display: flex">
<div
id="luckysheet"
:style="{
width: `calc(${prop.width} )`,
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}"
></div>
</div> </div>
<div>
<TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef" datePicker
@selectChange="selectChange" v-if="fullscreen">
<template v-slot:select>
<el-form-item label="模板策略">
<el-select filterable v-model="tableStore.table.params.tempId" placeholder="请选择模板策略" clearable>
<el-option v-for="item in templateList" :key="item.id" :label="item.excelName"
:value="item.id" />
</el-select>
</el-form-item>
<!-- <el-form-item label="监测对象">
<el-select filterable v-model="tableStore.table.params.sensitiveUserId" placeholder="请选择监测对象"
clearable>
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item> -->
</template>
<template v-slot:operation>
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出</el-button>
</template>
</TableHeader>
<div style="display: flex">
<div id="luckysheet" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}" v-if="tableStore.table.data.length"></div>
<el-empty description="暂无报表" v-else style="flex: 1" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}"></el-empty>
</div>
</div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide, reactive, watch, h, computed, nextTick } from 'vue' import { ref, onMounted, onUnmounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import { exportExcel } from '@/views/govern/reportForms/export.js' import { exportExcel } from '@/views/govern/reportForms/export.js'
import { destroyLuckysheet, renderLuckysheetReport } from '@/utils/luckysheetHelper'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit' import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import APFTree from '@/components/tree/govern/APFTree.vue'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
h: { type: [String, Number] }, h: { type: [String, Number] },
width: { type: [String, Number] }, width: { type: [String, Number] },
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const TableHeaderRef = ref() const TableHeaderRef = ref()
// 报表模板列表 // 报表模板列表
const templateList = ref() const templateList = ref([])
// 监测对象 // 监测对象
const idList = ref() const idList = ref()
// 监测对象
const initListByIds = () => {
getListByIds({}).then((res: any) => {
if (res.data.length > 0) {
idList.value = res.data
if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) { const handleNodeClick = async (data: any) => {
tableStore.table.params.sensitiveUserId = idList.value[0].id if (templateList.value.length == 0) {
await querySysExcel({}).then(res => {
templateList.value = res.data.filter(item => item.excelType == 4)
if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
tableStore.table.params.tempId = templateList.value[0].id
} }
templateListData() })
} }
})
if (data?.level == 3 || data?.level == 2) {
tableStore.table.params.sensitiveUserId = data.id
await tableStore.index()
} else {
tableStore.table.loading = false
}
} }
const templateListData = () => { const templateListData = () => {
querySysExcel({}).then(res => { querySysExcel({}).then(res => {
templateList.value = res.data.filter(item => item.excelType == 4) templateList.value = res.data.filter(item => item.excelType == 4)
@@ -87,7 +108,11 @@ const downloadExcel = () => {
} }
onMounted(() => { onMounted(() => {
initListByIds()
// initListByIds()
})
onUnmounted(() => {
destroyLuckysheet()
}) })
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
@@ -129,16 +154,7 @@ const tableStore: any = new TableStore({
// } // }
}, },
loadCallback: () => { loadCallback: () => {
luckysheet.create({ renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
container: 'luckysheet',
title: '', // 表 头名
lang: 'zh', // 中文
showtoolbar: false, // 是否显示工具栏
showinfobar: false, // 是否显示顶部信息栏
showsheetbar: true, // 是否显示底部sheet按钮
allowEdit: false, // 禁止所有编辑操作(必填)
data: tableStore.table.data
})
} }
}) })
@@ -174,6 +190,12 @@ watch(
tableStore.index() tableStore.index()
} }
) )
watch(
() => prop.height,
val => {
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
}
)
watch( watch(
() => prop.timeValue, () => prop.timeValue,
(newVal, oldVal) => { (newVal, oldVal) => {
@@ -188,4 +210,11 @@ watch(
// :deep(.el-select) { // :deep(.el-select) {
// min-width: 80px; // min-width: 80px;
// } // }
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style> </style>

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="dialogTitle" v-model="dialogVisible" append-to-body width="70%">
<!-- 总体指标占比详情谐波含有率 --> <!-- 总体指标占比详情谐波含有率 -->
<div> <div>
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange"> <TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
@@ -8,22 +8,10 @@
<DatePicker ref="datePickerRef"></DatePicker> <DatePicker ref="datePickerRef"></DatePicker>
</el-form-item> </el-form-item>
<el-form-item label="统计指标" label-width="80px"> <el-form-item label="统计指标" label-width="80px">
<el-select <el-select multiple :multiple-limit="2" collapse-tags collapse-tags-tooltip
multiple v-model="searchForm.index" placeholder="请选择统计指标" @change="onIndexChange($event)" filterable>
:multiple-limit="2" <el-option v-for="item in indexOptions" :key="item.id" :label="item.name"
collapse-tags :value="item.id"></el-option>
collapse-tags-tooltip
v-model="searchForm.index"
placeholder="请选择统计指标"
@change="onIndexChange($event)"
filterable
>
<el-option
v-for="item in indexOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@@ -33,12 +21,8 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="统计类型"> <el-form-item label="统计类型">
<el-select <el-select style="min-width: 90px !important" placeholder="请选择" v-model="searchForm.valueType"
style="min-width: 90px !important" filterable>
placeholder="请选择"
v-model="searchForm.valueType"
filterable
>
<el-option value="max" label="最大值"></el-option> <el-option value="max" label="最大值"></el-option>
<el-option value="min" label="最小值"></el-option> <el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option> <el-option value="avg" label="平均值"></el-option>
@@ -46,38 +30,21 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div <div class="history_count" v-for="(item, index) in countData" :key="index"
class="history_count" v-show="item.countOptions.length != 0">
v-for="(item, index) in countData"
:key="index"
v-show="item.countOptions.length != 0"
>
<span class="mr12"> <span class="mr12">
{{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }} {{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }}
</span> </span>
<el-select <el-select v-model="item.count" @change="onCountChange($event, index)" placeholder="请选择谐波次数"
v-model="item.count" style="width: 100px" class="mr20" filterable>
@change="onCountChange($event, index)" <el-option v-for="vv in item.countOptions" :key="vv"
placeholder="请选择谐波次数" :label="item.name.includes('间谐波') ? vv - 0.5 : vv" :value="vv"></el-option>
style="width: 100px"
class="mr20"
filterable
>
<el-option
v-for="vv in item.countOptions"
:key="vv"
:label="item.name.includes('间谐波') ? vv - 0.5 : vv"
:value="vv"
></el-option>
</el-select> </el-select>
</div> </div>
</el-form-item> </el-form-item>
</template> </template>
<template #operation> <template #operation>
<el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button> <el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button>
<el-button :type="timeControl ? 'primary' : ''" icon="el-icon-Sort" @click="setTimeControl">
缺失数据
</el-button>
</template> </template>
</TableHeader> </TableHeader>
</div> </div>
@@ -94,7 +61,7 @@ import { ref, onMounted, watch } from 'vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { queryStatistical } from '@/api/system-boot/csstatisticalset' import { queryStatistical } from '@/api/system-boot/csstatisticalset'
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod' import { yMethod, exportSeriesCSV, completeTimeSeries } from '@/utils/echartMethod'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit' import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
import DatePicker from '@/components/form/datePicker/index.vue' import DatePicker from '@/components/form/datePicker/index.vue'
@@ -109,6 +76,7 @@ const props = defineProps({
type: Array type: Array
} }
}) })
const dialogTitle = ref('趋势图')
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
// console.log("🚀 ~ props:", props.TrendList) // console.log("🚀 ~ props:", props.TrendList)
@@ -165,14 +133,14 @@ const initCode = (field: string, title: string) => {
let codeKey = field.includes('flickerOvertime') let codeKey = field.includes('flickerOvertime')
? '闪变' ? '闪变'
: field.includes('uharm') : field.includes('uharm')
? '谐波电压' ? '谐波电压'
: field.includes('iharm') : field.includes('iharm')
? '谐波电流' ? '谐波电流'
: field.includes('voltageDevOvertime') : field.includes('voltageDevOvertime')
? '电压偏差' ? '电压偏差'
: field.includes('ubalanceOvertime') : field.includes('ubalanceOvertime')
? '不平衡' ? '不平衡'
: '' : ''
// const titleMap: Record<string, number> = { // const titleMap: Record<string, number> = {
// flickerOvertime: 0, // flickerOvertime: 0,
@@ -381,8 +349,7 @@ const setEchart = () => {
itemStyle: { opacity: 0 }, //去圆点 itemStyle: { opacity: 0 }, //去圆点
type: 'scroll', // 开启滚动分页 type: 'scroll', // 开启滚动分页
// orient: 'vertical', // 垂直排列 // orient: 'vertical', // 垂直排列
top: 5,
right: 70
// width: 550, // width: 550,
// height: 50 // height: 50
}, },
@@ -442,27 +409,22 @@ const setEchart = () => {
myTool1: { myTool1: {
show: true, show: true,
title: '下载csv', title: '下载csv',
icon: 'path://M588.8 551.253333V512H352v39.253333h236.373333z m0 78.933334v-39.253334H352v39.253334h236.373333z m136.533333 78.933333V334.933333l-157.866666-157.866666H273.066667A59.306667 59.306667 0 0 0 213.333333 236.373333v551.253334a59.306667 59.306667 0 0 0 59.306667 59.306666h274.773333v42.666667H853.333333v-180.48zM568.746667 234.666667l100.266666 100.693333h-81.066666a20.053333 20.053333 0 0 1-19.626667-20.053333z m-20.48 573.013333H273.066667a19.2 19.2 0 0 1-17.493334-19.626667V236.373333a19.2 19.2 0 0 1 19.626667-19.626666h256v98.133333a58.88 58.88 0 0 0 58.88 59.306667h96.426667v334.933333h-98.133334v-39.68H352v39.68h196.266667z m100.266666 23.04a37.973333 37.973333 0 0 1-32 15.786667 38.826667 38.826667 0 0 1-32.426666-15.786667 53.76 53.76 0 0 1-10.24-32.853333 42.666667 42.666667 0 0 1 42.666666-47.786667 35.84 35.84 0 0 1 37.546667 29.866667h-12.8a23.893333 23.893333 0 0 0-24.746667-19.2c-17.066667 0-29.013333 14.08-29.013333 35.84s11.52 37.546667 28.586667 37.546666a26.453333 26.453333 0 0 0 26.453333-25.6h12.8a39.253333 39.253333 0 0 1-7.253333 22.186667z m59.733334 15.786667a35.84 35.84 0 0 1-40.106667-34.56H682.666667a23.893333 23.893333 0 0 0 26.88 23.04c12.8 0 22.613333-6.4 22.613333-15.786667s-4.266667-11.52-14.506667-13.653333l-21.333333-5.12c-17.066667-4.266667-24.32-11.52-24.32-23.893334s12.8-26.453333 34.133333-26.453333a31.573333 31.573333 0 0 1 35.413334 30.293333h-13.653334a19.626667 19.626667 0 0 0-22.613333-18.773333c-12.8 0-20.48 5.12-20.48 12.8s5.12 11.093333 17.066667 13.653333l14.933333 2.986667a42.666667 42.666667 0 0 1 20.906667 8.96 23.893333 23.893333 0 0 1 7.68 17.92c-0.426667 17.066667-14.506667 28.16-37.12 28.16z m88.746666 0h-14.506666l-32.426667-92.16h14.08l19.626667 59.733333 6.4 20.053333c0-9.386667 3.413333-12.8 5.546666-20.053333l19.2-59.733333h14.08z', icon: 'path://M642 673.1H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9s-8 17.9-17.9 17.9zM642 511.8H301.6c-9.9 0-17.9-8-17.9-17.9 0-9.9 8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9 0 9.9-8 17.9-17.9 17.9zM480.7 350.6H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9h179.2c9.9 0 17.9 8 17.9 17.9s-8.1 17.9-18 17.9zM874.9 350.6H695.7c-49.4 0-89.6-40.2-89.6-89.6V81.9c0-9.9 8-17.9 17.9-17.9 9.9 0 17.9 8 17.9 17.9V261c0 29.6 24.1 53.7 53.7 53.7h179.2c9.9 0 17.9 8 17.9 17.9s-7.9 18-17.8 18zM794.3 959.7H221c-49.4 0-89.6-40.2-89.6-89.6V153.5c0-49.4 40.2-89.6 89.6-89.6h403.1c4.8 0 9.3 1.9 12.7 5.2L887.6 320c3.4 3.4 5.2 7.9 5.2 12.7v537.5c0 52.7-51.9 89.5-98.5 89.5zM221 99.8c-29.6 0-53.7 24.1-53.7 53.7v716.6c0 29.6 24.1 53.7 53.7 53.7h573.3c29 0 62.7-23.5 62.7-53.7v-530L616.7 99.8H221z',
onclick: e => { onclick: () => {
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data)) exportSeriesCSV(
echartsData.value.options.series,
let list = echartsData.value.options.series?.map((item: any) => item.data) `${dialogTitle.value || '监测点指标趋势'}.csv`
let dataList = list[0]?.map((item: any, index: any) => {
let value = [item[0], item[1]]
list.forEach((item1: any, index1: any) => {
if (index1 > 0) {
value.push(item1 && item1[index] ? item1[index][1] : null)
}
})
return value
})
exportCSV(
echartsData.value.options.series.map((item: any) => item.name),
dataList,
'监测点指标趋势.csv'
) )
} }
},
myTool2: {
show: true,
title: timeControl.value ? '关闭缺失数据' : '缺失数据',
icon: 'path://M832 512l-192-192v128H128v128h512v128l192-192zM192 512l192 192v-128h512v-128H384V320L192 512z',
iconStyle: timeControl.value ? { borderColor: '#409EFF' } : {},
onclick: () => {
setTimeControl()
}
} }
} }
}, },
@@ -506,10 +468,10 @@ const setEchart = () => {
return item.anotherName == '电压负序分量' return item.anotherName == '电压负序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName == '电压正序分量' : item.anotherName == '电压正序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName == '电压零序分量' : item.anotherName == '电压零序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName : item.anotherName
}) })
) )
] ]
@@ -543,10 +505,10 @@ const setEchart = () => {
(kk[0].anotherName == '电压负序分量' (kk[0].anotherName == '电压负序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName == '电压正序分量' : kk[0].anotherName == '电压正序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName == '电压零序分量' : kk[0].anotherName == '电压零序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName) : kk[0].anotherName)
) )
let seriesList: any = [] let seriesList: any = []
@@ -644,7 +606,7 @@ const onIndexChange = (val: any) => {
} }
watch( watch(
() => searchForm.value.index, () => searchForm.value.index,
(val: any, oldval: any) => {}, (val: any, oldval: any) => { },
{ {
deep: true, deep: true,
immediate: true immediate: true
@@ -652,6 +614,7 @@ watch(
) )
const openDialog = async (row: any, field: any, title: any) => { const openDialog = async (row: any, field: any, title: any) => {
dialogTitle.value = row?.lineName + '_趋势图'
dialogVisible.value = true dialogVisible.value = true
trendRequestData.value = row trendRequestData.value = row

View File

@@ -1,10 +1,10 @@
<template> <template>
<div> <div>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="title" v-model="dialogVisible" append-to-body width="70%">
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef"> <TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
<template v-slot:select> <template v-slot:select>
<el-form-item label="监测点"> <!-- <el-form-item label="监测点">
<el-select <el-select
v-model="tableStore.table.params.lineId" v-model="tableStore.table.params.lineId"
placeholder="请选择监测点" placeholder="请选择监测点"
@@ -18,7 +18,7 @@
:value="item.lineId" :value="item.lineId"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table> <Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
@@ -38,7 +38,7 @@ import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
const harmonicRatioRef: any = ref(null) const harmonicRatioRef: any = ref(null)
const title = ref('指标越限详情')
const options = ref() const options = ref()
const height = mainHeight(0, 2).height as any const height = mainHeight(0, 2).height as any
const tableHeaderRef = ref() const tableHeaderRef = ref()
@@ -76,13 +76,13 @@ const tableStore: any = new TableStore({
{ {
title: '日期', title: '日期',
field: 'time', field: 'time',
width: '150', width: '120',
sortable: true sortable: true
}, },
{ {
title: '名称', title: '名称',
field: 'lineName', field: 'lineName',
width: '150' width: '120'
}, },
{ {
title: '长时闪变越限(%)', title: '长时闪变越限(%)',
@@ -93,15 +93,7 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
} }
}, },
{ {
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
},
{
title: '电压偏差越限(%)', title: '电压偏差越限(%)',
field: 'voltageDevOvertime', field: 'voltageDevOvertime',
width: '100', width: '100',
@@ -119,6 +111,15 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
} }
}, },
{
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
},
// { // {
// title: '频率偏差越限(%)', // title: '频率偏差越限(%)',
@@ -142,6 +143,7 @@ tableStore.table.params.sortBy = ''
tableStore.table.params.orderBy = '' tableStore.table.params.orderBy = ''
const open = async (row: any,searchBeginTime:any,searchEndTime:any,interval:any,list:any) => { const open = async (row: any,searchBeginTime:any,searchEndTime:any,interval:any,list:any) => {
dialogVisible.value = true dialogVisible.value = true
title.value = row.lineName + '_指标越限详情'
options.value = list options.value = list
// initCSlineList() // initCSlineList()
tableStore.table.params.lineId = row.lineId tableStore.table.params.lineId = row.lineId
@@ -160,7 +162,7 @@ const open = async (row: any,searchBeginTime:any,searchEndTime:any,interval:any,
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name' && column.field != 'time') { if (column.field != 'lineName' &&column.field != 'name' && column.field != 'time') {
dialogFlag.value = true dialogFlag.value = true
dialogVisible.value = false dialogVisible.value = false
nextTick(() => { nextTick(() => {

View File

@@ -1,28 +1,14 @@
<template> <template>
<div> <div>
<!--电网侧指标越限统计 --> <!--电网侧指标越限统计 -->
<TableHeader <TableHeader :showReset="false" ref="TableHeaderRef" @selectChange="selectChange" datePicker
:showReset="false" :timeKeyList="prop.timeKey" v-if="fullscreen"></TableHeader>
ref="TableHeaderRef" <my-echart class="tall" :options="echartList" :style="{
@selectChange="selectChange" width: prop.width,
datePicker height: `calc(${prop.height} / 2 )`
:timeKeyList="prop.timeKey" }" />
v-if="fullscreen" <Table ref="tableRef" @cell-click="cellClickEvent"
></TableHeader> :height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`" isGroup></Table>
<my-echart
class="tall"
:options="echartList"
:style="{
width: prop.width,
height: `calc(${prop.height} / 2 )`
}"
/>
<Table
ref="tableRef"
@cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`"
isGroup
></Table>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" /> <OverLimitDetails ref="OverLimitDetailsRef" />
</div> </div>
@@ -141,17 +127,20 @@ const tableStore: any = new TableStore({
} }
}, },
{ {
title: '名称', title: '监测点名称',
field: 'lineName', field: 'lineName',
minWidth: '90' minWidth: 120
}, },
{ title: '设备名称', field: 'devName', minWidth: 130, align: 'center', },
{ title: '项目名称', field: 'projectName', minWidth: 130, align: 'center' },
{ title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center' },
{ {
title: '越限占比(%)', title: '越限占比(%)',
children: [ children: [
{ {
title: '长时闪变', title: '长时闪变',
field: 'flicker', field: 'flicker',
minWidth: '70', minWidth: '80',
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
@@ -218,7 +207,7 @@ const cellClickEvent = ({ row, column }: any) => {
tableStore.table.params.searchBeginTime || prop.timeValue?.[0], tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
tableStore.table.params.searchEndTime || prop.timeValue?.[1], tableStore.table.params.searchEndTime || prop.timeValue?.[1],
tableStore.table.params.interval || prop.interval, tableStore.table.params.interval || prop.interval,
tableStore.table.data tableStore.table.data
) )
} }
@@ -261,6 +250,6 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -1,47 +1,32 @@
<template> <template>
<div> <div class="device-control">
<!--指标越限时间分布 <!--指标越限时间分布
--> -->
<TableHeader <div v-show="fullscreen">
:showReset="false" <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree>
:timeKeyList="prop.timeKey" </div>
ref="TableHeaderRef" <div>
@selectChange="selectChange" <TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef"
datePicker @selectChange="selectChange" datePicker v-if="fullscreen">
v-if="fullscreen" <!-- <template v-slot:select>
> <el-form-item label="监测点">
<template v-slot:select> <el-select size="small" filterable v-model="tableStore.table.params.lineId">
<el-form-item label="监测点"> <el-option v-for="item in lineList" :key="item.lineId" :label="item.name"
<el-select size="small" filterable v-model="tableStore.table.params.lineId"> :value="item.lineId" />
<el-option </el-select>
v-for="item in lineList" </el-form-item>
:key="item.lineId" </template> -->
:label="item.name" </TableHeader>
:value="item.lineId" <div v-loading="tableStore.table.loading">
/> <my-echart class="tall" v-if="lineShow" :options="echartList1" :style="{
</el-select> width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
</el-form-item>
</template>
</TableHeader>
<div v-loading="tableStore.table.loading">
<my-echart
class="tall"
v-if="lineShow"
:options="echartList1"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> <el-empty v-else description="暂无监测点" :style="{
<el-empty width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
v-else
description="暂无监测点"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> <!-- <my-echart
<!-- <my-echart
class="mt10" class="mt10"
:options="echartList1" :options="echartList1"
:style="{ :style="{
@@ -49,6 +34,7 @@
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )` height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}" }"
/> --> /> -->
</div>
</div> </div>
</div> </div>
</template> </template>
@@ -59,7 +45,7 @@ import TableHeader from '@/components/table/header/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { limitProbabilityData, cslineList } from '@/api/harmonic-boot/cockpit/cockpit' import { limitProbabilityData, cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import PointTree from '@/components/tree/govern/pointTree.vue'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
h: { type: [String, Number] }, h: { type: [String, Number] },
@@ -67,7 +53,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
// const options = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]')) // const options = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]'))
@@ -106,17 +93,28 @@ const echartList1 = ref()
const probabilityData = ref() const probabilityData = ref()
const initLineList = async () => { // const initLineList = async () => {
cslineList({}).then(res => { // cslineList({}).then(res => {
if (res.data.length == 0) { // if (res.data.length == 0) {
lineShow.value = false // lineShow.value = false
return (tableStore.table.loading = false) // return (tableStore.table.loading = false)
} // }
lineShow.value = true // lineShow.value = true
lineList.value = res.data // lineList.value = res.data
tableStore.table.params.lineId = lineList.value[0].lineId // tableStore.table.params.lineId = lineList.value[0].lineId
// tableStore.index()
// })
// }
const nodeClick = (e: any) => {
if (e == undefined) {
}
if (e.level == 3) {
tableStore.table.params.lineId = e.id
tableStore.index() tableStore.index()
}) }
}
const pointTypeChange = (val: any, obj: any) => {
nodeClick(obj)
} }
// 越限程度概率分布 // 越限程度概率分布
@@ -186,7 +184,7 @@ const initProbabilityData = () => {
var tips = '' var tips = ''
tips += '指标类型: ' + yAxisData[yIndex] + '</br>' tips += '指标类型: ' + yAxisData[yIndex] + '</br>'
tips += '越限程度: ' + params.seriesName + '</br>' tips += '越限程度: ' + params.seriesName + '</br>'
tips += '越限数: ' + params.value[2] + '</br>' tips += '越限数: ' + params.value[2] + '</br>'
return tips return tips
} }
}, },
@@ -228,7 +226,7 @@ const initProbabilityData = () => {
}, },
zAxis3D: { zAxis3D: {
type: 'value', type: 'value',
name: '越限数', name: '越限数',
nameLocation: 'middle', nameLocation: 'middle',
nameGap: 30, nameGap: 30,
minInterval: 10 minInterval: 10
@@ -438,7 +436,7 @@ const tableStore: any = new TableStore({
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
initLineList() // initLineList()
}) })
const setTime = () => { const setTime = () => {
@@ -475,6 +473,14 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped>
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style>

View File

@@ -101,7 +101,7 @@ const tableStore: any = new TableStore({
setTime() setTime()
}, },
loadCallback: () => { loadCallback: () => {
value.value = tableStore.table.params.searchBeginTime value.value = dayjs(tableStore.table.params.searchBeginTime).toDate()
if (tableStore.table.data && tableStore.table.data.length > 0) { if (tableStore.table.data && tableStore.table.data.length > 0) {
list.value = tableStore.table.data.map((item: any) => { list.value = tableStore.table.data.map((item: any) => {
// 将 items 数组转换为带换行的文本 // 将 items 数组转换为带换行的文本

View File

@@ -1,46 +1,31 @@
<template> <template>
<div> <div class="device-control">
<!--指标越限概率分布 --> <!--指标越限概率分布 -->
<TableHeader <div v-show="fullscreen">
:showReset="false" <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree>
:timeKeyList="prop.timeKey" </div>
ref="TableHeaderRef" <div>
@selectChange="selectChange" <TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef"
datePicker @selectChange="selectChange" datePicker v-if="fullscreen">
v-if="fullscreen" <!-- <template v-slot:select>
> <el-form-item label="监测点">
<template v-slot:select> <el-select size="small" filterable v-model="tableStore.table.params.lineId">
<el-form-item label="监测点"> <el-option v-for="item in lineList" :key="item.lineId" :label="item.name"
<el-select size="small" filterable v-model="tableStore.table.params.lineId"> :value="item.lineId" />
<el-option </el-select>
v-for="item in lineList" </el-form-item>
:key="item.lineId" </template> -->
:label="item.name" </TableHeader>
:value="item.lineId" <div v-loading="tableStore.table.loading">
/> <my-echart v-if="lineShow" class="tall" :options="echartList" :style="{
</el-select> width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
</el-form-item>
</template>
</TableHeader>
<div v-loading="tableStore.table.loading">
<my-echart
v-if="lineShow"
class="tall"
:options="echartList"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> <el-empty v-else description="暂无监测点" :style="{
<el-empty width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
v-else
description="暂无监测点"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> <!-- <my-echart
<!-- <my-echart
class="mt10" class="mt10"
:options="echartList1" :options="echartList1"
:style="{ :style="{
@@ -48,7 +33,9 @@
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )` height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}" }"
/> --> /> -->
</div>
</div> </div>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -58,7 +45,7 @@ import TableHeader from '@/components/table/header/index.vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { limitProbabilityData, cslineList } from '@/api/harmonic-boot/cockpit/cockpit' import { limitProbabilityData, cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import PointTree from '@/components/tree/govern/pointTree.vue'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
h: { type: [String, Number] }, h: { type: [String, Number] },
@@ -66,7 +53,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const lineShow = ref(true) const lineShow = ref(true)
// const options = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]')) // const options = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]'))
@@ -105,18 +93,31 @@ const echartList1 = ref()
const probabilityData = ref() const probabilityData = ref()
const initLineList = async () => { // const initLineList = async () => {
cslineList({}).then(res => { // cslineList({}).then(res => {
if (res.data.length == 0) { // if (res.data.length == 0) {
lineShow.value = false // lineShow.value = false
return (tableStore.table.loading = false) // return (tableStore.table.loading = false)
} // }
lineShow.value = true // lineShow.value = true
lineList.value = res.data // lineList.value = res.data
tableStore.table.params.lineId = lineList.value[0].lineId // tableStore.table.params.lineId = lineList.value[0].lineId
// tableStore.index()
// })
// }
const nodeClick = (e: any) => {
if (e == undefined) {
}
if (e.level == 3) {
tableStore.table.params.lineId = e.id
tableStore.index() tableStore.index()
}) }
} }
const pointTypeChange = (val: any, obj: any) => {
nodeClick(obj)
}
// 越限程度概率分布 // 越限程度概率分布
const initProbabilityData = () => { const initProbabilityData = () => {
@@ -185,7 +186,7 @@ const initProbabilityData = () => {
var tips = '' var tips = ''
tips += '指标类型: ' + yAxisData[yIndex] + '</br>' tips += '指标类型: ' + yAxisData[yIndex] + '</br>'
tips += '越限程度: ' + params.seriesName + '</br>' tips += '越限程度: ' + params.seriesName + '</br>'
tips += '越限数: ' + params.value[2] + '</br>' tips += '越限数: ' + params.value[2] + '</br>'
return tips return tips
} }
}, },
@@ -227,7 +228,7 @@ const initProbabilityData = () => {
}, },
zAxis3D: { zAxis3D: {
type: 'value', type: 'value',
name: '越限数', name: '越限数',
nameLocation: 'middle', nameLocation: 'middle',
nameGap: 30, nameGap: 30,
minInterval: 10 minInterval: 10
@@ -437,7 +438,7 @@ const tableStore: any = new TableStore({
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
initLineList() // initLineList()
}) })
const setTime = () => { const setTime = () => {
@@ -474,6 +475,13 @@ watch(
} }
) )
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped>
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style>

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="dialogTitle" v-model="dialogVisible" append-to-body width="70%">
<!-- 总体指标占比详情谐波含有率 --> <!-- 总体指标占比详情谐波含有率 -->
<div> <div>
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange"> <TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
@@ -8,22 +8,10 @@
<DatePicker ref="datePickerRef"></DatePicker> <DatePicker ref="datePickerRef"></DatePicker>
</el-form-item> </el-form-item>
<el-form-item label="统计指标" label-width="80px"> <el-form-item label="统计指标" label-width="80px">
<el-select <el-select multiple :multiple-limit="2" collapse-tags collapse-tags-tooltip
multiple v-model="searchForm.index" placeholder="请选择统计指标" @change="onIndexChange($event)" filterable>
:multiple-limit="2" <el-option v-for="item in indexOptions" :key="item.id" :label="item.name"
collapse-tags :value="item.id"></el-option>
collapse-tags-tooltip
v-model="searchForm.index"
placeholder="请选择统计指标"
@change="onIndexChange($event)"
filterable
>
<el-option
v-for="item in indexOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
@@ -33,12 +21,8 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="统计类型"> <el-form-item label="统计类型">
<el-select <el-select style="min-width: 120px !important" placeholder="请选择" v-model="searchForm.valueType"
style="min-width: 120px !important" filterable>
placeholder="请选择"
v-model="searchForm.valueType"
filterable
>
<el-option value="max" label="最大值"></el-option> <el-option value="max" label="最大值"></el-option>
<el-option value="min" label="最小值"></el-option> <el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option> <el-option value="avg" label="平均值"></el-option>
@@ -46,38 +30,21 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<div <div class="history_count" v-for="(item, index) in countData" :key="index"
class="history_count" v-show="item.countOptions.length != 0">
v-for="(item, index) in countData"
:key="index"
v-show="item.countOptions.length != 0"
>
<span class="mr12"> <span class="mr12">
{{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }} {{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }}
</span> </span>
<el-select <el-select v-model="item.count" @change="onCountChange($event, index)" placeholder="请选择谐波次数"
v-model="item.count" style="width: 100px" class="mr20" filterable>
@change="onCountChange($event, index)" <el-option v-for="vv in item.countOptions" :key="vv"
placeholder="请选择谐波次数" :label="item.name.includes('间谐波') ? vv - 0.5 : vv" :value="vv"></el-option>
style="width: 100px"
class="mr20"
filterable
>
<el-option
v-for="vv in item.countOptions"
:key="vv"
:label="item.name.includes('间谐波') ? vv - 0.5 : vv"
:value="vv"
></el-option>
</el-select> </el-select>
</div> </div>
</el-form-item> </el-form-item>
</template> </template>
<template #operation> <template #operation>
<el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button> <el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button>
<el-button :type="timeControl ? 'primary' : ''" icon="el-icon-Sort" @click="setTimeControl">
缺失数据
</el-button>
</template> </template>
</TableHeader> </TableHeader>
</div> </div>
@@ -94,7 +61,7 @@ import { ref, onMounted, watch } from 'vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { queryStatistical } from '@/api/system-boot/csstatisticalset' import { queryStatistical } from '@/api/system-boot/csstatisticalset'
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod' import { yMethod, exportSeriesCSV, completeTimeSeries } from '@/utils/echartMethod'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit' import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
import DatePicker from '@/components/form/datePicker/index.vue' import DatePicker from '@/components/form/datePicker/index.vue'
@@ -109,6 +76,7 @@ const props = defineProps({
type: Array type: Array
} }
}) })
const dialogTitle = ref('趋势图')
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
// console.log("🚀 ~ props:", props.TrendList) // console.log("🚀 ~ props:", props.TrendList)
@@ -181,14 +149,14 @@ const initCode = (field: string, title: string) => {
let codeKey = field.includes('flickerOvertime') let codeKey = field.includes('flickerOvertime')
? '闪变' ? '闪变'
: field.includes('uharm') : field.includes('uharm')
? '谐波电压' ? '谐波电压'
: field.includes('iharm') : field.includes('iharm')
? '谐波电流' ? '谐波电流'
: field.includes('voltageDevOvertime') : field.includes('uaberrance')
? '电压偏差' ? '电压偏差'
: field.includes('ubalanceOvertime') : field.includes('ubalanceOvertime')
? '不平衡' ? '不平衡'
: '' : ''
let defaultIndex = indexOptions.value.findIndex((item: any) => item.name.includes(codeKey)) || 0 let defaultIndex = indexOptions.value.findIndex((item: any) => item.name.includes(codeKey)) || 0
searchForm.value.index[0] = indexOptions.value[defaultIndex].id searchForm.value.index[0] = indexOptions.value[defaultIndex].id
@@ -380,8 +348,7 @@ const setEchart = () => {
itemStyle: { opacity: 0 }, //去圆点 itemStyle: { opacity: 0 }, //去圆点
type: 'scroll', // 开启滚动分页 type: 'scroll', // 开启滚动分页
// orient: 'vertical', // 垂直排列 // orient: 'vertical', // 垂直排列
top: 5,
right: 70
// width: 550, // width: 550,
// height: 50 // height: 50
}, },
@@ -441,27 +408,22 @@ const setEchart = () => {
myTool1: { myTool1: {
show: true, show: true,
title: '下载csv', title: '下载csv',
icon: 'path://M588.8 551.253333V512H352v39.253333h236.373333z m0 78.933334v-39.253334H352v39.253334h236.373333z m136.533333 78.933333V334.933333l-157.866666-157.866666H273.066667A59.306667 59.306667 0 0 0 213.333333 236.373333v551.253334a59.306667 59.306667 0 0 0 59.306667 59.306666h274.773333v42.666667H853.333333v-180.48zM568.746667 234.666667l100.266666 100.693333h-81.066666a20.053333 20.053333 0 0 1-19.626667-20.053333z m-20.48 573.013333H273.066667a19.2 19.2 0 0 1-17.493334-19.626667V236.373333a19.2 19.2 0 0 1 19.626667-19.626666h256v98.133333a58.88 58.88 0 0 0 58.88 59.306667h96.426667v334.933333h-98.133334v-39.68H352v39.68h196.266667z m100.266666 23.04a37.973333 37.973333 0 0 1-32 15.786667 38.826667 38.826667 0 0 1-32.426666-15.786667 53.76 53.76 0 0 1-10.24-32.853333 42.666667 42.666667 0 0 1 42.666666-47.786667 35.84 35.84 0 0 1 37.546667 29.866667h-12.8a23.893333 23.893333 0 0 0-24.746667-19.2c-17.066667 0-29.013333 14.08-29.013333 35.84s11.52 37.546667 28.586667 37.546666a26.453333 26.453333 0 0 0 26.453333-25.6h12.8a39.253333 39.253333 0 0 1-7.253333 22.186667z m59.733334 15.786667a35.84 35.84 0 0 1-40.106667-34.56H682.666667a23.893333 23.893333 0 0 0 26.88 23.04c12.8 0 22.613333-6.4 22.613333-15.786667s-4.266667-11.52-14.506667-13.653333l-21.333333-5.12c-17.066667-4.266667-24.32-11.52-24.32-23.893334s12.8-26.453333 34.133333-26.453333a31.573333 31.573333 0 0 1 35.413334 30.293333h-13.653334a19.626667 19.626667 0 0 0-22.613333-18.773333c-12.8 0-20.48 5.12-20.48 12.8s5.12 11.093333 17.066667 13.653333l14.933333 2.986667a42.666667 42.666667 0 0 1 20.906667 8.96 23.893333 23.893333 0 0 1 7.68 17.92c-0.426667 17.066667-14.506667 28.16-37.12 28.16z m88.746666 0h-14.506666l-32.426667-92.16h14.08l19.626667 59.733333 6.4 20.053333c0-9.386667 3.413333-12.8 5.546666-20.053333l19.2-59.733333h14.08z', icon: 'path://M642 673.1H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9s-8 17.9-17.9 17.9zM642 511.8H301.6c-9.9 0-17.9-8-17.9-17.9 0-9.9 8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9 0 9.9-8 17.9-17.9 17.9zM480.7 350.6H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9h179.2c9.9 0 17.9 8 17.9 17.9s-8.1 17.9-18 17.9zM874.9 350.6H695.7c-49.4 0-89.6-40.2-89.6-89.6V81.9c0-9.9 8-17.9 17.9-17.9 9.9 0 17.9 8 17.9 17.9V261c0 29.6 24.1 53.7 53.7 53.7h179.2c9.9 0 17.9 8 17.9 17.9s-7.9 18-17.8 18zM794.3 959.7H221c-49.4 0-89.6-40.2-89.6-89.6V153.5c0-49.4 40.2-89.6 89.6-89.6h403.1c4.8 0 9.3 1.9 12.7 5.2L887.6 320c3.4 3.4 5.2 7.9 5.2 12.7v537.5c0 52.7-51.9 89.5-98.5 89.5zM221 99.8c-29.6 0-53.7 24.1-53.7 53.7v716.6c0 29.6 24.1 53.7 53.7 53.7h573.3c29 0 62.7-23.5 62.7-53.7v-530L616.7 99.8H221z',
onclick: e => { onclick: () => {
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data)) exportSeriesCSV(
echartsData.value.options.series,
let list = echartsData.value.options.series?.map((item: any) => item.data) `${dialogTitle.value || '历史趋势'}.csv`
let dataList = list[0]?.map((item: any, index: any) => {
let value = [item[0], item[1]]
list.forEach((item1: any, index1: any) => {
if (index1 > 0) {
value.push(item1 && item1[index] ? item1[index][1] : null)
}
})
return value
})
exportCSV(
echartsData.value.options.series.map((item: any) => item.name),
dataList,
'历史趋势.csv'
) )
} }
},
myTool2: {
show: true,
title: timeControl.value ? '关闭缺失数据' : '缺失数据',
icon: 'path://M832 512l-192-192v128H128v128h512v128l192-192zM192 512l192 192v-128h512v-128H384V320L192 512z',
iconStyle: timeControl.value ? { borderColor: '#409EFF' } : {},
onclick: () => {
setTimeControl()
}
} }
} }
}, },
@@ -505,10 +467,10 @@ const setEchart = () => {
return item.anotherName == '电压负序分量' return item.anotherName == '电压负序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName == '电压正序分量' : item.anotherName == '电压正序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName == '电压零序分量' : item.anotherName == '电压零序分量'
? '电压不平衡' ? '电压不平衡'
: item.anotherName : item.anotherName
}) })
) )
] ]
@@ -542,10 +504,10 @@ const setEchart = () => {
(kk[0].anotherName == '电压负序分量' (kk[0].anotherName == '电压负序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName == '电压正序分量' : kk[0].anotherName == '电压正序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName == '电压零序分量' : kk[0].anotherName == '电压零序分量'
? '电压不平衡' ? '电压不平衡'
: kk[0].anotherName) : kk[0].anotherName)
) )
let seriesList: any = [] let seriesList: any = []
@@ -643,7 +605,7 @@ const onIndexChange = (val: any) => {
} }
watch( watch(
() => searchForm.value.index, () => searchForm.value.index,
(val: any, oldval: any) => {}, (val: any, oldval: any) => { },
{ {
deep: true, deep: true,
immediate: true immediate: true
@@ -652,6 +614,8 @@ watch(
const openDialog = async (row: any, field: any, title: any) => { const openDialog = async (row: any, field: any, title: any) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = row?.lineName + '_趋势图'
trendRequestData.value = row trendRequestData.value = row
nextTick(() => { nextTick(() => {

View File

@@ -1,9 +1,9 @@
<template> <template>
<div> <div>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="title" v-model="dialogVisible" append-to-body width="70%">
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef"> <TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
<template v-slot:select> <!-- <template v-slot:select>
<el-form-item label="监测点"> <el-form-item label="监测点">
<el-select <el-select
v-model="tableStore.table.params.lineId" v-model="tableStore.table.params.lineId"
@@ -19,7 +19,7 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
</template> </template> -->
</TableHeader> </TableHeader>
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table> <Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
</el-dialog> </el-dialog>
@@ -28,7 +28,7 @@
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, provide,nextTick } from 'vue' import { ref, provide, nextTick } from 'vue'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
@@ -40,7 +40,7 @@ const dialogVisible: any = ref(false)
const harmonicRatioRef: any = ref(null) const harmonicRatioRef: any = ref(null)
const dialogFlag = ref(false) const dialogFlag = ref(false)
const title = ref('指标越限详情')
const options = ref() const options = ref()
const height = mainHeight(0, 2).height as any const height = mainHeight(0, 2).height as any
const tableHeaderRef = ref() const tableHeaderRef = ref()
@@ -77,31 +77,23 @@ const tableStore: any = new TableStore({
{ {
title: '日期', title: '日期',
field: 'time', field: 'time',
width: '150', width: '120',
sortable: true sortable: true
}, },
{ {
title: '名称', title: '监测点名称',
field: 'lineName', field: 'lineName',
width: '150' width: '120'
}, },
{ {
title: '越限(分钟)', title: '长时闪变越限(分钟)',
field: 'flickerOvertime', field: 'flickerOvertime',
width: '90', width: '100',
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
} }
}, }, {
{
title: '谐波电压越限(分钟)',
children: loop50('uharm')
},
{
title: '谐波电流越限(分钟)',
children: loop50('iharm')
}, {
title: '电压偏差越限(分钟)', title: '电压偏差越限(分钟)',
field: 'uaberranceOvertime', field: 'uaberranceOvertime',
width: '100', width: '100',
@@ -119,6 +111,14 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
} }
}, },
{
title: '谐波电压越限(分钟)',
children: loop50('uharm')
},
{
title: '谐波电流越限(分钟)',
children: loop50('iharm')
},
// { // {
// title: '频率偏差越限(分钟)', // title: '频率偏差越限(分钟)',
@@ -130,7 +130,7 @@ const tableStore: any = new TableStore({
// } // }
// } // }
], ],
beforeSearchFun: () => { beforeSearchFun: () => {
}, },
loadCallback: () => { loadCallback: () => {
} }
@@ -140,15 +140,17 @@ const tableStore: any = new TableStore({
provide('tableStore', tableStore) provide('tableStore', tableStore)
tableStore.table.params.sortBy = '' tableStore.table.params.sortBy = ''
tableStore.table.params.orderBy = '' tableStore.table.params.orderBy = ''
const open = async (row: any,searchBeginTime:any,searchEndTime:any,data:any=[]) => { const open = async (row: any, searchBeginTime: any, searchEndTime: any, data: any = []) => {
console.log("🚀 ~ open ~ row:", row)
dialogVisible.value = true dialogVisible.value = true
// initCSlineList() // initCSlineList()
options.value = data options.value = data
title.value = row.lineName + '_指标越限详情'
tableStore.table.params.lineId = row.lineId tableStore.table.params.lineId = row.lineId
nextTick(() => { nextTick(() => {
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime]) tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
tableStore.table.params.searchBeginTime =searchBeginTime tableStore.table.params.searchBeginTime = searchBeginTime
tableStore.table.params.searchEndTime = searchEndTime tableStore.table.params.searchEndTime = searchEndTime
tableStore.index() tableStore.index()
}) })
@@ -157,11 +159,11 @@ const open = async (row: any,searchBeginTime:any,searchEndTime:any,data:any=[])
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name' && column.field != 'time') { if (column.field != 'lineName' && column.field != 'name' && column.field != 'time') {
dialogFlag.value = true dialogFlag.value = true
dialogVisible.value = false dialogVisible.value = false
nextTick(() => { nextTick(() => {
harmonicRatioRef.value.openDialog(row,column.field,column.title.replace(/次/g, "")) harmonicRatioRef.value.openDialog(row, column.field, column.title.replace(/次/g, ""))
}) })
} }

View File

@@ -1,25 +1,17 @@
<template> <template>
<div> <div>
<!--主要监测点列表 --> <!--主要监测点列表 -->
<TableHeader <TableHeader :showReset="false" :timeKeyList="prop.timeKey" @selectChange="selectChange" v-if="fullscreen"
:showReset="false" ref="TableHeaderRef">
:timeKeyList="prop.timeKey"
@selectChange="selectChange"
v-if="fullscreen"
ref="TableHeaderRef"
>
<template v-slot:select> <template v-slot:select>
<el-form-item label="关键字筛选"> <el-form-item label="关键字筛选">
<el-input v-model="tableStore.table.params.keywords" clearable placeholder="请输入监测点名称" /> <el-input maxlength="32" show-word-limit v-model="tableStore.table.params.keywords" clearable
placeholder="请输入监测点名称" />
</el-form-item> </el-form-item>
</template> </template>
</TableHeader> </TableHeader>
<Table <Table ref="tableRef" @cell-click="cellClickEvent"
ref="tableRef" :height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"></Table>
@cell-click="cellClickEvent"
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
></Table>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" /> <OverLimitDetails ref="OverLimitDetailsRef" />
</div> </div>
@@ -41,7 +33,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const OverLimitDetailsRef = ref() const OverLimitDetailsRef = ref()
const headerHeight = ref(57) const headerHeight = ref(57)
@@ -90,17 +83,17 @@ const tableStore: any = new TableStore({
{ {
title: '监测点名称', title: '监测点名称',
field: 'lineName', field: 'lineName',
minWidth: '90', minWidth: 120,
render: 'customTemplate',
customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
}
},
},
{ title: '设备名称', field: 'devName', minWidth: 130, align: 'center' },
{ title: '项目名称', field: 'projectName', minWidth: 130, align: 'center' },
{ title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center' },
{ {
title: '监测对象类型', title: '监测对象类型',
field: 'objType', field: 'objType',
minWidth: '90', minWidth: '100',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue || '/' return row.cellValue || '/'
} }
@@ -114,7 +107,11 @@ const tableStore: any = new TableStore({
} }
}, },
{ title: '主要存在的电能质量问题', field: 'problems', minWidth: '150', showOverflow: true } {
title: '主要存在的电能质量问题', field: 'problems', minWidth: '250', render: 'customTemplate', customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.problems}</span>`
}
}
], ],
beforeSearchFun: () => { beforeSearchFun: () => {
setTime() setTime()
@@ -131,12 +128,12 @@ provide('tableStore', tableStore)
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field == 'lineName') { if (column.field == 'problems') {
let time = getTimeOfTheMonth('3'); let time = getTimeOfTheMonth('3');
OverLimitDetailsRef.value.open( OverLimitDetailsRef.value.open(
row, row,
time[0], time[0],
time[1], time[1],
tableStore.table.data tableStore.table.data
) )
@@ -176,7 +173,13 @@ watch(
deep: true deep: true
} }
) )
watch(
() => prop.flag,
val => {
tableStore.showPage = fullscreen.value ? true : false
}
)
const addMenu = () => {} const addMenu = () => { }
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -73,15 +73,7 @@ const tableStore: any = new TableStore({
field: 'flicker', field: 'flicker',
width: '80' width: '80'
}, },
{ {
title: '谐波电压越限(分钟)',
children: loop50('voltage')
},
{
title: '谐波电流越限(分钟)',
children: loop50('harmonicCurrent')
},
{
title: '三相不平衡度越限(分钟)', title: '三相不平衡度越限(分钟)',
field: 'flicker', field: 'flicker',
width: '100' width: '100'
@@ -95,7 +87,16 @@ const tableStore: any = new TableStore({
title: '频率偏差越限(分钟)', title: '频率偏差越限(分钟)',
field: 'flicker', field: 'flicker',
width: '100' width: '100'
} },
{
title: '谐波电压越限(分钟)',
children: loop50('voltage')
},
{
title: '谐波电流越限(分钟)',
children: loop50('harmonicCurrent')
},
], ],
beforeSearchFun: () => {}, beforeSearchFun: () => {},
loadCallback: () => { loadCallback: () => {

View File

@@ -92,15 +92,7 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
} }
}, },
{ {
title: '谐波电压越限(分钟)',
children: loop50('voltage')
},
{
title: '谐波电流越限(分钟)',
children: loop50('harmonicCurrent')
},
{
title: '三相不平衡度越限(分钟)', title: '三相不平衡度越限(分钟)',
field: 'flicker', field: 'flicker',
width: '100' width: '100'
@@ -114,7 +106,16 @@ const tableStore: any = new TableStore({
title: '频率偏差越限(分钟)', title: '频率偏差越限(分钟)',
field: 'flicker', field: 'flicker',
width: '100' width: '100'
} },
{
title: '谐波电压越限(分钟)',
children: loop50('voltage')
},
{
title: '谐波电流越限(分钟)',
children: loop50('harmonicCurrent')
},
], ],
beforeSearchFun: () => {}, beforeSearchFun: () => {},
loadCallback: () => { loadCallback: () => {

View File

@@ -1,95 +1,64 @@
<template> <template>
<div> <div class="device-control">
<!--指标拟合图 --> <!--指标拟合图 -->
<TableHeader <div v-show="fullscreen">
datePicker <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree>
@selectChange="selectChange" </div>
v-if="fullscreen" <div>
ref="TableHeaderRef" <TableHeader datePicker @selectChange="selectChange" v-if="fullscreen" ref="TableHeaderRef"
:timeKeyList="prop.timeKey" :timeKeyList="prop.timeKey">
> <template v-slot:select>
<template v-slot:select> <!-- <el-form-item label="监测点">
<el-form-item label="监测点"> <el-select filterable v-model="tableStore.table.params.lineId" placeholder="请选择监测点" clearable>
<el-select filterable v-model="tableStore.table.params.lineId" placeholder="请选择监测点" clearable> <el-option v-for="item in lineList" :key="item.lineId" :label="item.name"
<el-option :value="item.lineId" />
v-for="item in lineList"
:key="item.lineId"
:label="item.name"
:value="item.lineId"
/>
</el-select>
</el-form-item>
<el-form-item label="用户功率">
<el-select
filterable
v-model="tableStore.table.params.power"
placeholder="请选择用户功率"
clearable
>
<el-option v-for="item in powerList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="统计类型">
<el-select
style="min-width: 120px !important"
placeholder="请选择"
v-model="tableStore.table.params.valueType"
filterable
>
<el-option value="max" label="最大值"></el-option>
<el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option>
<el-option value="cp95" label="cp95"></el-option>
</el-select>
</el-form-item>
<el-form-item label="电能质量指标">
<el-select
filterable
v-model="tableStore.table.params.indicator"
placeholder="请选择电能质量指标"
clearable
>
<el-option v-for="item in indicatorList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item>
<div v-if="shouldShowHarmonicCount()" style="display: flex; color: var(--el-text-color-regular)">
<span style="width: 160px">{{ getHarmonicTypeName() }}谐波次数</span>
<el-select
v-model="tableStore.table.params.harmonicCount"
placeholder="请选择谐波次数"
style="min-width: 80px !important"
filterable
>
<el-option
v-for="num in harmonicCountOptions"
:key="num"
:label="num"
:value="num"
></el-option>
</el-select> </el-select>
</div> </el-form-item> -->
</el-form-item> <el-form-item label="用户功率">
</template> <el-select filterable v-model="tableStore.table.params.power" placeholder="请选择用户功率" clearable>
</TableHeader> <el-option v-for="item in powerList" :key="item.id" :label="item.name" :value="item.id" />
<div v-loading="tableStore.table.loading"> </el-select>
<my-echart </el-form-item>
class="tall" <el-form-item label="统计类型">
v-if="lineShow" <el-select style="min-width: 120px !important" placeholder="请选择"
:options="echartList" v-model="tableStore.table.params.valueType" filterable>
:style="{ <el-option value="max" label="最大值"></el-option>
width: prop.width, <el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option>
<el-option value="cp95" label="cp95"></el-option>
</el-select>
</el-form-item>
<el-form-item label="电能质量指标">
<el-select filterable v-model="tableStore.table.params.indicator" placeholder="请选择电能质量指标"
clearable>
<el-option v-for="item in indicatorList" :key="item.id" :label="item.name"
:value="item.id" />
</el-select>
</el-form-item>
<el-form-item>
<div v-if="shouldShowHarmonicCount()"
style="display: flex; color: var(--el-text-color-regular)">
<span style="width: 160px">{{ getHarmonicTypeName() }}谐波次数</span>
<el-select v-model="tableStore.table.params.harmonicCount" placeholder="请选择谐波次数"
style="min-width: 80px !important" filterable>
<el-option v-for="num in harmonicCountOptions" :key="num" :label="num"
:value="num"></el-option>
</el-select>
</div>
</el-form-item>
</template>
</TableHeader>
<div v-loading="tableStore.table.loading">
<my-echart class="tall" v-if="lineShow" :options="echartList" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`
}" }" />
/> <el-empty v-else description="暂无监测点" :style="{
<el-empty width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
v-else
description="暂无监测点"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> </div>
</div> </div>
</div> </div>
</template> </template>
@@ -103,6 +72,11 @@ import { cslineList, fittingData } from '@/api/harmonic-boot/cockpit/cockpit'
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree' import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import { exportSeriesCSV } from '@/utils/echartMethod'
import PointTree from '@/components/tree/govern/pointTree.vue'
const CSV_DOWNLOAD_ICON =
'path://M896 346.8c-0.1 0 0 0 0 0 0-0.9-0.1-1.7-0.2-2.5 0-0.1 0-0.3-0.1-0.4-0.2-1.7-0.5-3.3-1-4.9-0.5-1.7-1-3.3-1.7-4.9v-0.1c-0.3-0.8-0.7-1.5-1.1-2.3v-0.1c-0.4-0.7-0.8-1.5-1.2-2.2-0.1-0.1-0.1-0.2-0.2-0.3-0.4-0.6-0.8-1.2-1.3-1.9-0.1-0.1-0.1-0.2-0.2-0.2-0.5-0.6-1-1.3-1.5-1.9-0.1-0.1-0.2-0.3-0.4-0.4-0.5-0.6-1-1.2-1.6-1.7l-0.1-0.1L637.3 74.5c-0.6-0.6-1.2-1.1-1.8-1.6-0.1-0.1-0.3-0.2-0.4-0.4-0.6-0.5-1.2-1-1.9-1.5-0.1 0-0.1-0.1-0.2-0.1-0.6-0.5-1.3-0.9-1.9-1.3-0.1-0.1-0.2-0.1-0.3-0.2-0.7-0.4-1.4-0.9-2.2-1.3-0.8-0.4-1.5-0.8-2.3-1.1h-0.1c-1.6-0.7-3.2-1.3-4.9-1.7-1.6-0.4-3.2-0.8-4.9-1-0.1 0-0.3 0-0.4-0.1-1.4-0.2-2.8-0.3-4.3-0.3H164c-19.9 0-36 16.1-36 36v823.3c0 19.9 16.1 36 36 36h696c19.9 0 36-16.1 36-36V348.6v-1.8zM647.8 186.9l125.4 125.6H647.8V186.9zM200 887.2V135.9h375.8v212.7c0 19.9 16.1 36 36 36H824v502.7H200zM363.5 661.5c-7.2 6.3-15.8 9.5-25.8 9.5-13.5 0-24.5-5-33-15S292 629.3 292 605.7c0-22.2 4.3-38.2 12.9-48.1 8.6-9.9 19.8-14.9 33.6-14.9 10 0 18.5 2.8 25.5 8.4s11.6 13.2 13.8 22.9l37.2-8.9c-4.2-14.9-10.6-26.3-19-34.3-14.2-13.5-32.7-20.2-55.5-20.2-26.1 0-47.1 8.6-63.1 25.7s-24 41.2-24 72.2c0 29.3 8 52.4 23.9 69.3 15.9 16.9 36.2 25.3 60.9 25.3 20 0 36.5-4.9 49.4-14.8 13-9.9 22.3-24.9 27.9-45.3L379 631.6c-3.1 13.6-8.3 23.6-15.5 29.9zM561.5 597.2c-8.8-4.6-22.3-9.1-40.6-13.4s-29.8-8.5-34.5-12.4c-3.7-3.1-5.6-6.9-5.6-11.3 0-4.8 2-8.7 6-11.6 6.2-4.5 14.7-6.7 25.6-6.7 10.6 0 18.5 2.1 23.8 6.3 5.3 4.2 8.7 11.1 10.3 20.6l37.6-1.7c-0.6-17.1-6.8-30.8-18.6-41s-29.4-15.4-52.7-15.4c-14.3 0-26.5 2.2-36.6 6.5-10.1 4.3-17.9 10.6-23.2 18.9-5.4 8.3-8.1 17.1-8.1 26.6 0 14.7 5.7 27.2 17.1 37.5 8.1 7.3 22.3 13.4 42.4 18.4 15.7 3.9 25.7 6.6 30.1 8.1 6.4 2.3 10.9 5 13.5 8.1 2.6 3.1 3.9 6.8 3.9 11.2 0 6.9-3.1 12.8-9.2 18-6.1 5.1-15.3 7.7-27.4 7.7-11.4 0-20.5-2.9-27.2-8.6-6.7-5.8-11.2-14.8-13.4-27l-36.6 3.6c2.5 20.8 10 36.7 22.6 47.5 12.6 10.9 30.7 16.3 54.2 16.3 16.2 0 29.7-2.3 40.5-6.8s19.2-11.4 25.1-20.8c5.9-9.3 8.9-19.3 8.9-30 0-11.8-2.5-21.6-7.4-29.6s-11.7-14.3-20.5-19zM689.9 651.6l-47.1-137.7h-40.7L668.6 700h40.1l66.7-186.1h-39.9z'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
@@ -111,7 +85,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const TableHeaderRef = ref() const TableHeaderRef = ref()
@@ -128,6 +103,8 @@ const lineShow = ref(true)
const fullscreen = computed(() => { const fullscreen = computed(() => {
const w = Number(prop.w) const w = Number(prop.w)
const h = Number(prop.h) const h = Number(prop.h)
if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) { if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) {
// 执行相应逻辑 // 执行相应逻辑
return true return true
@@ -148,17 +125,29 @@ const exceedingTheLimitList: any = ref([
const indicatorList = ref() const indicatorList = ref()
const initLineList = async () => { // const initLineList = async () => {
cslineList({}).then(res => { // cslineList({}).then(res => {
if (res.data.length == 0) { // setTime()
lineShow.value = false // if (res.data.length == 0) {
return (tableStore.table.loading = false) // lineShow.value = false
} // return (tableStore.table.loading = false)
lineShow.value = true // }
lineList.value = res.data // lineShow.value = true
tableStore.table.params.lineId = lineList.value[0].lineId // lineList.value = res.data
// tableStore.table.params.lineId = lineList.value[0].lineId
// initCode()
// })
// }
const nodeClick = (e: any) => {
if (e == undefined) {
}
if (e.level == 3) {
tableStore.table.params.lineId = e.id
initCode() initCode()
}) }
}
const pointTypeChange = (val: any, obj: any) => {
nodeClick(obj)
} }
const echartList = ref() const echartList = ref()
@@ -173,15 +162,52 @@ const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
} }
} }
const formatExceedanceValue = (value: any) => {
if (value == 0) return '不越限'
if (value == 1) return '越限'
return value
}
const getSeriesForCsvExport = () => {
const indicatorSeriesName = indicatorList.value?.find(
(item: any) => item.id === tableStore.table.params.indicator
)?.name
return echartList.value.options.series.map((item: any) => ({
name: item.name,
data: item.data?.map((point: any) => [
point[0],
item.name === indicatorSeriesName ? formatExceedanceValue(point[1]) : point[1],
point[2]
])
}))
}
const setEchart = () => { const setEchart = () => {
// 获取当前选择的功率和指标名称 // 获取当前选择的功率和指标名称
const powerName = powerList.value?.find((item: any) => item.id === tableStore.table.params.power)?.name || '功率' const powerName = powerList.value?.find((item: any) => item.id === tableStore.table.params.power)?.name || '功率'
const indicatorName = const indicatorName =
indicatorList.value?.find((item: any) => item.id === tableStore.table.params.indicator)?.name || '电能质量指标' indicatorList.value?.find((item: any) => item.id === tableStore.table.params.indicator)?.name || '电能质量指标'
const chartTitle = `${indicatorName}${powerName}负荷曲线拟合图`
echartList.value = { echartList.value = {
title: { title: {
text: `${indicatorName}${powerName}负荷曲线拟合图` text: chartTitle
},
toolbox: {
featureProps: {
myTool1: {
show: true,
title: '下载csv',
icon: CSV_DOWNLOAD_ICON,
onclick: () => {
exportSeriesCSV(
getSeriesForCsvExport(),
`${echartList.value.title?.text || '负荷曲线拟合图'}.csv`
)
}
}
}
}, },
tooltip: { tooltip: {
trigger: 'axis', trigger: 'axis',
@@ -190,12 +216,8 @@ const setEchart = () => {
params.forEach((item: any) => { params.forEach((item: any) => {
if (item.seriesName === indicatorName) { if (item.seriesName === indicatorName) {
// 对于电能质量指标格式化Y轴值显示 // 对于电能质量指标格式化Y轴值显示
let valueText = '' let valueText = formatExceedanceValue(item.value[1])
if (item.value[1] == 0) { if (valueText === item.value[1]) {
valueText = '不越限'
} else if (item.value[1] == 1) {
valueText = '越限'
} else {
valueText = item.value[1] valueText = item.value[1]
} }
result += `<br/>${item.marker}${item.seriesName}: ${valueText}` result += `<br/>${item.marker}${item.seriesName}: ${valueText}`
@@ -221,31 +243,48 @@ const setEchart = () => {
{}, {},
indicatorName indicatorName
? { ? {
min: 0, min: 0,
max: 1, max: 1,
axisLabel: { axisLabel: {
formatter: function (value: number) { formatter: function (value: number) {
if (value === 0) { if (value === 0) {
return '不越限' return '不越限'
} else if (value === 1) { } else if (value === 1) {
return '越限' return '越限'
} }
return value return value
} }
} }
} }
: {} : {}
], ],
grid: { // grid: {
left: '10px', // left: '10px',
right: '20px' // right: '30px',
}, // },
options: { options: {
// dataZoom: [
// {
// type: 'inside',
// start: 0,
// end: 100,
// filterMode: 'filter'
// },
// {
// type: 'slider',
// start: 0,
// end: 100,
// height: 13,
// bottom: '20px',
// filterMode: 'filter'
// }
// ],
series: [ series: [
{ {
type: 'bar', type: 'bar',
name: powerName, // 动态设置功率名称 name: powerName, // 动态设置功率名称
data: [], data: [],
clip: true,
itemStyle: { itemStyle: {
normal: { normal: {
color: function (params: any) { color: function (params: any) {
@@ -264,7 +303,7 @@ const setEchart = () => {
type: 'line', type: 'line',
step: 'end', step: 'end',
showSymbol: false, showSymbol: false,
// smooth: true, clip: true,
data: [], data: [],
yAxisIndex: 1 yAxisIndex: 1
} }
@@ -450,7 +489,7 @@ watch(
) )
onMounted(async () => { onMounted(async () => {
await initLineList() // await initCode()
}) })
watch( watch(
@@ -492,4 +531,11 @@ watch(
// :deep(.el-select) { // :deep(.el-select) {
// min-width: 80px; // min-width: 80px;
// } // }
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style> </style>

View File

@@ -1,10 +1,10 @@
<template> <template>
<div> <div>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="title" v-model="dialogVisible" append-to-body width="70%">
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef"> <TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
<template v-slot:select> <template v-slot:select>
<el-form-item label="监测点"> <!-- <el-form-item label="监测点">
<el-select <el-select
v-model="tableStore.table.params.lineId" v-model="tableStore.table.params.lineId"
placeholder="请选择监测点" placeholder="请选择监测点"
@@ -18,7 +18,7 @@
:value="item.lineId" :value="item.lineId"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table> <Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
@@ -38,7 +38,7 @@ import { cslineList ,governLineList} from '@/api/harmonic-boot/cockpit/cockpit'
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
const harmonicRatioRef: any = ref(null) const harmonicRatioRef: any = ref(null)
const title = ref('指标越限详情')
const options = ref() const options = ref()
const height = mainHeight(0, 2).height as any const height = mainHeight(0, 2).height as any
const tableHeaderRef = ref() const tableHeaderRef = ref()
@@ -76,13 +76,13 @@ const tableStore: any = new TableStore({
{ {
title: '日期', title: '日期',
field: 'time', field: 'time',
width: '150', width: '120',
sortable: true sortable: true
}, },
{ {
title: '名称', title: '名称',
field: 'lineName', field: 'lineName',
width: '150' width: '120'
}, },
{ {
title: '长时闪变越限(%)', title: '长时闪变越限(%)',
@@ -93,15 +93,7 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
} }
}, },
{ {
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
},
{
title: '电压偏差越限(%)', title: '电压偏差越限(%)',
field: 'voltageDevOvertime', field: 'voltageDevOvertime',
width: '100', width: '100',
@@ -119,6 +111,15 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
} }
}, },
{
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
},
// { // {
// title: '频率偏差越限(%)', // title: '频率偏差越限(%)',
@@ -143,6 +144,7 @@ tableStore.table.params.orderBy = ''
const time:any=ref([]) const time:any=ref([])
const open = async (row: any,searchBeginTime:any,searchEndTime:any) => { const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
dialogVisible.value = true dialogVisible.value = true
title.value = row.lineName + '_指标越限详情'
time.value=[searchBeginTime,searchEndTime] time.value=[searchBeginTime,searchEndTime]
initCSlineList() initCSlineList()
tableStore.table.params.lineId = row.lineId tableStore.table.params.lineId = row.lineId
@@ -158,7 +160,7 @@ const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name' && column.field != 'time') { if (column.field != 'lineName' && column.field != 'name' && column.field != 'time') {
dialogFlag.value = true dialogFlag.value = true
dialogVisible.value = false dialogVisible.value = false
nextTick(() => { nextTick(() => {

View File

@@ -1,43 +1,26 @@
<template> <template>
<div> <div>
<!-- 监测点列表 --> <!-- 监测点列表 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" v-if="fullscreen"
ref="TableHeaderRef" :timeKeyList="prop.timeKey">
:showReset="false" <template #select>
@selectChange="selectChange" <el-form-item label="关键字筛选">
<el-input maxlength="32" show-word-limit style="width: 240px"
v-if="fullscreen" v-model.trim="tableStore.table.params.searchValue" clearable placeholder="请输入监测点名称" />
:timeKeyList="prop.timeKey" </el-form-item>
></TableHeader> </template>
<Table </TableHeader>
ref="tableRef" <Table ref="tableRef" @cell-click="cellClickEvent"
@cell-click="cellClickEvent" :height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"></Table>
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
></Table>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<OverLimitDetails ref="OverLimitDetailsRef" /> <OverLimitDetails ref="OverLimitDetailsRef" />
<!-- 上传对话框 --> <!-- 上传对话框 -->
<el-dialog <el-dialog v-model="uploadDialogVisible" title="上传报告" append-to-body width="500px" @closed="handleDialogClosed">
v-model="uploadDialogVisible" <el-upload ref="uploadRef" class="upload-demo" action="" accept=".doc,.docx,.PDF" :on-change="handleChange"
title="上传报告" :before-upload="beforeUpload" :limit="1" :auto-upload="false" :on-exceed="handleExceed"
append-to-body :on-remove="handleRemove" :file-list="fileList">
width="500px"
@closed="handleDialogClosed"
>
<el-upload
ref="uploadRef"
class="upload-demo"
action=""
accept=".doc,.docx,.PDF"
:on-change="handleChange"
:before-upload="beforeUpload"
:limit="1"
:auto-upload="false"
:on-exceed="handleExceed"
:on-remove="handleRemove"
:file-list="fileList"
>
<el-button type="primary">点击上传</el-button> <el-button type="primary">点击上传</el-button>
<template #tip> <template #tip>
<div class="el-upload__tip">请上传Word或PDF文件</div> <div class="el-upload__tip">请上传Word或PDF文件</div>
@@ -61,7 +44,7 @@ import { ElMessage, ElMessageBox } from 'element-plus'
import OverLimitDetails from '@/components/cockpit/monitoringPointList/components/overLimitDetails.vue' import OverLimitDetails from '@/components/cockpit/monitoringPointList/components/overLimitDetails.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { uploadReport, getReportUrl } from '@/api/harmonic-boot/cockpit/cockpit' import { uploadReport, getReportUrl } from '@/api/harmonic-boot/cockpit/cockpit'
import { getTime } from '@/utils/formatTime'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
@@ -70,7 +53,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const headerHeight = ref(57) const headerHeight = ref(57)
@@ -123,16 +107,19 @@ const tableStore: any = new TableStore({
{ {
title: '监测点名称', title: '监测点名称',
field: 'lineName', field: 'lineName',
minWidth: '120', minWidth: 120,
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
} }
}, },
{ title: '设备名称', field: 'devName', minWidth: 130, align: 'center' },
{ title: '项目名称', field: 'projectName', minWidth: 130, align: 'center' },
{ title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center' },
{ {
title: '监测类型', title: '监测类型',
field: 'position', field: 'position',
minWidth: '80', minWidth: '100',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue || '/' return row.cellValue || '/'
} }
@@ -150,50 +137,45 @@ const tableStore: any = new TableStore({
title: '监测点状态', title: '监测点状态',
field: 'runStatus', field: 'runStatus',
render: 'tag', render: 'tag',
width: 90,
width: 100,
custom: { custom: {
停运: 'danger', // 0运行1检修2停运3调试4退运
退运: 'danger', 0: 'success',
运行: 'success', 1: 'warning',
在线: 'success', 2: 'danger',
中断: 'warning', 3: 'warning',
离线: 'danger', 4: 'info',
检修: 'warning',
调试: 'warning',
null: 'info' null: 'info'
}, },
replaceValue: { replaceValue: {
运行: '运行', 0: '运行',
在线: '在线', 1: '检修',
退运: '退运', 2: '运',
停运: '停运', 3: '调试',
中断: '中断', 4: '退运',
检修: '检修',
离线: '离线',
调试: '调试',
null: '/' null: '/'
} }
}, },
{
title: '电压等级(kV)',
field: 'volGrade',
minWidth: '80',
formatter: (row: any) => {
return row.cellValue == 0 ? '/' : row.cellValue || '/'
}
},
{ {
title: '治理对象', title: '治理对象',
field: 'sensitiveUser', field: 'sensitiveUser',
minWidth: '90', minWidth: '100',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue || '/' return row.cellValue || '/'
} }
}, },
{ {
title: '电压等级', title: '治理方案',
field: 'volGrade',
minWidth: '80',
formatter: (row: any) => {
return row.cellValue==0?'/': row.cellValue+'kV' || '/'
}
},
{
title: '是否治理',
field: 'govern', field: 'govern',
minWidth: '80', minWidth: '80',
formatter: (row: any) => { formatter: (row: any) => {
@@ -228,15 +210,16 @@ const tableStore: any = new TableStore({
// } // }
// }, // },
{ {
title: '报告', title: '治理前报告',
field: 'reportFilePath', field: 'reportFilePath',
minWidth: '120', minWidth: '150',
formatter: (row: any) => { formatter: (row: any) => {
return row.cellValue == null ? '/' : row.cellValue.split('/').pop() return row.cellValue == null ? '/' : row.cellValue.split('/').pop()
} }
}, },
{ {
title: '操作', fixed: 'right', title: '操作',
fixed: 'right',
width: 150, width: 150,
render: 'buttons', render: 'buttons',
buttons: [ buttons: [
@@ -294,6 +277,7 @@ const tableStore: any = new TableStore({
const tableRef = ref() const tableRef = ref()
provide('tableRef', tableRef) provide('tableRef', tableRef)
tableStore.table.params.keywords = '' tableStore.table.params.keywords = ''
tableStore.table.params.searchValue = ''
provide('tableStore', tableStore) provide('tableStore', tableStore)
const setTime = () => { const setTime = () => {
@@ -304,7 +288,6 @@ const setTime = () => {
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime] // ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
// : prop.timeValue // : prop.timeValue
// ) // )
// if (Array.isArray(time)) { // if (Array.isArray(time)) {
// tableStore.table.params.searchBeginTime = time[0] // tableStore.table.params.searchBeginTime = time[0]
// tableStore.table.params.searchEndTime = time[1] // tableStore.table.params.searchEndTime = time[1]
@@ -329,10 +312,11 @@ const cellClickEvent = ({ row, column }: any) => {
// 下载报告 // 下载报告
const downloadTheReport = (lineId: string, name: string) => { const downloadTheReport = (lineId: string, name: string) => {
getReportUrl({ lineId: lineId }).then((res: any) => { getReportUrl({ lineId: lineId }).then((res: any) => {
ElMessage.info('下载中......')
forceDownloadPdf(res.data, name.split('/').pop() || '') forceDownloadPdf(res.data, name.split('/').pop() || '')
}) })
} }
const forceDownloadPdf = async (pdfUrl, fileName = '文件.pdf') => { const forceDownloadPdf = async (pdfUrl: any, fileName = '文件.pdf') => {
try { try {
// 1. 请求 PDF 并转为 Blob关键绕开浏览器直接解析 // 1. 请求 PDF 并转为 Blob关键绕开浏览器直接解析
const response = await fetch(pdfUrl, { const response = await fetch(pdfUrl, {
@@ -359,8 +343,11 @@ const forceDownloadPdf = async (pdfUrl, fileName = '文件.pdf') => {
// 4. 清理资源(避免内存泄漏) // 4. 清理资源(避免内存泄漏)
document.body.removeChild(a) document.body.removeChild(a)
URL.revokeObjectURL(blobUrl) URL.revokeObjectURL(blobUrl)
setTimeout(() => {
ElMessage.success('下载成功')
}, 2000)
} catch (error) { } catch (error) {
console.error('PDF 下载失败:', error) console.error('下载失败:', error)
// ElMessage.error('文件下载失败,请检查网络或文件地址') // 适配 Element Plus // ElMessage.error('文件下载失败,请检查网络或文件地址') // 适配 Element Plus
} }
} }
@@ -438,6 +425,12 @@ const handleUpload = async () => {
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()
}) })
watch(
() => prop.flag,
val => {
tableStore.showPage = fullscreen.value ? true : false
}
)
watch( watch(
() => prop.timeKey, () => prop.timeKey,
val => { val => {

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="titles" v-model="dialogVisible" append-to-body width="70%">
<!-- 总体指标占比详情谐波含有率 --> <!-- 总体指标占比详情谐波含有率 -->
<div> <div>
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange"> <TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
@@ -7,7 +7,7 @@
<el-form-item> <el-form-item>
<DatePicker ref="datePickerRef"></DatePicker> <DatePicker ref="datePickerRef"></DatePicker>
</el-form-item> </el-form-item>
<el-form-item label="统计指标" label-width="80px"> <el-form-item label="统计指标" label-width="80px" v-if="props.showIndex">
<el-select <el-select
multiple multiple
:multiple-limit="2" :multiple-limit="2"
@@ -75,9 +75,6 @@
</template> </template>
<template #operation> <template #operation>
<el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button> <el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button>
<el-button :type="timeControl ? 'primary' : ''" icon="el-icon-Sort" @click="setTimeControl">
缺失数据
</el-button>
</template> </template>
</TableHeader> </TableHeader>
</div> </div>
@@ -94,7 +91,7 @@ import { ref, onMounted, watch } from 'vue'
import MyEchart from '@/components/echarts/MyEchart.vue' import MyEchart from '@/components/echarts/MyEchart.vue'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { queryStatistical } from '@/api/system-boot/csstatisticalset' import { queryStatistical } from '@/api/system-boot/csstatisticalset'
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod' import { yMethod, exportSeriesCSV, completeTimeSeries } from '@/utils/echartMethod'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit' import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
import DatePicker from '@/components/form/datePicker/index.vue' import DatePicker from '@/components/form/datePicker/index.vue'
@@ -107,9 +104,14 @@ defineOptions({
const props = defineProps({ const props = defineProps({
TrendList: { TrendList: {
type: Array type: Array
},
showIndex:{
type: Boolean,
default: true
} }
}) })
const titles = ref('趋势图')
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
// console.log("🚀 ~ props:", props.TrendList) // console.log("🚀 ~ props:", props.TrendList)
const showEchart = ref(true) const showEchart = ref(true)
@@ -268,6 +270,7 @@ const lineStyle = [{ type: 'solid' }, { type: 'dashed' }, { type: 'dotted' }]
const init = async () => { const init = async () => {
loading.value = true loading.value = true
// 选择指标的时候切换legend内容和data数据 // 选择指标的时候切换legend内容和data数据
echartsData.value = {}
let list: any = [] let list: any = []
legendDictList.value?.selectedList?.map((item: any) => { legendDictList.value?.selectedList?.map((item: any) => {
searchForm.value.index.map((vv: any) => { searchForm.value.index.map((vv: any) => {
@@ -380,8 +383,7 @@ const setEchart = () => {
itemStyle: { opacity: 0 }, //去圆点 itemStyle: { opacity: 0 }, //去圆点
type: 'scroll', // 开启滚动分页 type: 'scroll', // 开启滚动分页
// orient: 'vertical', // 垂直排列 // orient: 'vertical', // 垂直排列
top: 5,
right: 70
// width: 550, // width: 550,
// height: 50 // height: 50
}, },
@@ -407,6 +409,7 @@ const setEchart = () => {
formatter(params: any) { formatter(params: any) {
const xname = params[0].value[0] const xname = params[0].value[0]
let str = `${xname}<br>` let str = `${xname}<br>`
params.forEach((el: any, index: any) => { params.forEach((el: any, index: any) => {
let marker = '' let marker = ''
@@ -441,27 +444,22 @@ const setEchart = () => {
myTool1: { myTool1: {
show: true, show: true,
title: '下载csv', title: '下载csv',
icon: 'path://M588.8 551.253333V512H352v39.253333h236.373333z m0 78.933334v-39.253334H352v39.253334h236.373333z m136.533333 78.933333V334.933333l-157.866666-157.866666H273.066667A59.306667 59.306667 0 0 0 213.333333 236.373333v551.253334a59.306667 59.306667 0 0 0 59.306667 59.306666h274.773333v42.666667H853.333333v-180.48zM568.746667 234.666667l100.266666 100.693333h-81.066666a20.053333 20.053333 0 0 1-19.626667-20.053333z m-20.48 573.013333H273.066667a19.2 19.2 0 0 1-17.493334-19.626667V236.373333a19.2 19.2 0 0 1 19.626667-19.626666h256v98.133333a58.88 58.88 0 0 0 58.88 59.306667h96.426667v334.933333h-98.133334v-39.68H352v39.68h196.266667z m100.266666 23.04a37.973333 37.973333 0 0 1-32 15.786667 38.826667 38.826667 0 0 1-32.426666-15.786667 53.76 53.76 0 0 1-10.24-32.853333 42.666667 42.666667 0 0 1 42.666666-47.786667 35.84 35.84 0 0 1 37.546667 29.866667h-12.8a23.893333 23.893333 0 0 0-24.746667-19.2c-17.066667 0-29.013333 14.08-29.013333 35.84s11.52 37.546667 28.586667 37.546666a26.453333 26.453333 0 0 0 26.453333-25.6h12.8a39.253333 39.253333 0 0 1-7.253333 22.186667z m59.733334 15.786667a35.84 35.84 0 0 1-40.106667-34.56H682.666667a23.893333 23.893333 0 0 0 26.88 23.04c12.8 0 22.613333-6.4 22.613333-15.786667s-4.266667-11.52-14.506667-13.653333l-21.333333-5.12c-17.066667-4.266667-24.32-11.52-24.32-23.893334s12.8-26.453333 34.133333-26.453333a31.573333 31.573333 0 0 1 35.413334 30.293333h-13.653334a19.626667 19.626667 0 0 0-22.613333-18.773333c-12.8 0-20.48 5.12-20.48 12.8s5.12 11.093333 17.066667 13.653333l14.933333 2.986667a42.666667 42.666667 0 0 1 20.906667 8.96 23.893333 23.893333 0 0 1 7.68 17.92c-0.426667 17.066667-14.506667 28.16-37.12 28.16z m88.746666 0h-14.506666l-32.426667-92.16h14.08l19.626667 59.733333 6.4 20.053333c0-9.386667 3.413333-12.8 5.546666-20.053333l19.2-59.733333h14.08z', icon: 'path://M642 673.1H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9s-8 17.9-17.9 17.9zM642 511.8H301.6c-9.9 0-17.9-8-17.9-17.9 0-9.9 8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9 0 9.9-8 17.9-17.9 17.9zM480.7 350.6H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9h179.2c9.9 0 17.9 8 17.9 17.9s-8.1 17.9-18 17.9zM874.9 350.6H695.7c-49.4 0-89.6-40.2-89.6-89.6V81.9c0-9.9 8-17.9 17.9-17.9 9.9 0 17.9 8 17.9 17.9V261c0 29.6 24.1 53.7 53.7 53.7h179.2c9.9 0 17.9 8 17.9 17.9s-7.9 18-17.8 18zM794.3 959.7H221c-49.4 0-89.6-40.2-89.6-89.6V153.5c0-49.4 40.2-89.6 89.6-89.6h403.1c4.8 0 9.3 1.9 12.7 5.2L887.6 320c3.4 3.4 5.2 7.9 5.2 12.7v537.5c0 52.7-51.9 89.5-98.5 89.5zM221 99.8c-29.6 0-53.7 24.1-53.7 53.7v716.6c0 29.6 24.1 53.7 53.7 53.7h573.3c29 0 62.7-23.5 62.7-53.7v-530L616.7 99.8H221z',
onclick: e => { onclick: () => {
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data)) exportSeriesCSV(
echartsData.value.options.series,
let list = echartsData.value.options.series?.map((item: any) => item.data) `${titles.value || '监测点指标趋势'}.csv`
let dataList = list[0]?.map((item: any, index: any) => {
let value = [item[0], item[1]]
list.forEach((item1: any, index1: any) => {
if (index1 > 0) {
value.push(item1 && item1[index] ? item1[index][1] : null)
}
})
return value
})
exportCSV(
echartsData.value.options.series.map((item: any) => item.name),
dataList,
'监测点指标趋势.csv'
) )
} }
},
myTool2: {
show: true,
title: timeControl.value ? '关闭缺失数据' : '缺失数据',
icon: 'path://M832 512l-192-192v128H128v128h512v128l192-192zM192 512l192 192v-128h512v-128H384V320L192 512z',
iconStyle: timeControl.value ? { borderColor: '#409EFF' } : {},
onclick: () => {
setTimeControl()
}
} }
} }
}, },
@@ -651,6 +649,7 @@ watch(
) )
const openDialog = async (row: any, field: any, title: any) => { const openDialog = async (row: any, field: any, title: any) => {
titles.value = `${row?.lineName ? `${row.lineName}_` : ''}趋势图`
dialogVisible.value = true dialogVisible.value = true
trendRequestData.value = row trendRequestData.value = row

View File

@@ -1,10 +1,10 @@
<template> <template>
<div> <div>
<!-- 指标越限详情 --> <!-- 指标越限详情 -->
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%"> <el-dialog draggable :title="title" v-model="dialogVisible" append-to-body width="70%">
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef"> <TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
<template v-slot:select> <template v-slot:select>
<el-form-item label="监测点"> <!-- <el-form-item label="监测点">
<el-select <el-select
v-model="tableStore.table.params.lineId" v-model="tableStore.table.params.lineId"
placeholder="请选择监测点" placeholder="请选择监测点"
@@ -18,7 +18,7 @@
:value="item.lineId" :value="item.lineId"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item> -->
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table> <Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
@@ -38,7 +38,7 @@ import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
const dialogVisible: any = ref(false) const dialogVisible: any = ref(false)
const harmonicRatioRef: any = ref(null) const harmonicRatioRef: any = ref(null)
const title = ref('指标越限详情')
const options = ref() const options = ref()
const height = mainHeight(0, 2).height as any const height = mainHeight(0, 2).height as any
const tableHeaderRef = ref() const tableHeaderRef = ref()
@@ -76,13 +76,13 @@ const tableStore: any = new TableStore({
{ {
title: '日期', title: '日期',
field: 'time', field: 'time',
width: '150', width: '120',
sortable: true sortable: true
}, },
{ {
title: '名称', title: '名称',
field: 'lineName', field: 'lineName',
width: '150' width: '120'
}, },
{ {
title: '长时闪变越限(%)', title: '长时闪变越限(%)',
@@ -92,14 +92,6 @@ const tableStore: any = new TableStore({
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
} }
},
{
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
}, },
{ {
title: '电压偏差越限(%)', title: '电压偏差越限(%)',
@@ -119,7 +111,16 @@ const tableStore: any = new TableStore({
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
} }
}, },
{
title: '谐波电压越限(%)',
children: loop50('uharm')
},
{
title: '谐波电流越限(%)',
children: loop50('iharm')
},
// { // {
// title: '频率偏差越限(%)', // title: '频率偏差越限(%)',
// field: 'freqDevOvertime', // field: 'freqDevOvertime',
@@ -143,6 +144,7 @@ tableStore.table.params.orderBy = ''
const open = async (row: any,searchBeginTime:any,searchEndTime:any,data: any) => { const open = async (row: any,searchBeginTime:any,searchEndTime:any,data: any) => {
dialogVisible.value = true dialogVisible.value = true
// initCSlineList() // initCSlineList()
title.value = row.lineName + '_指标越限详情'
options.value = data options.value = data
tableStore.table.params.lineId = row.lineId tableStore.table.params.lineId = row.lineId
@@ -157,7 +159,7 @@ const open = async (row: any,searchBeginTime:any,searchEndTime:any,data: any) =>
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name' && column.field != 'time') { if (column.field != 'lineName' && column.field != 'name' && column.field != 'time') {
dialogFlag.value = true dialogFlag.value = true
dialogVisible.value = false dialogVisible.value = false
nextTick(() => { nextTick(() => {

View File

@@ -142,17 +142,20 @@ const tableStore: any = new TableStore({
} }
}, },
{ {
title: '名称', title: '监测点名称',
field: 'lineName', field: 'lineName',
minWidth: '90' minWidth: 120
}, },
{ title: '设备名称', field: 'devName', minWidth: 130, align: 'center' },
{ title: '项目名称', field: 'projectName', minWidth: 130, align: 'center' },
{ title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center' },
{ {
title: '越限占比(%)', title: '越限占比(%)',
children: [ children: [
{ {
title: '长时闪变', title: '长时闪变',
field: 'flicker', field: 'flicker',
minWidth: '70', minWidth: '80',
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>` return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`

View File

@@ -1,20 +1,17 @@
<template> <template>
<div> <div>
<!--敏感负荷列表 --> <!--敏感负荷列表 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" v-if="fullscreen"
ref="TableHeaderRef" :timeKeyList="prop.timeKey">
:showReset="false" <template #select>
@selectChange="selectChange" <el-form-item label="关键字筛选">
<el-input maxlength="32" show-word-limit style="width: 240px"
v-if="fullscreen" v-model.trim="tableStore.table.params.searchValue" clearable placeholder="请输入敏感用户名称" />
:timeKeyList="prop.timeKey" </el-form-item>
></TableHeader> </template>
<Table </TableHeader>
ref="tableRef" <Table ref="tableRef" @cell-click="cellClickEvent"
@cell-click="cellClickEvent" :height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`" isGroup></Table>
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
isGroup
></Table>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@@ -32,7 +29,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const headerHeight = ref(57) const headerHeight = ref(57)
@@ -66,7 +64,7 @@ const fullscreen = computed(() => {
const OverLimitDetailsRef = ref() const OverLimitDetailsRef = ref()
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
url: '/cs-harmonic-boot/pqSensitiveUser/getList', url: '/cs-harmonic-boot/pqSensitiveUser/getListByUser',
method: 'POST', method: 'POST',
showPage: fullscreen.value ? true : false, showPage: fullscreen.value ? true : false,
column: [ column: [
@@ -79,13 +77,13 @@ const tableStore: any = new TableStore({
} }
}, },
{ {
title: '敏感负荷名称', title: '敏感用户名称',
field: 'name', field: 'name',
minWidth: '90' minWidth: '90'
}, },
{ {
title: '敏感负荷类型', title: '敏感用户类型',
field: 'loadType', field: 'loadType',
minWidth: '70', minWidth: '70',
formatter: row => { formatter: row => {
@@ -113,9 +111,9 @@ const tableStore: any = new TableStore({
setTime() setTime()
}, },
loadCallback: () => {} loadCallback: () => { }
}) })
tableStore.table.params.searchValue = ''
const tableRef = ref() const tableRef = ref()
provide('tableRef', tableRef) provide('tableRef', tableRef)
@@ -137,7 +135,6 @@ const setTime = () => {
// ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime] // ? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
// : prop.timeValue // : prop.timeValue
// ) // )
// if (Array.isArray(time)) { // if (Array.isArray(time)) {
// tableStore.table.params.searchBeginTime = time[0] // tableStore.table.params.searchBeginTime = time[0]
// tableStore.table.params.searchEndTime = time[1] // tableStore.table.params.searchEndTime = time[1]
@@ -168,5 +165,11 @@ watch(
deep: true deep: true
} }
) )
watch(
() => prop.flag,
val => {
tableStore.showPage = fullscreen.value ? true : false
}
)
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -1,174 +1,155 @@
<template> <template>
<div> <div>
<!-- 暂态事件详情 --> <el-dialog draggable title="暂态事件" v-model="dialogVisible" append-to-body width="70%">
<el-dialog draggable title="暂态事件详情 " v-model="dialogVisible" append-to-body width="70%"> <TableHeader datePicker showExport ref="tableHeaderRef" @selectChange="selectChange"
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef" @selectChange="selectChange"> @onResetForm="onResetForm">
<template v-slot:select> <template v-slot:operation>
<el-form-item label="监测点"> <el-button type="primary" icon="el-icon-Operation" @click="openFilterDialog">事件筛选</el-button>
<el-select v-model="tableStore.table.params.lineId" placeholder="请选择监测点名称">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</template> </template>
</TableHeader> </TableHeader>
<MultiCondition v-model:visible="filterVisible" :params="tableStore.table.params" ref="multiConditionRef"
@confirm="onFilterConfirm" />
<Table ref="tableRef" isGroup :height="heightRef"></Table> <Table ref="tableRef" isGroup :height="heightRef"></Table>
</el-dialog> </el-dialog>
<!-- 查看波形 -->
<el-dialog <el-dialog v-model="isWaveCharts" draggable title="波形分析" append-to-body width="70%" @close="handleHideCharts">
v-model="isWaveCharts" <waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
draggable @handleHideCharts="handleHideCharts" :wp="wp" />
title="波形分析"
append-to-body
v-if="isWaveCharts"
width="70%"
@close="handleHideCharts"
>
<waveFormAnalysis
v-loading="loading"
ref="waveFormAnalysisRef"
@handleHideCharts="handleHideCharts"
:wp="wp"
/>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, provide } from 'vue' import { ref, provide, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import MultiCondition from '@/views/govern/alarm/multiCondition.vue'
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue' import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
import { analyseWave } from '@/api/common' import { analyseWave } from '@/api/common'
import { getSimpleLine } from '@/api/harmonic-boot/cockpit/cockpit' import { getFileZip } from '@/api/cs-harmonic-boot/datatrend'
import { useDictData } from '@/stores/dictData'
const dialogVisible: any = ref(false) const dialogVisible = ref(false)
const waveFormAnalysisRef: any = ref(null) const waveFormAnalysisRef = ref()
// 波形
const isWaveCharts = ref(false) const isWaveCharts = ref(false)
const loading = ref(false) const loading = ref(false)
const wp = ref({}) const wp = ref({})
const boxoList: any = ref({}) const boxoList: any = ref({})
const tableHeaderRef = ref() const tableHeaderRef = ref()
const filterVisible = ref(false)
const multiConditionRef = ref<InstanceType<typeof MultiCondition>>()
const currentOpenTime = ref('')
const dictData = useDictData()
const ReasonList: any = dictData.getBasicData('Event_Reason')
const EventTypeList: any = dictData.getBasicData('Event_Type')
const options = ref()
const heightRef = ref(mainHeight(168, 2.1).height) const heightRef = ref(mainHeight(168, 2.1).height)
const selectChange = (flag: boolean, h: any) => { const selectChange = (_flag: boolean, h: number) => {
heightRef.value = mainHeight(h, 2.1).height heightRef.value = mainHeight(h, 2.1).height
} }
const getSimpleLineList = async () => {
const res = await getSimpleLine()
options.value = res.data
}
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
url: '/cs-harmonic-boot/event/pageEvent', url: '/cs-harmonic-boot/eventUser/queryEventpageWeb',
method: 'POST', method: 'POST',
showPage: true, showPage: true,
exportName: '暂态事件详情', exportName: '暂态事件',
column: [ column: [
{ {
field: 'index',
title: '序号', title: '序号',
width: '80', width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ { title: '发生时刻', field: 'startTime', align: 'center', minWidth: 180, sortable: true },
title: '暂态时间', { title: '暂降幅值(%)', minWidth: 120, field: 'evtParamVVaDepth', align: 'center', sortable: true },
field: 'startTime', { title: '持续时间(s)', field: 'evtParamTm', minWidth: 110, align: 'center', sortable: true },
minWidth: '180'
},
{
title: '测点名称',
field: 'lineName',
minWidth: '150'
},
{
title: '暂态类型',
field: 'tag',
minWidth: '100'
},
{
title: '特征幅值(%)',
field: 'amplitude',
minWidth: '100'
},
{
title: '暂降深度(%)',
field: 'depth',
minWidth: '100',
formatter: (row: any) => {
// 当暂态类型不是电压暂升时,计算暂降深度 = 100 - 特征幅值
if (row.row.tag !== '电压暂升') {
const amplitude = parseFloat(row.row.amplitude)
if (!isNaN(amplitude)) {
return 100 - amplitude
}
return '-'
} else {
// 电压暂升时不显示暂降深度
return '/'
}
}
},
{
title: '持续时间(S)',
field: 'persistTime',
minWidth: '100'
},
{ {
title: '严重度', title: '严重度',
field: 'severity', field: 'severity',
minWidth: '80' minWidth: 80,
align: 'center',
sortable: true,
formatter: (row: any) => row.cellValue ? row.cellValue : '/'
},
{ title: '相别', field: 'evtParamPhase', minWidth: 80, align: 'center' },
{ title: '触发类型', field: 'showName', minWidth: 100, align: 'center' },
{
title: '暂降原因',
field: 'advanceReason',
minWidth: 100,
align: 'center',
formatter: (row: any) => ReasonList.find((item: any) => item.id == row.cellValue)?.name || '未知'
}, },
{ {
title: '波形', title: '暂降类型',
minWidth: '100', field: 'advanceType',
minWidth: 100,
align: 'center',
formatter: (row: any) => EventTypeList.find((item: any) => item.id == row.cellValue)?.name || '未知'
},
{ title: '监测点名称', field: 'lineName', minWidth: 130, align: 'center' },
{ title: '电压等级(kV)', field: 'lineVoltage', minWidth: 120, align: 'center', sortable: true },
{ title: '设备名称', field: 'equipmentName', minWidth: 130, align: 'center' },
{ title: '项目名称', field: 'projectName', minWidth: 130, align: 'center' },
{ title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center' },
{
title: '发生位置',
field: 'sagSource',
minWidth: 120,
align: 'center',
formatter: (row: any) => row.cellValue == 1 ? '上游' : row.cellValue == 2 ? '下游' : '未知'
},
{
title: '操作',
fixed: 'right',
align: 'center',
width: 150,
render: 'buttons', render: 'buttons',
buttons: [ buttons: [
{ {
name: 'edit', name: 'edit',
text: '波形分析', text: '暂无波形',
type: 'primary', type: 'info',
icon: 'el-icon-DataLine', icon: 'el-icon-DataLine',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
return !row.wavePath
return row.wavePath
}, },
click: async row => { },
{
name: 'edit',
title: '波形分析',
type: 'primary',
icon: 'el-icon-DataLine',
render: 'basicButton',
loading: 'loading1',
disabled: (row: any) => !row.wavePath,
click: async (row: any) => {
row.loading1 = true row.loading1 = true
loading.value = true
isWaveCharts.value = true
dialogVisible.value = false dialogVisible.value = false
// 在打开弹窗时立即设置高度
nextTick(() => {
if (waveFormAnalysisRef.value) {
// waveFormAnalysisRef.value.setHeight(false, 360)
waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
}
})
await analyseWave(row.id) await analyseWave(row.id)
.then(res => { .then(res => {
row.loading1 = false row.loading1 = false
if (res != undefined) { if (res != undefined) {
boxoList.value = row loading.value = true
// boxoList.value = { isWaveCharts.value = true
// ...row, boxoList.value = {
// duration: row.persistTime // 将 persistTime 值赋给 duration ...row,
// } engineeringName: row.projectName,
boxoList.value.featureAmplitude = (row.amplitude - 0) / 100 persistTime: row.evtParamTm,
// row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null featureAmplitude:
boxoList.value.systemType = 'YPT' row.evtParamVVaDepth != '-' ? (row.evtParamVVaDepth - 0) / 100 : null,
systemType: 'YPT',
}
wp.value = res.data wp.value = res.data
} }
loading.value = false loading.value = false
@@ -179,39 +160,142 @@ const tableStore: any = new TableStore({
}) })
nextTick(() => { nextTick(() => {
waveFormAnalysisRef.value && if (waveFormAnalysisRef.value) {
waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true) waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true)
waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
}
}) })
} }
}, },
{ {
name: 'edit', name: 'edit',
text: '暂无波形', title: '波形下载',
type: 'info', type: 'primary',
icon: 'el-icon-DataLine', icon: 'el-icon-Check',
loading: 'loading2',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: (row: any) => !row.wavePath,
return !!row.wavePath click: (row: any) => {
row.loading2 = true
ElMessage.info('下载中......')
getFileZip({ eventId: row.id }).then(res => {
const blob = new Blob([res as unknown as BlobPart], { type: 'application/zip' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = row.wavePath.split('/')[2] || '波形文件'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
ElMessage.success('波形下载成功')
row.loading2 = false
}).catch(() => {
row.loading2 = false
})
} }
} }
] ]
} }
], ],
beforeSearchFun: () => {}, beforeSearchFun: () => { },
loadCallback: () => {} resetCallback: () => {
restoreOpenDayTime()
},
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.loading = false
item.evtParamTm =
item.evtParamTm.split('s')[0] != '-' ? (item.evtParamTm.split('s')[0] - 0).toFixed(2) : '-'
item.evtParamVVaDepth =
item.evtParamVVaDepth.split('%')[0] != '-'
? (item.evtParamVVaDepth.split('%')[0] - 0).toFixed(2)
: '-'
})
}
})
tableStore.table.params.type = 0
Object.assign(tableStore.table.params, {
featureAmplitudeMin: undefined,
featureAmplitudeMax: undefined,
evtParamTmMin: undefined,
evtParamTmMax: undefined,
severityMin: undefined,
severityMax: undefined,
fileFlag: ''
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
const open = async (time: any) => {
dialogVisible.value = true const resetFilterParams = () => {
getSimpleLineList() Object.assign(tableStore.table.params, {
tableStore.table.params.lineId = '' featureAmplitudeMin: undefined,
featureAmplitudeMax: undefined,
evtParamTmMin: undefined,
evtParamTmMax: undefined,
severityMin: undefined,
severityMax: undefined,
fileFlag: ''
})
}
const restoreOpenDayTime = () => {
if (!currentOpenTime.value || !tableHeaderRef.value) return
tableHeaderRef.value.setInterval(5)
tableHeaderRef.value.setTimeInterval([currentOpenTime.value, currentOpenTime.value])
tableStore.table.params.searchBeginTime = currentOpenTime.value
tableStore.table.params.searchEndTime = currentOpenTime.value
}
const syncInitDataForReset = () => {
if (!tableStore.initData) return
Object.assign(tableStore.initData, {
searchBeginTime: currentOpenTime.value,
searchEndTime: currentOpenTime.value,
startTime: currentOpenTime.value,
endTime: currentOpenTime.value,
featureAmplitudeMin: undefined,
featureAmplitudeMax: undefined,
evtParamTmMin: undefined,
evtParamTmMax: undefined,
severityMin: undefined,
severityMax: undefined,
fileFlag: ''
})
}
const openFilterDialog = () => {
filterVisible.value = true
}
const onFilterConfirm = () => {
tableStore.onTableAction('search', {})
}
const onResetForm = () => {
filterVisible.value = false
resetFilterParams()
multiConditionRef.value?.reset()
syncInitDataForReset()
nextTick(() => { nextTick(() => {
tableHeaderRef.value.setInterval(5) restoreOpenDayTime()
tableHeaderRef.value.setTimeInterval([time, time]) })
tableStore.table.params.searchBeginTime = time }
tableStore.table.params.searchEndTime = time
const open = (time: string) => {
currentOpenTime.value = time
dialogVisible.value = true
filterVisible.value = false
resetFilterParams()
multiConditionRef.value?.reset()
tableStore.table.params.pageNum = 1
nextTick(() => {
restoreOpenDayTime()
tableStore.index() tableStore.index()
nextTick(() => {
syncInitDataForReset()
})
}) })
} }
@@ -222,4 +306,5 @@ const handleHideCharts = () => {
defineExpose({ open }) defineExpose({ open })
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -7,7 +7,7 @@
@selectChange="selectChange" @selectChange="selectChange"
datePicker datePicker
v-if="fullscreen" v-if="fullscreen"
:timeKeyList="prop.timeKey" :timeKeyList="prop.timeKey"
></TableHeader> ></TableHeader>
<el-calendar <el-calendar
v-model="value" v-model="value"
@@ -74,7 +74,7 @@ const prop = defineProps({
h: { type: [String, Number] }, h: { type: [String, Number] },
width: { type: [String, Number] }, width: { type: [String, Number] },
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number }
}) })
@@ -131,7 +131,7 @@ const tableStore: any = new TableStore({
}, },
loadCallback: () => { loadCallback: () => {
value.value = tableStore.table.params.searchBeginTime value.value = dayjs(tableStore.table.params.searchBeginTime).toDate()
list.value = tableStore.table.data list.value = tableStore.table.data
} }
}) })

View File

@@ -1,22 +1,12 @@
<template> <template>
<div> <div>
<!--暂态事件概率分布 --> <!--暂态事件概率分布 -->
<TableHeader <TableHeader ref="TableHeaderRef" :timeKeyList="prop.timeKey" :showReset="false" @selectChange="selectChange"
ref="TableHeaderRef" datePicker v-if="fullscreen"></TableHeader>
:timeKeyList="prop.timeKey" <my-echart class="tall" :options="echartList" :style="{
:showReset="false" width: prop.width,
@selectChange="selectChange" height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
datePicker }" />
v-if="fullscreen"
></TableHeader>
<my-echart
class="tall"
:options="echartList"
:style="{
width: prop.width,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}"
/>
<!-- <my-echart <!-- <my-echart
class="mt10" class="mt10"
:options="echartList1" :options="echartList1"
@@ -170,7 +160,11 @@ const tableStore: any = new TableStore({
}, },
title: { title: {
text: '暂态事件概率分布', text: '暂态事件概率分布',
x: 'center' x: 'center',
textStyle: {
color: '#000',
fontSize: '15'
},
}, },
visualMap: { visualMap: {
max: 500, max: 500,
@@ -206,22 +200,22 @@ const tableStore: any = new TableStore({
}, },
grid3D: { grid3D: {
viewControl: { viewControl: {
projection: 'perspective', projection: 'perspective',
distance: 260, distance: 260,
rotateSensitivity: 10, rotateSensitivity: 10,
zoomSensitivity: 2 zoomSensitivity: 2
},
boxWidth: 150,
boxDepth: 100,
boxHeight: 100,
light: {
main: {
intensity: 1.2
}, },
boxWidth: 150, ambient: {
boxDepth: 100, intensity: 0.4
boxHeight: 100,
light: {
main: {
intensity: 1.2
},
ambient: {
intensity: 0.4
}
} }
}
}, },
series: [ series: [
{ {
@@ -242,7 +236,7 @@ const tableStore: any = new TableStore({
echartList1.value = { echartList1.value = {
title: { title: {
text: '越限时间概率分布' text: '暂态事件概率分布',
}, },
xAxis: { xAxis: {
type: 'category', type: 'category',

View File

@@ -1,175 +1,178 @@
<template> <template>
<div> <div>
<!-- 暂态事件详情 --> <el-dialog draggable :title="title" v-model="dialogVisible" append-to-body width="70%">
<el-dialog draggable title="暂态事件详情 " v-model="dialogVisible" append-to-body width="70%"> <TableHeader datePicker showExport ref="tableHeaderRef" @selectChange="selectChange"
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef" @selectChange="selectChange"> @onResetForm="onResetForm">
<template v-slot:select> <template v-slot:operation>
<el-form-item label="监测点"> <el-button type="primary" icon="el-icon-Operation" @click="openFilterDialog">事件筛选</el-button>
<el-select filterable v-model="tableStore.table.params.lineId" placeholder="请选择监测点名称">
<el-option
v-for="item in options"
:key="item.lineId"
:label="item.name"
:value="item.lineId"
/>
</el-select>
</el-form-item>
</template> </template>
</TableHeader> </TableHeader>
<MultiCondition
v-model:visible="filterVisible"
:fixed-target="filterTarget"
:params="tableStore.table.params"
ref="multiConditionRef"
@confirm="onFilterConfirm"
/>
<Table ref="tableRef" isGroup :height="heightRef"></Table> <Table ref="tableRef" isGroup :height="heightRef"></Table>
</el-dialog> </el-dialog>
<!-- 查看波形 -->
<el-dialog <el-dialog v-model="isWaveCharts" draggable title="波形分析" append-to-body width="70%" @close="handleHideCharts">
v-model="isWaveCharts" <waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
draggable @handleHideCharts="handleHideCharts" :wp="wp" />
title="波形分析"
append-to-body
width="70%"
@close="handleHideCharts"
>
<waveFormAnalysis
v-loading="loading"
v-if="isWaveCharts"
ref="waveFormAnalysisRef"
@handleHideCharts="handleHideCharts"
:wp="wp"
/>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, provide } from 'vue' import { ref, provide, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import MultiCondition from '@/views/govern/alarm/multiCondition.vue'
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue' import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
import { analyseWave } from '@/api/common' import { analyseWave } from '@/api/common'
import { getSimpleLine } from '@/api/harmonic-boot/cockpit/cockpit' import { getFileZip } from '@/api/cs-harmonic-boot/datatrend'
import { useDictData } from '@/stores/dictData'
const dialogVisible: any = ref(false) const dialogVisible = ref(false)
const waveFormAnalysisRef: any = ref(null) const waveFormAnalysisRef = ref()
// 波形
const isWaveCharts = ref(false) const isWaveCharts = ref(false)
const loading = ref(false) const loading = ref(false)
const wp = ref({}) const wp = ref({})
const boxoList: any = ref({}) const boxoList: any = ref({})
const title = ref('暂态事件')
const tableHeaderRef = ref() const tableHeaderRef = ref()
const filterVisible = ref(false)
const filterTarget = ref('')
const multiConditionRef = ref<InstanceType<typeof MultiCondition>>()
const dictData = useDictData()
const ReasonList: any = dictData.getBasicData('Event_Reason')
const EventTypeList: any = dictData.getBasicData('Event_Type')
const options = ref()
const heightRef = ref(mainHeight(168, 2.2).height) const heightRef = ref(mainHeight(168, 2.2).height)
const selectChange = (flag: boolean, h: any) => { const tableParams = ref<any>({})
const selectChange = (_flag: boolean, h: number) => {
heightRef.value = mainHeight(h, 2.2).height heightRef.value = mainHeight(h, 2.2).height
} }
const getSimpleLineList = async () => {
const res = await getSimpleLine()
options.value = res.data
}
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
url: '/cs-harmonic-boot/event/pageEvent', url: '/cs-device-boot/csGroup/deviceDataByType',
method: 'POST', method: 'POST',
showPage: true, showPage: true,
exportName: '主要监测点列表', exportName: '暂态事件',
column: [ column: [
{ {
field: 'index',
title: '序号', title: '序号',
width: '80', width: 80,
formatter: (row: any) => { formatter: (row: any) => {
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1 return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
} }
}, },
{ field: 'startTime', title: '发生时刻', minWidth: 180, sortable: true },
{ {
title: '暂态时间', field: 'featureAmplitude',
field: 'startTime', title: '暂降幅值(%)',
minWidth: '180' minWidth: 120,
}, sortable: true,
{
title: '测点名称',
field: 'lineName',
minWidth: '150'
},
{
title: '暂态类型',
field: 'tag',
minWidth: '100'
},
{
title: '特征幅值(%)',
field: 'amplitude',
minWidth: '100'
},
{
title: '暂降深度(%)',
field: 'depth',
minWidth: '100',
formatter: (row: any) => { formatter: (row: any) => {
// 当暂态类型不是电压暂升时,计算暂降深度 = 100 - 特征幅值 row.cellValue = row.cellValue != null ? Number(row.cellValue).toFixed(2) : '/'
if (row.row.tag !== '电压暂升') { if (String(row.cellValue).split('.')[1] == '00') {
const amplitude = parseFloat(row.row.amplitude) row.cellValue = String(row.cellValue).split('.')[0]
if (!isNaN(amplitude)) {
return 100 - amplitude
}
return '-'
} else {
// 电压暂升时不显示暂降深度
return '/'
} }
return row.cellValue
} }
}, },
{ {
title: '持续时间(S)',
field: 'persistTime', field: 'persistTime',
minWidth: '100' title: '持续时间(s)',
minWidth: 110,
formatter: (row: any) => row.cellValue ? (row.cellValue - 0).toFixed(2) : '/',
sortable: true
},
{
field: 'phaseType',
title: '相别',
minWidth: 80,
formatter: (row: any) => row.cellValue || '/'
}, },
{ {
title: '严重度', title: '严重度',
field: 'severity', field: 'severity',
minWidth: '80' minWidth: 80,
align: 'center',
sortable: true,
formatter: (row: any) => row.cellValue ? row.cellValue : '/'
},
{ field: 'showName', title: '触发类型', minWidth: 100 },
{
title: '暂降原因',
field: 'advanceReason',
minWidth: 100,
align: 'center',
formatter: (row: any) => ReasonList.find((item: any) => item.id == row.cellValue)?.name || '未知'
}, },
{ {
title: '波形', title: '暂降类型',
width: '90', field: 'advanceType',
minWidth: 100,
align: 'center',
formatter: (row: any) => EventTypeList.find((item: any) => item.id == row.cellValue)?.name || '未知'
},
{ title: '电压等级(kV)', field: 'lineVoltage', minWidth: 120, align: 'center', sortable: true },
{
title: '发生位置',
field: 'sagSource',
minWidth: 120,
align: 'center',
formatter: (row: any) => row.cellValue == 1 ? '上游' : row.cellValue == 2 ? '下游' : '未知'
},
{
title: '操作',
fixed: 'right',
width: 150,
render: 'buttons', render: 'buttons',
buttons: [ buttons: [
{ {
name: 'edit', name: 'edit',
text: '波形分析', text: '暂无波形',
type: 'primary', type: 'info',
icon: 'el-icon-DataLine', icon: 'el-icon-DataLine',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: row => {
return !row.wavePath return row.wavePath
}, }
},
click: async row => { {
name: 'edit',
title: '波形分析',
type: 'primary',
icon: 'el-icon-Check',
render: 'basicButton',
loading: 'loading1',
disabled: (row: any) => !row.wavePath,
click: async (row: any) => {
row.loading1 = true row.loading1 = true
loading.value = true
isWaveCharts.value = true
dialogVisible.value = false
// 在打开弹窗时立即设置高度
nextTick(() => {
if (waveFormAnalysisRef.value) {
// waveFormAnalysisRef.value.setHeight(false, 360)
waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
}
})
await analyseWave(row.id) await analyseWave(row.id)
.then(res => { .then(res => {
row.loading1 = false row.loading1 = false
if (res != undefined) { if (res != undefined) {
boxoList.value = row loading.value = true
// boxoList.value = { isWaveCharts.value = true
// ...row, dialogVisible.value = false
// duration: row.persistTime // 将 persistTime 值赋给 duration boxoList.value = {
// } ...row,
// boxoList.value.featureAmplitude = systemType: 'YPT',
// row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null engineeringName: tableParams.value.projectName,
boxoList.value.featureAmplitude = (row.amplitude - 0) / 100 featureAmplitude:
boxoList.value.systemType = 'YPT' row.featureAmplitude != null ? Number(row.featureAmplitude / 100) : '-',
persistTime: row.persistTime ? row.persistTime.toFixed(2) : '-',
}
wp.value = res.data wp.value = res.data
} }
loading.value = false loading.value = false
@@ -180,33 +183,108 @@ const tableStore: any = new TableStore({
}) })
nextTick(() => { nextTick(() => {
waveFormAnalysisRef.value && if (waveFormAnalysisRef.value) {
waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true) waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value)
waveFormAnalysisRef.value.setHeight(999, 130, 1.6666666)
}
}) })
} }
}, },
{ {
name: 'edit', name: 'edit',
text: '暂无波形', title: '波形下载',
type: 'info', type: 'primary',
icon: 'el-icon-DataLine', loading: 'loading2',
icon: 'el-icon-Check',
render: 'basicButton', render: 'basicButton',
disabled: row => { disabled: (row: any) => !row.wavePath,
return !!row.wavePath click: (row: any) => {
row.loading2 = true
ElMessage.info('下载中......')
getFileZip({ eventId: row.id }).then(res => {
const blob = new Blob([res as unknown as BlobPart], { type: 'application/zip' })
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = row.wavePath.split('/')[2] || '波形文件'
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
ElMessage.success('波形下载成功')
row.loading2 = false
}).catch(() => {
row.loading2 = false
})
} }
} }
] ]
} }
], ],
beforeSearchFun: () => {}, beforeSearchFun: () => {
loadCallback: () => {} tableStore.table.params.devId = tableParams.value.devId
tableStore.table.params.lineId = tableParams.value.lineId
tableStore.table.params.list = tableParams.value.list
tableStore.table.params.type = 3
},
loadCallback: () => { }
})
tableStore.table.params.type = 3
Object.assign(tableStore.table.params, {
featureAmplitudeMin: undefined,
featureAmplitudeMax: undefined,
evtParamTmMin: undefined,
evtParamTmMax: undefined,
severityMin: undefined,
severityMax: undefined,
fileFlag: ''
}) })
provide('tableStore', tableStore) provide('tableStore', tableStore)
const open = async (row: any, searchBeginTime: any, searchEndTime: any) => {
const resetFilterParams = () => {
Object.assign(tableStore.table.params, {
featureAmplitudeMin: undefined,
featureAmplitudeMax: undefined,
evtParamTmMin: undefined,
evtParamTmMax: undefined,
severityMin: undefined,
severityMax: undefined,
fileFlag: ''
})
}
const openFilterDialog = () => {
filterVisible.value = true
}
const onFilterConfirm = () => {
tableStore.onTableAction('search', {})
}
const onResetForm = () => {
filterVisible.value = false
resetFilterParams()
multiConditionRef.value?.reset()
tableStore.index()
}
const open = (row: any, searchBeginTime: any, searchEndTime: any, type?: string) => {
filterTarget.value = type || ''
title.value = row.name + '_暂态事件'
dialogVisible.value = true dialogVisible.value = true
getSimpleLineList() filterVisible.value = false
tableStore.table.params.lineId = row.id resetFilterParams()
multiConditionRef.value?.reset()
const lineId = row.id || row.lineId
tableParams.value = {
lineId,
devId: row.devId,
engineeringName: row.engineeringName,
list: row.devId ? [{ lineId, devId: row.devId }] : undefined,
}
tableStore.table.params.pageNum = 1
nextTick(() => { nextTick(() => {
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime]) tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
tableStore.table.params.searchBeginTime = searchBeginTime tableStore.table.params.searchBeginTime = searchBeginTime
@@ -222,4 +300,5 @@ const handleHideCharts = () => {
defineExpose({ open }) defineExpose({ open })
</script> </script>
<style lang="scss" scoped></style> <style lang="scss" scoped></style>

View File

@@ -1,27 +1,14 @@
<template> <template>
<div> <div>
<!--暂态事件统计 --> <!--暂态事件统计 -->
<TableHeader <TableHeader ref="TableHeaderRef" :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"
ref="TableHeaderRef" :timeKeyList="prop.timeKey"></TableHeader>
:showReset="false" <my-echart class="tall" :options="echartList" :style="{
@selectChange="selectChange" width: prop.width,
datePicker height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
v-if="fullscreen" :timeKeyList="prop.timeKey" }" />
></TableHeader> <Table ref="tableRef" @cell-click="cellClickEvent"
<my-echart :height="`calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`" isGroup></Table>
class="tall"
:options="echartList"
:style="{
width: prop.width,
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
}"
/>
<Table
ref="tableRef"
@cell-click="cellClickEvent"
:height="`calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`"
isGroup
></Table>
<TransientStatisticsDetail ref="transientStatisticsDetailRef"></TransientStatisticsDetail> <TransientStatisticsDetail ref="transientStatisticsDetailRef"></TransientStatisticsDetail>
</div> </div>
</template> </template>
@@ -41,7 +28,7 @@ const prop = defineProps({
h: { type: [String, Number] }, h: { type: [String, Number] },
width: { type: [String, Number] }, width: { type: [String, Number] },
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number }
}) })
@@ -129,7 +116,11 @@ const eventEcharts = () => {
title: [ title: [
{ {
text: '暂态事件统计', text: '暂态事件统计',
left: 'center' left: 'center',
textStyle: {
color: '#000',
fontSize: '15'
},
}, },
{ {
text: rawData.eventOff + rawData.eventDown + rawData.eventUp + '次', text: rawData.eventOff + rawData.eventDown + rawData.eventUp + '次',
@@ -173,15 +164,30 @@ const tableStore: any = new TableStore({
} }
}, },
{ {
title: '名称', title: '监测点名称',
field: 'name', field: 'name',
minWidth: '90' minWidth: 120
},
{
title: '设备名称', field: 'devName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
title: '项目名称', field: 'projectName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
},
{
title: '工程名称', field: 'engineeringName', minWidth: 130, align: 'center', formatter: (row: any) => {
return row.cellValue || '/'
}
}, },
{ {
title: '电压中断(次)', title: '电压中断(次)',
field: 'eventOff', field: 'eventOff',
minWidth: '70', minWidth: '90',
sortable: true, sortable: true,
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
@@ -191,7 +197,7 @@ const tableStore: any = new TableStore({
{ {
title: '电压暂降(次)', title: '电压暂降(次)',
field: 'eventDown', field: 'eventDown',
minWidth: '80', minWidth: '90',
sortable: true, sortable: true,
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
@@ -201,7 +207,7 @@ const tableStore: any = new TableStore({
{ {
title: '电压暂升(次)', title: '电压暂升(次)',
field: 'eventUp', field: 'eventUp',
minWidth: '80', minWidth: '90',
sortable: true, sortable: true,
render: 'customTemplate', render: 'customTemplate',
customTemplate: (row: any) => { customTemplate: (row: any) => {
@@ -224,11 +230,13 @@ provide('tableStore', tableStore)
// 点击行 // 点击行
const cellClickEvent = ({ row, column }: any) => { const cellClickEvent = ({ row, column }: any) => {
if (column.field != 'name') { if (column.field != 'name' && column.field != 'devName' && column.field != 'projectName' && column.field != 'engineeringName') {
transientStatisticsDetailRef.value.open( transientStatisticsDetailRef.value.open(
row, row,
tableStore.table.params.searchBeginTime || prop.timeValue?.[0], tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
tableStore.table.params.searchEndTime || prop.timeValue?.[1] tableStore.table.params.searchEndTime || prop.timeValue?.[1],
column.field=='eventOff'?'中断':column.field=='eventDown'?'暂降':column.field=='eventUp'?'暂升':''
) )
} }
} }

View File

@@ -1,26 +1,22 @@
<template> <template>
<div> <div class="device-control">
<!--趋势对比 --> <!--趋势对比 -->
<TableHeader <div v-show="fullscreen">
datePicker <!-- <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree> -->
ref="TableHeaderRef" <APFTree :height="flag ? 126 : 70" @node-click="handleNodeClick" @init="handleNodeClick"></APFTree>
:timeKeyList="prop.timeKey" </div>
:showReset="false" <div>
@selectChange="selectChange"
v-if="fullscreen" <TableHeader datePicker ref="TableHeaderRef" :timeKeyList="prop.timeKey" :showReset="false"
> @selectChange="selectChange" v-if="fullscreen">
<template v-slot:select> <template v-slot:select>
<el-form-item label="监测对象"> <!-- <el-form-item label="监测对象">
<el-select <el-select filterable v-model="tableStore.table.params.sensitiveUserId" placeholder="请选择监测对象"
filterable clearable>
v-model="tableStore.table.params.sensitiveUserId" <el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
placeholder="请选择监测对象" </el-select>
clearable </el-form-item> -->
> <!-- <el-form-item label="监测点名称">
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<!-- <el-form-item label="监测点名称">
<el-select v-model="tableStore.table.params.lineId" placeholder="请选择监测点名称" clearable> <el-select v-model="tableStore.table.params.lineId" placeholder="请选择监测点名称" clearable>
<el-option <el-option
v-for="item in lineIdList" v-for="item in lineIdList"
@@ -30,57 +26,45 @@
/> />
</el-select> </el-select>
</el-form-item> --> </el-form-item> -->
<el-form-item label="电能质量指标"> <el-form-item label="电能质量指标">
<el-select v-model="tableStore.table.params.indicator" placeholder="请选择电能质量指标" clearable> <el-select v-model="tableStore.table.params.indicator" placeholder="请选择电能质量指标" clearable>
<el-option v-for="item in indicatorList" :key="item.id" :label="item.name" :value="item.id" /> <el-option v-for="item in indicatorList" :key="item.id" :label="item.name"
</el-select> :value="item.id" />
</el-form-item>
<el-form-item>
<el-radio-group v-model="tableStore.table.params.dataLevel">
<el-radio-button label="一次值" value="Primary" />
<el-radio-button label="二次值" value="Secondary" />
</el-radio-group>
</el-form-item>
<el-form-item label="统计类型">
<el-select
style="min-width: 120px !important"
placeholder="请选择"
v-model="tableStore.table.params.valueType"
>
<el-option value="max" label="最大值"></el-option>
<el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option>
<el-option value="cp95" label="cp95"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<div v-if="shouldShowHarmonicCount()" style="display: flex; color: var(--el-text-color-regular)">
<span style="width: 160px">{{ getHarmonicTypeName() }}谐波次数</span>
<el-select
v-model="tableStore.table.params.harmonicCount"
placeholder="请选择谐波次数"
style="min-width: 80px !important"
>
<el-option
v-for="num in harmonicCountOptions"
:key="num"
:label="num"
:value="num"
></el-option>
</el-select> </el-select>
</div> </el-form-item>
</el-form-item> <el-form-item>
</template> <el-radio-group v-model="tableStore.table.params.dataLevel" @change="tableStore.index()">
</TableHeader> <el-radio-button label="一次值" value="Primary" />
<my-echart <el-radio-button label="二次值" value="Secondary" />
v-loading="tableStore.table.loading" </el-radio-group>
class="tall" </el-form-item>
:options="echartList" <el-form-item label="统计类型">
:style="{ <el-select style="min-width: 120px !important" placeholder="请选择"
width: prop.width, v-model="tableStore.table.params.valueType">
<el-option value="max" label="最大值"></el-option>
<el-option value="min" label="最小值"></el-option>
<el-option value="avg" label="平均值"></el-option>
<el-option value="cp95" label="cp95"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<div v-if="shouldShowHarmonicCount()"
style="display: flex; color: var(--el-text-color-regular)">
<span style="width: 160px">{{ getHarmonicTypeName() }}谐波次数</span>
<el-select v-model="tableStore.table.params.harmonicCount" placeholder="请选择谐波次数"
style="min-width: 80px !important">
<el-option v-for="num in harmonicCountOptions" :key="num" :label="num"
:value="num"></el-option>
</el-select>
</div>
</el-form-item>
</template>
</TableHeader>
<my-echart v-loading="tableStore.table.loading" class="tall" :options="echartList" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)` height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
}" }" />
/> </div>
<!-- <el-empty description="暂无数据" /> --> <!-- <el-empty description="暂无数据" /> -->
</div> </div>
</template> </template>
@@ -93,8 +77,8 @@ import { useConfig } from '@/stores/config'
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree' import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit' import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
import { getTime } from '@/utils/formatTime' import { getTime } from '@/utils/formatTime'
import { yMethod, exportCSV } from '@/utils/echartMethod' import { yMethod, exportSeriesCSV, completeTimeSeries } from '@/utils/echartMethod'
import { max } from 'lodash' import APFTree from '@/components/tree/govern/APFTree.vue'
const prop = defineProps({ const prop = defineProps({
w: { type: [String, Number] }, w: { type: [String, Number] },
h: { type: [String, Number] }, h: { type: [String, Number] },
@@ -102,7 +86,8 @@ const prop = defineProps({
height: { type: [String, Number] }, height: { type: [String, Number] },
timeKey: { type: Array as () => string[] }, timeKey: { type: Array as () => string[] },
timeValue: { type: Object }, timeValue: { type: Object },
interval: { type: Number } interval: { type: Number },
flag: { type: Boolean }
}) })
const TableHeaderRef = ref() const TableHeaderRef = ref()
@@ -125,6 +110,7 @@ const harmonicCountOptions = ref(Array.from({ length: 49 }, (_, i) => i + 2))
const indicatorList = ref() const indicatorList = ref()
const echartList = ref() const echartList = ref()
const timeControl = ref(false)
const headerHeight = ref(57) const headerHeight = ref(57)
@@ -136,12 +122,26 @@ const initListByIds = () => {
getListByIds({}).then((res: any) => { getListByIds({}).then((res: any) => {
if (res.data?.length > 0) { if (res.data?.length > 0) {
idList.value = res.data idList.value = res.data
initCode()
} else { } else {
tableStore.index() tableStore.index()
} }
}) })
} }
const handleNodeClick = async (data: any) => {
if (data?.level == 3 || data?.level == 2) {
tableStore.table.params.sensitiveUserId = data.id
await tableStore.index()
} else {
tableStore.table.loading = false
}
}
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => { const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
headerHeight.value = height headerHeight.value = height
@@ -158,7 +158,7 @@ const initCode = () => {
indicatorList.value = item.data indicatorList.value = item.data
tableStore.table.params.indicator = indicatorList.value[0].id tableStore.table.params.indicator = indicatorList.value[0].id
nextTick(() => { nextTick(() => {
tableStore.index() // tableStore.index()
}) })
}) })
}) })
@@ -192,7 +192,7 @@ const setEchart = () => {
if (!afterGroupedByPhase[phase]) { if (!afterGroupedByPhase[phase]) {
afterGroupedByPhase[phase] = [] afterGroupedByPhase[phase] = []
} }
afterGroupedByPhase[phase].push([item.time, item.statisticalData, item.unit, 'dotted']) afterGroupedByPhase[phase].push([item.time, item.statisticalData, item.unit, 'dashed'])
}) })
// 构建系列数据 // 构建系列数据
@@ -211,7 +211,7 @@ const setEchart = () => {
const color = phaseColors[phase] || config.layout.elementUiPrimary[0] const color = phaseColors[phase] || config.layout.elementUiPrimary[0]
series.push({ series.push({
name: `治理前${phaseName}`, name: `${phaseName}_治理前`,
type: 'line', type: 'line',
showSymbol: false, showSymbol: false,
smooth: true, smooth: true,
@@ -224,7 +224,6 @@ const setEchart = () => {
}, },
lineStyle: { lineStyle: {
type: 'solid', // 实线 type: 'solid', // 实线
width: 2 // 线条宽度
}, },
yAxisIndex: 0 yAxisIndex: 0
}) })
@@ -236,12 +235,12 @@ const setEchart = () => {
const color = phaseColors[phase] || config.layout.elementUiPrimary[0] const color = phaseColors[phase] || config.layout.elementUiPrimary[0]
series.push({ series.push({
name: `治理后${phaseName}`, name: `${phaseName}_治理后`,
type: 'line', type: 'line',
showSymbol: false, showSymbol: false,
smooth: true, smooth: true,
symbol: 'none', symbol: 'none',
data: afterGroupedByPhase[phase], data: timeControl.value ? completeTimeSeries(afterGroupedByPhase[phase]) : afterGroupedByPhase[phase],
itemStyle: { itemStyle: {
normal: { normal: {
color: color color: color
@@ -249,7 +248,6 @@ const setEchart = () => {
}, },
lineStyle: { lineStyle: {
type: 'dashed', // 虚线 type: 'dashed', // 虚线
width: 2 // 线条宽度
}, },
yAxisIndex: 0 yAxisIndex: 0
}) })
@@ -258,9 +256,9 @@ const setEchart = () => {
// 获取指标名称用于图表标题 // 获取指标名称用于图表标题
let titleText = '治理前后对比' let titleText = '治理前后对比'
if (beforeData.length > 0 && beforeData[0].anotherName) { if (beforeData.length > 0 && beforeData[0].anotherName) {
titleText = beforeData[0].anotherName titleText = beforeData[0].anotherName+'治理前后对比'
} else if (afterData.length > 0 && afterData[0].anotherName) { } else if (afterData.length > 0 && afterData[0].anotherName) {
titleText = afterData[0].anotherName titleText = afterData[0].anotherName+'治理前后对比'
} }
// statisticalData // statisticalData
@@ -285,9 +283,9 @@ const setEchart = () => {
return { return {
name: item.name, name: item.name,
icon: isBefore // icon: isBefore
? 'rect' // ? 'rect'
: 'path://M0,2 L8,2 L8,6 L0,6 Z M12,2 L20,2 L20,6 L12,6 Z M24,2 L32,2 L32,6 L24,6 Z M36,2 L44,2 L44,6 L36,6 Z', // 矩形组成的粗虚线 // : 'path://M0,2 L8,2 L8,6 L0,6 Z M12,2 L20,2 L20,6 L12,6 Z M24,2 L32,2 L32,6 L24,6 Z M36,2 L44,2 L44,6 L36,6 Z', // 矩形组成的粗虚线
itemStyle: { itemStyle: {
color: color // 明确指定图例图标的颜色 color: color // 明确指定图例图标的颜色
}, },
@@ -297,7 +295,7 @@ const setEchart = () => {
} }
} }
}) })
let [min, max] = yMethod( let [min, max] = yMethod(
[...chartsListBefore.value.map((item: any) => item.statisticalData), [...chartsListBefore.value.map((item: any) => item.statisticalData),
...chartsListAfter.value.map((item: any) => item.statisticalData)] ...chartsListAfter.value.map((item: any) => item.statisticalData)]
) )
@@ -326,21 +324,28 @@ const setEchart = () => {
let str = `${xname}<br>` let str = `${xname}<br>`
params.forEach((el: any, index: any) => { params.forEach((el: any, index: any) => {
let marker = '' let marker = ''
if (el.value[3] == 'dashed') {
for (let i = 0; i < 3; i++) {
marker += `<span style="display:inline-block;border: 2px ${el.color} solid;margin-right:5px;width:10px;height:0px;background-color:#ffffff00;"></span>`
}
} else {
marker = `<span style="display:inline-block;border: 2px ${el.color} ${el.value[3]};margin-right:5px;width:40px;height:0px;background-color:#ffffff00;"></span>`//`<span style="display:inline-block;border: 2px ${el.color} ${el.value[3]};margin-right:5px;width:40px;height:0px;background-color:#ffffff00;"></span>`
marker = `<span style="display:inline-block;border: 2px ${el.color} ${el.value[3]};margin-right:5px;width:40px;height:0px;background-color:#ffffff00;"></span>` }
str += `${marker}${el.seriesName.split('(')[0]}${ str += `${marker}${el.seriesName.split('(')[0]}${el.value[1] != null ? el.value[1] + ' ' + (el.value[2] == null ? '' : el.value[2]) : '-'
el.value[1] != null ? el.value[1] + ' ' + (el.value[2] == null ? '' : el.value[2]) : '-' }<br>`
}<br>`
}) })
return str return str
} }
}, },
legend: { legend: {
data: legendData, data: legendData,
icon: 'rect', // icon: 'rect',
itemWidth: 18, itemWidth: 18,
itemHeight: 3, itemHeight: 3,
type: 'scroll',
itemStyle: { itemStyle: {
borderWidth: 0 borderWidth: 0
}, },
@@ -367,10 +372,40 @@ const setEchart = () => {
left: '10px', left: '10px',
right: '20px' right: '20px'
}, },
toolbox: {
featureProps: {
myTool1: {
show: true,
title: '下载csv',
icon: 'path://M642 673.1H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9s-8 17.9-17.9 17.9zM642 511.8H301.6c-9.9 0-17.9-8-17.9-17.9 0-9.9 8-17.9 17.9-17.9H642c9.9 0 17.9 8 17.9 17.9 0 9.9-8 17.9-17.9 17.9zM480.7 350.6H301.6c-9.9 0-17.9-8-17.9-17.9s8-17.9 17.9-17.9h179.2c9.9 0 17.9 8 17.9 17.9s-8.1 17.9-18 17.9zM874.9 350.6H695.7c-49.4 0-89.6-40.2-89.6-89.6V81.9c0-9.9 8-17.9 17.9-17.9 9.9 0 17.9 8 17.9 17.9V261c0 29.6 24.1 53.7 53.7 53.7h179.2c9.9 0 17.9 8 17.9 17.9s-7.9 18-17.8 18zM794.3 959.7H221c-49.4 0-89.6-40.2-89.6-89.6V153.5c0-49.4 40.2-89.6 89.6-89.6h403.1c4.8 0 9.3 1.9 12.7 5.2L887.6 320c3.4 3.4 5.2 7.9 5.2 12.7v537.5c0 52.7-51.9 89.5-98.5 89.5zM221 99.8c-29.6 0-53.7 24.1-53.7 53.7v716.6c0 29.6 24.1 53.7 53.7 53.7h573.3c29 0 62.7-23.5 62.7-53.7v-530L616.7 99.8H221z',
iconStyle: timeControl.value ? { borderColor: '#409EFF' } : {},
onclick: () => {
exportSeriesCSV(
echartList.value.series,
`${echartList.value.title?.text || '趋势对比'}.csv`
)
}
},
myTool2: {
show: true,
title: timeControl.value ? '关闭缺失数据' : '缺失数据',
icon: 'path://M832 512l-192-192v128H128v128h512v128l192-192zM192 512l192 192v-128h512v-128H384V320L192 512z',
iconStyle: timeControl.value ? { borderColor: '#409EFF' } : {},
onclick: () => {
setTimeControl()
}
}
}
},
series: series series: series
} }
} }
const setTimeControl = () => {
timeControl.value = !timeControl.value
setEchart()
}
const tableStore: any = new TableStore({ const tableStore: any = new TableStore({
url: '/cs-device-boot/csGroup/sensitiveUserTrendData', url: '/cs-device-boot/csGroup/sensitiveUserTrendData',
method: 'POST', method: 'POST',
@@ -379,9 +414,9 @@ const tableStore: any = new TableStore({
column: [], column: [],
beforeSearchFun: () => { beforeSearchFun: () => {
setTime() setTime()
if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) { // if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) {
tableStore.table.params.sensitiveUserId = idList.value[0].id // tableStore.table.params.sensitiveUserId = idList.value[0].id
} // }
let lists: any = [] let lists: any = []
// 处理电能质量指标 // 处理电能质量指标
const selectedIndicator = indicatorList.value?.find( const selectedIndicator = indicatorList.value?.find(
@@ -420,7 +455,8 @@ tableStore.table.params.valueType = 'avg'
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
initListByIds() initCode()
// initListByIds()
}) })
const setTime = () => { const setTime = () => {
@@ -504,4 +540,11 @@ watch(
// :deep(.el-select) { // :deep(.el-select) {
// min-width: 80px; // min-width: 80px;
// } // }
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style> </style>

View File

@@ -43,9 +43,10 @@ const initChart = () => {
left: 'center', left: 'center',
// textStyle: { // textStyle: {
color: '#000', color: '#000',
top: 5,
textStyle: { textStyle: {
color: '#000', color: '#000',
fontSize: '18' fontSize: '15'
}, },
// }, // },
...(props.options?.title || null) ...(props.options?.title || null)
@@ -66,10 +67,11 @@ const initChart = () => {
}, },
toolbox: { toolbox: {
right: 20, right: 20,
top: 15, top: props.options?.title?.text ? 20 : 0,
feature: { feature: {
saveAsImage: { saveAsImage: {
title: '保存图片' title: '下载图片',
name: props.options?.title?.text || '图表'
}, },
...(props.options?.toolbox?.featureProps || null) ...(props.options?.toolbox?.featureProps || null)
}, },
@@ -77,10 +79,11 @@ const initChart = () => {
...(props.options?.toolbox || null) ...(props.options?.toolbox || null)
}, },
legend: { legend: {
right: 50, right: 100,
top: 25, top: props.options?.title?.text ? 25 : 5,
itemGap: 10, itemGap: 10,
itemStyle: {}, itemStyle: {},
type: 'scroll', // 开启滚动分页
// textStyle: { // textStyle: {
fontSize: 12, fontSize: 12,
// padding: [2, 0, 0, 0], //[上、右、下、左] // padding: [2, 0, 0, 0], //[上、右、下、左]
@@ -90,7 +93,7 @@ const initChart = () => {
...(props.options?.legend || null) ...(props.options?.legend || null)
}, },
grid: { grid: {
top: '50px', top: props.options?.title?.text ? '50px' : '25px',
left: '30px', left: '30px',
right: '70px', right: '70px',
bottom: props.options?.options?.dataZoom === null ? '10px' : '40px', bottom: props.options?.options?.dataZoom === null ? '10px' : '40px',
@@ -106,13 +109,15 @@ const initChart = () => {
start: 0, start: 0,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
}, },
{ {
start: 0, start: 0,
height: 13, height: 13,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
} }
// { // {
// show: true, // show: true,

View File

@@ -236,7 +236,7 @@ const fliteWaveData = (wp, step, iphasicValue, isOpen) => {
// 监听消息 // 监听消息
self.onmessage = function (e) { self.onmessage = function (e) {
const { wp, isOpen, value, boxoList } = JSON.parse(e.data) const { wp, isOpen, value, boxoList, requestId } = e.data
try { try {
const iphasicValue = wp.iphasic || 1 const iphasicValue = wp.iphasic || 1
@@ -258,8 +258,8 @@ self.onmessage = function (e) {
boxoList.measurementPointName + boxoList.measurementPointName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'%  持续时间:' + '%  持续时间:' +
boxoList.duration + boxoList.duration +
's' 's'
@@ -270,7 +270,7 @@ self.onmessage = function (e) {
boxoList.equipmentName + boxoList.equipmentName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
boxoList.evtParamVVaDepth + boxoList.evtParamVVaDepth +
'% 持续时间:' + '% 持续时间:' +
boxoList.evtParamTm + boxoList.evtParamTm +
@@ -282,8 +282,8 @@ self.onmessage = function (e) {
boxoList.lineName + boxoList.lineName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'% 持续时间:' + '% 持续时间:' +
boxoList.persistTime + boxoList.persistTime +
's' 's'
@@ -295,14 +295,15 @@ self.onmessage = function (e) {
boxoList.lineName + boxoList.lineName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'% 持续时间:' + '% 持续时间:' +
boxoList.duration + boxoList.duration +
's' 's'
} }
// 发送处理结果回主线程 // 发送处理结果回主线程
self.postMessage({ self.postMessage({
requestId,
titles: titles, titles: titles,
success: true, success: true,
waveDatas, waveDatas,
@@ -313,6 +314,7 @@ self.onmessage = function (e) {
}) })
} catch (error) { } catch (error) {
self.postMessage({ self.postMessage({
requestId,
success: false, success: false,
error: error.message error: error.message
}) })

View File

@@ -14,9 +14,15 @@ import html2canvas from 'html2canvas'
import $ from 'jquery' import $ from 'jquery'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { calcRmsYAxisRange, formatAxisLabel } from '@/utils/chartAxisHelper'
import url from '@/assets/img/point.png' import url from '@/assets/img/point.png'
import url2 from '@/assets/img/dw.png' import url2 from '@/assets/img/dw.png'
const worker = ref<Worker | null>(null) import { buildWaveCacheKey, getWaveCache, setWaveCache } from '@/utils/waveCache'
import { getRmsWorker, buildWorkerPayload } from '@/utils/waveWorkerPool'
let waveRequestId = 0
const pendingCacheKeys = new Map<number, string>()
let rmsWorker: Worker | null = null
interface WaveData { interface WaveData {
instantF: { max: number; min: number } instantF: { max: number; min: number }
instantS: { max: number; min: number } instantS: { max: number; min: number }
@@ -125,52 +131,61 @@ const vw = computed(() => '100%')
watch( watch(
() => props.value, () => props.value,
newVal => { () => {
if (newVal == 2) { query()
initWaves()
} else {
$('#wave1').remove()
initWaves()
}
} }
) )
watch(
() => props.wp,
() => {
query()
}
)
const applyWorkerResult = (data: any) => {
titles.value = data.titles
waveDatas.value = data.waveDatas
time.value = data.time
type.value = data.type
severity.value = data.severity
iphasic.value = data.iphasic
if (Number(severity.value) < 0) {
severity.value = '/'
type.value = '/'
}
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
loading.value = false
}
onMounted(() => { onMounted(() => {
const zoomValue = document.body.style.getPropertyValue('zoom') const zoomValue = document.body.style.getPropertyValue('zoom')
zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1) zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1)
window.addEventListener('resize', handleResize) window.addEventListener('resize', handleResize)
// 初始化 Web Worker rmsWorker = getRmsWorker(data => {
worker.value = new Worker(new URL('./rmsWorker.js', import.meta.url)) if (data.requestId !== waveRequestId) return
worker.value.onmessage = e => { if (!data.success) {
if (e.data.success) { console.error('Worker error:', data.error)
const data = e.data
titles.value = data.titles
waveDatas.value = data.waveDatas
time.value = data.time
type.value = data.type
severity.value = data.severity
iphasic.value = data.iphasic
// 初始化波形图
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
} else {
console.error('Worker error:', e.data.error)
loading.value = false loading.value = false
return
} }
} const cacheKey = pendingCacheKeys.get(data.requestId)
if (cacheKey) {
setWaveCache(cacheKey, data)
pendingCacheKeys.delete(data.requestId)
}
applyWorkerResult(data)
})
nextTick(() => { nextTick(() => {
setTimeout(() => { query()
query()
}, 500)
}) })
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (worker.value) {
worker.value.terminate()
}
backbxlb() backbxlb()
window.removeEventListener('resize', handleResize) window.removeEventListener('resize', handleResize)
}) })
@@ -195,23 +210,15 @@ const download = () => {
} }
} }
const EXTRA_PANEL_CLASS = 'wave-extra-panel'
const resetWaveDom = () => {
backbxlb()
$('#rmsp').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
}
const query = () => { const query = () => {
loading.value = true initWaves()
if (props.wp) {
// 使用 Worker 处理数据
if (worker.value) {
worker.value.postMessage(
JSON.stringify({
wp: props.wp,
isOpen: isOpen.value,
value: props.value,
boxoList: props.boxoList
})
)
}
} else {
initWave(null, null, null, null, null)
}
} }
const waveData = ( const waveData = (
@@ -245,29 +252,31 @@ const waveData = (
} }
const initWaves = () => { const initWaves = () => {
if (props.wp) { if (!props.wp?.listRmsData?.length) {
iphasic.value = props.wp.iphasic || 1
const picCounts = (props.wp.waveTitle.length - 1) / iphasic.value
waveDatas.value = []
for (let i = 0; i < picCounts; i++) {
const data = fliteWaveData(props.wp, i)
waveDatas.value.push(data)
}
time.value = props.wp.time
type.value = props.wp.waveType
severity.value = props.wp.yzd
if (Number(severity.value) < 0) {
severity.value = '/'
type.value = '/'
}
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
} else {
initWave(null, null, null, null, null) initWave(null, null, null, null, null)
loading.value = false
return
} }
const cacheKey = buildWaveCacheKey('rms', props.wp, props.value, isOpen.value, props.boxoList)
const cached = getWaveCache<any>(cacheKey)
if (cached) {
applyWorkerResult(cached)
return
}
loading.value = true
iphasic.value = props.wp.iphasic || 1
const currentRequestId = ++waveRequestId
pendingCacheKeys.set(currentRequestId, cacheKey)
rmsWorker?.postMessage(
buildWorkerPayload('rms', props.wp, props.boxoList, {
requestId: currentRequestId,
value: props.value,
isOpen: isOpen.value
})
)
} }
const fliteWaveData = (wp: any, step: number): WaveData => { const fliteWaveData = (wp: any, step: number): WaveData => {
@@ -482,7 +491,7 @@ const initWave = (
severity: string | null, severity: string | null,
isOpen: boolean | null isOpen: boolean | null
) => { ) => {
$('div.bx').remove() resetWaveDom()
let picHeight = vh.value let picHeight = vh.value
const show = !isOpen const show = !isOpen
@@ -594,19 +603,25 @@ const initWave = (
for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) { for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) {
const rmsId = 'rms' + step const rmsId = 'rms' + step
const newDivRms = $( const newDivRms = $(
`<div style="height:${vh.value};overflow: hidden;min-height: 200px;"><div class='bx' id='${rmsId}'></div></div>` `<div class="${EXTRA_PANEL_CLASS}" style="height:${vh.value};overflow: hidden;min-height: 200px;"><div class='bx' id='${rmsId}'></div></div>`
) )
newDivRms.insertAfter($('#rmsp')) newDivRms.insertAfter($('#rmsp'))
$(`#${rmsId}`).css('height', picHeight).css('width', vw.value).css('min-height', '200px') $(`#${rmsId}`).css('height', picHeight).css('width', vw.value).css('min-height', '200px')
} }
} else { } else {
titleText = `变电站名称:${subName.value} 监测点名称:${lineName.value} 发生时刻:${time} 暂降(骤升)幅值:${( titleText = `变电站名称:${subName.value} 监测点名称:${lineName.value} 发生时刻:${time} 暂降幅值:${(
Number(eventValue.value) * 1 Number(eventValue.value) * 1
).toFixed(0)}% 持续时间:${persistTime.value}s` ).toFixed(0)}% 持续时间:${persistTime.value}s`
} }
const rms = document.getElementById('rmsp') const rms = document.getElementById('rmsp')
if (!rms) return if (!rms) return
const yRange = calcRmsYAxisRange(rmscu[0]?.[1] ?? 0, rmscm[0]?.[1] ?? 0)
const existingChart = echarts.getInstanceByDom(rms)
if (existingChart) existingChart.dispose()
const myChartes = echarts.init(rms) const myChartes = echarts.init(rms)
const echartsColor = { const echartsColor = {
WordColor: '#000', WordColor: '#000',
@@ -669,7 +684,7 @@ const initWave = (
align: 'left' align: 'left'
}, },
textStyle: { textStyle: {
fontSize: '16px', fontSize: '14px',
color: props.DColor ? '#000' : echartsColor.WordColor color: props.DColor ? '#000' : echartsColor.WordColor
} }
}, },
@@ -748,8 +763,10 @@ const initWave = (
rotation: 0, rotation: 0,
y: -10 y: -10
}, },
max: rmscm[0]?.[1] * 1.06 || 0, // max: rmscm[0]?.[1] * 1.06 || 0,
min: rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0, // min: rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0,
max: yRange.max,
min: yRange.min,
boundaryGap: [0, '100%'], boundaryGap: [0, '100%'],
showLastLabel: true, showLastLabel: true,
opposite: false, opposite: false,
@@ -768,7 +785,7 @@ const initWave = (
fontSize: '12px', fontSize: '12px',
color: props.DColor ? '#000' : echartsColor.WordColor, color: props.DColor ? '#000' : echartsColor.WordColor,
formatter: function (value: number) { formatter: function (value: number) {
return Math.floor(value * 1000) / 1000 return formatAxisLabel(value)
} }
}, },
splitLine: { splitLine: {
@@ -780,11 +797,11 @@ const initWave = (
} }
}, },
grid: { grid: {
left: '1%', left: '60px',
right: '45px', right: '45px',
bottom: '40px', bottom: '40px',
top: '60px', top: '60px'
containLabel: true // containLabel: true
}, },
dataZoom: [ dataZoom: [
{ {
@@ -792,13 +809,15 @@ const initWave = (
height: 13, height: 13,
start: 0, start: 0,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
}, },
{ {
start: 0, start: 0,
height: 13, height: 13,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
} }
], ],
series: [ series: [
@@ -837,7 +856,7 @@ const initWave = (
data: rmscu data: rmscu
}, },
{ {
name: '最小暂降(骤升)幅值', name: '最小暂降幅值',
type: 'scatter', type: 'scatter',
symbol: 'image://' + url2, symbol: 'image://' + url2,
itemStyle: { width: 45, height: 45 }, itemStyle: { width: 45, height: 45 },
@@ -953,6 +972,10 @@ const drawPics = (
const rmsIds = document.getElementById(rmsId) const rmsIds = document.getElementById(rmsId)
if (!rmsIds) return if (!rmsIds) return
const subMin = props.value === 1 ? waveDataTemp.RMSF.min : waveDataTemp.RMSS.min
const subMax = props.value === 1 ? waveDataTemp.RMSF.max : waveDataTemp.RMSS.max
const yRange = calcRmsYAxisRange(subMin, subMax)
const myChartes = echarts.init(rmsIds) const myChartes = echarts.init(rmsIds)
const echartsColor = { const echartsColor = {
WordColor: '#000', WordColor: '#000',
@@ -1006,7 +1029,7 @@ const drawPics = (
left: 'center', left: 'center',
text: '', //titlename || title, text: '', //titlename || title,
textStyle: { textStyle: {
fontSize: '16px', fontSize: '15px',
color: props.DColor ? '#000' : echartsColor.WordColor color: props.DColor ? '#000' : echartsColor.WordColor
} }
}, },
@@ -1076,7 +1099,11 @@ const drawPics = (
}, },
boundaryGap: [0, '100%'], boundaryGap: [0, '100%'],
showLastLabel: true, showLastLabel: true,
max: yRange.max,
min: yRange.min,
opposite: false, opposite: false,
// max: Math.floor((rmscm[0]?.[1] * 1.06 || 0) * 1.1 * 10) / 10,
// min: Math.floor((rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0) * 10) / 10,
nameTextStyle: { nameTextStyle: {
fontSize: '12px', fontSize: '12px',
color: props.DColor ? '#000' : echartsColor.WordColor color: props.DColor ? '#000' : echartsColor.WordColor
@@ -1092,8 +1119,7 @@ const drawPics = (
fontSize: '12px', fontSize: '12px',
color: props.DColor ? '#000' : echartsColor.WordColor, color: props.DColor ? '#000' : echartsColor.WordColor,
formatter: function (value: number) { formatter: function (value: number) {
// return (value - 0).toFixed(2) return formatAxisLabel(value)
return Math.floor(value * 1000) / 1000
} }
}, },
splitLine: { splitLine: {
@@ -1105,11 +1131,11 @@ const drawPics = (
} }
}, },
grid: { grid: {
left: '1%', left: '60px',
right: '45px', right: '45px',
bottom: '40px', bottom: '40px',
top: '60px', top: '60px'
containLabel: true // containLabel: true
}, },
dataZoom: [ dataZoom: [
{ {
@@ -1209,12 +1235,7 @@ const backbxlb = () => {
myChartess4.value = null myChartess4.value = null
myChartess5.value = null myChartess5.value = null
// echarts.disconnect(charts.filter(Boolean) as echarts.ECharts[]) $('#rmsp').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
charts.filter(Boolean).forEach(chart => {
if (chart && typeof chart.dispose === 'function') {
chart.dispose()
}
})
} }
const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => { const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => {

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
// waveData.worker.js // waveData.worker.js
self.addEventListener('message', function (e) { self.addEventListener('message', function (e) {
const { wp, value, iphasic, isOpen, boxoList } = JSON.parse(e.data) const { wp, value, iphasic, isOpen, boxoList, requestId } = e.data
// 处理波形数据的函数 // 处理波形数据的函数
const fliteWaveData = (wp, step) => { const fliteWaveData = (wp, step) => {
@@ -131,8 +131,8 @@ self.addEventListener('message', function (e) {
boxoList.measurementPointName + boxoList.measurementPointName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'% 持续时间:' + '% 持续时间:' +
boxoList.duration + boxoList.duration +
's' 's'
@@ -143,20 +143,21 @@ self.addEventListener('message', function (e) {
boxoList.equipmentName + boxoList.equipmentName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
boxoList.evtParamVVaDepth + boxoList.evtParamVVaDepth +
'% 持续时间:' + '% 持续时间:' +
boxoList.evtParamTm + boxoList.evtParamTm +
's' 's'
} else if (boxoList.systemType == 'YPT') { } else if (boxoList.systemType == 'YPT') {
console.log("🚀 ~ boxoList.featureAmplitude:", boxoList.featureAmplitude)
titles = titles =
(boxoList.engineeringName == undefined ? '' : ' 项目名称:' + boxoList.engineeringName) + (boxoList.engineeringName == undefined ? '' : ' 项目名称:' + boxoList.engineeringName) +
' 监测点名称:' + ' 监测点名称:' +
boxoList.lineName + boxoList.lineName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'% 持续时间:' + '% 持续时间:' +
boxoList.persistTime + boxoList.persistTime +
's' 's'
@@ -168,8 +169,8 @@ self.addEventListener('message', function (e) {
boxoList.lineName + boxoList.lineName +
' 发生时刻:' + ' 发生时刻:' +
boxoList.startTime + boxoList.startTime +
' 暂降(骤升)幅值:' + ' 暂降幅值:' +
(boxoList.featureAmplitude * 100).toFixed(2) + Math.floor(boxoList.featureAmplitude * 10000) / 100 +
'% 持续时间:' + '% 持续时间:' +
boxoList.duration + boxoList.duration +
's' 's'
@@ -195,6 +196,8 @@ self.addEventListener('message', function (e) {
// 将处理结果发送回主线程 // 将处理结果发送回主线程
self.postMessage({ self.postMessage({
requestId,
success: true,
waveDatas, waveDatas,
time, time,
type, type,

View File

@@ -1,8 +1,8 @@
<template> <template>
<div v-loading="loading" class="boxbx" style="position: relative; height: 100%"> <div v-loading="loading" class="boxbx" style="position: relative; height: 100%">
<div id="boxsj"> <div id="boxsj">
<div id="shushi" :style="`height:${vh};overflow: hidden;min-height: 200px;`"> <div id="shushi" :style="containerStyle">
<div class="bx" id="wave" style="min-height: 200px"></div> <div class="bx" id="wave" :style="waveStyle"></div>
</div> </div>
</div> </div>
</div> </div>
@@ -14,9 +14,14 @@ import html2canvas from 'html2canvas'
import $ from 'jquery' import $ from 'jquery'
import * as echarts from 'echarts' import * as echarts from 'echarts'
import { mainHeight } from '@/utils/layout' import { mainHeight } from '@/utils/layout'
import { calcShuYAxisRange, formatAxisLabel } from '@/utils/chartAxisHelper'
import url from '@/assets/img/point.png' import url from '@/assets/img/point.png'
// 创建Worker import { buildWaveCacheKey, getWaveCache, setWaveCache } from '@/utils/waveCache'
let waveDataWorker: Worker | null = null import { getShuWorker, buildWorkerPayload } from '@/utils/waveWorkerPool'
let waveRequestId = 0
const pendingCacheKeys = new Map<number, string>()
let shuWorker: Worker | null = null
interface WaveData { interface WaveData {
instantF: { max: number; min: number } instantF: { max: number; min: number }
instantS: { max: number; min: number } instantS: { max: number; min: number }
@@ -110,38 +115,82 @@ const vh = computed(() => {
const vw = computed(() => '100%') const vw = computed(() => '100%')
const containerStyle = computed(() => ({
height: vh.value,
overflow: 'hidden',
minHeight: '200px'
}))
const waveStyle = computed(() => ({
width: '100%',
height: '100%',
minHeight: '200px'
}))
const applyChartSize = (el: HTMLElement) => {
el.style.width = '100%'
el.style.height = vh.value
}
const finishChartRender = (chart: echarts.ECharts, endLoading = false) => {
nextTick(() => {
chart.resize()
if (endLoading) {
loading.value = false
}
})
}
watch( watch(
() => props.value, () => props.value,
newVal => { () => {
if (newVal == 2) { query()
initWaves()
} else {
$('#wave1').remove()
initWaves()
}
} }
) )
watch(
() => props.wp,
() => {
query()
}
)
const applyWorkerResult = (data: any) => {
titles.value = data.titles
iphasic.value = data.iphasic
time.value = data.time
type.value = data.type
severity.value = data.severity
initWave(data.waveDatas, data.time, data.type, data.severity, isOpen.value)
loading.value = false
}
onMounted(() => { onMounted(() => {
const zoomValue = document.body.style.getPropertyValue('zoom') const zoomValue = document.body.style.getPropertyValue('zoom')
zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1) zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1)
window.addEventListener('resize', handleResize) window.addEventListener('resize', handleResize)
shuWorker = getShuWorker(data => {
if (data.requestId !== waveRequestId) return
if (!data.success) {
console.error('Worker error:', data.error)
loading.value = false
return
}
const cacheKey = pendingCacheKeys.get(data.requestId)
if (cacheKey) {
setWaveCache(cacheKey, data)
pendingCacheKeys.delete(data.requestId)
}
applyWorkerResult(data)
})
nextTick(() => { nextTick(() => {
setTimeout(() => { query()
query()
}, 500)
}) })
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
console.log('组件卸载')
if (waveDataWorker) {
waveDataWorker.terminate()
waveDataWorker = null
}
backbxlb() backbxlb()
window.removeEventListener('resize', handleResize) window.removeEventListener('resize', handleResize)
}) })
@@ -166,6 +215,13 @@ const download = () => {
} }
} }
const EXTRA_PANEL_CLASS = 'wave-extra-panel'
const resetWaveDom = () => {
backbxlb()
$('#shushi').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
}
const query = () => { const query = () => {
loading.value = true loading.value = true
initWaves() initWaves()
@@ -184,48 +240,32 @@ const waveData = (instantF: any, instantS: any, shunshiF: any, shunshiS: any, ti
// 在组件中修改initWaves函数 // 在组件中修改initWaves函数
const initWaves = () => { const initWaves = () => {
if (props.wp) { if (!props.wp?.listWaveData?.length) {
loading.value = true
iphasic.value = props.wp.iphasic || 1
// 使用Web Worker处理数据
if (!waveDataWorker) {
waveDataWorker = new Worker(new URL('./shuWorker.js', import.meta.url))
waveDataWorker.onmessage = function (e) {
const data = e.data
titles.value = data.titles
iphasic.value = data.iphasic
time.value = data.time
type.value = data.type
severity.value = data.severity
initWave(data.waveDatas, data.time, data.type, data.severity, isOpen.value)
loading.value = false
}
waveDataWorker.onerror = function (error) {
console.error('Worker error:', error)
loading.value = false
// 备用方案:在主线程处理数据
// processDataInMainThread();
}
}
// 发送数据到Worker
waveDataWorker.postMessage(
JSON.stringify({
wp: props.wp,
value: props.value,
iphasic: iphasic.value,
isOpen: isOpen.value,
boxoList: props.boxoList
})
)
} else {
initWave(null, null, null, null, null) initWave(null, null, null, null, null)
loading.value = false
return
} }
const cacheKey = buildWaveCacheKey('shu', props.wp, props.value, isOpen.value, props.boxoList)
const cached = getWaveCache<any>(cacheKey)
if (cached) {
applyWorkerResult(cached)
return
}
loading.value = true
iphasic.value = props.wp.iphasic || 1
const currentRequestId = ++waveRequestId
pendingCacheKeys.set(currentRequestId, cacheKey)
shuWorker?.postMessage(
buildWorkerPayload('shu', props.wp, props.boxoList, {
requestId: currentRequestId,
value: props.value,
isOpen: isOpen.value,
iphasic: iphasic.value
})
)
} }
const initWave = ( const initWave = (
@@ -235,6 +275,7 @@ const initWave = (
severity: string | null, severity: string | null,
isOpen: boolean | null isOpen: boolean | null
) => { ) => {
resetWaveDom()
$('div.bx1').remove() $('div.bx1').remove()
let picHeight = vh.value let picHeight = vh.value
@@ -327,14 +368,14 @@ const initWave = (
for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) { for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) {
const waveId = 'wave' + step const waveId = 'wave' + step
const newDivShunshi = $(`<div style="height:${vh.value};overflow: hidden;min-height: 200px;"> const newDivShunshi = $(`<div class="${EXTRA_PANEL_CLASS}" style="height:${vh.value};overflow: hidden;min-height: 200px;">
<div class='bx1' id='${waveId}'></div> <div class='bx1' id='${waveId}'></div>
</div>`) </div>`)
newDivShunshi.insertAfter($('#shushi')) newDivShunshi.insertAfter($('#shushi'))
$(`#${waveId}`).css('height', picHeight).css('width', vw.value).css('min-height', '200px') $(`#${waveId}`).css('height', picHeight).css('width', vw.value).css('min-height', '200px')
} }
} else { } else {
titleText = `变电站名称:${subName.value} 监测点名称:${lineName.value} 发生时刻:${time} 暂降(骤升)幅值:${( titleText = `变电站名称:${subName.value} 监测点名称:${lineName.value} 发生时刻:${time} 暂降幅值:${(
Number(eventValue.value) * 1 Number(eventValue.value) * 1
).toFixed(0)}% 持续时间:${persistTime.value}s` ).toFixed(0)}% 持续时间:${persistTime.value}s`
} }
@@ -342,6 +383,13 @@ const initWave = (
const wave = document.getElementById('wave') const wave = document.getElementById('wave')
if (!wave) return if (!wave) return
applyChartSize(wave)
const yRange = calcShuYAxisRange(Number(min), Number(max))
const existingChart = echarts.getInstanceByDom(wave)
if (existingChart) existingChart.dispose()
const myChartes = echarts.init(wave) const myChartes = echarts.init(wave)
const echartsColor = { const echartsColor = {
WordColor: '#000', WordColor: '#000',
@@ -363,11 +411,6 @@ const initWave = (
] ]
} }
setTimeout(() => {
wave.style.width = '100%'
wave.style.height = vh.value
}, 0)
const option = { const option = {
tooltip: { tooltip: {
top: '10px', top: '10px',
@@ -405,7 +448,7 @@ const initWave = (
left: 'center', left: 'center',
text: titleText, text: titleText,
textStyle: { textStyle: {
fontSize: '16px', fontSize: '14px',
color: props.DColor ? '#000' : echartsColor.WordColor color: props.DColor ? '#000' : echartsColor.WordColor
} }
}, },
@@ -481,8 +524,8 @@ const initWave = (
}, },
boundaryGap: [0, '100%'], boundaryGap: [0, '100%'],
showLastLabel: true, showLastLabel: true,
max: max.toFixed(2) * 1.1, max: yRange.max,
min: min.toFixed(2) > 0 ? min.toFixed(2) - min.toFixed(2) * 0.1 : min.toFixed(2) * 1.1, min: yRange.min,
opposite: false, opposite: false,
nameTextStyle: { nameTextStyle: {
fontSize: '12px', fontSize: '12px',
@@ -499,8 +542,7 @@ const initWave = (
fontSize: '12px', fontSize: '12px',
color: props.DColor ? '#000' : echartsColor.WordColor, color: props.DColor ? '#000' : echartsColor.WordColor,
formatter: function (value: number) { formatter: function (value: number) {
// return (value - 0).toFixed(2) return formatAxisLabel(value)
return Math.floor(value * 1000) / 1000
} }
}, },
splitLine: { splitLine: {
@@ -512,11 +554,10 @@ const initWave = (
} }
}, },
grid: { grid: {
left: '1%', left: '60px',
right: '45px', right: '45px',
bottom: '40px', bottom: '40px',
top: '60px', top: '60px'
containLabel: true
}, },
dataZoom: [ dataZoom: [
{ {
@@ -524,13 +565,15 @@ const initWave = (
height: 13, height: 13,
start: 0, start: 0,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
}, },
{ {
start: 0, start: 0,
height: 13, height: 13,
bottom: '20px', bottom: '20px',
end: 100 end: 100,
filterMode: 'filter'
} }
], ],
series: [ series: [
@@ -576,11 +619,7 @@ const initWave = (
myChartes.setOption(option) myChartes.setOption(option)
myChartess.value = myChartes myChartess.value = myChartes
finishChartRender(myChartes, true)
setTimeout(() => {
myChartes.resize()
loading.value = false
}, 400)
if (waveDatas && waveDatas.length > 1) { if (waveDatas && waveDatas.length > 1) {
const waveDatasTemp = waveDatas.slice(1) const waveDatasTemp = waveDatas.slice(1)
@@ -677,6 +716,13 @@ const drawPics = (
const waveIds = document.getElementById(waveId) const waveIds = document.getElementById(waveId)
if (!waveIds) return if (!waveIds) return
applyChartSize(waveIds)
const yRange = calcShuYAxisRange(Number(min), Number(max))
const existingChart = echarts.getInstanceByDom(waveIds)
if (existingChart) existingChart.dispose()
const myChartes = echarts.init(waveIds) const myChartes = echarts.init(waveIds)
const echartsColor = { const echartsColor = {
WordColor: '#000', WordColor: '#000',
@@ -789,8 +835,8 @@ const drawPics = (
}, },
boundaryGap: [0, '100%'], boundaryGap: [0, '100%'],
showLastLabel: true, showLastLabel: true,
max: max.toFixed(2) * 1.1, max: yRange.max,
min: min.toFixed(2) > 0 ? min.toFixed(2) - min.toFixed(2) * 0.1 : min.toFixed(2) * 1.1, min: yRange.min,
opposite: false, opposite: false,
nameTextStyle: { nameTextStyle: {
fontSize: '12px', fontSize: '12px',
@@ -807,8 +853,7 @@ const drawPics = (
fontSize: '12px', fontSize: '12px',
color: props.DColor ? '#000' : echartsColor.WordColor, color: props.DColor ? '#000' : echartsColor.WordColor,
formatter: function (value: number) { formatter: function (value: number) {
// return (value - 0).toFixed(2) return formatAxisLabel(value)
return Math.floor(value * 1000) / 1000
} }
}, },
splitLine: { splitLine: {
@@ -820,11 +865,11 @@ const drawPics = (
} }
}, },
grid: { grid: {
left: '1%', left: '60px',
right: '45px', right: '45px',
bottom: '40px', bottom: '40px',
top: '60px', top: '60px'
containLabel: true // containLabel: true
}, },
dataZoom: [ dataZoom: [
{ {
@@ -895,10 +940,7 @@ const drawPics = (
break break
} }
setTimeout(() => { finishChartRender(myChartes)
myChartes.resize()
loading.value = false
}, 400)
echarts.connect([myChartes1, myChartes]) echarts.connect([myChartes1, myChartes])
} }
@@ -927,12 +969,8 @@ const backbxlb = () => {
myChartess4.value = null myChartess4.value = null
myChartess5.value = null myChartess5.value = null
// echarts.disconnect(charts.filter(Boolean) as echarts.ECharts[]) $('#shushi').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
charts.filter(Boolean).forEach(chart => { $('div.bx1').remove()
if (chart && typeof chart.dispose === 'function') {
chart.dispose()
}
})
} }
const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => { const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => {

File diff suppressed because it is too large Load Diff

View File

@@ -1,25 +1,12 @@
<template> <template>
<div style="width: 540px"> <div style="width: 540px">
<el-select <el-select v-model.trim="interval" style="min-width: 90px; width: 90px; margin-right: 10px"
v-model.trim="interval" @change="timeChange">
style="min-width: 90px; width: 90px; margin-right: 10px"
@change="timeChange"
>
<el-option v-for="item in filteredTimeOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in filteredTimeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
<el-date-picker <el-date-picker v-model.trim="timeValue" type="daterange" :disabled="disabledPicker"
v-model.trim="timeValue" style="width: 220px; margin-right: 10px" unlink-panels :clearable="false" range-separator=""
type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD" :shortcuts="shortcuts" />
:disabled="disabledPicker"
style="width: 220px; margin-right: 10px"
unlink-panels
:clearable="false"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="YYYY-MM-DD"
:shortcuts="shortcuts"
/>
<el-button :disabled="backDisabled" type="primary" :icon="DArrowLeft" @click="preClick"></el-button> <el-button :disabled="backDisabled" type="primary" :icon="DArrowLeft" @click="preClick"></el-button>
<el-button type="primary" :icon="VideoPause" @click="nowTime">当前</el-button> <el-button type="primary" :icon="VideoPause" @click="nowTime">当前</el-button>
@@ -95,6 +82,12 @@ const shortcuts = [
// 计算过滤后的 timeOptions // 计算过滤后的 timeOptions
const filteredTimeOptions = computed(() => { const filteredTimeOptions = computed(() => {
// console.log("🚀 ~ props.timeKeyList:", props.timeKeyList)
if (props.timeKeyList.length > 0 && !props.timeKeyList.includes(interval.value.toString())) {
interval.value = Number(props.timeKeyList[0])
}
if (!props.timeKeyList || props.timeKeyList.length === 0) { if (!props.timeKeyList || props.timeKeyList.length === 0) {
return timeOptions.value return timeOptions.value
} }
@@ -181,10 +174,10 @@ const timeChange = (e: number) => {
timeFlag.value = 1 timeFlag.value = 1
} }
nextTick(() => { nextTick(() => {
// 检查按钮状态 // 检查按钮状态
checkInitialButtonStatus() checkInitialButtonStatus()
}) })
// 触发 change 事件 // 触发 change 事件
emitChange() emitChange()

View File

@@ -1,35 +1,36 @@
<template> <template>
<div class="mac-address-input" :class="{ disabled: disabled }"> <div class="mac-address-input" :class="{ disabled: disabled }">
<el-input <el-input show-word-limit
ref="inputRef" ref="inputRef"
v-model="macValue" placeholder="请输入设备mac地址"
type="text" v-model="macValue"
maxlength="17" type="text"
:disabled="disabled" maxlength="17"
@input="handleInput" :disabled="disabled"
@keydown="handleKeydown" @input="handleInput"
@focus="handleFocus" @keydown="handleKeydown"
@blur="handleBlur" @focus="handleFocus"
@paste="handlePaste" @blur="handleBlur"
/> @paste="handlePaste"
</div> />
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
interface Props { interface Props {
modelValue?: string modelValue?: string
disabled?: boolean disabled?: boolean
} }
interface Emits { interface Emits {
(e: 'update:modelValue', value: string): void (e: 'update:modelValue', value: string): void
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
modelValue: '', modelValue: '',
disabled: false disabled: false
}) })
const emit = defineEmits<Emits>() const emit = defineEmits<Emits>()
@@ -42,35 +43,35 @@ const macValue = ref<string>('')
// 解析传入的MAC地址 // 解析传入的MAC地址
const parseMacAddress = (mac: string): string => { const parseMacAddress = (mac: string): string => {
if (!mac) return '' if (!mac) return ''
// 移除非十六进制字符并转为大写 // 移除非十六进制字符并转为大写
const cleanMac = mac.replace(/[^0-9a-fA-F]/g, '').toUpperCase() const cleanMac = mac.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
// 按每2个字符分割并用冒号连接 // 按每2个字符分割并用冒号连接
let result = '' let result = ''
for (let i = 0; i < cleanMac.length; i += 2) { for (let i = 0; i < cleanMac.length; i += 2) {
if (i > 0) result += ':' if (i > 0) result += ':'
result += cleanMac.substr(i, 2) result += cleanMac.substr(i, 2)
} }
return result.substring(0, 17) // 最多17个字符 (12个数字+5个冒号) return result.substring(0, 17) // 最多17个字符 (12个数字+5个冒号)
} }
// 格式化MAC地址 - 改进版 // 格式化MAC地址 - 改进版
const formatMac = (value: string): string => { const formatMac = (value: string): string => {
// 移除所有冒号 // 移除所有冒号
const cleanValue = value.replace(/:/g, '') const cleanValue = value.replace(/:/g, '')
// 只保留十六进制字符并转为大写 // 只保留十六进制字符并转为大写
const hexOnly = cleanValue.replace(/[^0-9a-fA-F]/g, '').toUpperCase() const hexOnly = cleanValue.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
// 按每两个字符添加冒号最多6段 // 按每两个字符添加冒号最多6段
let formatted = '' let formatted = ''
for (let i = 0; i < Math.min(hexOnly.length, 12); i += 2) { for (let i = 0; i < Math.min(hexOnly.length, 12); i += 2) {
if (i > 0) formatted += ':' if (i > 0) formatted += ':'
formatted += hexOnly.substr(i, 2) formatted += hexOnly.substr(i, 2)
} }
return formatted return formatted
} }
// 当前聚焦的输入框索引 // 当前聚焦的输入框索引
@@ -78,88 +79,86 @@ const focusedIndex = ref<number | null>(null)
// 处理输入事件 // 处理输入事件
const handleInput = (value: string) => { const handleInput = (value: string) => {
const formatted = formatMac(value) const formatted = formatMac(value)
macValue.value = formatted macValue.value = formatted
// 发出不带冒号的纯净值 // 发出不带冒号的纯净值
emit('update:modelValue', formatted.replace(/:/g, '')) emit('update:modelValue', formatted.replace(/:/g, ''))
} }
// 处理键盘事件 // 处理键盘事件
const handleKeydown = (event: KeyboardEvent) => { const handleKeydown = (event: KeyboardEvent) => {
const target = event.target as HTMLInputElement const target = event.target as HTMLInputElement
// 处理退格键 // 处理退格键
if (event.key === 'Backspace') { if (event.key === 'Backspace') {
// 处理在冒号前删除的情况 // 处理在冒号前删除的情况
const cursorPos = target.selectionStart || 0 const cursorPos = target.selectionStart || 0
if (cursorPos > 0 && macValue.value[cursorPos - 1] === ':' && if (cursorPos > 0 && macValue.value[cursorPos - 1] === ':' && target.selectionStart === target.selectionEnd) {
target.selectionStart === target.selectionEnd) { event.preventDefault()
event.preventDefault() // 删除冒号前的两个字符
// 删除冒号前的两个字符 const newValue = macValue.value.substring(0, cursorPos - 3) + macValue.value.substring(cursorPos)
const newValue = macValue.value.substring(0, cursorPos - 3) + macValue.value = newValue
macValue.value.substring(cursorPos) // 设置光标位置
macValue.value = newValue setTimeout(() => {
// 设置光标位置 if (target.setSelectionRange) {
setTimeout(() => { target.setSelectionRange(cursorPos - 3, cursorPos - 3)
if (target.setSelectionRange) { }
target.setSelectionRange(cursorPos - 3, cursorPos - 3) }, 0)
emit('update:modelValue', newValue.replace(/:/g, ''))
} }
}, 0)
emit('update:modelValue', newValue.replace(/:/g, ''))
} }
}
} }
// 处理焦点事件 // 处理焦点事件
const handleFocus = () => { const handleFocus = () => {
focusedIndex.value = 0 focusedIndex.value = 0
} }
// 处理失焦事件 // 处理失焦事件
const handleBlur = () => { const handleBlur = () => {
focusedIndex.value = null focusedIndex.value = null
} }
// 处理粘贴事件 // 处理粘贴事件
const handlePaste = (event: ClipboardEvent) => { const handlePaste = (event: ClipboardEvent) => {
event.preventDefault() event.preventDefault()
const pastedText = event.clipboardData?.getData('text') || '' const pastedText = event.clipboardData?.getData('text') || ''
// 清理粘贴的文本 // 清理粘贴的文本
const cleanPastedText = pastedText.replace(/[^0-9a-fA-F]/g, '').toUpperCase() const cleanPastedText = pastedText.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
const formatted = formatMac(cleanPastedText) const formatted = formatMac(cleanPastedText)
macValue.value = formatted macValue.value = formatted
emit('update:modelValue', formatted.replace(/:/g, '')) emit('update:modelValue', formatted.replace(/:/g, ''))
} }
// 监听modelValue变化 // 监听modelValue变化
watch( watch(
() => props.modelValue, () => props.modelValue,
(newVal) => { newVal => {
const cleanNewVal = (newVal || '').replace(/[^0-9a-fA-F]/g, '').toUpperCase() const cleanNewVal = (newVal || '').replace(/[^0-9a-fA-F]/g, '').toUpperCase()
const currentCleanValue = macValue.value.replace(/:/g, '') const currentCleanValue = macValue.value.replace(/:/g, '')
if (cleanNewVal !== currentCleanValue) { if (cleanNewVal !== currentCleanValue) {
macValue.value = parseMacAddress(cleanNewVal) macValue.value = parseMacAddress(cleanNewVal)
} }
}, },
{ immediate: true } { immediate: true }
) )
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.mac-address-input { .mac-address-input {
width: 100%; width: 100%;
&.disabled { &.disabled {
opacity: 0.7; opacity: 0.7;
} }
:deep(.el-input__wrapper) { :deep(.el-input__wrapper) {
input { input {
text-transform: uppercase; text-transform: uppercase;
font-family: inherit; // 使用继承的字体而不是等宽字体 font-family: inherit; // 使用继承的字体而不是等宽字体
}
} }
}
} }
</style> </style>

View File

@@ -31,7 +31,7 @@
</el-button> </el-button>
<el-button <el-button
@click="onComSearch" @click="onComSearch"
v-if="showSearch" v-if="showSearch &&showQuery"
:loading="tableStore.table.loading" :loading="tableStore.table.loading"
type="primary" type="primary"
:icon="Search" :icon="Search"
@@ -81,7 +81,7 @@ import { defineProps } from 'vue'
import { useTimeCacheStore } from '@/stores/timeCache' import { useTimeCacheStore } from '@/stores/timeCache'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const emit = defineEmits(['selectChange']) const emit = defineEmits(['selectChange','onResetForm'])
const tableStore = inject('tableStore') as TableStore const tableStore = inject('tableStore') as TableStore
const tableHeader = ref() const tableHeader = ref()
@@ -102,6 +102,7 @@ interface Props {
showSearch?: boolean showSearch?: boolean
nextFlag?: boolean //控制时间是否可以往后推 nextFlag?: boolean //控制时间是否可以往后推
theCurrentTime?: boolean //控制时间前3天展示上个月时间 theCurrentTime?: boolean //控制时间前3天展示上个月时间
showQuery?: boolean //是否显示查詢
showReset?: boolean //是否显示重置 showReset?: boolean //是否显示重置
showExport?: boolean //导出控制 showExport?: boolean //导出控制
timeCacheFlag?: boolean //是否取缓存时间 timeCacheFlag?: boolean //是否取缓存时间
@@ -115,6 +116,7 @@ const props = withDefaults(defineProps<Props>(), {
nextFlag: false, nextFlag: false,
theCurrentTime: true, theCurrentTime: true,
showReset: true, showReset: true,
showQuery: true,
showExport: false, showExport: false,
timeCacheFlag: true, timeCacheFlag: true,
timeKeyList: () => ['1', '2', '3', '4', '5'] // 修改为箭头函数返回空数组 timeKeyList: () => ['1', '2', '3', '4', '5'] // 修改为箭头函数返回空数组
@@ -244,6 +246,7 @@ const setDatePicker = (list: any) => {
const onResetForm = () => { const onResetForm = () => {
//时间重置成默认值 //时间重置成默认值
datePickerRef.value?.setInterval(3) datePickerRef.value?.setInterval(3)
emit('onResetForm')
tableStore.onTableAction('reset', {}) tableStore.onTableAction('reset', {})
} }
const setInterval = (val: any) => { const setInterval = (val: any) => {

View File

@@ -10,10 +10,11 @@
@checkbox-all="selectChangeEvent" @checkbox-all="selectChangeEvent"
@checkbox-change="selectChangeEvent" @checkbox-change="selectChangeEvent"
:showOverflow="showOverflow" :showOverflow="showOverflow"
:sort-config="{ remote: true }"
@sort-change="handleSortChange"
> >
<!-- :sort-config="{ remote: true }" -->
<!-- @sort-change="handleSortChange" -->
<!-- Column 组件内部是 el-table-column --> <!-- Column 组件内部是 el-table-column -->
<template v-if="isGroup"> <template v-if="isGroup">
<GroupColumn :column="tableStore.table.column" /> <GroupColumn :column="tableStore.table.column" />

View File

@@ -1,20 +1,20 @@
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden"> <div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden">
<div class="mt10 mr10" style="display: flex; justify-content: end"> <div class="mt10 mr10" style="display: flex; justify-content: end" v-if="showBut">
<el-button type="primary" icon="el-icon-Select" @click="save" :loading="loading">保存</el-button> <el-button type="primary" icon="el-icon-Select" @click="save" :loading="loading">保存</el-button>
</div> </div>
<Icon <!-- <Icon
v-show="menuCollapse" v-show="menuCollapse"
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18px"
class="fold ml10 mt20 menu-collapse" class="fold ml10 mt20 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
/> /> -->
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }"> <div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
<div style="display: flex; align-items: center" class="mb10"> <div style="display: flex; align-items: center" class="mb10">
<el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable> <el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable>
<template #prefix> <template #prefix>
<Icon name="el-icon-Search" style="font-size: 16px" /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
@@ -23,23 +23,19 @@
<template #content> <template #content>
<span>台账推送</span> <span>台账推送</span>
</template> </template>
<Icon <Icon
name="el-icon-Promotion" name="el-icon-Promotion"
size="20" size="20px"
class="fold ml10 menu-collapse" class="fold ml10 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
:style="{ color: config.getColorVal('elementUiPrimary') }" :style="{ color: config.getColorVal('elementUiPrimary') }"
@click="onAdd" @click="onAdd"
/> />
</el-tooltip> </el-tooltip>
<!-- <Icon @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" v-else
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
style='cursor: pointer' v-if='props.canExpand' /> -->
</div> </div>
<el-tree <el-tree
:style="{ height: 'calc(100vh - 267px)' }" :style="{ height: `calc(100vh - ${height}px)` }"
style="overflow: auto" style="overflow: auto"
ref="treeRef" ref="treeRef"
:props="defaultProps" :props="defaultProps"
@@ -50,13 +46,13 @@
node-key="id" node-key="id"
v-bind="$attrs" v-bind="$attrs"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
@@ -69,89 +65,55 @@
<script lang="ts" setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree } from 'element-plus'
import { emit } from 'process'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { t } from 'vxe-table'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { createTreeFilterNode } from './govern/treeFilterUtils'
defineOptions({ defineOptions({ name: 'govern/allocation', inheritAttrs: false })
name: 'govern/tree'
})
interface Props { interface Props {
width?: string width?: string
canExpand?: boolean canExpand?: boolean
showPush?: boolean showPush?: boolean
showBut?: boolean
height?: number
} }
const loading = ref(false)
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
width: '280px', width: '280px',
canExpand: true, canExpand: true,
showPush: false showPush: false,
showBut: true,
height: 267
}) })
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'checkChange'])
const config = useConfig() const config = useConfig()
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const filterText = ref('') const filterText = ref('')
const defaultProps = { const loading = ref(false)
label: 'name', const defaultProps = { label: 'name', value: 'id' }
value: 'id' const filterNode = createTreeFilterNode()
}
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'checkChange']) watch(filterText, val => treeRef.value?.filter(val))
watch(filterText, val => {
treeRef.value!.filter(val)
})
const onMenuCollapse = () => { const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse) proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
} }
const save = () => { const save = () => {
loading.value = true loading.value = true
emit('checkChange') emit('checkChange')
} }
const filterNode = (value: string, data: any, node: any) => {
console.log(value, data, node, 'filterNode')
if (!value) return true
// return data.name.includes(value)
if (data.name) {
return chooseNode(value, data, node)
}
}
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符.
const chooseNode = (value: string, data: any, node: any) => {
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
}
const checkTreeNodeChange = () => { const checkTreeNodeChange = () => {
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes()) emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
} }
const onAdd = () => { const onAdd = () => emit('onAdd')
emit('onAdd')
}
const treeRef = ref<InstanceType<typeof ElTree>>() const treeRef = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef, loading }) defineExpose({ treeRef, loading })
@@ -183,7 +145,5 @@ defineExpose({ treeRef, loading })
.custom-tree-node { .custom-tree-node {
display: flex; display: flex;
align-items: center; align-items: center;
} }
</style> </style>

View File

@@ -1,27 +1,43 @@
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style='transition: all 0.3s; overflow: hidden;'> <div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden">
<Icon v-show='menuCollapse' @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" <!-- <Icon
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 mt20 menu-collapse' v-show="menuCollapse"
style='cursor: pointer' /> @click="onMenuCollapse"
<div class='cn-tree' :style='{ opacity: menuCollapse ? 0 : 1 }'> :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
<div style='display: flex; align-items: center' class='mb10'> :class="menuCollapse ? 'unfold' : ''"
<el-input maxlength="32" show-word-limit v-model.trim='filterText' placeholder='请输入内容' clearable> size="18px"
class="fold ml10 mt20 menu-collapse"
style="cursor: pointer"
/> -->
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
<div style="display: flex; align-items: center" class="mb10">
<el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable>
<template #prefix> <template #prefix>
<Icon name='el-icon-Search' style='font-size: 16px' /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
</el-input> </el-input>
<!-- <Icon @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
style='cursor: pointer' v-if='props.canExpand' /> -->
</div> </div>
<el-tree :style="{ height: 'calc(100vh - 230px)' }" <el-tree
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current :default-expand-all="false" :style="{ height: 'calc(100vh - 230px)' }"
@check-change="checkTreeNodeChange" :filter-node-method='filterNode' node-key='id' v-bind='$attrs'> style="overflow: auto"
<template #default='{ node, data }'> ref="treeRef"
<span class='custom-tree-node'> :props="defaultProps"
<Icon :name='data.icon' style='font-size: 16px' :style='{ color: data.color }' highlight-current
v-if='data.icon' /> :default-expand-all="false"
<span style='margin-left: 4px'>{{ node.label }}</span> @check-change="checkTreeNodeChange"
:filter-node-method="filterNode"
node-key="id"
v-bind="$attrs"
>
<template #default="{ node, data: nodeData }">
<span class="custom-tree-node">
<Icon
:name="nodeData.icon"
style="font-size: 16px"
:style="{ color: nodeData.color }"
v-if="nodeData.icon"
/>
<span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
@@ -29,14 +45,13 @@
</div> </div>
</template> </template>
<script lang='ts' setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree } from 'element-plus'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { createTreeFilterNode } from './govern/treeFilterUtils'
defineOptions({ defineOptions({ name: 'govern/cloudDevice', inheritAttrs: false })
name: 'govern/tree'
})
interface Props { interface Props {
width?: string width?: string
@@ -47,66 +62,31 @@ const props = withDefaults(defineProps<Props>(), {
width: '280px', width: '280px',
canExpand: true canExpand: true
}) })
const emit = defineEmits(['checkTreeNodeChange'])
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const filterText = ref('') const filterText = ref('')
const defaultProps = { const defaultProps = { label: 'name', value: 'id' }
label: 'name', const filterNode = createTreeFilterNode()
value: 'id'
} watch(filterText, val => treeRef.value?.filter(val))
const emit = defineEmits(['checkTreeNodeChange'])
watch(filterText, val => {
treeRef.value!.filter(val)
})
const onMenuCollapse = () => { const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse) proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
} }
const filterNode = (value: string, data: any, node: any) => {
if (!value) return true
// return data.name.includes(value)
if (data.name) {
return chooseNode(value, data, node)
}
}
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符.
const chooseNode = (value: string, data: any, node: any) => {
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
}
const checkTreeNodeChange = () => { const checkTreeNodeChange = () => {
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes()) emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
} }
const treeRef = ref<InstanceType<typeof ElTree>>() const treeRef = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef }) defineExpose({ treeRef })
</script> </script>
<style lang='scss' scoped> <style lang="scss" scoped>
.cn-tree { .cn-tree {
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;

View File

@@ -1,61 +1,66 @@
<!-- 设备管理使用折叠面板渲染多个tree --> <!-- 设备管理使用折叠面板渲染多个tree -->
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden"> <div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden">
<Icon <!-- <Icon
v-show="menuCollapse" v-show="menuCollapse"
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18px"
class="fold ml10 mt20 menu-collapse" class="fold ml10 mt20 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
/> /> -->
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }"> <div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
<div style="display: flex; align-items: center" class="mb10"> <div style="display: flex; align-items: center" class="mb10">
<!-- <el-form-item> --> <el-input maxlength="32" show-word-limit
<el-input
maxlength="32"
show-word-limit
v-model.trim="filterText" v-model.trim="filterText"
autocomplete="off" autocomplete="off"
placeholder="请输入内容" placeholder="请输入内容"
clearable clearable
> >
<template #prepend>
<el-select v-model="treeType" @change="changeTreeType" style="min-width: 75px">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template #prefix> <template #prefix>
<Icon name="el-icon-Search" style="font-size: 16px" /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
</el-input> </el-input>
<!-- </el-form-item> -->
<Icon <!-- <Icon
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18px"
class="fold ml10 menu-collapse" class="fold ml10 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
v-if="props.canExpand" v-if="props.canExpand"
/> /> -->
</div> </div>
<el-collapse <el-collapse
:accordion="true" :accordion="true"
v-model.trim="activeName" v-model="activeName"
style="flex: 1; height: 100%" style="flex: 1; height: 100%"
@change="changeDevice" @change="changeDevice"
v-if="treeType == '1'"
v-loading="loading"
> >
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length != 0"> <el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length">
<el-select v-model.trim="process" clearable placeholder="请选择状态" class="mb10"> <el-select v-model="process" clearable placeholder="请选择状态" class="mb10">
<el-option label="功能调试" value="2"></el-option> <el-option label="功能调试" value="2" />
<el-option label="出厂调试" value="3"></el-option> <el-option label="出厂调试" value="3" />
<el-option label="正式投运" value="4"></el-option> <el-option label="正式投运" value="4" />
</el-select> </el-select>
<el-tree <el-tree
:style="{ :style="{ height: governTreeHeight }"
height:
bxsDeviceData.length != 0
? `calc(100vh - 380px - ${props.height}px)`
: 'calc(100vh - 278px)'
}"
ref="treeRef1" ref="treeRef1"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -66,27 +71,22 @@
:data="zlDevList" :data="zlDevList"
style="overflow: auto" style="overflow: auto"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0"> <el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length">
<el-tree <el-tree
:style="{ :style="{ height: otherTreeHeight }"
height:
zlDeviceData.length != 0
? `calc(100vh - 340px - ${props.height}px)`
: 'calc(100vh - 238px)'
}"
ref="treeRef2" ref="treeRef2"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -97,27 +97,22 @@
v-bind="$attrs" v-bind="$attrs"
style="overflow: auto" style="overflow: auto"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="监测设备" name="2" v-if="frontDeviceData.length != 0"> <el-collapse-item title="监测设备" name="2" v-if="frontDeviceData.length">
<el-tree <el-tree
:style="{ :style="{ height: otherTreeHeight }"
height:
zlDeviceData.length != 0
? `calc(100vh - 340px - ${props.height}px)`
: 'calc(100vh - 238px)'
}"
ref="treeRef3" ref="treeRef3"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -128,13 +123,13 @@
v-bind="$attrs" v-bind="$attrs"
style="overflow: auto" style="overflow: auto"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
@@ -142,246 +137,249 @@
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
<div v-if="treeType == '2'" v-loading="loading">
<el-tree
:style="{ height: engineeringTreeHeight }"
ref="treeRef4"
:props="defaultProps"
highlight-current
:filter-node-method="filterNode"
node-key="id"
v-bind="$attrs"
:data="props.data"
style="overflow: auto"
:default-expand-all="false"
>
<template #default="{ node, data: nodeData }">
<span class="custom-tree-node">
<Icon
:name="nodeData.icon"
style="font-size: 16px"
:style="{ color: nodeData.color }"
v-if="nodeData.icon"
/>
<span style="margin-left: 4px">{{ node.label }}</span>
</span>
</template>
</el-tree>
</div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree, type CollapseModelValue } from 'element-plus'
import { ref, watch, defineEmits, onMounted, nextTick } from 'vue' import { ref, watch, onMounted, nextTick, computed } from 'vue'
import { collectDeviceLeaves } from './govern/lineTreeUtils'
import { collectDeviceApiLeaves } from './govern/deviceTreeUtils'
defineOptions({ defineOptions({
name: 'govern/tree' name: 'govern/tree',
inheritAttrs: false
}) })
const emit = defineEmits(['changeDeviceType'])
const emit = defineEmits(['changeDeviceType', 'changeTreeType'])
interface Props { interface Props {
width?: string width?: string
canExpand?: boolean canExpand?: boolean
type?: string type?: string
data?: any data?: any[]
height?: number height?: number
engineering?: boolean
/** line: getLineTree 四层叶子device: getDeviceTree 三层叶子 */
leafMode?: 'line' | 'device'
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
width: '280px', width: '280px',
canExpand: true, canExpand: true,
type: '', type: '',
data: [], data: () => [],
height: 0 height: 0,
engineering: false,
leafMode: 'line'
}) })
const treeType = ref('2')
const options = [
{ label: '工程', value: '2' },
{ label: '设备', value: '1' },
]
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const activeName = ref('0') const activeName = ref('0')
const filterText = ref('') const filterText = ref('')
const defaultProps = {
label: 'name',
value: 'id'
}
const process = ref('') const process = ref('')
//治理设备数据 const loading = ref(false)
const zlDeviceData = ref([])
const zlDevList = ref<any>([]) const defaultProps = { label: 'name', value: 'id' }
//便携式设备数据
const bxsDeviceData = ref([]) const zlDeviceData = ref<any[]>([])
//前置设备数据 const zlDevList = ref<any[]>([])
const frontDeviceData = ref([]) const bxsDeviceData = ref<any[]>([])
const frontDeviceData = ref<any[]>([])
const governTreeHeight = computed(() => `calc(100vh - 380px - ${props.height}px)`)
const otherTreeHeight = computed(() =>
zlDeviceData.value.length ? `calc(100vh - 340px - ${props.height}px)` : `calc(100vh - 238px - ${props.height}px)`
)
const engineeringTreeHeight = computed(() => `calc(100vh - 188px - ${props.height}px)`)
const treeRef1 = ref<InstanceType<typeof ElTree>>()
const treeRef2 = ref<InstanceType<typeof ElTree>>()
const treeRef3 = ref<InstanceType<typeof ElTree>>()
const treeRef4 = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
function splitTreeData(val: any[]) {
zlDeviceData.value = []
bxsDeviceData.value = []
frontDeviceData.value = []
val.forEach(item => {
if (item.name === '治理设备') {
zlDeviceData.value = item.children ?? []
} else if (item.name === '便携式设备') {
bxsDeviceData.value = item.children ?? []
} else if (item.name === '监测设备') {
frontDeviceData.value = item.children ?? []
}
})
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
}
function filterProcess(nodes: any[]): any[] {
if (!process.value) return nodes
return nodes
.map(node => {
const children = node.children ? filterProcess(node.children) : []
if (node.process == process.value || children.length > 0) {
return { ...node, children }
}
return null
})
.filter(Boolean)
}
function getActiveTreeRef() {
if (treeType.value === '2') return treeRef4.value
if (activeName.value === '0') return treeRef1.value
if (activeName.value === '1') return treeRef2.value
return treeRef3.value
}
function resolveActiveName() {
if (zlDeviceData.value.length) return '0'
if (bxsDeviceData.value.length) return '1'
if (frontDeviceData.value.length) return '2'
return ''
}
function selectDevicePanel(panelName: string, node?: any) {
if (!node) return
emit('changeDeviceType', panelName, node)
nextTick(() => {
getActiveTreeRef()?.setCurrentKey(node.id)
})
}
const changeDevice = (val: CollapseModelValue) => {
if (Array.isArray(val) || val == null || val === '') return
const panelName = String(val)
const collectLeaves = props.leafMode === 'device' ? collectDeviceApiLeaves : collectDeviceLeaves
const { govern, portable, monitor } = collectLeaves(
zlDevList.value,
bxsDeviceData.value,
frontDeviceData.value
)
const panelMap: Record<string, { nodes: any[]; clearOthers: any[][] }> = {
'0': { nodes: govern, clearOthers: [portable, monitor] },
'1': { nodes: portable, clearOthers: [govern, monitor] },
'2': { nodes: monitor, clearOthers: [govern, portable] }
}
const panel = panelMap[panelName]
if (!panel) return
panel.clearOthers.forEach(list => list.forEach(item => (item.checked = false)))
selectDevicePanel(panelName, panel.nodes[0])
}
const setActiveName = () => {
activeName.value = resolveActiveName()
if (activeName.value) {
nextTick(() => changeDevice(activeName.value))
}
}
watch( watch(
() => props.data, () => props.data,
(val, oldVal) => { val => {
if (val && val.length != 0) { if (!val?.length) return
val.map((item: any) => { splitTreeData(val)
if (item.name == '治理设备') { if (treeType.value === '1') {
zlDeviceData.value = [] nextTick(() => setActiveName())
item.children.map((vv: any) => {
zlDeviceData.value.push(vv)
})
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
} else if (item.name == '便携式设备') {
bxsDeviceData.value = []
item.children.map((vv: any) => {
bxsDeviceData.value.push(vv)
})
} else if (item.name == '监测设备') {
frontDeviceData.value = []
item.children.map((vv: any) => {
frontDeviceData.value.push(vv)
})
}
})
} }
}, },
{ { immediate: true, deep: true }
immediate: true,
deep: true
}
) )
watch(filterText, val => { watch(filterText, val => {
if (activeName.value == '0') { getActiveTreeRef()?.filter(val)
treeRef1.value!.filter(val) })
} else if (activeName.value == '1') {
treeRef2.value!.filter(val) watch(process, () => {
} else { zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
treeRef3.value!.filter(val) if (activeName.value === '0') {
nextTick(() => changeDevice(activeName.value))
} }
}) })
watch(process, val => {
if (val == '' || val == undefined) {
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
console.log('🚀 ~ zlDevList.value:', zlDeviceData.value)
} else {
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
}
setTimeout(() => {
changeDevice(activeName.value)
}, 0)
})
function filterProcess(nodes: any) {
if (process.value == '') {
return nodes
}
return nodes
.map(node => {
// 递归处理子节点
const children = node.children ? filterProcess(node.children) : []
// 如果当前节点的process=4或者有子节点满足条件则保留当前节点
if (node.process == process.value || children.length > 0) {
return {
...node,
children: children
}
}
// 否则过滤掉当前节点
return null
})
.filter(Boolean) // 移除null节点
}
const onMenuCollapse = () => { const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse) proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
} }
const filterNode = (value: string, data: any, node: any) => {
const filterNode = (value: string, data: any, node: any): boolean => {
if (!value) return true if (!value) return true
// return data.name.includes(value) if (!data.name) return false
if (data.name) { return chooseNode(value, data, node)
return chooseNode(value, data, node)
}
} }
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符. const chooseNode = (value: string, data: any, node: any): boolean => {
const chooseNode = (value: string, data: any, node: any) => { if (data.name.indexOf(value) !== -1) return true
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了 if (level === 1) return false
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent let parentData = node.parent
// 遍历当前节点的父节点 for (let i = 0; i < level - 1; i++) {
let index = 0 if (parentData?.data?.name?.indexOf(value) !== -1) return true
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent parentData = parentData.parent
index++
} }
// 没匹配到返回false
return false return false
} }
const changeDevice = (val: any) => { const changeTreeType = (val: string) => {
let arr1: any = [] loading.value = true
emit('changeTreeType', val)
//zlDeviceData if (val === '1') {
nextTick(() => setActiveName())
zlDevList.value.forEach((item: any) => {
item.children.forEach((item2: any) => {
item2.children.forEach((item3: any) => {
arr1.push(item3)
})
})
})
let arr2: any = []
bxsDeviceData.value.forEach((item: any) => {
// item.children.forEach((item2: any) => {
arr2.push(item)
// })
})
let arr3: any = []
frontDeviceData.value.forEach((item: any) => {
item.children.forEach((item2: any) => {
item2.children.forEach((item3: any) => {
arr3.push(item3)
})
})
})
if (val == '0') {
arr2.map((item: any) => {
item.checked = false
})
emit('changeDeviceType', activeName.value, arr1[0])
setTimeout(() => {
treeRef1.value?.setCurrentKey(arr1[0]?.id)
}, 100)
} }
if (val == '1') {
arr1.map((item: any) => {
item.checked = false
})
emit('changeDeviceType', activeName.value, arr2[0])
setTimeout(() => {
treeRef2.value?.setCurrentKey(arr2[0]?.id)
}, 100)
}
if (val == '2') {
arr3.map((item: any) => {
item.checked = false
})
emit('changeDeviceType', activeName.value, arr3[0])
setTimeout(() => {
treeRef3.value?.setCurrentKey(arr3[0]?.id)
}, 100)
}
}
//治理
const treeRef1 = ref<InstanceType<typeof ElTree>>()
//便携式
const treeRef2 = ref<InstanceType<typeof ElTree>>()
//前置
const treeRef3 = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef1, treeRef2, treeRef3 })
onMounted(() => {
setTimeout(() => { setTimeout(() => {
if (zlDeviceData.value.length != 0) { loading.value = false
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value))) }, 300)
activeName.value = '0' }
}
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length != 0) { onMounted(() => {
activeName.value = '1' // treeType.value = props.engineering ? '2' : '1'
}
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length === 0) {
activeName.value = '2'
}
if (!zlDeviceData.value && !bxsDeviceData.value) {
activeName.value = ''
}
nextTick(() => {
changeDevice(activeName.value)
})
}, 500)
}) })
</script> </script>
@@ -412,4 +410,10 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
} }
:deep(.el-input-group__prepend) {
background-color: var(--el-fill-color-blank);
}
:deep(.is-disabled) {
display: none !important;
}
</style> </style>

View File

@@ -0,0 +1,168 @@
<template>
<div class="apf-tree">
<div class="cn-tree" :style="{ height: `calc(100vh - 125px - ${height}px)` }">
<div style="display: flex; align-items: center" class="mb10">
<el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable>
<template #prefix>
<Icon name="el-icon-Search" style="font-size: 16px" />
</template>
</el-input>
</div>
<el-tree style="flex: 1; overflow: auto" :props="defaultProps" highlight-current
:filter-node-method="filterNode" node-key="id" default-expand-all :data="tree" ref="treRef"
@node-click="clickNode" :expand-on-click-node="false">
<template #default="{ node, data: nodeData }">
<span class="custom-tree-node">
<Icon :name="nodeData.icon" style="font-size: 16px" :style="{ color: nodeData.color }"
v-if="nodeData.icon" />
<span style="margin-left: 5px">{{ node.label }}</span>
</span>
</template>
</el-tree>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, watch, nextTick } from 'vue'
import { ElTree } from 'element-plus'
import { getUserDevTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData'
import { createLineTreeDecorators } from './lineTreeUtils'
import { bootstrapWithTemplate } from './treeCommonUtils'
import { createTreeFilterNode } from './treeFilterUtils'
interface Props {
template?: boolean
type?: string
height?: number
}
const props = withDefaults(defineProps<Props>(), { template: false, type: 'apf', height: 0 })
defineOptions({ name: 'govern/APFTree', inheritAttrs: false })
const emit = defineEmits(['init', 'node-click', 'deviceTypeChange', 'Policy'])
const config = useConfig()
const dictData = useDictData()
const tree = ref<any[]>([])
const treRef = ref<InstanceType<typeof ElTree>>()
const filterText = ref('')
const defaultProps = { children: 'children', label: 'name', value: 'id' }
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const filterNode = createTreeFilterNode()
watch(filterText, val => treRef.value?.filter(val))
/** 将 { 用户名: 设备[] | null } 转为两级树 */
function transformUserDevTree(data: Record<string, any[] | null>) {
const nodes: any[] = []
const devices: any[] = []
const { primary, statusColor, applyMeta } = decorators
if (!data || typeof data !== 'object') {
return { nodes, devices }
}
Object.entries(data).forEach(([userName, deviceList]) => {
const hasDevices = Array.isArray(deviceList) && deviceList.length > 0
const userId = hasDevices ? deviceList[0]?.monitorUser || userName : `apf-user-${userName}`
const children = hasDevices
? deviceList.map((device: any) => {
const node = {
...device,
level: 2,
pid: userId,
pname: userName
}
applyMeta(node, {
icon: 'el-icon-Platform',
color: statusColor(device.runStatus)
})
devices.push(node)
return node
})
: undefined
const userNode: any = {
id: userId,
name: userName,
level: 1,
...(children ? { children } : {})
}
applyMeta(userNode, { icon: 'el-icon-User', color: primary(), disabled: true })
nodes.push(userNode)
})
return { nodes, devices }
}
async function selectFirstDevice(devices: any[]) {
const node = devices[0]
if (!node) {
emit('init', { ...node })
return
}
await nextTick()
treRef.value?.setCurrentKey(node.id)
emit('init', { level: 2, ...node })
}
async function loadTree() {
tree.value = []
const res = await getUserDevTree({ type: props.type })
const { nodes, devices } = transformUserDevTree(res.data)
tree.value = nodes
await selectFirstDevice(devices)
}
const clickNode = (node: any) => {
if (node?.children?.length) return
emit('node-click', node)
}
bootstrapWithTemplate(
props.template,
loadTree,
() => querySysExcel({ id: dictData.state.area[0]?.id }),
data => emit('Policy', data)
)
watch(() => props.type, () => {
loadTree()
})
</script>
<style lang="scss" scoped>
.apf-tree {
width: 280px;
flex-shrink: 0;
}
.cn-tree {
display: flex;
flex-direction: column;
box-sizing: border-box;
padding: 10px;
overflow-y: auto;
:deep(.el-tree) {
border: 1px solid var(--el-border-color);
}
:deep(.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content) {
background-color: var(--el-color-primary-light-7);
}
.custom-tree-node {
display: flex;
}
}
</style>

View File

@@ -0,0 +1,205 @@
<template>
<Tree ref="treRef" @check="handleCheck" @check-change="handleCheckChange" :default-checked-keys="defaultCheckedKeys" check-strictly
:show-checkbox="props.showCheckbox" :data="tree" :height="props.height" @changeDeviceType="changeDeviceType"
@changeTreeType="loadTree" :engineering="props.engineering" />
</template>
<script lang="ts" setup>
import { ref, nextTick, onMounted } from 'vue'
import Tree from '../device.vue'
import { getLineTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config'
import {
createLineTreeDecorators,
decorateLineTree,
type LineTreeLeaves
} from './lineTreeUtils'
defineOptions({
name: 'govern/analyzeTree'
})
const props = withDefaults(
defineProps<{
showCheckbox?: boolean
defaultCheckedKeys?: any
height?: number
engineering?: boolean
}>(),
{
showCheckbox: false,
defaultCheckedKeys: () => [],
height: 0,
engineering: false
}
)
const emit = defineEmits(['init', 'checkChange', 'check', 'deviceTypeChange'])
const config = useConfig()
const tree = ref<any[]>([])
const treRef = ref<InstanceType<typeof Tree>>()
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const changeDeviceType = (val: any, obj: any) => {
emit('deviceTypeChange', val, obj)
}
type TreeRefKey = 'treeRef1' | 'treeRef2' | 'treeRef3' | 'treeRef4'
async function waitForTreeRef(refKey: TreeRefKey, maxRetries = 20) {
for (let i = 0; i < maxRetries; i++) {
await nextTick()
if (treRef.value?.[refKey]) return treRef.value[refKey]
await new Promise(resolve => setTimeout(resolve, 50))
}
return null
}
async function selectInitialNode(
type: string | undefined,
leaves: LineTreeLeaves
) {
const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
type === '2'
? [{ refKey: 'treeRef4', list: leaves.engineering, level: 3 }]
: [
{ refKey: 'treeRef1', list: leaves.govern, level: 2 },
{ refKey: 'treeRef2', list: leaves.portable, level: 2 },
{ refKey: 'treeRef3', list: leaves.monitor, level: 2 }
]
for (const { refKey, list, level } of candidates) {
const node = list[0]
if (!node) continue
const treeInstance = await waitForTreeRef(refKey)
treeInstance?.setCurrentKey(node.id)
emit('init', { ...node })
return
}
emit('init')
}
const loadTree = (type?: string) => {
getLineTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
const leaves = decorateLineTree(res.data, type, decorators)
tree.value = res.data
selectInitialNode(type, leaves)
})
}
onMounted(() => {
loadTree(props.engineering ? '2' : '1')
})
const handleCheck = (data: any, state: any) => {
emit('check', data, state)
}
const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
emit('checkChange', { data, checked, indeterminate })
}
defineExpose({ treRef })
</script>

View File

@@ -1,179 +1,80 @@
<template> <template>
<Tree ref="treRef" :width="width" :showPush="props.showPush" :data="tree" default-expand-all @changePointType="changePointType" @onAdd="onAdd"/> <Tree
ref="treRef"
:width="width"
:showPush="props.showPush"
:expand-on-click-node="false"
:data="tree"
@changePointType="changePointType"
@onAdd="onAdd"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, onMounted, defineProps } from 'vue' import { ref } from 'vue'
import Tree from '../index.vue' import Tree from '../index.vue'
import { getLineTree,getCldTree } from '@/api/cs-device-boot/csLedger' import { getCldTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { createLineTreeDecorators } from './lineTreeUtils'
import { decorateCloudTree } from './deviceTreeUtils'
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
interface Props { interface Props {
template?: boolean template?: boolean
showPush?: boolean showPush?: boolean
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
template: false, template: false,
showPush: false showPush: false
}) })
defineOptions({
name: 'govern/deviceTree'
})
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy','onAdd']) defineOptions({ name: 'govern/cloudDeviceEntryTree' })
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
const config = useConfig() const config = useConfig()
const tree = ref()
const dictData = useDictData() const dictData = useDictData()
const treRef = ref() const tree = ref<any[]>([])
const treRef = ref<InstanceType<typeof Tree>>()
const width = ref('') const width = ref('')
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const info = (selectedNodeId?: string) => { const changePointType = (_val: any, obj: any) => {
emit('pointTypeChange', _val, obj)
}
const onAdd = () => emit('onAdd')
async function loadTree() {
tree.value = [] tree.value = []
let arr1: any[] = [] const res = await getCldTree()
getCldTree().then(res => { const leaves = decorateCloudTree(res.data, decorators)
try { tree.value = [res.data]
// 检查响应数据结构
let rootData = null;
if (Array.isArray(res.data)) {
// 旧的数据结构 - 数组
rootData = res.data.find((item: any) => item.name == '监测设备');
} else if (res.data && res.data.name == '监测设备') {
// 新的数据结构 - 单个对象
rootData = res.data;
}
// 治理设备 const node = leaves[0]
if (rootData) { if (!node) {
rootData.icon = 'el-icon-Menu' emit('init')
rootData.level = 0 return
rootData.color = config.getColorVal('elementUiPrimary') }
// 确保根节点的 children 是数组
if (!Array.isArray(rootData.children)) {
rootData.children = []
}
rootData.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.level = 1
item.color = config.getColorVal('elementUiPrimary')
// 确保 children 是数组
if (!Array.isArray(item.children)) {
item.children = []
}
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.level = 2
item2.color = config.getColorVal('elementUiPrimary')
// 确保 children 是数组
if (!Array.isArray(item2.children)) {
item2.children = []
}
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.level = 3
item3.color =
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// 确保 children 是数组
if (!Array.isArray(item3.children)) {
item3.children = []
}
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.level = 4
item4.color =
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
arr1.push(item4)
})
})
})
})
tree.value = [rootData] // 确保 tree.value 是数组
} else {
tree.value = []
}
nextTick(() => {
if (arr1.length) {
// 安全检查 treRef 和 treeRef 是否存在
console.log("🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:", treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey)
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) { await selectTreeNode(treRef.value, node, {
// 如果传入了要选中的节点ID则选中该节点否则选中第一个节点 onSelect: selected => {
console.log('selectedNodeId:', selectedNodeId); emit('init', { ...selected, level: selected.level ?? 3 })
if (selectedNodeId) { changePointType('4', selected)
treRef.value.treeRef.setCurrentKey(selectedNodeId);
// 查找对应的节点数据并触发事件
let selectedNode = null;
const findNode = (nodes: any[]) => {
for (const node of nodes) {
if (node.id === selectedNodeId) {
selectedNode = node;
return true;
}
if (node.children && findNode(node.children)) {
return true;
}
}
return false;
};
findNode(tree.value);
if (selectedNode) {
emit('init', {
level: selectedNode.level,
...selectedNode
});
}
} else {
// 初始化选中第一个节点
treRef.value.treeRef.setCurrentKey(arr1[0].id);
emit('init', {
level: 2,
...arr1[0]
});
}
}
} else {
}
})
} catch (error) {
console.error('Error in processing getCldTree response:', error)
} }
}) })
} }
bootstrapWithTemplate(
props.template,
loadTree,
() => querySysExcel({ id: dictData.state.area[0]?.id }),
data => emit('Policy', data)
)
const changePointType = (val: any, obj: any) => { defineExpose({ info: loadTree })
emit('pointTypeChange', val, obj)
}
const onAdd = () => {
emit('onAdd')
}
if (props.template) {
querySysExcel({ id: dictData.state.area[0]?.id })
.then((res: any) => {
emit('Policy', res.data)
info()
})
.catch(err => {
info()
})
} else {
info()
}
// 暴露 info 方法给父组件调用
defineExpose({
info
})
onMounted(() => {})
</script> </script>

View File

@@ -1,106 +1,70 @@
<template> <template>
<Tree
ref="treRef" <Tree ref="treRef" :width="width" :height="height" :showPush="props.showPush" :data="tree" default-expand-all
:width="width" @changePointType="changePointType" @onAdd="onAdd" />
:showPush="props.showPush"
:data="tree"
default-expand-all
@changePointType="changePointType"
@onAdd="onAdd"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, onMounted, defineProps } from 'vue' import { ref } from 'vue'
import Tree from '../index.vue' import Tree from '../index.vue'
import { getLineTree, objTree } from '@/api/cs-device-boot/csLedger' import { objTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { createLineTreeDecorators } from './lineTreeUtils'
import { decorateObjTree } from './deviceTreeUtils'
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
interface Props { interface Props {
template?: boolean template?: boolean
showPush?: boolean showPush?: boolean
height?: number
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
template: false, template: false,
showPush: false showPush: false,
}) height: 0
defineOptions({
name: 'govern/deviceTree'
}) })
defineOptions({ name: 'govern/cloudDeviceEntryTreeZL' })
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd']) const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
const config = useConfig() const config = useConfig()
const tree = ref()
const dictData = useDictData() const dictData = useDictData()
const treRef = ref() const tree = ref<any[]>([])
const treRef = ref<InstanceType<typeof Tree>>()
const width = ref('') const width = ref('')
const info = (selectedNodeId?: string) => { const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const changePointType = (val: any, obj: any) => emit('pointTypeChange', val, obj)
const onAdd = () => emit('onAdd')
async function loadTree() {
tree.value = [] tree.value = []
let arr1: any[] = [] const res = await objTree()
objTree().then(res => { const leaves = decorateObjTree(res.data, decorators)
try { tree.value = res.data
res.data.map((item: any) => {
item.icon = 'el-icon-HomeFilled' const node = leaves[0]
item.level = 1 if (!node) {
item.color = config.getColorVal('elementUiPrimary') emit('init')
item.children.forEach((item: any) => { return
item.icon = 'el-icon-List' }
item.level = 2
item.color = config.getColorVal('elementUiPrimary') await selectTreeNode(treRef.value, node, {
item.children.forEach((item2: any) => { onSelect: selected => emit('init', selected)
arr1.push(item2)
item2.icon = 'el-icon-Platform'
item2.level = 3
item2.color = config.getColorVal('elementUiPrimary')
})
})
})
tree.value = res.data
nextTick(() => {
if (arr1.length) {
//初始化选中
treRef.value.treeRef.setCurrentKey(arr1[0].id)
// 注册父组件事件
emit('init', arr1[0])
return
} else {
emit('init')
return
}
})
} catch (error) {
console.error('Error in processing getCldTree response:', error)
}
}) })
} }
const changePointType = (val: any, obj: any) => { bootstrapWithTemplate(
emit('pointTypeChange', val, obj) props.template,
} loadTree,
() => querySysExcel({ id: dictData.state.area[0]?.id }),
data => emit('Policy', data)
)
const onAdd = () => { defineExpose({ info: loadTree })
emit('onAdd')
}
if (props.template) {
querySysExcel({ id: dictData.state.area[0]?.id })
.then((res: any) => {
emit('Policy', res.data)
info()
})
.catch(err => {
info()
})
} else {
info()
}
// 暴露 info 方法给父组件调用
defineExpose({
info
})
onMounted(() => {})
</script> </script>

View File

@@ -1,179 +1,80 @@
<template> <template>
<Tree ref="treRef" :width="width" :showPush="props.showPush" :data="tree" default-expand-all @changePointType="changePointType" @onAdd="onAdd"/> <Tree
ref="treRef"
:width="width"
:showPush="props.showPush"
:data="tree"
default-expand-all
@changePointType="changePointType"
@onAdd="onAdd"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, onMounted, defineProps } from 'vue' import { ref } from 'vue'
import Tree from '../index.vue' import Tree from '../index.vue'
import { getLineTree,lineTree } from '@/api/cs-device-boot/csLedger' import { lineTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import { createLineTreeDecorators } from './lineTreeUtils'
import { decorateLedgerLineTree, resolveMonitorRoot } from './deviceTreeUtils'
import { bootstrapWithTemplate, findNodeById, selectTreeNode } from './treeCommonUtils'
interface Props { interface Props {
template?: boolean template?: boolean
showPush?: boolean showPush?: boolean
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
template: false, template: false,
showPush: false showPush: false
}) })
defineOptions({
name: 'govern/deviceTree'
})
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy','onAdd']) defineOptions({ name: 'govern/csLedgerLineTree' })
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
const config = useConfig() const config = useConfig()
const tree = ref() const tree = ref<any[]>([])
const dictData = useDictData() const treRef = ref<InstanceType<typeof Tree>>()
const treRef = ref()
const width = ref('') const width = ref('')
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const info = (selectedNodeId?: string) => { const changePointType = (val: any, obj: any) => emit('pointTypeChange', val, obj)
const onAdd = () => emit('onAdd')
async function loadTree(selectedNodeId?: string) {
tree.value = [] tree.value = []
let arr1: any[] = [] const res = await lineTree()
lineTree().then(res => { const rootData = resolveMonitorRoot(res.data)
try { const leaves = decorateLedgerLineTree(rootData, decorators)
// 检查响应数据结构 tree.value = rootData ? [rootData] : []
let rootData = null;
if (Array.isArray(res.data)) {
// 旧的数据结构 - 数组
rootData = res.data.find((item: any) => item.name == '监测设备');
} else if (res.data && res.data.name == '监测设备') {
// 新的数据结构 - 单个对象
rootData = res.data;
}
// 治理设备 if (!leaves.length) {
if (rootData) { emit('init')
rootData.icon = 'el-icon-Menu' return
rootData.level = 0 }
rootData.color = config.getColorVal('elementUiPrimary')
// 确保根节点的 children 是数组
if (!Array.isArray(rootData.children)) {
rootData.children = []
}
rootData.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.level = 1
item.color = config.getColorVal('elementUiPrimary')
// 确保 children 是数组
if (!Array.isArray(item.children)) {
item.children = []
}
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.level = 2
item2.color = config.getColorVal('elementUiPrimary')
// 确保 children 是数组
if (!Array.isArray(item2.children)) {
item2.children = []
}
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.level = 3
item3.color =
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// 确保 children 是数组
if (!Array.isArray(item3.children)) {
item3.children = []
}
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.level = 4
item4.color =
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
arr1.push(item4)
})
})
})
})
tree.value = [rootData] // 确保 tree.value 是数组
} else {
tree.value = []
}
nextTick(() => {
if (arr1.length) {
// 安全检查 treRef 和 treeRef 是否存在
console.log("🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:", treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey)
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) { const targetNode = selectedNodeId
// 如果传入了要选中的节点ID则选中该节点否则选中第一个节点 ? findNodeById(tree.value, selectedNodeId) ?? leaves[0]
console.log('selectedNodeId:', selectedNodeId); : leaves[0]
if (selectedNodeId) {
treRef.value.treeRef.setCurrentKey(selectedNodeId); await selectTreeNode(treRef.value, targetNode, {
// 查找对应的节点数据并触发事件 onSelect: selected =>
let selectedNode = null; emit('init', {
const findNode = (nodes: any[]) => { level: selected.level ?? 2,
for (const node of nodes) { ...selected
if (node.id === selectedNodeId) {
selectedNode = node;
return true;
}
if (node.children && findNode(node.children)) {
return true;
}
}
return false;
};
findNode(tree.value);
if (selectedNode) {
emit('init', {
level: selectedNode.level,
...selectedNode
});
}
} else {
// 初始化选中第一个节点
treRef.value.treeRef.setCurrentKey(arr1[0].id);
emit('init', {
level: 2,
...arr1[0]
});
}
}
} else {
}
}) })
} catch (error) {
console.error('Error in processing getCldTree response:', error)
}
}) })
} }
bootstrapWithTemplate(
props.template,
() => loadTree(),
() => querySysExcel({}),
data => emit('Policy', data)
)
const changePointType = (val: any, obj: any) => { defineExpose({ info: loadTree })
emit('pointTypeChange', val, obj)
}
const onAdd = () => {
emit('onAdd')
}
if (props.template) {
querySysExcel({ id: dictData.state.area[0]?.id })
.then((res: any) => {
emit('Policy', res.data)
info()
})
.catch(err => {
info()
})
} else {
info()
}
// 暴露 info 方法给父组件调用
defineExpose({
info
})
onMounted(() => {})
</script> </script>

View File

@@ -1,107 +1,64 @@
<template> <template>
<Tree <Tree
ref="treRef" ref="treRef"
@checkTreeNodeChange="handleCheckChange" @checkTreeNodeChange="handleCheckChange"
:default-checked-keys="defaultCheckedKeys" :default-checked-keys="defaultCheckedKeys"
:show-checkbox="props.showCheckbox" :show-checkbox="props.showCheckbox"
:data="tree" :data="tree"
/> />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, defineProps } from 'vue' import { ref } from 'vue'
import Tree from '../index.vue' import Tree from '../index.vue'
import { getDeviceTree } from '@/api/cs-device-boot/csLedger' import { getDeviceTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
defineOptions({ import { createLineTreeDecorators } from './lineTreeUtils'
name: 'govern/deviceTree' import { decorateDeviceInfoTree } from './deviceTreeUtils'
}) import { selectTreeNode } from './treeCommonUtils'
const props = withDefaults(
defineProps<{ defineOptions({ name: 'govern/deviceInfoTree' })
showCheckbox?: boolean
defaultCheckedKeys?: any const props = withDefaults(
}>(), defineProps<{
{ showCheckbox?: boolean
showCheckbox: false, defaultCheckedKeys?: any[]
defaultCheckedKeys: [] }>(),
} {
) showCheckbox: false,
defaultCheckedKeys: () => []
const emit = defineEmits(['init', 'checkChange']) }
const config = useConfig() )
const tree = ref()
const treRef = ref() const emit = defineEmits(['init', 'checkChange'])
getDeviceTree().then(res => {
return const config = useConfig()
let arr: any[] = [] const tree = ref<any[]>([])
res.data.forEach((item: any) => { const treRef = ref<InstanceType<typeof Tree>>()
item.icon = 'el-icon-HomeFilled' const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => { async function initTree(list: any[]) {
item2.icon = 'el-icon-List' const leaves = decorateDeviceInfoTree(list, decorators)
item2.color = config.getColorVal('elementUiPrimary') tree.value = list
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform' const node = leaves[0]
item3.color = config.getColorVal('elementUiPrimary') if (!node) {
if (item3.comFlag === 1) { emit('init')
item3.color = '#e26257 !important' return
} }
arr.push(item3)
}) await selectTreeNode(treRef.value, node, {
}) onSelect: selected => emit('init', { ...selected, level: 2 })
}) })
tree.value = res.data }
nextTick(() => {
if (arr.length) { getDeviceTree().then(res => initTree(res.data))
treRef.value.treeRef.setCurrentKey(arr[0].id)
// 注册父组件事件 const getTreeList = (list: any[]) => initTree(list)
emit('init', {
level: 2, const handleCheckChange = (data: any) => {
...arr[0] emit('checkChange', { data })
}) }
} else {
emit('init') defineExpose({ getTreeList })
} </script>
})
})
const getTreeList = (list: any) => {
let arr: any[] = []
list.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.color = config.getColorVal('elementUiPrimary')
item2.children?.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.color = config.getColorVal('elementUiPrimary')
if (item3.comFlag === 1) {
item3.color = '#e26257 !important'
item3.color = item3.comFlag == 3 ? '#e26257 !important' : config.getColorVal('elementUiPrimary')
}
arr.push(item3)
})
})
})
tree.value = list
nextTick(() => {
if (arr.length) {
treRef.value.treeRef.setCurrentKey(arr[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr[0]
})
} else {
emit('init')
}
})
}
//接收tree选择的数据后传递给父级组件
const handleCheckChange = (data: any) => {
emit('checkChange', {
data
})
}
defineExpose({ getTreeList })
</script>

View File

@@ -1,174 +1,85 @@
<template> <template>
<Tree <Tree ref="treRef" @check-change="handleCheckChange" :default-checked-keys="defaultCheckedKeys" default-expand-all
ref="treRef" :show-checkbox="props.showCheckbox" :data="tree" :height="props.height" @changeDeviceType="changeDeviceType"
@check-change="handleCheckChange" @changeTreeType="loadTree" :engineering="props.engineering" leaf-mode="device" />
:default-checked-keys="defaultCheckedKeys"
:show-checkbox="props.showCheckbox"
:data="tree"
:height="props.height"
@changeDeviceType="changeDeviceType"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick } from 'vue' import { ref, onMounted, onBeforeUnmount } from 'vue'
import { debounce } from 'lodash-es'
import Tree from '../device.vue' import Tree from '../device.vue'
import { getDeviceTree } from '@/api/cs-device-boot/csLedger' import { getDeviceTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { throttle } from 'lodash' import { waitForTreeRef, type TreeRefKey } from './lineTreeUtils'
defineOptions({ import { createLineTreeDecorators } from './lineTreeUtils'
name: 'govern/deviceTree' import { decorateDeviceTree } from './deviceTreeUtils'
}) import type { LineTreeLeaves } from './lineTreeUtils'
defineOptions({ name: 'govern/deviceTree' })
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
showCheckbox?: boolean showCheckbox?: boolean
defaultCheckedKeys?: any defaultCheckedKeys?: any[]
height?: number height?: number
engineering?: boolean
}>(), }>(),
{ {
showCheckbox: false, showCheckbox: false,
defaultCheckedKeys: [], defaultCheckedKeys: () => [],
height: 0 height: 0,
engineering: false
} }
) )
const emit = defineEmits(['init', 'checkChange', 'deviceTypeChange']) const emit = defineEmits(['init', 'checkChange', 'deviceTypeChange'])
const config = useConfig() const config = useConfig()
const tree = ref() const tree = ref<any[]>([])
const treRef = ref() const treRef = ref<InstanceType<typeof Tree>>()
const changeDeviceType = (val: any, obj: any) => { const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const changeDeviceType = debounce((val: any, obj: any) => {
emit('deviceTypeChange', val, obj) emit('deviceTypeChange', val, obj)
} }, 300)
getDeviceTree().then(res => {
let arr: any[] = []
let arr2: any[] = []
let arr3: any[] = []
//治理设备
res.data.map((item: any) => {
if (item.name == '治理设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.pName = '治理设备'
item3.icon = 'el-icon-Platform'
item3.level = 2
item3.color = config.getColorVal('elementUiPrimary')
if (item3.comFlag === 1) {
item3.color = '#e26257 !important'
}
arr.push(item3)
})
})
})
} else if (item.name == '便携式设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-Platform'
item.color = config.getColorVal('elementUiPrimary')
item.color = '#e26257 !important'
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// item.disabled =true
item.pName = '便携式设备'
if (item.type == 'device') {
arr2.push(item)
}
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-Platform'
item2.color = item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item2.pName = '便携式设备'
// item2.children.forEach((item3: any) => {
// item3.icon = 'el-icon-Platform'
// item3.color = config.getColorVal('elementUiPrimary')
// if (item3.comFlag === 1) {
// item3.color = '#e26257 !important'
// }
// arr.push(item3)
// })
})
})
} else if (item.name == '监测设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.pName = '监测设备'
item3.icon = 'el-icon-Platform'
item3.color = config.getColorVal('elementUiPrimary')
if (item3.comFlag === 1) {
item3.color = '#e26257 !important'
}
arr3.push(item3)
})
})
})
}
})
tree.value = res.data
nextTick(() => { onBeforeUnmount(() => changeDeviceType.cancel())
setTimeout(() => {
if (arr.length > 0) {
treRef.value.treeRef1.setCurrentKey(arr[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr[0]
})
return
} else if (arr2.length > 0) {
treRef.value.treeRef2.setCurrentKey(arr2[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr2[0]
})
return
} else if (arr3.length > 0) {
console.log('🚀 ~ arr3:', arr3)
treRef.value.treeRef3.setCurrentKey(arr3[0].id) async function selectInitialNode(type: string | undefined, leaves: LineTreeLeaves) {
// 注册父组件事件 const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
emit('init', { type === '2'
level: 2, ? [{ refKey: 'treeRef4', list: leaves.engineering, level: 2 }]
...arr3[0] : [
}) { refKey: 'treeRef1', list: leaves.govern, level: 2 },
return { refKey: 'treeRef2', list: leaves.portable, level: 2 },
} else { { refKey: 'treeRef3', list: leaves.monitor, level: 2 }
emit('init') ]
return
}
}, 500)
})
})
throttle( for (const { refKey, list, level } of candidates) {
(data: any, checked: any, indeterminate: any) => { const node = list[0]
emit('checkChange', { if (!node) continue
data, const treeInstance = await waitForTreeRef(treRef.value, refKey)
checked, treeInstance?.setCurrentKey(node.id)
indeterminate emit('init', { ...node })
}) return
},
300,
{
leading: true, // 首次触发立即执行(可选,默认 true
trailing: false // 节流结束后是否执行最后一次(可选,默认 true根据需求调整
} }
) emit('init')
}
const handleCheckChange = (data: any, checked: any, indeterminate: any) => { const loadTree = (type?: string) => {
emit('checkChange', { getDeviceTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
data, const leaves = decorateDeviceTree(res.data, type, decorators)
checked, tree.value = res.data
indeterminate selectInitialNode(type, leaves)
}) })
} }
defineExpose({
treRef onMounted(() => loadTree( '2' ))
})
const handleCheckChange =
(data: any, checked: any, indeterminate: any) => {
emit('checkChange', { data, checked, indeterminate })
}
defineExpose({ treRef })
</script> </script>

View File

@@ -0,0 +1,224 @@
import type { LineTreeDecorators, LineTreeLeaves } from './lineTreeUtils'
/** getDeviceTree 接口专用装饰(与 getLineTree 层级不同) */
export function decorateDeviceTree(
data: any[],
type: string | undefined,
decorators: LineTreeDecorators
): LineTreeLeaves {
const leaves: LineTreeLeaves = { govern: [], portable: [], monitor: [], engineering: [] }
const { primary, statusColor, applyMeta } = decorators
data.forEach(item => {
if (type === '2') {
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary() })
item.children?.forEach((child: any) => {
applyMeta(child, { icon: 'el-icon-List', color: primary() })
child.children?.forEach((grand: any) => {
applyMeta(grand, {
icon: 'el-icon-Platform',
color: statusColor(grand.comFlag),
level: 3
})
leaves.engineering.push(grand)
})
})
return
}
if (item.name === '治理设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
l2.children?.forEach((l3: any) => {
l3.pName = '治理设备'
applyMeta(l3, {
icon: 'el-icon-Platform',
level: 2,
color: l3.comFlag === 1 ? '#e26257 !important' : primary()
})
leaves.govern.push(l3)
})
})
})
} else if (item.name === '便携式设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, {
icon: 'el-icon-Platform',
color: statusColor(l1.comFlag)
})
l1.pName = '便携式设备'
if (l1.type === 'device') {
leaves.portable.push(l1)
}
l1.children?.forEach((l2: any) => {
applyMeta(l2, {
icon: 'el-icon-Platform',
color: statusColor(l2.comFlag)
})
l2.pName = '便携式设备'
})
})
} else if (item.name === '监测设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
l2.children?.forEach((l3: any) => {
l3.pName = '监测设备'
applyMeta(l3, {
icon: 'el-icon-Platform',
level: 3,
color: l3.comFlag === 1 ? '#e26257 !important' : primary()
})
leaves.monitor.push(l3)
})
})
})
}
})
return leaves
}
/** 装饰 getDeviceTree 扁平列表deviceInfoTree */
export function decorateDeviceInfoTree(list: any[], decorators: LineTreeDecorators): any[] {
const { primary, applyMeta } = decorators
const leaves: any[] = []
list.forEach(item => {
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary() })
item.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
l2.children?.forEach((l3: any) => {
applyMeta(l3, {
icon: 'el-icon-Platform',
color: l3.comFlag === 1 || l3.comFlag === 3 ? '#e26257 !important' : primary()
})
leaves.push(l3)
})
})
})
return leaves
}
/** 装饰云端设备树 getCldTree */
export function decorateCloudTree(root: any, decorators: LineTreeDecorators): any[] {
const { primary, statusColor, applyMeta } = decorators
const leaves: any[] = []
applyMeta(root, { icon: 'el-icon-Menu', color: primary() })
root.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
l2.children?.forEach((l3: any) => {
applyMeta(l3, {
icon: 'el-icon-Platform',
level: 2,
color: statusColor(l3.comFlag)
})
leaves.push(l3)
})
})
})
return leaves
}
/** 装饰 objTree治理对象树 */
export function decorateObjTree(data: any[], decorators: LineTreeDecorators): any[] {
const { primary, applyMeta } = decorators
const leaves: any[] = []
data.forEach(l1 => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1 })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 2 })
l2.children?.forEach((l3: any) => {
applyMeta(l3, { icon: 'el-icon-Platform', color: primary(), level: 3 })
leaves.push(l3)
})
})
})
return leaves
}
/** 装饰 lineTree 台账线路树(监测设备根节点) */
export function decorateLedgerLineTree(root: any, decorators: LineTreeDecorators): any[] {
const { primary, statusColor, applyMeta } = decorators
const leaves: any[] = []
if (!root) return leaves
applyMeta(root, { icon: 'el-icon-Menu', color: primary(), level: 0 })
if (!Array.isArray(root.children)) root.children = []
root.children.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1 })
if (!Array.isArray(l1.children)) l1.children = []
l1.children.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 2 })
if (!Array.isArray(l2.children)) l2.children = []
l2.children.forEach((l3: any) => {
applyMeta(l3, {
icon: 'el-icon-Platform',
color: statusColor(l3.comFlag),
level: 3
})
if (!Array.isArray(l3.children)) l3.children = []
l3.children.forEach((l4: any) => {
applyMeta(l4, {
icon: 'el-icon-Platform',
color: statusColor(l4.comFlag),
level: 4
})
leaves.push(l4)
})
})
})
})
return leaves
}
/** getDeviceTree 接口叶子收集3 层结构,便携式为 type=device 节点) */
export function collectDeviceApiLeaves(
governNodes: any[],
portableNodes: any[],
monitorNodes: any[]
): { govern: any[]; portable: any[]; monitor: any[] } {
const govern: any[] = []
const portable: any[] = []
const monitor: any[] = []
governNodes.forEach(l1 => {
l1.children?.forEach((l2: any) => {
l2.children?.forEach((l3: any) => govern.push(l3))
})
})
portableNodes.forEach(l1 => {
if (l1.type === 'device') portable.push(l1)
})
monitorNodes.forEach(l1 => {
l1.children?.forEach((l2: any) => {
l2.children?.forEach((l3: any) => monitor.push(l3))
})
})
return { govern, portable, monitor }
}
/** 从 lineTree 数据中解析监测设备根节点 */
export function resolveMonitorRoot(data: any): any | null {
if (Array.isArray(data)) {
return data.find(item => item.name === '监测设备') ?? null
}
if (data?.name === '监测设备') return data
return null
}

View File

@@ -1,29 +1,28 @@
<template> <template>
<Tree ref="treRef" :data="tree" /> <Tree ref="treRef" :data="tree" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'
import { getMarketList } from '@/api/user-boot/user' import { getMarketList } from '@/api/user-boot/user'
import Tree from '../cloudDevice.vue' import Tree from '../cloudDevice.vue'
import { useConfig } from '@/stores/config' import { mapUserTreeNodes, selectTreeNode } from './treeCommonUtils'
import { ref, reactive, nextTick } from 'vue'
const config = useConfig() const tree = ref<any[]>([])
const tree = ref() const treRef = ref<InstanceType<typeof Tree>>()
const treRef = ref()
const emit = defineEmits(['selectUser']) const emit = defineEmits(['selectUser'])
getMarketList().then((res: any) => {
if (res.code === 'A0000') { async function loadTree() {
tree.value = res.data.map((item: any) => { const res: any = await getMarketList()
return { if (res.code !== 'A0000') return
...item,
icon: 'el-icon-User', tree.value = mapUserTreeNodes(res.data)
color: 'royalblue' const first = tree.value[0]
} if (!first) return
})
emit('selectUser', tree.value[0]) emit('selectUser', first)
nextTick(() => { await selectTreeNode(treRef.value, first)
treRef.value.treeRef.setCurrentKey(tree.value[0].id) }
})
} loadTree()
})
</script> </script>
<style lang="scss" scoped></style>

View File

@@ -0,0 +1,212 @@
import { nextTick } from 'vue'
export interface LineTreeLeaves {
govern: any[]
portable: any[]
monitor: any[]
engineering: any[]
}
export interface LineTreeDecorators {
primary: () => string
statusColor: (comFlag: number) => string
applyMeta: (
node: any,
meta: { icon: string; color?: string; level?: number; disabled?: boolean; pname?: string }
) => void
}
export function createLineTreeDecorators(getPrimaryColor: () => string): LineTreeDecorators {
const offlineColor = '#e26257 !important'
// const statusColor = (comFlag: number) => (comFlag === 2 ? getPrimaryColor() : offlineColor)
const statusColor = (comFlag: number) => (comFlag === 2 ? "#2ab914" : offlineColor)
const applyMeta = (
node: any,
meta: { icon: string; color?: string; level?: number; disabled?: boolean }
) => {
node.icon = meta.icon
if (meta.color !== undefined) node.color = meta.color
if (meta.level !== undefined) node.level = meta.level
if (meta.disabled) node.disabled = true
}
return {
primary: getPrimaryColor,
statusColor,
applyMeta
}
}
export type TreeRefKey = 'treeRef1' | 'treeRef2' | 'treeRef3' | 'treeRef4'
/** 线路树可选叶子节点元数据 */
export const LINE_LEAF_META = { level: 3, type: 'line' as const }
/** 是否为线路树可选叶子(监测点/线路) */
export function isLineTreeLeaf(node: any): boolean {
if (!node?.id) return false
return node.type === 'line' || node.level === 3
}
/** 是否为报告/导出可选监测点 */
export function isReportMonitorPoint(node: any): boolean {
if (!node?.id) return false
return isLineTreeLeaf(node) || node.level === 3 || (!node.children?.length && !!node.pid)
}
export interface DecorateLineTreeOptions {
/** 是否禁用父级节点(分析树隐藏父节点,测点树不禁用) */
disableParents?: boolean
}
/** 装饰线路树节点并收集可选叶子节点 */
export function decorateLineTree(
data: any[],
type: string | undefined,
decorators: LineTreeDecorators,
options: DecorateLineTreeOptions = {}
): LineTreeLeaves {
const leaves: LineTreeLeaves = { govern: [], portable: [], monitor: [], engineering: [] }
const { primary, statusColor, applyMeta } = decorators
const disableParents = options.disableParents ?? true
const parentDisabled = disableParents ? ({ disabled: true } as const) : {}
data.forEach(item => {
if (type === '2') {
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary(), ...parentDisabled })
item.children?.forEach((child: any) => {
applyMeta(child, { icon: 'el-icon-List', color: primary(), ...parentDisabled })
child.children?.forEach((grand: any) => {
applyMeta(grand, {
icon: 'el-icon-Platform',
color: statusColor(grand.comFlag),
level: 2,
...parentDisabled
})
grand.children?.forEach((leaf: any) => {
applyMeta(leaf, {
icon: 'local-监测点',
color: statusColor(leaf.comFlag),
...LINE_LEAF_META
})
leaf.pname=item.name,
leaves.engineering.push(leaf)
})
})
})
return
}
if (item.name === '治理设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1, ...parentDisabled })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 1, ...parentDisabled })
l2.children?.forEach((l3: any) => {
applyMeta(l3, {
icon: 'el-icon-Platform',
color: statusColor(l3.comFlag),
level: 2,
...parentDisabled
})
l3.children?.forEach((l4: any) => {
applyMeta(l4, {
icon: 'local-监测点',
color: statusColor(l4.comFlag),
...LINE_LEAF_META
})
l4.pname=item.name,
leaves.govern.push(l4)
})
})
})
})
} else if (item.name === '便携式设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-Platform', color: statusColor(l1.comFlag) })
l1.children?.forEach((l2: any) => {
applyMeta(l2, {
icon: 'local-监测点',
color: statusColor(l2.comFlag),
...LINE_LEAF_META
})
l2.pname=item.name,
leaves.portable.push(l2)
})
})
} else if (item.name === '监测设备') {
item.children?.forEach((l1: any) => {
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1, ...parentDisabled })
l1.children?.forEach((l2: any) => {
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 1, ...parentDisabled })
l2.children?.forEach((l3: any) => {
applyMeta(l3, {
icon: 'el-icon-Platform',
color: statusColor(l3.comFlag),
level: 1,
...parentDisabled
})
l3.children?.forEach((l4: any) => {
applyMeta(l4, {
icon: 'local-监测点',
color: statusColor(l4.comFlag),
...LINE_LEAF_META
})
l4.pname=item.name,
leaves.monitor.push(l4)
})
})
})
})
}
})
return leaves
}
/** 从折叠面板树数据中收集叶子节点(与 decorateLineTree 层级一致) */
export function collectDeviceLeaves(
governNodes: any[],
portableNodes: any[],
monitorNodes: any[]
): Pick<LineTreeLeaves, 'govern' | 'portable' | 'monitor'> {
const govern: any[] = []
const portable: any[] = []
const monitor: any[] = []
governNodes.forEach(l1 => {
l1.children?.forEach((l2: any) => {
l2.children?.forEach((l3: any) => {
l3.children?.forEach((l4: any) => govern.push(l4))
})
})
})
portableNodes.forEach(l1 => {
l1.children?.forEach((l2: any) => portable.push(l2))
})
monitorNodes.forEach(l1 => {
l1.children?.forEach((l2: any) => {
l2.children?.forEach((l3: any) => {
l3.children?.forEach((l4: any) => monitor.push(l4))
})
})
})
return { govern, portable, monitor }
}
export async function waitForTreeRef(treRef: any, refKey: TreeRefKey, maxRetries = 20) {
for (let i = 0; i < maxRetries; i++) {
await nextTick()
if (treRef?.[refKey]) return treRef[refKey]
await new Promise(resolve => setTimeout(resolve, 50))
}
return null
}

View File

@@ -1,29 +1,28 @@
<template> <template>
<Tree ref="treRef" :data="tree" /> <Tree ref="treRef" :data="tree" />
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'
import { getFormalUserList } from '@/api/user-boot/official' import { getFormalUserList } from '@/api/user-boot/official'
import Tree from '../cloudDevice.vue' import Tree from '../cloudDevice.vue'
import { useConfig } from '@/stores/config' import { mapUserTreeNodes, selectTreeNode } from './treeCommonUtils'
import { ref, reactive, nextTick } from 'vue'
const config = useConfig() const tree = ref<any[]>([])
const tree = ref() const treRef = ref<InstanceType<typeof Tree>>()
const treRef = ref()
const emit = defineEmits(['selectUser']) const emit = defineEmits(['selectUser'])
getFormalUserList().then((res: any) => {
if (res.code === 'A0000') { async function loadTree() {
tree.value = res.data.map((item: any) => { const res: any = await getFormalUserList()
return { if (res.code !== 'A0000') return
...item,
icon: 'el-icon-User', tree.value = mapUserTreeNodes(res.data)
color: 'royalblue' const first = tree.value[0]
} if (!first) return
})
emit('selectUser', tree.value[0]) emit('selectUser', first)
nextTick(() => { await selectTreeNode(treRef.value, first)
treRef.value.treeRef.setCurrentKey(tree.value[0].id) }
})
} loadTree()
})
</script> </script>
<style lang="scss" scoped></style>

View File

@@ -1,153 +1,109 @@
<template> <template>
<Tree ref="treRef" :width="width" :data="tree" default-expand-all @changePointType="changePointType" /> <Tree
ref="treRef"
:width="width"
:data="tree"
default-expand-all
@changePointType="changePointType"
@changeTreeType="loadTree"
:height="height"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, onMounted, defineProps } from 'vue' import { ref, nextTick } from 'vue'
import Tree from '../point.vue' import Tree from '../point.vue'
import { getLineTree } from '@/api/cs-device-boot/csLedger' import { getLineTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import {
// const props = defineProps(['template']) createLineTreeDecorators,
decorateLineTree,
waitForTreeRef,
type LineTreeLeaves,
type TreeRefKey
} from './lineTreeUtils'
interface Props { interface Props {
template?: boolean template?: boolean
height?: number
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
template: false template: false,
height: 0
}) })
defineOptions({ defineOptions({
name: 'govern/deviceTree' name: 'govern/pointTree'
}) })
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy']) const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
const config = useConfig() const config = useConfig()
const tree = ref() const tree = ref<any[]>([])
const dictData = useDictData() const treRef = ref<InstanceType<typeof Tree>>()
const treRef = ref()
const width = ref('') const width = ref('')
const info = () => { const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
tree.value = []
let arr1: any[] = []
let arr2: any[] = []
let arr3: any[] = []
getLineTree().then(res => {
//治理设备
res.data.map((item: any) => {
if (item.name == '治理设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.level = 1
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.level = 1
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.level = 2
item3.color =
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.color =
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// item4.color = '#e26257 !important'
arr1.push(item4)
})
})
})
})
} else if (item.name == '便携式设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-Platform'
item.color = config.getColorVal('elementUiPrimary')
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-Platform'
item2.color =
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
arr2.push(item2)
})
})
} else if (item.name == '监测设备') {
item.children.forEach((item: any) => {
item.icon = 'el-icon-HomeFilled'
item.level = 1
item.color = config.getColorVal('elementUiPrimary')
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List'
item2.level = 1
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.level = 1
item3.color =
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.color =
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// item4.color = '#e26257 !important'
arr3.push(item4)
})
})
})
})
}
})
tree.value = res.data
nextTick(() => {
setTimeout(() => {
if (arr1.length > 0) {
//初始化选中
treRef.value?.treeRef1.setCurrentKey(arr1[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr1[0]
})
return
} else if (arr2.length > 0) {
//初始化选中
treRef.value?.treeRef2.setCurrentKey(arr2[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr2[0]
})
return
} else if (arr3.length > 0) {
treRef.value?.treeRef3?.setCurrentKey(arr3[0].id)
emit('init', {
level: 2,
...arr3[0]
})
return
} else {
emit('init')
return
}
}, 500)
})
})
}
const changePointType = (val: any, obj: any) => { const changePointType = (val: any, obj: any) => {
emit('pointTypeChange', val, obj) emit('pointTypeChange', val, obj)
} }
if (props.template) {
querySysExcel({ id: dictData.state.area[0]?.id }) async function selectInitialNode(type: string | undefined, leaves: LineTreeLeaves) {
.then((res: any) => { const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
emit('Policy', res.data) type === '2'
info() ? [{ refKey: 'treeRef4', list: leaves.engineering, level: 3 }]
}) : [
.catch(err => { { refKey: 'treeRef1', list: leaves.govern, level: 2 },
info() { refKey: 'treeRef2', list: leaves.portable, level: 2 },
}) { refKey: 'treeRef3', list: leaves.monitor, level: 2 }
} else { ]
info()
for (const { refKey, list, level } of candidates) {
const node = list[0]
if (!node) continue
const treeInstance = await waitForTreeRef(treRef.value, refKey)
treeInstance?.setCurrentKey(node.id)
emit('init', { ...node })
if (type === '2') {
changePointType('4', node)
}
return
}
emit('init')
} }
onMounted(() => {})
const loadTree = (type?: string) => {
console.log("🚀 ~ loadTree ~ type:", type)
tree.value = []
getLineTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
const leaves = decorateLineTree(res.data, type, decorators, { disableParents: false })
tree.value = res.data
nextTick(() => selectInitialNode(type, leaves))
})
}
function bootstrap() {
if (props.template) {
querySysExcel({})
.then((res: any) => {
emit('Policy', res.data)
loadTree('2')
})
.catch(() => loadTree())
} else {
loadTree('2')
}
}
bootstrap()
defineExpose({ treRef })
</script> </script>

View File

@@ -3,13 +3,7 @@
<div style="transition: all 0.3s; overflow: hidden; height: 100%"> <div style="transition: all 0.3s; overflow: hidden; height: 100%">
<div class="cn-tree"> <div class="cn-tree">
<div style="display: flex; align-items: center" class="mb10"> <div style="display: flex; align-items: center" class="mb10">
<el-input <el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable>
maxlength="32"
show-word-limit
v-model.trim="filterText"
placeholder="请输入内容"
clearable
>
<template #prefix> <template #prefix>
<Icon name="el-icon-Search" style="font-size: 16px" /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
@@ -28,16 +22,16 @@
@node-click="clickNode" @node-click="clickNode"
:expand-on-click-node="false" :expand-on-click-node="false"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<div class="left" style="display: flex; align-items: center"> <div class="left" style="display: flex; align-items: center">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 5px;">{{ node.label }}</span> <span style="margin-left: 5px">{{ node.label }}</span>
</div> </div>
</span> </span>
</template> </template>
@@ -48,127 +42,84 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, watch, defineProps, defineEmits } from 'vue' import { ref, watch } from 'vue'
import { getSchemeTree, getTestRecordInfo } from '@/api/cs-device-boot/planData' import { getSchemeTree } from '@/api/cs-device-boot/planData'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree } from 'element-plus'
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel' import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import { createLineTreeDecorators } from './lineTreeUtils'
defineOptions({ import { bootstrapWithTemplate } from './treeCommonUtils'
name: 'govern/schemeTree' import { createTreeFilterNode } from './treeFilterUtils'
})
defineOptions({ name: 'govern/schemeTree', inheritAttrs: false })
interface Props { interface Props {
template?: boolean template?: boolean
} }
const dictData = useDictData()
const props = withDefaults(defineProps<Props>(), {
template: false
})
const filterText = ref('')
watch(filterText, val => {
treRef.value!.filter(val)
})
const filterNode = (value: string, data: any, node: any) => { const props = withDefaults(defineProps<Props>(), { template: false })
if (!value) return true
// return data.name.includes(value) const emit = defineEmits(['init', 'checkChange', 'nodeChange', 'node-click', 'editNode', 'getChart', 'Policy'])
if (data.name) {
return chooseNode(value, data, node)
}
}
const chooseNode = (value: string, data: any, node: any) => {
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
}
/** 树形结构数据 */
const defaultProps = {
children: 'children',
label: 'name',
value: 'id'
}
const emit = defineEmits(['init', 'checkChange', 'nodeChange', 'editNode', 'getChart', 'Policy'])
const config = useConfig() const config = useConfig()
const tree = ref() const tree = ref<any[]>([])
const treRef = ref() const treRef = ref<InstanceType<typeof ElTree>>()
const id: any = ref(null) const filterText = ref('')
const treeData = ref({}) const id = ref<string | null>(null)
//获取方案树形数据 const planId = ref('')
const getTreeList = () => {
getSchemeTree().then(res => {
let arr: any[] = []
res.data.forEach((item: any) => { const defaultProps = { children: 'children', label: 'name', value: 'id' }
item.icon = 'el-icon-Menu' const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
item.color = config.getColorVal('elementUiPrimary') const filterNode = createTreeFilterNode()
item?.children.forEach((item2: any) => {
item2.icon = 'el-icon-Document' watch(filterText, val => treRef.value?.filter(val))
item2.color = config.getColorVal('elementUiPrimary')
arr.push(item2) function decorateSchemeTree(data: any[]): any[] {
}) const { primary, applyMeta } = decorators
const leaves: any[] = []
data.forEach(item => {
applyMeta(item, { icon: 'el-icon-Menu', color: primary() })
item.children?.forEach((child: any) => {
applyMeta(child, { icon: 'el-icon-Document', color: primary() })
leaves.push(child)
}) })
})
return leaves
}
function getTreeList() {
getSchemeTree().then(res => {
const leaves = decorateSchemeTree(res.data)
tree.value = res.data tree.value = res.data
nextTick(() => {
if (arr.length) { const node = id.value ? leaves.find(item => item.id == id.value) : leaves[0]
treRef.value.setCurrentKey(id.value || arr[0].id) if (!node) {
let list = id.value ? arr.find((item: any) => item.id == id.value) : arr[0] emit('init')
// 注册父组件事件 return
emit('init', { }
level: 2,
...list treRef.value?.setCurrentKey(node.id)
}) emit('init', { level: 2, ...node })
} else {
emit('init')
}
})
}) })
} }
//方案id const clickNode = (e: any) => {
const planId: any = ref('') planId.value = e?.children ? e.id : e.pid
const clickNode = (e: anyObj) => {
e?.children ? (planId.value = e.id) : (planId.value = e.pid)
id.value = e.id id.value = e.id
emit('nodeChange', e) emit('nodeChange', e)
emit('node-click', e)
} }
if (props.template) { bootstrapWithTemplate(
querySysExcel({ id: dictData.state.area[0]?.id }) props.template,
.then((res: any) => { getTreeList,
emit('Policy', res.data) () => querySysExcel({}),
getTreeList() data => emit('Policy', data)
}) )
.catch(err => {
getTreeList()
})
} else {
getTreeList()
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.cn-tree { .cn-tree {
flex-shrink: 0; flex-shrink: 0;

View File

@@ -1,105 +1,64 @@
<template> <template>
<Tree ref="treRef" :width="width" :data="tree" default-expand-all @checkedNodesChange="handleCheckedNodesChange"/> <Tree
ref="treRef"
:width="width"
:data="tree"
default-expand-all
@checkedNodesChange="handleCheckedNodesChange"
/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, nextTick, onMounted, defineProps } from 'vue' import { ref } from 'vue'
import Tree from '../select.vue' import Tree from '../select.vue'
import { getLineTree } from '@/api/cs-device-boot/csLedger' import { getLineTree } from '@/api/cs-device-boot/csLedger'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { getTemplateByDept } from '@/api/harmonic-boot/luckyexcel' import { getTemplateByDept } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
// const props = defineProps(['template']) import { createLineTreeDecorators, decorateLineTree } from './lineTreeUtils'
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
interface Props { interface Props {
template?: boolean template?: boolean
} }
const props = withDefaults(defineProps<Props>(), {
template: false const props = withDefaults(defineProps<Props>(), { template: false })
})
defineOptions({ defineOptions({ name: 'govern/selectTree' })
name: 'govern/deviceTree'
})
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy']) const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
const config = useConfig() const config = useConfig()
const tree = ref()
const dictData = useDictData() const dictData = useDictData()
const treRef = ref() const tree = ref<any[]>([])
const treRef = ref<InstanceType<typeof Tree>>()
const width = ref('') const width = ref('')
const info = () => { const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
const handleCheckedNodesChange = (nodes: any[]) => emit('checkChange', nodes)
async function loadTree() {
tree.value = [] tree.value = []
let arr3: any[] = [] const res = await getLineTree()
getLineTree().then(res => { const leaves = decorateLineTree(res.data, '1', decorators, { disableParents: false })
//治理设备 tree.value = res.data.filter((item: any) => item.name === '监测设备')
res.data.map((item: any) => {
if (item.name == '监测设备') { const node = leaves.monitor[0]
item.children.forEach((item: any) => { if (!node) {
item.icon = 'el-icon-HomeFilled' emit('init')
item.level = 1 return
item.color = config.getColorVal('elementUiPrimary') }
item.children.forEach((item2: any) => {
item2.icon = 'el-icon-List' await selectTreeNode(treRef.value, node, {
item2.level = 1 onSelect: selected => emit('init', { level: 2, ...selected })
item2.color = config.getColorVal('elementUiPrimary')
item2.children.forEach((item3: any) => {
item3.icon = 'el-icon-Platform'
item3.level = 1
item3.color =
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
item3.children.forEach((item4: any) => {
item4.icon = 'el-icon-Platform'
item4.color =
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
// item4.color = '#e26257 !important'
arr3.push(item4)
})
})
})
})
}
})
tree.value = res.data.filter(item => item.name == '监测设备')
nextTick(() => {
if (arr3.length) {
//初始化选中
treRef.value.treeRef.setCurrentKey(arr3[0].id)
// 注册父组件事件
emit('init', {
level: 2,
...arr3[0]
})
return
}
else {
emit('init')
return
}
})
}) })
} }
// 处理子组件传递的勾选节点变化,并转发给父组件 bootstrapWithTemplate(
const handleCheckedNodesChange = (nodes: any[]) => { props.template,
// 先给父组件 loadTree,
emit('checkChange', nodes) () => getTemplateByDept({ id: dictData.state.area[0]?.id }),
} data => emit('Policy', data)
)
if (props.template) {
getTemplateByDept({ id: dictData.state.area[0]?.id })
.then((res: any) => {
emit('Policy', res.data)
info()
})
.catch(err => {
info()
})
} else {
info()
}
onMounted(() => {})
</script> </script>

View File

@@ -0,0 +1,74 @@
import { nextTick } from 'vue'
import { createLineTreeDecorators, type LineTreeDecorators } from './lineTreeUtils'
export { createLineTreeDecorators, type LineTreeDecorators }
export function findNodeById(nodes: any[], id: string): any | null {
for (const node of nodes) {
if (node.id === id) return node
if (node.children?.length) {
const found = findNodeById(node.children, id)
if (found) return found
}
}
return null
}
export async function waitForSingleTreeRef(treRef: any, maxRetries = 20) {
for (let i = 0; i < maxRetries; i++) {
await nextTick()
if (treRef?.treeRef) return treRef.treeRef
await new Promise(resolve => setTimeout(resolve, 50))
}
return null
}
export async function selectTreeNode(
treRef: any,
node: any | undefined,
options?: { level?: number; onSelect?: (node: any) => void }
) {
if (!node) return false
const treeInstance = await waitForSingleTreeRef(treRef)
if (!treeInstance) return false
await nextTick()
expandTreeNodePath(treeInstance, node.id)
treeInstance.setCurrentKey(node.id)
options?.onSelect?.(node)
return true
}
/** 展开到目标节点的全部祖先,保证深层节点可见 */
export function expandTreeNodePath(treeInstance: any, nodeId: string) {
const target = treeInstance.getNode?.(nodeId)
if (!target) return
let parent = target.parent
while (parent && parent.level > 0) {
parent.expanded = true
parent = parent.parent
}
}
export function bootstrapWithTemplate(
template: boolean,
loadFn: () => void,
fetchTemplate: () => Promise<any>,
onPolicy: (data: any) => void
) {
if (template) {
fetchTemplate()
.then(res => {
onPolicy(res.data)
loadFn()
})
.catch(() => loadFn())
} else {
loadFn()
}
}
export function mapUserTreeNodes(data: any[], icon = 'el-icon-User', color = 'royalblue') {
return data.map(item => ({ ...item, icon, color }))
}

View File

@@ -0,0 +1,20 @@
/** 树节点搜索:匹配当前节点或任一祖先节点名称 */
export function matchTreeNodeName(value: string, data: any, node: any): boolean {
if (!value) return true
if (!data?.name) return false
if (data.name.indexOf(value) !== -1) return true
const level = node.level
if (level === 1) return false
let parentData = node.parent
for (let i = 0; i < level - 1; i++) {
if (parentData?.data?.name?.indexOf(value) !== -1) return true
parentData = parentData.parent
}
return false
}
export function createTreeFilterNode() {
return (value: string, data: any, node: any): boolean => matchTreeNodeName(value, data, node)
}

View File

@@ -1,41 +1,67 @@
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style='transition: all 0.3s; overflow: hidden;'> <div
<Icon v-show='menuCollapse' @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" class="cn-tree-root"
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 mt20 menu-collapse' :class="{ 'is-collapsed': menuCollapse, 'is-fill-height': props.fillHeight }"
style='cursor: pointer' /> :style="{ width: menuCollapse ? '40px' : props.width }"
<div class='cn-tree' :style='{ opacity: menuCollapse ? 0 : 1 }'> >
<div style='display: flex; align-items: center' class='mb10'> <!-- <Icon
<el-input maxlength="32" show-word-limit v-model.trim='filterText' placeholder='请输入内容' clearable> v-show="menuCollapse"
@click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
size="18px"
class="cn-tree-root__collapse-btn cn-tree-root__collapse-btn--float"
/> -->
<div class="cn-tree" :class="{ 'is-hidden': menuCollapse }">
<div class="cn-tree__toolbar">
<el-input maxlength="32" show-word-limit
v-model.trim="filterText"
placeholder="请输入内容"
clearable
class="cn-tree__search"
>
<template #prefix> <template #prefix>
<Icon name='el-icon-Search' style='font-size: 16px' /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
</el-input> </el-input>
<el-tooltip placement="bottom" :hide-after="0" v-if="props.showPush"> <el-tooltip v-if="props.showPush" placement="bottom" :hide-after="0" content="台账推送">
<template #content> <Icon
<span>台账推送</span> name="el-icon-Promotion"
</template> size="20px"
class="cn-tree__push-btn"
<Icon :style="{ color: config.getColorVal('elementUiPrimary') }"
name="el-icon-Promotion" @click="onAdd"
size="20" />
class="fold ml10 menu-collapse"
style="cursor: pointer;"
:style="{ color: config.getColorVal('elementUiPrimary') }"
@click="onAdd" />
</el-tooltip> </el-tooltip>
<!-- <Icon @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" v-else <!-- <Icon
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse' v-if="props.canExpand"
style='cursor: pointer' v-if='props.canExpand' /> --> @click="onMenuCollapse"
name="el-icon-Fold"
size="18px"
class="cn-tree__collapse-btn"
/> -->
</div> </div>
<el-tree :style="{ height: 'calc(100vh - 190px)' }" <el-tree
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current :default-expand-all="false" ref="treeRef"
@check-change="checkTreeNodeChange" :filter-node-method='filterNode' node-key='id' v-bind='$attrs'> :style="{ height: treeHeight }"
<template #default='{ node, data }'> :props="defaultProps"
<span class='custom-tree-node'> highlight-current
<Icon :name='data.icon' style='font-size: 16px' :style='{ color: data.color }' :default-expand-all="false"
v-if='data.icon' /> @check-change="checkTreeNodeChange"
<span style='margin-left: 4px'>{{ node.label }}</span> :filter-node-method="filterNode"
node-key="id"
v-bind="$attrs"
>
<template #default="{ node, data: nodeData }">
<span class="custom-tree-node">
<Icon
v-if="nodeData.icon"
:name="nodeData.icon"
style="font-size: 16px"
:style="{ color: nodeData.color }"
/>
<span class="custom-tree-node__label">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
@@ -43,120 +69,158 @@
</div> </div>
</template> </template>
<script lang='ts' setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree } from 'element-plus'
import { emit } from 'process'; import { ref, watch, computed } from 'vue'
import { ref, watch } from 'vue'
import { t } from 'vxe-table';
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { createTreeFilterNode } from './govern/treeFilterUtils'
defineOptions({ defineOptions({ name: 'govern/indexTree', inheritAttrs: false })
name: 'govern/tree'
})
interface Props { interface Props {
width?: string width?: string
canExpand?: boolean canExpand?: boolean
showPush?: boolean showPush?: boolean
/** 默认高度基准偏移100vh - baseOffset */
baseOffset?: number
/** 在 baseOffset 基础上额外减去的高度 */
height?: number
/** 自定义树高度,优先级最高 */
treeHeight?: string
/** 撑满父容器高度 */
fillHeight?: boolean
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
width: '280px', width: '280px',
canExpand: true, canExpand: true,
showPush: false showPush: false,
baseOffset: 190,
height: 0,
treeHeight: '',
fillHeight: false
}) })
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'changePointType'])
const config = useConfig() const config = useConfig()
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const filterText = ref('') const filterText = ref('')
const defaultProps = { const defaultProps = { label: 'name', value: 'id' }
label: 'name', const filterNode = createTreeFilterNode()
value: 'id'
} const SEARCH_BAR_HEIGHT = 42
const emit = defineEmits(['checkTreeNodeChange','onAdd'])
watch(filterText, val => { const treeHeight = computed(() => {
treeRef.value!.filter(val) if (props.treeHeight) return props.treeHeight
if (props.fillHeight) return `calc(100% - ${SEARCH_BAR_HEIGHT}px)`
return `calc(100vh - ${props.baseOffset}px - ${props.height}px)`
}) })
watch(filterText, val => treeRef.value?.filter(val))
const onMenuCollapse = () => { const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse) proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
} }
const filterNode = (value: string, data: any, node: any) => {
console.log(value, data, node, 'filterNode');
if (!value) return true
// return data.name.includes(value)
if (data.name) {
return chooseNode(value, data, node)
}
}
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符.
const chooseNode = (value: string, data: any, node: any) => {
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
}
const checkTreeNodeChange = () => { const checkTreeNodeChange = () => {
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes()) emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
} }
const onAdd = () => { const onAdd = () => emit('onAdd')
emit('onAdd')
}
const treeRef = ref<InstanceType<typeof ElTree>>() const treeRef = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef }) defineExpose({ treeRef })
</script> </script>
<style lang='scss' scoped> <style lang="scss" scoped>
.cn-tree { .cn-tree-root {
flex-shrink: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden;
height: 100%;
transition: width 0.3s;
box-sizing: border-box;
&.is-fill-height {
height: 100%;
}
&__collapse-btn {
color: var(--el-color-primary);
cursor: pointer;
flex-shrink: 0;
&--float {
margin: 20px 0 0 10px;
}
}
}
.cn-tree {
display: flex;
flex-direction: column;
flex: 1;
min-height: 0;
width: 100%;
box-sizing: border-box; box-sizing: border-box;
padding: 10px; padding: 10px;
height: 100%; transition: opacity 0.3s;
width: 100%;
&.is-hidden {
opacity: 0;
pointer-events: none;
}
&__toolbar {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 10px;
flex-shrink: 0;
}
&__search {
flex: 1;
min-width: 0;
}
&__push-btn,
&__collapse-btn {
color: var(--el-color-primary);
cursor: pointer;
flex-shrink: 0;
}
&__body {
flex: 1;
min-height: 0;
overflow: auto;
}
:deep(.el-tree) { :deep(.el-tree) {
border: 1px solid var(--el-border-color); border: 1px solid var(--el-border-color);
border-radius: 4px;
} }
:deep(.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content) { :deep(.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content) {
background-color: var(--el-color-primary-light-7); background-color: var(--el-color-primary-light-7);
} }
.menu-collapse {
color: var(--el-color-primary);
}
} }
.custom-tree-node { .custom-tree-node {
display: flex; display: flex;
align-items: center; align-items: center;
min-width: 0;
&__label {
margin-left: 4px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
} }
</style> </style>

View File

@@ -1,49 +1,60 @@
<!-- 设备监控使用折叠面板渲染多个tree --> <!-- 设备监控使用折叠面板渲染多个tree -->
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden"> <div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden">
<Icon <!-- <Icon
v-show="menuCollapse" v-show="menuCollapse"
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18px"
class="fold ml10 mt20 menu-collapse" class="fold ml10 mt20 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
v-if="route.path != '/admin/govern/reportCore/statistics/index'" v-if="route.path != '/admin/govern/reportCore/statistics/index'"
/> /> -->
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1, display: menuCollapse ? 'none' : '' }"> <div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1, display: menuCollapse ? 'none' : '' }">
<div style="display: flex; align-items: center" class="mb10"> <div style="display: flex; align-items: center" class="mb10">
<el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable> <el-input v-model.trim="filterText" placeholder="请输入内容" clearable>
<template #prepend>
<el-select v-model="treeType" @change="changeTreeType" style="min-width: 75px">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</template>
<template #prefix> <template #prefix>
<Icon name="el-icon-Search" style="font-size: 16px" /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
</el-input> </el-input>
<Icon <!-- <Icon
@click="onMenuCollapse" @click="onMenuCollapse"
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="menuCollapse ? 'unfold' : ''" :class="menuCollapse ? 'unfold' : ''"
size="18" size="18px"
class="fold ml10 menu-collapse" class="fold ml10 menu-collapse"
style="cursor: pointer" style="cursor: pointer"
v-if="props.canExpand && route.path != '/admin/govern/reportCore/statistics/index'" v-if="props.canExpand && route.path != '/admin/govern/reportCore/statistics/index'"
/> /> -->
</div> </div>
<el-collapse <el-collapse
:accordion="true" :accordion="true"
v-model.trim="activeName" v-model="activeName"
style="flex: 1; height: 100%" style="flex: 1; height: 100%"
@change="changeDevice" @change="changeDevice"
v-if="treeType == '1'"
v-loading="loading"
> >
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length != 0"> <el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length">
<el-select v-model.trim="process" clearable placeholder="请选择状态" class="mb10"> <el-select v-model="process" clearable placeholder="请选择状态" class="mb10">
<el-option label="功能调试" value="2"></el-option> <el-option label="功能调试" value="2" />
<el-option label="出厂调试" value="3"></el-option> <el-option label="出厂调试" value="3" />
<el-option label="正式投运" value="4"></el-option> <el-option label="正式投运" value="4" />
</el-select> </el-select>
<el-tree <el-tree
:style="{ height: bxsDeviceData.length != 0 ? 'calc(100vh - 380px)' : 'calc(100vh - 278px)' }" :style="{ height: governTreeHeight }"
ref="treeRef1" ref="treeRef1"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -54,22 +65,22 @@
style="overflow: auto" style="overflow: auto"
:default-expand-all="false" :default-expand-all="false"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0"> <el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length">
<el-tree <el-tree
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 238px)' }" :style="{ height: otherTreeHeight }"
ref="treeRef2" ref="treeRef2"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -80,22 +91,22 @@
v-bind="$attrs" v-bind="$attrs"
style="overflow: auto" style="overflow: auto"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
<el-collapse-item title="监测设备" name="2" v-if="yqfDeviceData.length != 0"> <el-collapse-item title="监测设备" name="2" v-if="yqfDeviceData.length">
<el-tree <el-tree
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 238px)' }" :style="{ height: otherTreeHeight }"
ref="treeRef3" ref="treeRef3"
:props="defaultProps" :props="defaultProps"
highlight-current highlight-current
@@ -106,13 +117,13 @@
v-bind="$attrs" v-bind="$attrs"
style="overflow: auto" style="overflow: auto"
> >
<template #default="{ node, data }"> <template #default="{ node, data: nodeData }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<Icon <Icon
:name="data.icon" :name="nodeData.icon"
style="font-size: 16px" style="font-size: 16px"
:style="{ color: data.color }" :style="{ color: nodeData.color }"
v-if="data.icon" v-if="nodeData.icon"
/> />
<span style="margin-left: 4px">{{ node.label }}</span> <span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
@@ -120,288 +131,253 @@
</el-tree> </el-tree>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
<div v-if="treeType == '2'" v-loading="loading">
<el-tree
:style="{ height: engineeringTreeHeight }"
class="pt10"
ref="treeRef4"
:props="defaultProps"
highlight-current
:filter-node-method="filterNode"
node-key="id"
v-bind="$attrs"
:data="props.data"
style="overflow: auto"
:default-expand-all="false"
>
<template #default="{ node, data: nodeData }">
<span class="custom-tree-node">
<Icon
:name="nodeData.icon"
style="font-size: 16px"
:style="{ color: nodeData.color }"
v-if="nodeData.icon"
/>
<span style="margin-left: 4px">{{ node.label }}</span>
</span>
</template>
</el-tree>
</div>
</div> </div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElTree } from 'element-plus' import { ElTree, type CollapseModelValue } from 'element-plus'
import { el, fa } from 'element-plus/es/locale' import { ref, watch, nextTick, computed } from 'vue'
import { ref, watch, defineEmits, onMounted, nextTick, computed } from 'vue'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import { collectDeviceLeaves } from './govern/lineTreeUtils'
defineOptions({ defineOptions({
name: 'govern/tree' name: 'govern/point',
inheritAttrs: false
}) })
const emit = defineEmits(['changePointType'])
const emit = defineEmits(['changePointType', 'changeTreeType'])
interface Props { interface Props {
width?: string width?: string
canExpand?: boolean canExpand?: boolean
type?: string type?: string
data?: any data?: any[]
height?: number
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
width: '100%', width: '100%',
canExpand: true, canExpand: true,
type: '', type: '',
data: [] data: () => [],
height: 0
}) })
const process = ref('')
const route = useRoute() const route = useRoute()
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const treeType = ref('2')
const options = [
{ label: '工程', value: '2' },
{ label: '设备', value: '1' },
]
const menuCollapse = ref(false) const menuCollapse = ref(false)
const activeName = ref('0') const activeName = ref('0')
const filterText = ref('') const filterText = ref('')
const defaultProps = { const process = ref('')
label: 'name', const loading = ref(false)
value: 'id'
} const defaultProps = { label: 'name', value: 'id' }
//治理设备数据
const zlDeviceData = ref<any>([]) const zlDeviceData = ref<any[]>([])
const zlDevList = ref<any>([]) const zlDevList = ref<any[]>([])
//便携式设备数据 const bxsDeviceData = ref<any[]>([])
const bxsDeviceData = ref<any>([]) const yqfDeviceData = ref<any[]>([])
//监测设备数据
const yqfDeviceData = ref<any>([]) const governTreeHeight = computed(() => `calc(100vh - 380px - ${props.height}px)`)
watch( const otherTreeHeight = computed(() =>
() => props.data, zlDeviceData.value.length ? `calc(100vh - 340px - ${props.height}px)` : `calc(100vh - 238px - ${props.height}px)`
(val, oldVal) => {
if (val && val.length != 0) {
val.map((item: any) => {
if (item.name == '治理设备') {
zlDeviceData.value = []
item.children.map((vv: any) => {
zlDeviceData.value.push(vv)
})
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
} else if (item.name == '便携式设备') {
bxsDeviceData.value = []
item.children.map((vv: any) => {
bxsDeviceData.value.push(vv)
})
} else if (item.name == '监测设备') {
yqfDeviceData.value = []
item.children.map((vv: any) => {
yqfDeviceData.value.push(vv)
})
}
})
}
},
{
immediate: true,
deep: true
}
) )
const engineeringTreeHeight = computed(() => `calc(100vh - 188px - ${props.height}px)`)
watch(filterText, val => { const treeRef1 = ref<InstanceType<typeof ElTree>>()
if (activeName.value == '0') { const treeRef2 = ref<InstanceType<typeof ElTree>>()
treeRef1.value!.filter(val) const treeRef3 = ref<InstanceType<typeof ElTree>>()
} else if (activeName.value == '1') { const treeRef4 = ref<InstanceType<typeof ElTree>>()
treeRef2.value!.filter(val)
} else {
treeRef3.value!.filter(val)
}
})
watch(process, val => {
if (val == '' || val == undefined) {
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
} else {
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
}
setTimeout(() => { defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
changeDevice(activeName.value)
}, 0)
})
const changeDevice = (val: any) => { function splitTreeData(val: any[]) {
console.log('🚀 ~ changeDevice ~ val:', val) zlDeviceData.value = []
bxsDeviceData.value = []
yqfDeviceData.value = []
let arr1: any = [] val.forEach(item => {
//zlDeviceData if (item.name === '治理设备') {
zlDevList.value.forEach((item: any) => { zlDeviceData.value = item.children ?? []
item.children.forEach((item2: any) => { } else if (item.name === '便携式设备') {
item2.children.forEach((item3: any) => { bxsDeviceData.value = item.children ?? []
item3.children.forEach((item4: any) => { } else if (item.name === '监测设备') {
arr1.push(item4) yqfDeviceData.value = item.children ?? []
}) }
})
})
}) })
let arr2: any = []
bxsDeviceData.value.forEach((item: any) => { zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
item.children.forEach((item2: any) => {
arr2.push(item2)
})
})
let arr3: any = []
yqfDeviceData.value.forEach((item: any) => {
item.children.forEach((item2: any) => {
item2.children.forEach((item3: any) => {
item3.children.forEach((item4: any) => {
arr3.push(item4)
})
})
})
})
activeName.value = val
if (val == '0') {
arr2.map((item: any) => {
item.checked = false
})
emit('changePointType', activeName.value, arr1[0])
setTimeout(() => {
treeRef1.value?.setCurrentKey(arr1[0]?.id)
}, 100)
}
if (val == '1') {
arr1.map((item: any) => {
item.checked = false
})
emit('changePointType', activeName.value, arr2[0])
setTimeout(() => {
treeRef2.value?.setCurrentKey(arr2[0]?.id)
}, 100)
}
if (val == '2') {
arr3.map((item: any) => {
item.checked = false
})
emit('changePointType', activeName.value, arr3[0])
setTimeout(() => {
treeRef3.value?.setCurrentKey(arr3[0]?.id)
}, 100)
}
// if(activeName.value){
// emit('changePointType', activeName.value)
// }
}
const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
}
const filterNode = (value: string, data: any, node: any) => {
if (!value) return true
// return data.name.includes(value)
if (data.name) {
return chooseNode(value, data, node)
}
} }
function filterProcess(nodes: any) { /** 测点树专用level=2 按 process 过滤,其余层级保留有子节点或匹配的节点 */
if (process.value == '') { function filterProcess(nodes: any[]): any[] {
return nodes if (!process.value) return nodes
}
return nodes return nodes
.map(node => { .map(node => {
// 递归处理子节点
const children = node.children ? filterProcess(node.children) : [] const children = node.children ? filterProcess(node.children) : []
// 对于装置层级level=2只保留 process 值匹配的节点
if (node.level === 2) { if (node.level === 2) {
if (node.process == process.value) { if (node.process == process.value) {
return { return { ...node, children }
...node,
children: children
}
} }
return null return null
} }
// 对于其他节点: if (children.length > 0 || node.process == process.value || !node.children?.length) {
// 1. 如果有满足条件的子节点则保留 return { ...node, children }
// 2. 如果本身 process 值匹配则保留
// 3. 如果是叶子节点也保留(监测点通常没有子节点)
if (children.length > 0 || node.process == process.value || !node.children || node.children.length === 0) {
return {
...node,
children: children
}
} }
return null return null
}) })
.filter(Boolean) // 移除null节点 .filter(Boolean)
} }
// function filterProcess(nodes: any) { function getActiveTreeRef() {
// if (process.value == '') { if (treeType.value === '2') return treeRef4.value
// return nodes if (activeName.value === '0') return treeRef1.value
// } if (activeName.value === '1') return treeRef2.value
// return nodes return treeRef3.value
// .map(node => { }
// // 递归处理子节点
// const children = node.children ? filterProcess(node.children) : []
// // 如果当前节点的process=4或者有子节点满足条件则保留当前节点 function resolveActiveName() {
if (zlDeviceData.value.length) return '0'
if (bxsDeviceData.value.length) return '1'
if (yqfDeviceData.value.length) return '2'
return ''
}
// if (node.process == process.value || children.length > 0) { function selectPointPanel(panelName: string, node?: any) {
// return { if (!node) return
// ...node, emit('changePointType', panelName, node)
// children: node.children nextTick(() => {
// } getActiveTreeRef()?.setCurrentKey(node.id)
// } })
}
// // 否则过滤掉当前节点 const changeDevice = (val: CollapseModelValue) => {
// return null if (Array.isArray(val) || val == null || val === '') return
// }) const panelName = String(val)
// .filter(Boolean) // 移除null节点 const { govern, portable, monitor } = collectDeviceLeaves(
// } zlDevList.value,
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符. bxsDeviceData.value,
const chooseNode = (value: string, data: any, node: any) => { yqfDeviceData.value
if (data.name.indexOf(value) !== -1) { )
return true
const panelMap: Record<string, { nodes: any[]; clearOthers: any[][] }> = {
'0': { nodes: govern, clearOthers: [portable, monitor] },
'1': { nodes: portable, clearOthers: [govern, monitor] },
'2': { nodes: monitor, clearOthers: [govern, portable] }
} }
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了 const panel = panelMap[panelName]
if (level === 1) { if (!panel) return
return false
panel.clearOthers.forEach(list => list.forEach(item => (item.checked = false)))
selectPointPanel(panelName, panel.nodes[0])
}
const setActiveName = () => {
activeName.value = resolveActiveName()
if (activeName.value) {
nextTick(() => changeDevice(activeName.value))
} }
// 先取当前节点的父节点 }
let parentData = node.parent
// 遍历当前节点的父节点 watch(
let index = 0 () => props.data,
while (index < level - 1) { val => {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤 if (!val?.length) return
if (parentData.data.name.indexOf(value) !== -1) { splitTreeData(val)
return true if (treeType.value === '1') {
nextTick(() => setActiveName())
} }
// 否则的话再往上一层做匹配 },
parentData = parentData.parent { immediate: true, deep: true }
index++ )
watch(filterText, val => {
getActiveTreeRef()?.filter(val)
})
watch(process, () => {
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
if (activeName.value === '0') {
nextTick(() => changeDevice(activeName.value))
}
})
const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
}
const filterNode = (value: string, data: any, node: any): boolean => {
if (!value) return true
if (!data.name) return false
return chooseNode(value, data, node)
}
const chooseNode = (value: string, data: any, node: any): boolean => {
if (data.name.indexOf(value) !== -1) return true
const level = node.level
if (level === 1) return false
let parentData = node.parent
for (let i = 0; i < level - 1; i++) {
if (parentData?.data?.name?.indexOf(value) !== -1) return true
parentData = parentData.parent
} }
// 没匹配到返回false
return false return false
} }
//治理
const treeRef1 = ref<InstanceType<typeof ElTree>>() const changeTreeType = (val: string) => {
//便携式 loading.value = true
const treeRef2 = ref<InstanceType<typeof ElTree>>() emit('changeTreeType', val)
//在线 if (val === '1') {
const treeRef3 = ref<InstanceType<typeof ElTree>>() nextTick(() => setActiveName())
defineExpose({ treeRef1, treeRef2, treeRef3 }) }
onMounted(() => {
setTimeout(() => { setTimeout(() => {
if (zlDeviceData.value.length != 0) { loading.value = false
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value))) }, 300)
activeName.value = '0' }
}
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length != 0) {
activeName.value = '1'
}
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length === 0) {
activeName.value = '2'
}
if (!zlDeviceData.value && !bxsDeviceData.value) {
activeName.value = '2'
}
nextTick(() => {
changeDevice(activeName.value)
})
}, 500)
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@@ -432,4 +408,7 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
} }
:deep(.el-input-group__prepend) {
background-color: var(--el-fill-color-blank);
}
</style> </style>

View File

@@ -1,36 +1,45 @@
<template> <template>
<div :style="{ width: menuCollapse ? '40px' : props.width }" style='transition: all 0.3s; overflow: hidden;'> <div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden">
<Icon v-show='menuCollapse' @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" <!-- <Icon
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 mt20 menu-collapse' v-show="menuCollapse"
style='cursor: pointer' /> @click="onMenuCollapse"
<div class='cn-tree' :style='{ opacity: menuCollapse ? 0 : 1 }'> :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
<div style='display: flex; align-items: center' class='mb10'> :class="menuCollapse ? 'unfold' : ''"
<el-input maxlength="32" show-word-limit v-model.trim='filterText' placeholder='请输入内容' clearable> size="18px"
class="fold ml10 mt20 menu-collapse"
style="cursor: pointer"
/> -->
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
<div style="display: flex; align-items: center" class="mb10">
<el-input maxlength="32" show-word-limit v-model.trim="filterText" placeholder="请输入内容" clearable>
<template #prefix> <template #prefix>
<Icon name='el-icon-Search' style='font-size: 16px' /> <Icon name="el-icon-Search" style="font-size: 16px" />
</template> </template>
</el-input> </el-input>
</div> </div>
<el-tree <el-tree
:style="{ height: 'calc(100vh)' }" :style="{ height: 'calc(100vh - 120px)' }"
style='overflow: auto;' style="overflow: auto"
ref='treeRef' ref="treeRef"
:props='defaultProps' :props="defaultProps"
highlight-current highlight-current
:filter-node-method='filterNode' :filter-node-method="filterNode"
node-key='id' node-key="id"
show-checkbox show-checkbox
@check="handleCheckChange" @check="handleCheckChange"
@node-click="handleNodeClick"
:default-checked-keys="defaultCheckedKeys" :default-checked-keys="defaultCheckedKeys"
v-bind='$attrs' v-bind="$attrs"
:default-expand-all="false" :default-expand-all="false"
> >
<template #default='{ node, data }'> <template #default="{ node, data: nodeData }">
<span class='custom-tree-node'> <span class="custom-tree-node">
<Icon :name='data.icon' style='font-size: 16px' :style='{ color: data.color }' <Icon
v-if='data.icon' /> :name="nodeData.icon"
<span style='margin-left: 4px'>{{ node.label }}</span> style="font-size: 16px"
:style="{ color: nodeData.color }"
v-if="nodeData.icon"
/>
<span style="margin-left: 4px">{{ node.label }}</span>
</span> </span>
</template> </template>
</el-tree> </el-tree>
@@ -38,15 +47,14 @@
</div> </div>
</template> </template>
<script lang='ts' setup> <script lang="ts" setup>
import useCurrentInstance from '@/utils/useCurrentInstance' import useCurrentInstance from '@/utils/useCurrentInstance'
import { ElMessage, ElTree } from 'element-plus' import { ElMessage, ElTree } from 'element-plus'
import { emit } from 'process';
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { createTreeFilterNode } from './govern/treeFilterUtils'
import { isLineTreeLeaf } from './govern/lineTreeUtils'
defineOptions({ defineOptions({ name: 'govern/select', inheritAttrs: false })
name: 'govern/tree'
})
interface Props { interface Props {
width?: string width?: string
@@ -57,174 +65,67 @@ const props = withDefaults(defineProps<Props>(), {
width: '280px', width: '280px',
canExpand: true canExpand: true
}) })
const emit = defineEmits(['changePointType', 'checkedNodesChange'])
const { proxy } = useCurrentInstance() const { proxy } = useCurrentInstance()
const menuCollapse = ref(false) const menuCollapse = ref(false)
const filterText = ref('') const filterText = ref('')
const defaultProps = { const defaultProps = { label: 'name', value: 'id' }
label: 'name', const filterNode = createTreeFilterNode()
value: 'id' const checkedNodes = ref<any[]>([])
} const defaultCheckedKeys = ref<string[]>([])
const emit = defineEmits(['changePointType', 'checkedNodesChange']) const MAX_CHECK = 5
const isMonitorLeaf = (node: any) => isLineTreeLeaf(node)
watch(filterText, val => treeRef.value?.filter(val))
watch(filterText, val => {
treeRef.value!.filter(val)
})
const onMenuCollapse = () => { const onMenuCollapse = () => {
menuCollapse.value = !menuCollapse.value menuCollapse.value = !menuCollapse.value
proxy.eventBus.emit('cnTreeCollapse', menuCollapse) proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
} }
const filterNode = (value: string, data: any, node: any) => {
if (!value) return true
// return data.name.includes(value)
if (data.name) {
return chooseNode(value, data, node) const handleCheckChange = (_data: any, checkInfo: any) => {
} const monitoringPointNodes = (checkInfo.checkedNodes as any[]).filter(isMonitorLeaf)
}
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配则返回该节点以及其下的所有子节点如果参数是子节点则返回该节点的父节点。name是中文字符enName是英文字符. if (monitoringPointNodes.length > MAX_CHECK) {
const chooseNode = (value: string, data: any, node: any) => { const previousCheckedNodes = checkedNodes.value
if (data.name.indexOf(value) !== -1) {
return true
}
const level = node.level
// 如果传入的节点本身就是一级节点就不用校验了
if (level === 1) {
return false
}
// 先取当前节点的父节点
let parentData = node.parent
// 遍历当前节点的父节点
let index = 0
while (index < level - 1) {
// 如果匹配到直接返回此处name值是中文字符enName是英文字符。判断匹配中英文过滤
if (parentData.data.name.indexOf(value) !== -1) {
return true
}
// 否则的话再往上一层做匹配
parentData = parentData.parent
index++
}
// 没匹配到返回false
return false
}
// 处理节点点击事件
const handleNodeClick = (data: any, node: any, event: any) => {
}
// 存储所有勾选的节点
const checkedNodes = ref<any[]>([])
const defaultCheckedKeys = ref<string[]>([])
// 处理节点勾选变化
const handleCheckChange = (data: any, checkInfo: any) => {
const { checkedNodes: nodes } = checkInfo
// 过滤出监测点层级(level=3)的节点
const monitoringPointNodes = nodes.filter((node: any) => {
return node.level === 3
})
// 限制最多只能勾选5个监测点
if (monitoringPointNodes.length > 5) {
// 获取之前选中的节点
const previousCheckedNodes = checkedNodes.value || []
// 计算新增的节点
const newNodes = monitoringPointNodes.filter( const newNodes = monitoringPointNodes.filter(
(node: any) => !previousCheckedNodes.some((prev: any) => prev.id === node.id) node => !previousCheckedNodes.some(prev => prev.id === node.id)
) )
// 如果是从父级勾选导致超过限制,保留前几个直到达到限制数量
if (newNodes.length > 0) { if (newNodes.length > 0) {
const allowedNewCount = 5 - previousCheckedNodes.length const allowedNewCount = MAX_CHECK - previousCheckedNodes.length
if (allowedNewCount > 0) { if (allowedNewCount > 0) {
// 允许添加allowedNewCount个新节点 const finalNodes = [...previousCheckedNodes, ...newNodes.slice(0, allowedNewCount)]
const allowedNewNodes = newNodes.slice(0, allowedNewCount)
const finalNodes = [...previousCheckedNodes, ...allowedNewNodes]
checkedNodes.value = finalNodes checkedNodes.value = finalNodes
// 设置树的勾选状态为正确的节点
treeRef.value?.setCheckedNodes(finalNodes) treeRef.value?.setCheckedNodes(finalNodes)
// 将勾选的监测点节点暴露出去
emit('checkedNodesChange', finalNodes) emit('checkedNodesChange', finalNodes)
// 更新节点的可勾选状态
updateNodeCheckStatus(finalNodes.length) updateNodeCheckStatus(finalNodes.length)
if (monitoringPointNodes.length > MAX_CHECK) {
// 只有在真正超过5个时才提示警告 ElMessage.warning(`最多只能选择${MAX_CHECK}个监测点`)
if (monitoringPointNodes.length > 5) {
ElMessage.warning('最多只能选择5个监测点')
} }
return return
} }
} }
// 其他情况回滚到之前的状态 ElMessage.warning(`最多只能选择${MAX_CHECK}个监测点`)
ElMessage.warning('最多只能选择5个监测点')
treeRef.value?.setCheckedNodes(checkedNodes.value) treeRef.value?.setCheckedNodes(checkedNodes.value)
return return
} }
checkedNodes.value = monitoringPointNodes checkedNodes.value = monitoringPointNodes
// 将勾选的监测点节点暴露出去
emit('checkedNodesChange', monitoringPointNodes) emit('checkedNodesChange', monitoringPointNodes)
// 更新节点的可勾选状态
updateNodeCheckStatus(monitoringPointNodes.length)
}
// 处理节点勾选变化
const handleCheckChange2 = (data: any, checkInfo: any) => {
const { checkedNodes: nodes } = checkInfo
// 过滤出监测点层级(level=3)的节点
const monitoringPointNodes = nodes.filter((node: any) => {
// 监测点节点通常具有 comFlag 属性或其他标识
return node.level === 3
})
// 限制最多只能勾选5个监测点
if (monitoringPointNodes.length > 5) {
ElMessage.warning('最多只能选择5个监测点')
// 保持之前勾选的状态
treeRef.value?.setCheckedNodes(checkedNodes.value)
return
}
checkedNodes.value = monitoringPointNodes
// 将勾选的监测点节点暴露出去
emit('checkedNodesChange', monitoringPointNodes)
// 更新节点的可勾选状态
updateNodeCheckStatus(monitoringPointNodes.length) updateNodeCheckStatus(monitoringPointNodes.length)
} }
// 更新节点的可勾选状态
const updateNodeCheckStatus = (currentCount: number) => { const updateNodeCheckStatus = (currentCount: number) => {
if (!treeRef.value) return if (!treeRef.value) return
const isMaxSelected = currentCount >= MAX_CHECK
// 如果已经选了5个则禁用其他未选中的监测点节点 treeRef.value.store._getAllNodes().forEach((node: any) => {
const isMaxSelected = currentCount >= 5 if (isMonitorLeaf(node.data)) {
node.data.disabled = isMaxSelected && !node.checked
// 获取所有节点并更新状态
const allNodes = treeRef.value.store._getAllNodes()
allNodes.forEach((node: any) => {
if (node.level === 3) { // 监测点层级
// 如果已达到最大数量且该节点未被选中,则禁用勾选
if (isMaxSelected && !node.data.checked) {
node.data.disabled = true
} else {
node.data.disabled = false
}
} }
}) })
} }
@@ -233,8 +134,7 @@ const treeRef = ref<InstanceType<typeof ElTree>>()
defineExpose({ treeRef }) defineExpose({ treeRef })
</script> </script>
<style lang="scss" scoped>
<style lang='scss' scoped>
.cn-tree { .cn-tree {
flex-shrink: 0; flex-shrink: 0;
display: flex; display: flex;

View File

@@ -63,7 +63,7 @@
:model-value="configStore.getColorVal('menuTopBarBackground')" /> :model-value="configStore.getColorVal('menuTopBarBackground')" />
</el-form-item> </el-form-item>
<el-form-item label="侧边菜单宽度(展开时)"> <el-form-item label="侧边菜单宽度(展开时)">
<el-input maxlength="32" show-word-limit @input="onCommitState($event, 'menuWidth')" <el-input maxlength="32" show-word-limit @input="onCommitState($event, 'menuWidth')"
type="number" :step="10" :model-value="configStore.layout.menuWidth"> type="number" :step="10" :model-value="configStore.layout.menuWidth">
<template #append>px</template> <template #append>px</template>
</el-input> </el-input>

View File

@@ -1,79 +1,79 @@
<template> <template>
<div class="layout-logo"> <div class="layout-logo">
<img v-if="!config.layout.menuCollapse" class="logo-img" :src="getTheme.logoUrl" /> <img v-if="!config.layout.menuCollapse && getTheme.logoUrl" class="logo-img" :src="getTheme.logoUrl" />
<!-- <div--> <!-- <div-->
<!-- v-if="!config.layout.menuCollapse"--> <!-- v-if="!config.layout.menuCollapse"-->
<!-- :style="{ color: config.getColorVal('menuActiveColor') }"--> <!-- :style="{ color: config.getColorVal('menuActiveColor') }"-->
<!-- class="website-name"--> <!-- class="website-name"-->
<!-- >--> <!-- >-->
<!-- 灿能--> <!-- 灿能-->
<!-- </div>--> <!-- </div>-->
<Icon <Icon
v-if="config.layout.layoutMode != 'Streamline'" v-if="config.layout.layoutMode != 'Streamline'"
@click="onMenuCollapse" @click="onMenuCollapse"
:name="config.layout.menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" :name="config.layout.menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
:class="config.layout.menuCollapse ? 'unfold' : ''" :class="config.layout.menuCollapse ? 'unfold' : ''"
:color="config.getColorVal('menuActiveColor')" :color="config.getColorVal('menuActiveColor')"
style="margin: 15px;" style="margin: 15px;"
size="18" size="18"
class="fold" class="fold"
/> />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import { closeShade } from '@/utils/pageShade' import { closeShade } from '@/utils/pageShade'
import { Session } from '@/utils/storage' import { getStoredTheme } from '@/utils/storage'
import { setNavTabsWidth } from '@/utils/layout' import { setNavTabsWidth } from '@/utils/layout'
const config = useConfig() const config = useConfig()
const getTheme = JSON.parse(window.localStorage.getItem('getTheme') as string) const getTheme = getStoredTheme()
const onMenuCollapse = function () { const onMenuCollapse = function () {
if (config.layout.shrink && !config.layout.menuCollapse) { if (config.layout.shrink && !config.layout.menuCollapse) {
closeShade() closeShade()
} }
config.setLayout('menuCollapse', !config.layout.menuCollapse) config.setLayout('menuCollapse', !config.layout.menuCollapse)
// 等待侧边栏动画结束后重新计算导航栏宽度 // 等待侧边栏动画结束后重新计算导航栏宽度
setTimeout(() => { setTimeout(() => {
setNavTabsWidth() setNavTabsWidth()
}, 350) }, 350)
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.layout-logo { .layout-logo {
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
box-sizing: border-box; box-sizing: border-box;
padding: 5px 10px; padding: 5px 10px;
background: v-bind( background: v-bind(
'config.layout.layoutMode != "Streamline" ? config.getColorVal("menuTopBarBackground"):"transparent"' 'config.layout.layoutMode != "Streamline" ? config.getColorVal("menuTopBarBackground"):"transparent"'
); );
} }
.logo-img { .logo-img {
height: 50px; height: 50px;
object-fit: cover; object-fit: cover;
margin: auto; margin: auto;
} }
.website-name { .website-name {
display: block; display: block;
width: 180px; width: 180px;
padding-left: 4px; padding-left: 4px;
font-size: var(--el-font-size-extra-large); font-size: var(--el-font-size-extra-large);
font-weight: 600; font-weight: 600;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.fold { .fold {
margin-left: auto; margin-left: auto;
} }
.unfold { .unfold {
margin: 0 auto; margin: 0 auto;
} }
</style> </style>

View File

@@ -1,111 +1,112 @@
<template> <template>
<div class="nav-bar"> <div class="nav-bar">
<div v-if="config.layout.shrink && config.layout.menuCollapse" class="unfold"> <div v-if="config.layout.shrink && config.layout.menuCollapse" class="unfold">
<Icon @click="onMenuCollapse" name="fa fa-indent" :color="config.getColorVal('menuActiveColor')" <!-- <Icon @click="onMenuCollapse" name="fa fa-indent" :color="config.getColorVal('menuActiveColor')"
size="18" /> size="18" /> -->
</div> </div>
<span class="nav-bar-title">{{ getTheme.name }} <span style="font-size: 14px;" v-if="Version?.versionName"> <span class="nav-bar-title">{{ themeName }} <span style="font-size: 14px;" v-if="Version?.versionName">
({{ Version?.versionName }}) ({{ Version?.versionName }})
</span></span> </span></span>
<NavMenus /> <NavMenus />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref } from 'vue'
import { useConfig } from '@/stores/config' import { useConfig } from '@/stores/config'
import NavTabs from '@/layouts/admin/components/navBar/tabs.vue' import NavTabs from '@/layouts/admin/components/navBar/tabs.vue'
import NavMenus from '../navMenus.vue' import NavMenus from '../navMenus.vue'
import { showShade } from '@/utils/pageShade' import { showShade } from '@/utils/pageShade'
import { onMounted } from 'vue' import { onMounted } from 'vue'
import { getLastData } from '@/api/systerm' import { getLastData } from '@/api/systerm'
const config = useConfig() import { getStoredThemeName } from '@/utils/storage'
const getTheme = JSON.parse(window.localStorage.getItem('getTheme') as string) const config = useConfig()
const Version: any = ref({}) const themeName = getStoredThemeName()
const onMenuCollapse = () => { const Version: any = ref({})
showShade('ba-aside-menu-shade', () => { const onMenuCollapse = () => {
config.setLayout('menuCollapse', true) showShade('ba-aside-menu-shade', () => {
}) config.setLayout('menuCollapse', true)
config.setLayout('menuCollapse', false) })
} config.setLayout('menuCollapse', false)
onMounted(() => { }
getLastData({ versionType: 'WEB' }).then(res => { onMounted(() => {
Version.value = res.data getLastData({ versionType: 'WEB' }).then(res => {
Version.value = res.data
})
document.title = getTheme.name })
}) document.title = themeName
</script> })
</script>
<style scoped lang="scss">
.nav-bar { <style scoped lang="scss">
display: flex; .nav-bar {
align-items: center; display: flex;
height: 60px; align-items: center;
width: 100%; height: 60px;
background-color: v-bind('config.getColorVal("headerBarBackground")'); width: 100%;
background-color: v-bind('config.getColorVal("headerBarBackground")');
.nav-bar-title {
color: v-bind('config.getColorVal("headerBarTabColor")'); .nav-bar-title {
font-size: 24px; color: v-bind('config.getColorVal("headerBarTabColor")');
margin-left: 10px; font-size: 24px;
font-weight: 700; margin-left: 10px;
} font-weight: 700;
}
:deep(.nav-tabs) {
display: flex; :deep(.nav-tabs) {
height: 100%; display: flex;
position: relative; height: 100%;
position: relative;
.ba-nav-tab {
display: flex; .ba-nav-tab {
align-items: center; display: flex;
justify-content: center; align-items: center;
padding: 0 20px; justify-content: center;
cursor: pointer; padding: 0 20px;
z-index: 1; cursor: pointer;
height: 100%; z-index: 1;
user-select: none; height: 100%;
color: v-bind('config.getColorVal("headerBarTabColor")'); user-select: none;
transition: all 0.2s; color: v-bind('config.getColorVal("headerBarTabColor")');
-webkit-transition: all 0.2s; transition: all 0.2s;
-webkit-transition: all 0.2s;
.close-icon {
padding: 2px; .close-icon {
margin: 2px 0 0 4px; padding: 2px;
color: v-bind('config.getColorVal("headerBarTabColor")') !important; margin: 2px 0 0 4px;
} color: v-bind('config.getColorVal("headerBarTabColor")') !important;
}
&.active {
color: v-bind('config.getColorVal("headerBarTabActiveColor")'); &.active {
color: v-bind('config.getColorVal("headerBarTabActiveColor")');
.close-icon {
color: v-bind('config.getColorVal("headerBarTabActiveColor")') !important; .close-icon {
} color: v-bind('config.getColorVal("headerBarTabActiveColor")') !important;
} }
}
&:hover {
color: v-bind('config.getColorVal("headerBarTabActiveColor")'); &:hover {
background-color: v-bind('config.getColorVal("headerBarHoverBackground")'); color: v-bind('config.getColorVal("headerBarTabActiveColor")');
background-color: v-bind('config.getColorVal("headerBarHoverBackground")');
.close-icon {
color: v-bind('config.getColorVal("headerBarTabActiveColor")') !important; .close-icon {
} color: v-bind('config.getColorVal("headerBarTabActiveColor")') !important;
} }
} }
}
.nav-tabs-active-box {
position: absolute; .nav-tabs-active-box {
height: 50px; position: absolute;
background-color: v-bind('config.getColorVal("headerBarTabActiveBackground")'); height: 50px;
transition: all 0.2s; background-color: v-bind('config.getColorVal("headerBarTabActiveBackground")');
-webkit-transition: all 0.2s; transition: all 0.2s;
} -webkit-transition: all 0.2s;
} }
} }
}
.unfold {
align-self: center; .unfold {
padding-left: var(--ba-main-space); align-self: center;
} padding-left: var(--ba-main-space);
</style> }
</style>

View File

@@ -116,11 +116,11 @@ const handleCommand = async (key: string) => {
popupPwd.value.open() popupPwd.value.open()
break break
case 'layout': case 'layout':
await window.location.reload() navTabs.closeTabs()
window.localStorage.clear()
adminInfo.reset()
setTimeout(() => { setTimeout(() => {
navTabs.closeTabs() window.location.reload()
window.localStorage.clear()
adminInfo.reset()
router.push({ name: 'login' }) router.push({ name: 'login' })
}, 0) }, 0)
break break
@@ -231,9 +231,11 @@ const handleCommand = async (key: string) => {
0% { 0% {
transform: scale(0); transform: scale(0);
} }
80% { 80% {
transform: scale(1.2); transform: scale(1.2);
} }
100% { 100% {
transform: scale(1); transform: scale(1);
} }

View File

@@ -1,51 +1,51 @@
<template> <template>
<el-dialog draggable width="600px" v-model.trim="dialogVisible" :title="title"> <el-dialog draggable width="500px" v-model.trim="dialogVisible" :title="title">
<el-form :inline="false" :model="form" label-width="auto" class="form-one"> <el-form :inline="false" :model="form" label-width="auto" class="form-one">
<el-form-item label="用户名称:"> <el-form-item label="用户名称:">
<el-input v-model.trim="form.name" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.name" :disabled="true"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="登录名称:" class="top"> <el-form-item label="登录名称:" class="top">
<el-input v-model.trim="form.loginName" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.loginName" :disabled="true"></el-input>
</el-form-item> </el-form-item>
<!-- <el-form-item label="归属部门名称:" class="top"> <!-- <el-form-item label="归属部门名称:" class="top">
<el-input v-model.trim="form.deptName" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.deptName" :disabled="true"></el-input>
</el-form-item> --> </el-form-item> -->
<el-form-item label="拥有的角色:" class="top"> <el-form-item label="拥有的角色:" class="top">
<el-input v-model.trim="form.role" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.role" :disabled="true"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="电话号码:" class="top"> <el-form-item label="电话号码:" class="top">
<el-input v-model.trim="form.phone" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.phone" :disabled="true"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="电子邮箱:" class="top"> <el-form-item label="电子邮箱:" class="top">
<el-input v-model.trim="form.email" :disabled="true"></el-input> <el-input maxlength="32" show-word-limit v-model.trim="form.email" :disabled="true"></el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-dialog> </el-dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, inject } from 'vue' import { ref, inject } from 'vue'
import { reactive } from 'vue' import { reactive } from 'vue'
import { useAdminInfo } from '@/stores/adminInfo' import { useAdminInfo } from '@/stores/adminInfo'
const dialogVisible = ref(false) const dialogVisible = ref(false)
const title = ref('用户信息') const title = ref('用户信息')
const adminInfo = useAdminInfo() const adminInfo = useAdminInfo()
const formRef = ref() const formRef = ref()
const form = reactive({ const form = reactive({
name: '', name: '',
deptName: '', deptName: '',
phone: '', phone: '',
email: '', email: '',
role: '', role: '',
loginName: '' loginName: ''
}) })
const open = () => { const open = () => {
dialogVisible.value = true dialogVisible.value = true
for (const key in form) { for (const key in form) {
form[key] = Array.isArray(adminInfo.$state[key]) ? adminInfo.$state[key].join(',') : adminInfo.$state[key] form[key] = Array.isArray(adminInfo.$state[key]) ? adminInfo.$state[key].join(',') : adminInfo.$state[key]
} }
} }
defineExpose({ open }) defineExpose({ open })
</script> </script>

View File

@@ -3,13 +3,13 @@
<el-scrollbar> <el-scrollbar>
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" class="form-one" ref="formRef"> <el-form :inline="false" :model="form" label-width="120px" :rules="rules" class="form-one" ref="formRef">
<el-form-item label="校验密码:" prop="password"> <el-form-item label="校验密码:" prop="password">
<el-input v-model.trim="form.password" type="password" placeholder="请输入校验密码" show-password /> <el-input maxlength="32" show-word-limit v-model.trim="form.password" type="password" placeholder="请输入校验密码" show-password />
</el-form-item> </el-form-item>
<el-form-item label="新密码:" prop="newPwd"> <el-form-item label="新密码:" prop="newPwd">
<el-input v-model.trim="form.newPwd" type="password" placeholder="请输入新密码" show-password /> <el-input maxlength="32" show-word-limit v-model.trim="form.newPwd" type="password" placeholder="请输入新密码" show-password />
</el-form-item> </el-form-item>
<el-form-item label="确认密码:" prop="confirmPwd"> <el-form-item label="确认密码:" prop="confirmPwd">
<el-input <el-input maxlength="32" show-word-limit
v-model.trim="form.confirmPwd" v-model.trim="form.confirmPwd"
type="password" type="password"
placeholder="请输入确认密码" placeholder="请输入确认密码"

View File

@@ -51,11 +51,11 @@ onBeforeMount(() => {
}) })
const init = async () => { const init = async () => {
await Promise.all([getAreaList(), dictDataCache(), getUserById(), areaSelect(),getAllUserSimpleList()]).then(res => { await Promise.all([ dictDataCache(), getUserById(), areaSelect(),getAllUserSimpleList()]).then(res => {
dictData.state.area = res[0].data // dictData.state.area = res[0].data
dictData.state.basic = res[1].data dictData.state.basic = res[0].data
// dictData.state.userList=res[4].data // dictData.state.userList=res[4].data
adminInfo.dataFill(res[2].data) adminInfo.dataFill(res[1].data)
// dictData.state.areaTree = res[3].data // dictData.state.areaTree = res[3].data
}) })
/** /**

View File

@@ -1,88 +1,88 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, reactive } from 'vue' import { ref, computed, reactive } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { useDesign } from '@/hooks/web/useDesign' import { useDesign } from '@/hooks/web/useDesign'
import { useLockStore } from '@/stores/modules/lock' import { useLockStore } from '@/stores/modules/lock'
import avatarImg from '@/assets/imgs/avatar.gif' import avatarImg from '@/assets/imgs/avatar.gif'
import { useUserStore } from '@/stores/modules/user' import { useUserStore } from '@/stores/modules/user'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
const { getPrefixCls } = useDesign() const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('lock-dialog') const prefixCls = getPrefixCls('lock-dialog')
const { required } = useValidator() const { required } = useValidator()
const { t } = useI18n() const { t } = useI18n()
const lockStore = useLockStore() const lockStore = useLockStore()
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: Boolean type: Boolean
} }
}) })
const userStore = useUserStore() const userStore = useUserStore()
const avatar = computed(() => userStore.user.avatar ?? avatarImg) const avatar = computed(() => userStore.user.avatar ?? avatarImg)
const userName = computed(() => userStore.user.nickname ?? 'Admin') const userName = computed(() => userStore.user.nickname ?? 'Admin')
const emit = defineEmits(['update:modelValue']) const emit = defineEmits(['update:modelValue'])
const dialogVisible = computed({ const dialogVisible = computed({
get: () => props.modelValue, get: () => props.modelValue,
set: val => { set: val => {
// console.log('set: ', val) // console.log('set: ', val)
emit('update:modelValue', val) emit('update:modelValue', val)
} }
}) })
const dialogTitle = ref(t('lock.lockScreen')) const dialogTitle = ref(t('lock.lockScreen'))
const formData = ref({ const formData = ref({
password: undefined password: undefined
}) })
const formRules = reactive({ const formRules = reactive({
password: [required()] password: [required()]
}) })
const formRef = ref() // 表单 Ref const formRef = ref() // 表单 Ref
const handleLock = async () => { const handleLock = async () => {
// 校验表单 // 校验表单
if (!formRef) return if (!formRef) return
const valid = await formRef.value.validate() const valid = await formRef.value.validate()
if (!valid) return if (!valid) return
// 提交请求 // 提交请求
dialogVisible.value = false dialogVisible.value = false
lockStore.setLockInfo({ lockStore.setLockInfo({
...formData.value, ...formData.value,
isLock: true isLock: true
}) })
} }
</script> </script>
<template> <template>
<Dialog v-model.trim="dialogVisible" width="500px" max-height="170px" :class="prefixCls" :title="dialogTitle"> <Dialog v-model.trim="dialogVisible" width="500px" max-height="170px" :class="prefixCls" :title="dialogTitle">
<div class="flex flex-col items-center"> <div class="flex flex-col items-center">
<img :src="avatar" alt="" class="w-70px h-70px rounded-[50%]" /> <img :src="avatar" alt="" class="w-70px h-70px rounded-[50%]" />
<span class="text-14px my-10px text-[var(--top-header-text-color)]"> <span class="text-14px my-10px text-[var(--top-header-text-color)]">
{{ userName }} {{ userName }}
</span> </span>
</div> </div>
<el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px"> <el-form ref="formRef" :model="formData" :rules="formRules" label-width="80px">
<el-form-item :label="t('lock.lockPassword')" prop="password"> <el-form-item :label="t('lock.lockPassword')" prop="password">
<el-input maxlength="32" show-word-limit type="password" v-model.trim="formData.password" <el-input maxlength="32" show-word-limit type="password" v-model.trim="formData.password"
:placeholder="'请输入' + t('lock.lockPassword')" clearable show-password /> :placeholder="'请输入' + t('lock.lockPassword')" clearable show-password />
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<ElButton type="primary" @click="handleLock">{{ t('lock.lock') }}</ElButton> <ElButton type="primary" @click="handleLock">{{ t('lock.lock') }}</ElButton>
</template> </template>
</Dialog> </Dialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
:global(.v-lock-dialog) { :global(.v-lock-dialog) {
@media (max-width: 767px) { @media (max-width: 767px) {
max-width: calc(100vw - 16px); max-width: calc(100vw - 16px);
} }
} }
</style> </style>

View File

@@ -35,6 +35,16 @@ export const adminBaseRoute = {
title: pageTitle('router.supplementaryRecruitment') title: pageTitle('router.supplementaryRecruitment')
} }
}, },
{
// 版本维护
path: '/version',
name: 'version',
component: () => import('@/views/govern/manage/basic/version.vue'),
meta: {
title: pageTitle('router.version')
}
},
{ {
path: 'cockpit', path: 'cockpit',
name: '项目管理', name: '项目管理',

View File

@@ -1,3 +1,4 @@
/* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-s */ /* 修复 Chrome 浏览器输入框内选中字符行高异常的bug-s */
.el-input .el-input__inner { .el-input .el-input__inner {
height: 30px; height: 30px;

View File

@@ -1,36 +1,38 @@
@use 'sass:map'; @use 'sass:map';
@use 'mixins' as *; @use 'mixins' as *;
// 后台主体窗口左右间距 // 后台主体窗口左右间距
$main-space: 10px; $main-space: 10px;
$primary-light: #3f6ad8; $primary-light: #3f6ad8;
// --ba-background // --ba-background
$bg-color: () !default; $bg-color: () !default;
$bg-color: map.merge( $bg-color: map.merge(
( (
'': #edf0f3, '': #edf0f3,
'overlay': #ffffff, 'overlay': #ffffff
), ),
$bg-color $bg-color
); );
// --ba-border-color // --ba-border-color
$border-color: () !default; $border-color: () !default;
$border-color: map.merge( $border-color: map.merge(
( (
'': #f6f6f6, '': #f6f6f6
), ),
$border-color $border-color
); );
:root { :root {
@include set-css-var-value('main-space', $main-space); @include set-css-var-value('main-space', $main-space);
@include set-css-var-value('color-primary-light', $primary-light); @include set-css-var-value('color-primary-light', $primary-light);
@include set-component-css-var('bg-color', $bg-color); @include set-component-css-var('bg-color', $bg-color);
@include set-component-css-var('border-color', $border-color); @include set-component-css-var('border-color', $border-color);
// --vxe-table-row-current-background-color: var(--el-color-primary-light-7); --el-color-danger: #e26257;
// --vxe-table-row-hover-background-color: var(--el-color-primary-light-9); --el-color-success: #2ab914;
// --vxe-table-row-hover-current-background-color: var(--el-color-primary-light-7); // --vxe-table-row-current-background-color: var(--el-color-primary-light-7);
// --vxe-table-row-hover-striped-background-color: var(--el-color-primary-light-9); // --vxe-table-row-hover-background-color: var(--el-color-primary-light-9);
} // --vxe-table-row-hover-current-background-color: var(--el-color-primary-light-7);
// --vxe-table-row-hover-striped-background-color: var(--el-color-primary-light-9);
}

View File

@@ -1,15 +1,15 @@
<template> <template>
<el-dialog width="600px" v-model.trim='dialogVisible' :title='title'> <el-dialog width="500px" v-model.trim='dialogVisible' :title='title'>
<el-scrollbar> <el-scrollbar>
<el-form :inline='false' :model='form' label-width='auto' class="form-one" :rules='rules' ref='formRef'> <el-form :inline='false' :model='form' label-width='auto' class="form-one" :rules='rules' ref='formRef'>
<el-form-item label='角色名称'> <el-form-item label='角色名称'>
<el-input maxlength="32" show-word-limit v-model.trim='form.name' placeholder='请输入菜单名称' /> <el-input maxlength="32" show-word-limit v-model.trim='form.name' placeholder='请输入菜单名称' />
</el-form-item> </el-form-item>
<el-form-item label='角色编码'> <el-form-item label='角色编码'>
<el-input maxlength="32" show-word-limit v-model.trim='form.code' placeholder='请输入菜单名称' /> <el-input maxlength="32" show-word-limit v-model.trim='form.code' placeholder='请输入菜单名称' />
</el-form-item> </el-form-item>
<el-form-item label='角色描述'> <el-form-item label='角色描述'>
<el-input maxlength="300" show-word-limit v-model.trim='form.remark' :rows='2' type='textarea' <el-input show-word-limit maxlength="300" v-model.trim='form.remark' :rows='2' type='textarea'
placeholder='请输入描述' /> placeholder='请输入描述' />
</el-form-item> </el-form-item>
</el-form> </el-form>

View File

@@ -0,0 +1,59 @@
const AXIS_DECIMALS = 2
export function roundAxisValue(val: number, decimals = AXIS_DECIMALS): number {
if (!Number.isFinite(val)) return 0
const factor = 10 ** decimals
return Math.round(val * factor) / factor
}
/** Y 轴刻度:最多 2 位小数,末尾 0 去掉(如 1.00 → 10.10 → 0.1 */
export function formatAxisLabel(value: number): string {
if (!Number.isFinite(value)) return '0'
return String(Number(roundAxisValue(value).toFixed(AXIS_DECIMALS)))
}
/** 瞬间波形 Y 轴范围 */
export function calcShuYAxisRange(dataMin: number, dataMax: number): { min: number; max: number } {
const min = Number(dataMin)
const max = Number(dataMax)
if (!Number.isFinite(min) || !Number.isFinite(max)) {
return { min: 0, max: 1 }
}
let axisMax = max * 1.1
let axisMin = min > 0 ? min - min * 0.1 : min * 1.1
if (axisMax <= axisMin) {
const pad = Math.abs(max) * 0.1 || 0.01
axisMax = max + pad
axisMin = min - pad
}
return {
min: roundAxisValue(axisMin),
max: roundAxisValue(axisMax)
}
}
/** RMS 波形 Y 轴范围 */
export function calcRmsYAxisRange(dataMin: number, dataMax: number): { min: number; max: number } {
const min = Number(dataMin)
const max = Number(dataMax)
if (!Number.isFinite(min) || !Number.isFinite(max)) {
return { min: 0, max: 1 }
}
let axisMax = max * 1.06 * 1.1
let axisMin = min - min * 0.2
if (axisMax <= axisMin) {
const pad = Math.abs(max - min) * 0.1 || Math.abs(max) * 0.1 || 0.01
axisMax = max + pad
axisMin = min - pad
}
return {
min: roundAxisValue(axisMin),
max: roundAxisValue(axisMax)
}
}

105
src/utils/downloadFile.ts Normal file
View File

@@ -0,0 +1,105 @@
import { ElMessage, ElMessageBox, ElInput, ElSegmented } from 'element-plus'
export const downLoadFile = (name: string, key: string, res: any) => {
let blob = new Blob([res], {
type: getFileType(key)
})
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // 创建a标签
link.href = url
link.download = name // 设置下载的文件名
document.body.appendChild(link)
link.click() //执行下载
document.body.removeChild(link)
setTimeout(() => {
ElMessage.success('下载成功')
}, 2000)
}
const getFileType = (url: string) => {
const ext = url.split('.').pop()?.toLowerCase() || ''
const mimeMap: Record<string, string> = {
// Excel
xls: 'application/vnd.ms-excel',
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
// CSV
csv: 'text/csv',
// Word
doc: 'application/msword',
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
// PDF
pdf: 'application/pdf',
// PowerPoint
ppt: 'application/vnd.ms-powerpoint',
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
// 图片
png: 'image/png',
gif: 'image/gif',
jpeg: 'image/jpeg',
jpg: 'image/jpeg',
bmp: 'image/bmp',
ico: 'image/vnd.microsoft.icon',
tif: 'image/tiff',
tiff: 'image/tiff',
svg: 'image/svg+xml',
webp: 'image/webp',
// 音频
mp3: 'audio/mpeg',
aac: 'audio/aac',
mid: 'audio/midi',
midi: 'audio/midi',
oga: 'audio/ogg',
wav: 'audio/wav',
weba: 'audio/webm',
// 视频
avi: 'video/x-msvideo',
mpeg: 'video/mpeg',
ogv: 'video/ogg',
webm: 'video/webm',
'3gp': 'video/3gpp',
'3g2': 'video/3gpp2',
// 网页/代码
html: 'text/html',
css: 'text/css',
js: 'text/javascript',
mjs: 'text/javascript',
json: 'application/json',
jsonld: 'application/ld+json',
xhtml: 'application/xhtml+xml',
xml: 'application/xml',
xul: 'application/vnd.mozilla.xul+xml',
// 文档
abw: 'application/x-abiword',
odp: 'application/vnd.oasis.opendocument.presentation',
ods: 'application/vnd.oasis.opendocument.spreadsheet',
odt: 'application/vnd.oasis.opendocument.text',
rtf: 'application/rtf',
txt: 'text/plain',
vsd: 'application/vnd.visio',
// 字体
otf: 'font/otf',
ttf: 'font/ttf',
woff: 'font/woff',
woff2: 'font/woff2',
eot: 'application/vnd.ms-fontobject',
// 压缩/归档
arc: 'application/x-freearc',
bz: 'application/x-bzip',
bz2: 'application/x-bzip2',
rar: 'application/x-rar-compressed',
tar: 'application/x-tar',
zip: 'application/zip',
'7z': 'application/x-7z-compressed',
// 其他
bin: 'application/octet-stream',
csh: 'application/x-csh',
epub: 'application/epub+zip',
azw: 'application/vnd.amazon.ebook',
ics: 'text/calendar',
jar: 'application/java-archive',
mpkg: 'application/vnd.apple.installer+xml',
ogx: 'application/ogg',
sh: 'application/x-sh',
swf: 'application/x-shockwave-flash'
}
return mimeMap[ext] || ''
}

View File

@@ -1,5 +1,3 @@
import { number } from 'vue-types'
const dataProcessing = (arr: any[]) => { const dataProcessing = (arr: any[]) => {
return arr return arr
.filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item)))) .filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item))))
@@ -163,6 +161,41 @@ export const exportCSV = (title: object, data: any, filename: string) => {
URL.revokeObjectURL(link.href) URL.revokeObjectURL(link.href)
} }
/**
* 将多条折线按时间对齐合并为 CSV 行(避免各 series 长度不一致时按索引对齐丢数据)
*/
export const buildSeriesCsvData = (seriesList: Array<{ name: string; data?: any[] }>) => {
if (!seriesList?.length) {
return { titles: [], rows: [] }
}
const titles = seriesList.map(s => s.name)
const timeMap = new Map<string, (string | number | null)[]>()
seriesList.forEach((series, seriesIndex) => {
series.data?.forEach((point: any) => {
const time = point?.[0]
if (!time) return
const timeKey = String(time)
if (!timeMap.has(timeKey)) {
timeMap.set(timeKey, [timeKey, ...Array(seriesList.length).fill(null)])
}
const row = timeMap.get(timeKey)!
row[seriesIndex + 1] = point[1] ?? null
})
})
const rows = Array.from(timeMap.values()).sort(
(a, b) => new Date(a[0] as string).getTime() - new Date(b[0] as string).getTime()
)
return { titles, rows }
}
export const exportSeriesCSV = (seriesList: Array<{ name: string; data?: any[] }>, filename: string) => {
const { titles, rows } = buildSeriesCsvData(seriesList)
if (!rows.length) return
exportCSV(titles, rows, filename)
}
/** /**
* 补全时间序列数据中缺失的条目 * 补全时间序列数据中缺失的条目
* @param rawData 原始数据,格式为 [["时间字符串", "数值", "单位", "类型"], ...] * @param rawData 原始数据,格式为 [["时间字符串", "数值", "单位", "类型"], ...]
@@ -259,6 +292,32 @@ export const completeTimeSeries = (rawData: string[][]): (string | null)[][] =>
} }
}) })
// 补首尾边界:首日 00:00:00、末日 23:59:59
const createPadItem = (timeStr: string): (string | null | undefined)[] => {
const result: (string | null | undefined)[] = [timeStr, '/']
if (template.length > 2) result.push(template[2])
if (template.length > 3) result.push(template[3])
return result
}
const firstDate = new Date(completedData[0][0] as string)
const dayStartStr = formatTime(
new Date(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate(), 0, 0, 0)
)
const lastDate = new Date(completedData[completedData.length - 1][0] as string)
const dayEndStr = formatTime(new Date(lastDate.getFullYear(), lastDate.getMonth(), lastDate.getDate(), 23, 59, 59))
const firstTimeStr = formatTime(new Date(completedData[0][0] as string))
if (firstTimeStr !== dayStartStr) {
completedData.unshift(createPadItem(dayStartStr))
}
const lastTimeStr = formatTime(new Date(completedData[completedData.length - 1][0] as string))
if (lastTimeStr !== dayEndStr) {
completedData.push(createPadItem(dayEndStr))
}
return completedData return completedData
} }

View File

@@ -0,0 +1,87 @@
import { ElMessage } from 'element-plus'
import { nextTick } from 'vue'
import { exportExcel } from '@/views/system/reportForms/export.js'
/** 解析 Luckysheet 接口返回的 sheet 数据 */
export function parseLuckysheetSheets(sheets: any[]) {
sheets.forEach((item: any) => {
if (item.data1) {
try {
item.data = JSON.parse(item.data1)
} catch {
/* ignore invalid json */
}
}
item.celldata?.forEach((cell: any) => {
if (item.data?.[cell.r]?.[cell.c]?.v != null) {
item.data[cell.r][cell.c] = cell.v
}
})
})
}
declare const luckysheet: any
const DEFAULT_REPORT_OPTIONS = {
title: '',
lang: 'zh',
showtoolbar: false,
showinfobar: false,
showsheetbar: true,
}
/** 销毁已有 Luckysheet 实例,避免重复 create 导致 DOM 堆积 */
export function destroyLuckysheet() {
try {
if (typeof luckysheet !== 'undefined' && luckysheet.destroy) {
luckysheet.destroy()
}
} catch {
/* ignore */
}
}
/** 解析 sheet 数据、销毁旧实例并渲染报表 */
export function renderLuckysheetReport(
container: string,
sheets: any[],
options: Record<string, any> = {}
) {
parseLuckysheetSheets(sheets)
destroyLuckysheet()
nextTick(() => {
requestAnimationFrame(() => {
luckysheet.create({
container,
...DEFAULT_REPORT_OPTIONS,
...options,
data: sheets,
})
})
})
}
/** 安全导出 Luckysheet无数据时提示并返回 false */
export function exportLuckysheetFile(filename: string, hasData = true): boolean {
if (!hasData) {
ElMessage.warning('暂无数据')
return false
}
try {
if (typeof luckysheet === 'undefined' || !luckysheet.getAllSheets) {
ElMessage.warning('暂无数据')
return false
}
const sheets = luckysheet.getAllSheets()
if (!sheets?.length) {
ElMessage.warning('暂无数据')
return false
}
exportExcel(sheets, filename)
ElMessage.success('生成成功')
return true
} catch {
ElMessage.warning('导出失败,请先加载报表数据')
return false
}
}

View File

@@ -4,7 +4,7 @@ import { ElLoading, ElMessage, ElNotification, type LoadingOptions } from 'eleme
import { refreshToken } from '@/api/user-boot/user' import { refreshToken } from '@/api/user-boot/user'
import router from '@/router/index' import router from '@/router/index'
import { useAdminInfo } from '@/stores/adminInfo' import { useAdminInfo } from '@/stores/adminInfo'
import { useNavTabs } from '@/stores/navTabs'
window.requests = [] window.requests = []
window.tokenRefreshing = false window.tokenRefreshing = false
let loginExpireTimer: any = null let loginExpireTimer: any = null
@@ -13,7 +13,7 @@ const loadingInstance: LoadingInstance = {
target: null, target: null,
count: 0 count: 0
} }
const navTabs = useNavTabs()
/** /**
* 根据运行环境获取基础请求URL * 根据运行环境获取基础请求URL
*/ */
@@ -76,7 +76,12 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
config.url == '/cs-harmonic-boot/limitRateDetailD/limitTimeProbabilityData' || config.url == '/cs-harmonic-boot/limitRateDetailD/limitTimeProbabilityData' ||
config.url == '/cs-harmonic-boot/limitRateDetailD/limitProbabilityData' || config.url == '/cs-harmonic-boot/limitRateDetailD/limitProbabilityData' ||
config.url == '/system-boot/dictTree/queryByCode' || config.url == '/system-boot/dictTree/queryByCode' ||
config.url == '/system-boot/dictTree/query' config.url == '/system-boot/dictTree/queryByid' ||
config.url == '/system-boot/dictTree/query'||
config.url == '/cs-harmonic-boot/csevent/f47Curve'||
config.url == '/cs-harmonic-boot/sysExcel/querySysExcel'||
config.url == '/cs-device-boot/csLedger/lineTree'||
config.url == '/cs-harmonic-boot/pqSensitiveUser/getUserDevTree'
) )
) )
removePending(config) removePending(config)
@@ -164,6 +169,9 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
message: response.data.message message: response.data.message
}) })
adminInfo.removeToken() adminInfo.removeToken()
navTabs.closeTabs()
window.localStorage.clear()
adminInfo.reset()
router.push({ name: 'login' }) router.push({ name: 'login' })
loginExpireTimer = null // 执行后清空定时器 loginExpireTimer = null // 执行后清空定时器
}, 100) // 可根据实际情况调整延迟时间 }, 100) // 可根据实际情况调整延迟时间

View File

@@ -1,45 +1,60 @@
/** /**
* window.localStorage * window.localStorage
* @method set 设置 * @method set 设置
* @method get 获取 * @method get 获取
* @method remove 移除 * @method remove 移除
* @method clear 移除全部 * @method clear 移除全部
*/ */
export const Local = { export const Local = {
set(key: string, val: any) { set(key: string, val: any) {
window.localStorage.setItem(key, JSON.stringify(val)) window.localStorage.setItem(key, JSON.stringify(val))
}, },
get(key: string) { get(key: string) {
const json: any = window.localStorage.getItem(key) const json: any = window.localStorage.getItem(key)
return JSON.parse(json) return JSON.parse(json)
}, },
remove(key: string) { remove(key: string) {
window.localStorage.removeItem(key) window.localStorage.removeItem(key)
}, },
clear() { clear() {
window.localStorage.clear() window.localStorage.clear()
}, },
} }
/** /**
* window.sessionStorage * window.sessionStorage
* @method set 设置会话缓存 * @method set 设置会话缓存
* @method get 获取会话缓存 * @method get 获取会话缓存
* @method remove 移除会话缓存 * @method remove 移除会话缓存
* @method clear 移除全部会话缓存 * @method clear 移除全部会话缓存
*/ */
export const Session = { const DEFAULT_THEME_NAME = '电能质量监测系统'
set(key: string, val: any) {
window.sessionStorage.setItem(key, JSON.stringify(val)) export function getStoredTheme(): { name?: string; logoUrl?: string; [key: string]: any } {
}, try {
get(key: string) { const raw = window.localStorage.getItem('getTheme')
const json: any = window.sessionStorage.getItem(key) return raw ? JSON.parse(raw) : {}
return JSON.parse(json) } catch {
}, return {}
remove(key: string) { }
window.sessionStorage.removeItem(key) }
},
clear() { export function getStoredThemeName(): string {
window.sessionStorage.clear() return getStoredTheme().name || DEFAULT_THEME_NAME
}, }
}
export const Session = {
set(key: string, val: any) {
window.sessionStorage.setItem(key, JSON.stringify(val))
},
get(key: string) {
const json: any = window.sessionStorage.getItem(key)
return JSON.parse(json)
},
remove(key: string) {
window.sessionStorage.removeItem(key)
},
clear() {
window.sessionStorage.clear()
},
}

View File

@@ -19,7 +19,7 @@ interface TableStoreParams {
resetCallback?: () => void // 重置 resetCallback?: () => void // 重置
loadCallback?: () => void // 接口调用后的回调 loadCallback?: () => void // 接口调用后的回调
exportProcessingData?: () => void //导出处理数据 exportProcessingData?: () => void //导出处理数据
beforeSearchFun?: () => void // 接口调用前的回调 beforeSearchFun?: () => void | boolean // 接口调用前的回调,返回 false 中止请求
} }
export default class TableStore { export default class TableStore {
@@ -75,7 +75,13 @@ export default class TableStore {
} }
index() { index() {
this.table.beforeSearchFun && this.table.beforeSearchFun() if (this.table.beforeSearchFun) {
const canSearch = this.table.beforeSearchFun()
if (canSearch === false) {
this.table.loading = false
return
}
}
this.table.data = [] this.table.data = []
this.table.loading = true this.table.loading = true
// 重置用的数据数据 // 重置用的数据数据

42
src/utils/waveCache.ts Normal file
View File

@@ -0,0 +1,42 @@
const MAX_CACHE_SIZE = 30
const cache = new Map<string, unknown>()
function dataFingerprint(data: unknown[][] | undefined): string {
if (!data?.length) return '0'
const first = data[0]
const last = data[data.length - 1]
return `${data.length}:${first?.[0]}:${last?.[0]}`
}
export function buildWaveCacheKey(
type: 'shu' | 'rms',
wp: Record<string, any> | undefined,
value: number,
isOpen: boolean,
boxoList: Record<string, any>
): string {
if (!wp) return ''
const waveFp =
type === 'shu' ? dataFingerprint(wp.listWaveData) : dataFingerprint(wp.listRmsData)
const boxoFp = boxoList?.startTime ?? boxoList?.lineName ?? boxoList?.equipmentName ?? ''
return `${type}|${wp.time}|${wp.waveType}|${wp.iphasic}|${value}|${isOpen}|${waveFp}|${boxoFp}`
}
export function getWaveCache<T>(key: string): T | null {
if (!key || !cache.has(key)) return null
const value = cache.get(key) as T
cache.delete(key)
cache.set(key, value)
return value
}
export function setWaveCache(key: string, value: unknown): void {
if (!key) return
if (cache.has(key)) cache.delete(key)
cache.set(key, value)
while (cache.size > MAX_CACHE_SIZE) {
const oldest = cache.keys().next().value
if (oldest !== undefined) cache.delete(oldest)
}
}

Some files were not shown because too many files have changed in this diff Show More