Compare commits
103 Commits
2025-09
...
f1439e0464
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1439e0464 | ||
|
|
29c88b56dc | ||
|
|
0c71b2ac32 | ||
|
|
f916721b6a | ||
|
|
f2d02ff7f5 | ||
|
|
2de28c0067 | ||
|
|
09326b287e | ||
|
|
d365932648 | ||
|
|
925c9c6f15 | ||
|
|
b0df1157ad | ||
|
|
d450383cfd | ||
|
|
e603ba9f8c | ||
|
|
704f735744 | ||
|
|
0249ccac48 | ||
|
|
e49e34df6d | ||
|
|
042798c6a7 | ||
|
|
3827490cd1 | ||
|
|
da7cb2cb90 | ||
|
|
36e182a99a | ||
|
|
05e0287407 | ||
|
|
7a68a4114b | ||
|
|
ddc8f81196 | ||
|
|
5bed340320 | ||
|
|
2048da5e52 | ||
|
|
4184d35854 | ||
|
|
59b56d4a19 | ||
|
|
0a6bd2e453 | ||
|
|
60e9685b7e | ||
|
|
d8433d8d9c | ||
|
|
0f090666e9 | ||
|
|
1d849bcff9 | ||
|
|
e9b09e2193 | ||
|
|
f66dd649c7 | ||
|
|
af05b9c810 | ||
|
|
0af955d05c | ||
|
|
49dcf440ff | ||
|
|
d6bfd8b958 | ||
|
|
ea6aed9b99 | ||
|
|
cd565c03ca | ||
|
|
f82ef923ae | ||
|
|
4c2ed4aade | ||
|
|
8cd3e14922 | ||
|
|
5580d0618e | ||
|
|
c1ebcfed6f | ||
|
|
6303bd1e2c | ||
|
|
d9efb37083 | ||
|
|
e271a3be06 | ||
|
|
078488a842 | ||
|
|
384ea90acd | ||
|
|
25971e5239 | ||
|
|
c3d7e91f4e | ||
|
|
72c37c2759 | ||
|
|
d1eb7f2dad | ||
|
|
308ceb1a03 | ||
|
|
ad7b77ff92 | ||
|
|
0e76ab66f3 | ||
|
|
24afa84f29 | ||
|
|
a5f3571906 | ||
|
|
d16d262d1a | ||
|
|
593f2e2c66 | ||
|
|
d1e7aab876 | ||
|
|
8a3e0263d2 | ||
|
|
35ce7314b0 | ||
|
|
5538d18127 | ||
|
|
00dd79e000 | ||
|
|
b5aff1a837 | ||
|
|
1ec3bd11a0 | ||
|
|
d553754847 | ||
|
|
dc44e16d4d | ||
|
|
13c0a28c95 | ||
|
|
443d5ab2bd | ||
|
|
288f4254b0 | ||
|
|
130db82e41 | ||
|
|
55a30a323d | ||
|
|
608be23687 | ||
|
|
8f8f2aad6e | ||
|
|
a9dcb54286 | ||
|
|
dede918f34 | ||
|
|
d113df832d | ||
|
|
f41af33413 | ||
|
|
f2e328826d | ||
|
|
b3154e894a | ||
|
|
f3252f8a15 | ||
|
|
7f5296daee | ||
|
|
ed0800359d | ||
|
|
e97aa2cd0e | ||
|
|
f0adfe65a5 | ||
|
|
a7b0982527 | ||
|
|
bf22f7b312 | ||
|
|
43b5e4e497 | ||
|
|
269d941828 | ||
|
|
29b5cfa4db | ||
|
|
987441f2df | ||
|
|
a236693cf6 | ||
|
|
f252422f65 | ||
|
|
4bd192dabc | ||
|
|
e7612c4083 | ||
|
|
676bb37bbe | ||
|
|
177e50de75 | ||
|
|
448d450936 | ||
|
|
6e5e289271 | ||
|
|
e7f38519b4 | ||
|
|
1211277a0d |
10908
package-lock.json
generated
16
package.json
@@ -26,8 +26,10 @@
|
||||
"element-plus": "^2.7.5",
|
||||
"exceljs": "v4.4.0",
|
||||
"file-saver": "v2.0.5",
|
||||
"grid-layout-plus": "^1.1.0",
|
||||
"html2canvas": "^1.4.1",
|
||||
"jquery": "^3.7.1",
|
||||
"jsencrypt": "^3.3.2",
|
||||
"jszip": "^3.10.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
@@ -38,28 +40,30 @@
|
||||
"nprogress": "^0.2.0",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"qs": "^6.12.0",
|
||||
"screenfull": "^6.0.2",
|
||||
"splitpanes": "3.1.5",
|
||||
"splitpanes": "^3.1.5",
|
||||
"use-element-plus-theme": "^0.0.5",
|
||||
"vue": "^3.3.11",
|
||||
"vue-draggable-resizable": "3.0.0-beta.2",
|
||||
"vue-draggable-resizable": "^3.0.0-beta.2",
|
||||
"vue-i18n": "9.10.2",
|
||||
"vue-router": "4",
|
||||
"vue-types": "^5.1.1",
|
||||
"vxe-table": "^4.5.17",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.7",
|
||||
"grid-layout-plus": "^1.1.0",
|
||||
"vue-i18n": "9.10.2",
|
||||
"web-storage-cache": "^1.1.1",
|
||||
"xe-utils": "^3.5.14"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@purge-icons/generated": "^0.9.0",
|
||||
"@purge-icons/generated": "^0.9.0",
|
||||
"@types/lodash-es": "^4.17.12",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/splitpanes": "2.2.6",
|
||||
"@vitejs/plugin-vue": "^4.5.2",
|
||||
"@vitejs/plugin-vue-jsx": "^3.1.0",
|
||||
"unplugin-auto-import": "^0.16.7",
|
||||
"sass": "^1.69.5",
|
||||
"typescript": "^5.2.2",
|
||||
"unplugin-auto-import": "^0.16.7",
|
||||
"vite": "^5.0.8",
|
||||
"vue-tsc": "^1.8.25"
|
||||
}
|
||||
|
||||
2651
pnpm-lock.yaml
generated
@@ -54,3 +54,12 @@ export function downloadWave(params: string) {
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//根据事件补召波形
|
||||
export function getFileByEventId(eventId: string) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/icd/bzFileByEventId?eventId=' + eventId,
|
||||
method: 'POST'
|
||||
})
|
||||
}
|
||||
@@ -130,3 +130,20 @@ export function updateLine(data: any) {
|
||||
})
|
||||
}
|
||||
|
||||
//推送日志台账信息
|
||||
export function pushLog() {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/csTerminalLogs/pushCldInfo',
|
||||
method: 'post',
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
//查询推送结果
|
||||
export function queryPushResult() {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/csTerminalReply/queryData',
|
||||
method: 'post',
|
||||
|
||||
})
|
||||
}
|
||||
59
src/api/cs-device-boot/frontManagement.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import createAxios from '@/utils/request'
|
||||
|
||||
// 新增前置机
|
||||
export function addNode(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/addNode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//修改前置机
|
||||
export function updateNode(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/updateNode',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//删除前置机
|
||||
export function delNode(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/delNode',
|
||||
method: 'post',
|
||||
params: { id: data }
|
||||
})
|
||||
}
|
||||
|
||||
//查询前置-进程-设备-设备树
|
||||
export function nodeDeviceTree(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/getProcessNoAndDeviceById',
|
||||
method: 'get',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
//重启前置机进程
|
||||
export function restartProcess(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/restartProcess',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
//更新进程号
|
||||
export function updateProcess(data:any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/node/updateDevNode',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
20
src/api/cs-device-boot/recall.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import createAxios from '@/utils/request'
|
||||
|
||||
//补召事件
|
||||
export function eventRecall(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/icd/bzEvent',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//补召波形
|
||||
export function fileRecall(data: any) {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/icd/bzFile',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -53,3 +53,25 @@ export const removeMarketData = (data: any) => {
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户未绑定的在运的便携式设备
|
||||
*/
|
||||
export const queryRunPortableDevByUseId = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/EquipmentDelivery/getRunPortableDev',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户未绑定的工程信息
|
||||
*/
|
||||
export const queryUnlinkEngineeringByUseId = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-device-boot/engineering/getUnlinkedEngineering',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
29
src/api/cs-system-boot/official.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import createAxios from '@/utils/request'
|
||||
|
||||
// * 根据用户id查询工程和便携式设备
|
||||
export const queryDevByUseId = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/wlUser/selectDevByUserId',
|
||||
method: 'POST',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
// * 用户绑定工程和便携式设备
|
||||
export const add = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/wlUser/addUserDev',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 用户取消绑定工程和便携式设备
|
||||
*/
|
||||
export const removeUserDev = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/wlUser/deleteUserDev',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
237
src/api/harmonic-boot/cockpit/cockpit.ts
Normal file
@@ -0,0 +1,237 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 主要监测点列表查询>>分页
|
||||
export function mainLineList(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/mainLine/list',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 主要监测点指标越限详情
|
||||
export function statLimitRateDetails(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/mainLine/statLimitRateDetails',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询监测点列表=全部>>不分页
|
||||
export function cslineList(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csline/list',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 监测点详情 趋势图数据
|
||||
export function trendData(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csGroup/trendData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 每日越限占比统计
|
||||
export function totalLimitStatisticsDetails(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/totalLimitStatistics/details',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 总体指标越限统计列表
|
||||
export function totalLimitStatisticsList(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/totalLimitStatistics/list',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 总体指标越限统计数据
|
||||
export function totalLimitStatisticsData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/totalLimitStatistics/data',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 指标越限程度数据
|
||||
export function limitExtentData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitExtentData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
// 指标日趋势图数据
|
||||
export function limitExtentDayData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitExtentDayData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 指标越限明细日历数据
|
||||
export function limitCalendarData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitCalendarData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//指标拟合图数据
|
||||
export function fittingData(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csGroup/fittingData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//指标越限时间概率分布
|
||||
export function limitTimeProbabilityData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitTimeProbabilityData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
//指标越限程度概率分布
|
||||
export function limitProbabilityData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitProbabilityData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 电网侧指标越限统计列表
|
||||
export function gridSideLimitStatisticsList(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/gridSideLimitStatistics/list',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 电网侧指标越限统计数据
|
||||
export function gridSideLimitStatisticsData(data: any) {
|
||||
return request({
|
||||
url: '/harmonic-boot/gridSideLimitStatistics/data',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 敏感负荷用户监测点列表
|
||||
export function governLineList(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csline/getSensitiveUserLineList',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 根据id集合获取敏感负荷用户列表
|
||||
export function getListByIds(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/pqSensitiveUser/getListByIds',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 上传治理报告
|
||||
export function uploadReport(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csline/uploadReport',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取治理报告链接
|
||||
export function getReportUrl(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csline/getReportUrl',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
|
||||
// 查询监测对象电网侧和负载侧监测点指标趋势对比数据
|
||||
export function sensitiveUserTrendData(data: any) {
|
||||
return request({
|
||||
url: '/cs-device-boot/csGroup/sensitiveUserTrendData',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取敏感负荷用户列表
|
||||
export function getList(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/pqSensitiveUser/getList',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// F47曲线
|
||||
export function f47Curve(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/csevent/f47Curve',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取电压暂态表及密度坐标图
|
||||
export function getEventCoords(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/csevent/getEventCoords',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 日历暂降事件详情
|
||||
export function getEventDate(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/csevent/getEventDate',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 暂降类型分类统计Echart
|
||||
export function netEventEcharts(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/csevent/netEventEcharts',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 暂降类型分类统计表格
|
||||
export function netEventTable(data: any) {
|
||||
return request({
|
||||
url: '/cs-harmonic-boot/csevent/netEventTable',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -69,3 +69,19 @@ export const queryById = (params: any) => {
|
||||
params
|
||||
})
|
||||
}
|
||||
// 更具id 查询驾驶舱页面
|
||||
export const queryByPagePath = (params: any) => {
|
||||
return createAxios({
|
||||
url: '/system-boot/dashboard/queryByPagePath',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
// 根据用户id查询用户驾驶舱
|
||||
export const getDashboardPageByUserId = (params: any) => {
|
||||
return createAxios({
|
||||
url: '/system-boot/dashboard/getDashboardPageByUserId',
|
||||
method: 'post',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
72
src/api/system-boot/file.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import createAxios from '@/utils/request'
|
||||
|
||||
const SYSTEM_PREFIX = '/system-boot'
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
*/
|
||||
export const uploadFile = (file: any, path: string) => {
|
||||
let form = new FormData()
|
||||
form.append('file', file)
|
||||
form.append('path', path)
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/upload',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
data: form
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*/
|
||||
export const deleteFile = (filePath: string) => {
|
||||
let form = new FormData()
|
||||
form.append('filePath', filePath)
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/delete',
|
||||
method: 'POST',
|
||||
data: form
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
export const downloadFile = (filePath: any) => {
|
||||
// let form = new FormData()
|
||||
// form.append('filePath', filePath)
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/download',
|
||||
method: 'GET',
|
||||
params: filePath,
|
||||
responseType: 'blob'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件的短期url展示
|
||||
*/
|
||||
export const getFileUrl = (params:any) => {
|
||||
let form = new FormData()
|
||||
// form.append('filePath', filePath)
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/getFileUrl',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据获取文件的一个短期url及文件名
|
||||
*/
|
||||
export const getFileNameAndFilePath = (query: any) => {
|
||||
return createAxios({
|
||||
url: SYSTEM_PREFIX + '/file/getFileVO',
|
||||
method: 'GET',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
11
src/api/user-boot/official.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request'
|
||||
/**
|
||||
* 获取移动端、便携式正式用户列表
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
export const getFormalUserList = () => {
|
||||
return request({
|
||||
url: '/user-boot/user/getFormalUserList',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
BIN
src/assets/img/amplify.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
src/assets/img/lightning.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
src/assets/img/reduce.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
src/assets/imgs/1x1.png
Normal file
|
After Width: | Height: | Size: 118 B |
BIN
src/assets/imgs/2x2.png
Normal file
|
After Width: | Height: | Size: 137 B |
BIN
src/assets/imgs/2x3.png
Normal file
|
After Width: | Height: | Size: 160 B |
BIN
src/assets/imgs/3x3.png
Normal file
|
After Width: | Height: | Size: 179 B |
BIN
src/assets/imgs/amplify.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
src/assets/imgs/avatar.gif
Normal file
|
After Width: | Height: | Size: 6.2 KiB |
BIN
src/assets/imgs/avatar.jpg
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
src/assets/imgs/bg02.png
Normal file
|
After Width: | Height: | Size: 697 B |
BIN
src/assets/imgs/bg1.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/assets/imgs/ditu.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
src/assets/imgs/ditu1.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
src/assets/imgs/diy/app-nav-bar-mp.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
src/assets/imgs/diy/statusBar.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
src/assets/imgs/logo.png
Normal file
|
After Width: | Height: | Size: 2.7 KiB |
BIN
src/assets/imgs/profile.jpg
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
src/assets/imgs/reduce.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
src/assets/imgs/t_1.png
Normal file
|
After Width: | Height: | Size: 506 B |
BIN
src/assets/imgs/t_3.png
Normal file
|
After Width: | Height: | Size: 472 B |
BIN
src/assets/imgs/t_7.png
Normal file
|
After Width: | Height: | Size: 290 B |
BIN
src/assets/imgs/wechat.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
3
src/components/Backtop/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import Backtop from './src/Backtop.vue'
|
||||
|
||||
export { Backtop }
|
||||
17
src/components/Backtop/src/Backtop.vue
Normal file
@@ -0,0 +1,17 @@
|
||||
<script lang="ts" setup>
|
||||
import { ElBacktop } from 'element-plus'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
|
||||
defineOptions({ name: 'BackTop' })
|
||||
|
||||
const { getPrefixCls, variables } = useDesign()
|
||||
|
||||
const prefixCls = getPrefixCls('backtop')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ElBacktop
|
||||
:class="`${prefixCls}-backtop`"
|
||||
:target="`.${variables.namespace}-layout-content-scrollbar .${variables.elNamespace}-scrollbar__wrap`"
|
||||
/>
|
||||
</template>
|
||||
111
src/components/RouterSearch/index.vue
Normal file
@@ -0,0 +1,111 @@
|
||||
<template>
|
||||
<ElDialog v-if="isModal" v-model="showSearch" :show-close="false" title="菜单搜索">
|
||||
<el-select
|
||||
filterable
|
||||
:reserve-keyword="false"
|
||||
remote
|
||||
placeholder="请输入菜单内容"
|
||||
:remote-method="remoteMethod"
|
||||
style="width: 100%"
|
||||
@change="handleChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</ElDialog>
|
||||
<div v-else class="custom-hover" @click.stop="showTopSearch = !showTopSearch">
|
||||
<Icon icon="ep:search" />
|
||||
<el-select
|
||||
filterable
|
||||
:reserve-keyword="false"
|
||||
remote
|
||||
placeholder="请输入菜单内容"
|
||||
:remote-method="remoteMethod"
|
||||
class="overflow-hidden transition-all-600"
|
||||
:class="showTopSearch ? '!w-220px ml2' : '!w-0'"
|
||||
@change="handleChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
defineProps({
|
||||
isModal: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
})
|
||||
|
||||
const router = useRouter() // 路由对象
|
||||
const showSearch = ref(false) // 是否显示弹框
|
||||
const showTopSearch = ref(false) // 是否显示顶部搜索框
|
||||
const value: Ref = ref('') // 用户输入的值
|
||||
|
||||
const routers = router.getRoutes() // 路由对象
|
||||
const options = computed(() => {
|
||||
// 提示选项
|
||||
if (!value.value) {
|
||||
return []
|
||||
}
|
||||
const list = routers.filter((item: any) => {
|
||||
if (item.meta.title?.indexOf(value.value) > -1 || item.path.indexOf(value.value) > -1) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
return list.map((item) => {
|
||||
return {
|
||||
label: `${item.meta.title}${item.path}`,
|
||||
value: item.path
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function remoteMethod(data) {
|
||||
// 这里可以执行相应的操作(例如打开搜索框等)
|
||||
value.value = data
|
||||
}
|
||||
|
||||
function handleChange(path) {
|
||||
router.push({ path })
|
||||
hiddenTopSearch()
|
||||
}
|
||||
|
||||
function hiddenTopSearch() {
|
||||
showTopSearch.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', listenKey)
|
||||
window.addEventListener('click', hiddenTopSearch)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('keydown', listenKey)
|
||||
window.removeEventListener('click', hiddenTopSearch)
|
||||
})
|
||||
|
||||
// 监听 ctrl + k
|
||||
function listenKey(event) {
|
||||
if ((event.ctrlKey || event.metaKey) && event.key === 'k') {
|
||||
showSearch.value = !showSearch.value
|
||||
// 这里可以执行相应的操作(例如打开搜索框等)
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openSearch: () => {
|
||||
showSearch.value = true
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -1,282 +1,282 @@
|
||||
<template>
|
||||
<div class="w100">
|
||||
<!-- el-select 的远程下拉只在有搜索词时,才会加载数据(显示出 option 列表) -->
|
||||
<!-- 使用 el-popover 在无数据/无搜索词时,显示一个无数据的提醒 -->
|
||||
<el-popover width="100%" placement="bottom" popper-class="remote-select-popper"
|
||||
:visible="state.focusStatus && !state.loading && !state.keyword && !state.options.length"
|
||||
:teleported="false" :content="$t('utils.No data')">
|
||||
<template #reference>
|
||||
<el-select ref="selectRef" class="w100" @focus="onFocus" @blur="onBlur"
|
||||
:loading="state.loading || state.accidentBlur" :filterable="true" :remote="true" clearable
|
||||
remote-show-suffix :remote-method="onLogKeyword" v-model.trim="state.value" @change="onChangeSelect"
|
||||
:multiple="multiple" :key="state.selectKey" @clear="onClear" @visible-change="onVisibleChange"
|
||||
v-bind="$attrs">
|
||||
<el-option class="remote-select-option" v-for="item in state.options" :label="item[field]"
|
||||
:value="item[state.primaryKey].toString()" :key="item[state.primaryKey]">
|
||||
<el-tooltip placement="right" effect="light" v-if="!isEmpty(tooltipParams)">
|
||||
<template #content>
|
||||
<p v-for="(tooltipParam, key) in tooltipParams" :key="key">{{ key }}: {{
|
||||
item[tooltipParam] }}</p>
|
||||
</template>
|
||||
<div>{{ item[field] }}</div>
|
||||
</el-tooltip>
|
||||
</el-option>
|
||||
<el-pagination v-if="state.total" :currentPage="state.currentPage" :page-size="state.pageSize"
|
||||
class="select-pagination" layout="->, prev, next" :total="state.total"
|
||||
@current-change="onSelectCurrentPageChange" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, watch, onMounted, onUnmounted, ref, nextTick, getCurrentInstance, toRaw } from 'vue'
|
||||
import { getSelectData } from '@/api/common'
|
||||
import { uuid } from '@/utils/random'
|
||||
import type { ElSelect } from 'element-plus'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { getArrayKey } from '@/utils/common'
|
||||
|
||||
const selectRef = ref<InstanceType<typeof ElSelect> | undefined>()
|
||||
type ElSelectProps = Partial<InstanceType<typeof ElSelect>['$props']>
|
||||
type valType = string | number | string[] | number[]
|
||||
|
||||
interface Props extends /* @vue-ignore */ ElSelectProps {
|
||||
pk?: string
|
||||
field?: string
|
||||
params?: anyObj
|
||||
multiple?: boolean
|
||||
remoteUrl: string
|
||||
modelValue: valType
|
||||
labelFormatter?: (optionData: anyObj, optionKey: string) => string
|
||||
tooltipParams?: anyObj
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
pk: 'id',
|
||||
field: 'name',
|
||||
params: () => {
|
||||
return {}
|
||||
},
|
||||
remoteUrl: '',
|
||||
modelValue: '',
|
||||
multiple: false,
|
||||
tooltipParams: () => {
|
||||
return {}
|
||||
},
|
||||
})
|
||||
|
||||
const state: {
|
||||
// 主表字段名(不带表别名)
|
||||
primaryKey: string
|
||||
options: anyObj[]
|
||||
loading: boolean
|
||||
total: number
|
||||
currentPage: number
|
||||
pageSize: number
|
||||
params: anyObj
|
||||
keyword: string
|
||||
value: valType
|
||||
selectKey: string
|
||||
initializeData: boolean
|
||||
accidentBlur: boolean
|
||||
focusStatus: boolean
|
||||
} = reactive({
|
||||
primaryKey: props.pk,
|
||||
options: [],
|
||||
loading: false,
|
||||
total: 0,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
params: props.params,
|
||||
keyword: '',
|
||||
value: props.modelValue ? props.modelValue : '',
|
||||
selectKey: uuid(),
|
||||
initializeData: false,
|
||||
accidentBlur: false,
|
||||
focusStatus: false,
|
||||
})
|
||||
|
||||
let io: null | IntersectionObserver = null
|
||||
const instance = getCurrentInstance()
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'update:modelValue', value: valType): void
|
||||
(e: 'row', value: any): void
|
||||
}>()
|
||||
|
||||
const onChangeSelect = (val: valType) => {
|
||||
emits('update:modelValue', val)
|
||||
if (typeof instance?.vnode.props?.onRow == 'function') {
|
||||
let pkArr = props.pk.split('.')
|
||||
let pk = pkArr[pkArr.length - 1]
|
||||
if (typeof val == 'number' || typeof val == 'string') {
|
||||
const dataKey = getArrayKey(state.options, pk, val.toString())
|
||||
emits('row', dataKey ? toRaw(state.options[dataKey]) : {})
|
||||
} else {
|
||||
const valueArr = []
|
||||
for (const key in val) {
|
||||
let dataKey = getArrayKey(state.options, pk, val[key].toString())
|
||||
if (dataKey) valueArr.push(toRaw(state.options[dataKey]))
|
||||
}
|
||||
emits('row', valueArr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onVisibleChange = (val: boolean) => {
|
||||
// 保持面板状态和焦点状态一致
|
||||
if (!val) {
|
||||
nextTick(() => {
|
||||
selectRef.value?.blur()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onFocus = () => {
|
||||
state.focusStatus = true
|
||||
if (selectRef.value?.query != state.keyword) {
|
||||
state.keyword = ''
|
||||
state.initializeData = false
|
||||
// el-select 自动清理搜索词会产生意外的脱焦
|
||||
state.accidentBlur = true
|
||||
}
|
||||
if (!state.initializeData) {
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
const onBlur = () => {
|
||||
state.focusStatus = false
|
||||
}
|
||||
|
||||
const onClear = () => {
|
||||
state.keyword = ''
|
||||
state.initializeData = false
|
||||
}
|
||||
|
||||
const onLogKeyword = (q: string) => {
|
||||
if (state.keyword != q) {
|
||||
state.keyword = q
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
const getData = (initValue: valType = '') => {
|
||||
state.loading = true
|
||||
state.params.page = state.currentPage
|
||||
state.params.initKey = props.pk
|
||||
state.params.initValue = initValue
|
||||
getSelectData(props.remoteUrl, state.keyword, state.params)
|
||||
.then((res) => {
|
||||
let initializeData = true
|
||||
let opts = res.data.options ? res.data.options : res.data.list
|
||||
if (typeof props.labelFormatter == 'function') {
|
||||
for (const key in opts) {
|
||||
opts[key][props.field] = props.labelFormatter(opts[key], key)
|
||||
}
|
||||
}
|
||||
state.options = opts
|
||||
state.total = res.data.total ?? 0
|
||||
if (initValue) {
|
||||
// 重新渲染组件,确保在赋值前,opts已加载到-兼容 modelValue 更新
|
||||
state.selectKey = uuid()
|
||||
initializeData = false
|
||||
}
|
||||
state.loading = false
|
||||
state.initializeData = initializeData
|
||||
if (state.accidentBlur) {
|
||||
nextTick(() => {
|
||||
const inputEl = selectRef.value?.$el.querySelector('.el-select__tags .el-select__input')
|
||||
inputEl && inputEl.focus()
|
||||
state.accidentBlur = false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
state.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
const onSelectCurrentPageChange = (val: number) => {
|
||||
state.currentPage = val
|
||||
getData()
|
||||
}
|
||||
|
||||
const initDefaultValue = () => {
|
||||
if (state.value) {
|
||||
// number[]转string[]确保默认值能够选中
|
||||
if (typeof state.value === 'object') {
|
||||
for (const key in state.value as string[]) {
|
||||
state.value[key] = state.value[key].toString()
|
||||
}
|
||||
} else if (typeof state.value === 'number') {
|
||||
state.value = state.value.toString()
|
||||
}
|
||||
getData(state.value)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.pk.indexOf('.') > 0) {
|
||||
let pk = props.pk.split('.')
|
||||
state.primaryKey = pk[1] ? pk[1] : pk[0]
|
||||
}
|
||||
initDefaultValue()
|
||||
|
||||
setTimeout(() => {
|
||||
if (window?.IntersectionObserver) {
|
||||
io = new IntersectionObserver((entries) => {
|
||||
for (const key in entries) {
|
||||
if (!entries[key].isIntersecting) selectRef.value?.blur()
|
||||
}
|
||||
})
|
||||
if (selectRef.value?.$el instanceof Element) {
|
||||
io.observe(selectRef.value.$el)
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
io?.disconnect()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
if (String(state.value) != String(newVal)) {
|
||||
state.value = newVal ? newVal : ''
|
||||
initDefaultValue()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const getSelectRef = () => {
|
||||
return selectRef.value
|
||||
}
|
||||
|
||||
const focus = () => {
|
||||
selectRef.value?.focus()
|
||||
}
|
||||
|
||||
const blur = () => {
|
||||
selectRef.value?.blur()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
blur,
|
||||
focus,
|
||||
getSelectRef,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.remote-select-popper) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.remote-select-option {
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="w100">
|
||||
<!-- el-select 的远程下拉只在有搜索词时,才会加载数据(显示出 option 列表) -->
|
||||
<!-- 使用 el-popover 在无数据/无搜索词时,显示一个无数据的提醒 -->
|
||||
<el-popover width="100%" placement="bottom" popper-class="remote-select-popper"
|
||||
:visible="state.focusStatus && !state.loading && !state.keyword && !state.options.length"
|
||||
:teleported="false" :content="$t('utils.No data')">
|
||||
<template #reference>
|
||||
<el-select ref="selectRef" class="w100" @focus="onFocus" @blur="onBlur"
|
||||
:loading="state.loading || state.accidentBlur" :filterable="true" :remote="true" clearable
|
||||
remote-show-suffix :remote-method="onLogKeyword" v-model.trim="state.value" @change="onChangeSelect"
|
||||
:multiple="multiple" :key="state.selectKey" @clear="onClear" @visible-change="onVisibleChange"
|
||||
v-bind="$attrs">
|
||||
<el-option class="remote-select-option" v-for="item in state.options" :label="item[field]"
|
||||
:value="item[state.primaryKey].toString()" :key="item[state.primaryKey]">
|
||||
<el-tooltip placement="right" effect="light" v-if="!isEmpty(tooltipParams)">
|
||||
<template #content>
|
||||
<p v-for="(tooltipParam, key) in tooltipParams" :key="key">{{ key }}: {{
|
||||
item[tooltipParam] }}</p>
|
||||
</template>
|
||||
<div>{{ item[field] }}</div>
|
||||
</el-tooltip>
|
||||
</el-option>
|
||||
<el-pagination v-if="state.total" :currentPage="state.currentPage" :page-size="state.pageSize"
|
||||
class="select-pagination" layout="->, prev, next" :total="state.total"
|
||||
@current-change="onSelectCurrentPageChange" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-popover>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive, watch, onMounted, onUnmounted, ref, nextTick, getCurrentInstance, toRaw } from 'vue'
|
||||
// import { getSelectData } from '@/api/common'
|
||||
import { uuid } from '@/utils/random'
|
||||
import type { ElSelect } from 'element-plus'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
// import { getArrayKey } from '@/utils/common'
|
||||
|
||||
const selectRef = ref<InstanceType<typeof ElSelect> | undefined>()
|
||||
type ElSelectProps = Partial<InstanceType<typeof ElSelect>['$props']>
|
||||
type valType = string | number | string[] | number[]
|
||||
|
||||
interface Props extends /* @vue-ignore */ ElSelectProps {
|
||||
pk?: string
|
||||
field?: string
|
||||
params?: anyObj
|
||||
multiple?: boolean
|
||||
remoteUrl: string
|
||||
modelValue: valType
|
||||
labelFormatter?: (optionData: anyObj, optionKey: string) => string
|
||||
tooltipParams?: anyObj
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
pk: 'id',
|
||||
field: 'name',
|
||||
params: () => {
|
||||
return {}
|
||||
},
|
||||
remoteUrl: '',
|
||||
modelValue: '',
|
||||
multiple: false,
|
||||
tooltipParams: () => {
|
||||
return {}
|
||||
},
|
||||
})
|
||||
|
||||
const state: {
|
||||
// 主表字段名(不带表别名)
|
||||
primaryKey: string
|
||||
options: anyObj[]
|
||||
loading: boolean
|
||||
total: number
|
||||
currentPage: number
|
||||
pageSize: number
|
||||
params: anyObj
|
||||
keyword: string
|
||||
value: valType
|
||||
selectKey: string
|
||||
initializeData: boolean
|
||||
accidentBlur: boolean
|
||||
focusStatus: boolean
|
||||
} = reactive({
|
||||
primaryKey: props.pk,
|
||||
options: [],
|
||||
loading: false,
|
||||
total: 0,
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
params: props.params,
|
||||
keyword: '',
|
||||
value: props.modelValue ? props.modelValue : '',
|
||||
selectKey: uuid(),
|
||||
initializeData: false,
|
||||
accidentBlur: false,
|
||||
focusStatus: false,
|
||||
})
|
||||
|
||||
let io: null | IntersectionObserver = null
|
||||
const instance = getCurrentInstance()
|
||||
|
||||
const emits = defineEmits<{
|
||||
(e: 'update:modelValue', value: valType): void
|
||||
(e: 'row', value: any): void
|
||||
}>()
|
||||
|
||||
const onChangeSelect = (val: valType) => {
|
||||
emits('update:modelValue', val)
|
||||
if (typeof instance?.vnode.props?.onRow == 'function') {
|
||||
let pkArr = props.pk.split('.')
|
||||
let pk = pkArr[pkArr.length - 1]
|
||||
if (typeof val == 'number' || typeof val == 'string') {
|
||||
// const dataKey = getArrayKey(state.options, pk, val.toString())
|
||||
// emits('row', dataKey ? toRaw(state.options[dataKey]) : {})
|
||||
} else {
|
||||
// const valueArr = []
|
||||
// for (const key in val) {
|
||||
// let dataKey = getArrayKey(state.options, pk, val[key].toString())
|
||||
// if (dataKey) valueArr.push(toRaw(state.options[dataKey]))
|
||||
// }
|
||||
// emits('row', valueArr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const onVisibleChange = (val: boolean) => {
|
||||
// 保持面板状态和焦点状态一致
|
||||
if (!val) {
|
||||
nextTick(() => {
|
||||
selectRef.value?.blur()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const onFocus = () => {
|
||||
state.focusStatus = true
|
||||
if (selectRef.value?.query != state.keyword) {
|
||||
state.keyword = ''
|
||||
state.initializeData = false
|
||||
// el-select 自动清理搜索词会产生意外的脱焦
|
||||
state.accidentBlur = true
|
||||
}
|
||||
if (!state.initializeData) {
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
const onBlur = () => {
|
||||
state.focusStatus = false
|
||||
}
|
||||
|
||||
const onClear = () => {
|
||||
state.keyword = ''
|
||||
state.initializeData = false
|
||||
}
|
||||
|
||||
const onLogKeyword = (q: string) => {
|
||||
if (state.keyword != q) {
|
||||
state.keyword = q
|
||||
getData()
|
||||
}
|
||||
}
|
||||
|
||||
const getData = (initValue: valType = '') => {
|
||||
state.loading = true
|
||||
state.params.page = state.currentPage
|
||||
state.params.initKey = props.pk
|
||||
state.params.initValue = initValue
|
||||
getSelectData(props.remoteUrl, state.keyword, state.params)
|
||||
.then((res) => {
|
||||
let initializeData = true
|
||||
let opts = res.data.options ? res.data.options : res.data.list
|
||||
if (typeof props.labelFormatter == 'function') {
|
||||
for (const key in opts) {
|
||||
opts[key][props.field] = props.labelFormatter(opts[key], key)
|
||||
}
|
||||
}
|
||||
state.options = opts
|
||||
state.total = res.data.total ?? 0
|
||||
if (initValue) {
|
||||
// 重新渲染组件,确保在赋值前,opts已加载到-兼容 modelValue 更新
|
||||
state.selectKey = uuid()
|
||||
initializeData = false
|
||||
}
|
||||
state.loading = false
|
||||
state.initializeData = initializeData
|
||||
if (state.accidentBlur) {
|
||||
nextTick(() => {
|
||||
const inputEl = selectRef.value?.$el.querySelector('.el-select__tags .el-select__input')
|
||||
inputEl && inputEl.focus()
|
||||
state.accidentBlur = false
|
||||
})
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
state.loading = false
|
||||
})
|
||||
}
|
||||
|
||||
const onSelectCurrentPageChange = (val: number) => {
|
||||
state.currentPage = val
|
||||
getData()
|
||||
}
|
||||
|
||||
const initDefaultValue = () => {
|
||||
if (state.value) {
|
||||
// number[]转string[]确保默认值能够选中
|
||||
if (typeof state.value === 'object') {
|
||||
for (const key in state.value as string[]) {
|
||||
state.value[key] = state.value[key].toString()
|
||||
}
|
||||
} else if (typeof state.value === 'number') {
|
||||
state.value = state.value.toString()
|
||||
}
|
||||
getData(state.value)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (props.pk.indexOf('.') > 0) {
|
||||
let pk = props.pk.split('.')
|
||||
state.primaryKey = pk[1] ? pk[1] : pk[0]
|
||||
}
|
||||
initDefaultValue()
|
||||
|
||||
setTimeout(() => {
|
||||
if (window?.IntersectionObserver) {
|
||||
io = new IntersectionObserver((entries) => {
|
||||
for (const key in entries) {
|
||||
if (!entries[key].isIntersecting) selectRef.value?.blur()
|
||||
}
|
||||
})
|
||||
if (selectRef.value?.$el instanceof Element) {
|
||||
io.observe(selectRef.value.$el)
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
io?.disconnect()
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
if (String(state.value) != String(newVal)) {
|
||||
state.value = newVal ? newVal : ''
|
||||
initDefaultValue()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const getSelectRef = () => {
|
||||
return selectRef.value
|
||||
}
|
||||
|
||||
const focus = () => {
|
||||
selectRef.value?.focus()
|
||||
}
|
||||
|
||||
const blur = () => {
|
||||
selectRef.value?.blur()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
blur,
|
||||
focus,
|
||||
getSelectRef,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.remote-select-popper) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.remote-select-option {
|
||||
white-space: pre;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,414 +1,414 @@
|
||||
<script lang="ts">
|
||||
import type { PropType, VNode } from 'vue'
|
||||
import type { modelValueTypes, InputAttr, InputData } from '@/components/baInput'
|
||||
import { createVNode, resolveComponent, defineComponent, computed, reactive } from 'vue'
|
||||
import { inputTypes } from '@/components/baInput'
|
||||
import Array from '@/components/baInput/components/array.vue'
|
||||
import RemoteSelect from '@/components/baInput/components/remoteSelect.vue'
|
||||
import IconSelector from '@/components/baInput/components/iconSelector.vue'
|
||||
import Editor from '@/components/baInput/components/editor.vue'
|
||||
import { getArea } from '@/api/common'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'baInput',
|
||||
props: {
|
||||
// 输入框类型,支持的输入框见 inputTypes
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
validator: (value: string) => {
|
||||
return inputTypes.includes(value)
|
||||
},
|
||||
},
|
||||
// 双向绑定值
|
||||
modelValue: {
|
||||
type: null,
|
||||
required: true,
|
||||
},
|
||||
// 输入框的附加属性
|
||||
attr: {
|
||||
type: Object as PropType<InputAttr>,
|
||||
default: () => {},
|
||||
},
|
||||
// 额外数据,radio、checkbox的选项等数据
|
||||
data: {
|
||||
type: Object as PropType<InputData>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
setup(props, { emit }) {
|
||||
const onValueUpdate = (value: modelValueTypes) => {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
|
||||
// 子级元素属性
|
||||
let childrenAttr = props.data && props.data.childrenAttr ? props.data.childrenAttr : {}
|
||||
|
||||
// string number textarea password
|
||||
const sntp = () => {
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-input'), {
|
||||
type: props.type == 'string' ? 'text' : props.type,
|
||||
...props.attr,
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
// radio checkbox
|
||||
const rc = () => {
|
||||
if (!props.data || !props.data.content) {
|
||||
console.warn('请传递 ' + props.type + '的 content')
|
||||
}
|
||||
let vNode: VNode[] = []
|
||||
for (const key in props.data.content) {
|
||||
vNode.push(
|
||||
createVNode(
|
||||
resolveComponent('el-' + props.type),
|
||||
{
|
||||
label: key,
|
||||
...childrenAttr,
|
||||
},
|
||||
() => props.data.content[key]
|
||||
)
|
||||
)
|
||||
}
|
||||
return () => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.type == 'radio') {
|
||||
if (props.modelValue == undefined) return ''
|
||||
return '' + props.modelValue
|
||||
} else {
|
||||
let modelValueArr: anyObj = []
|
||||
for (const key in props.modelValue) {
|
||||
modelValueArr[key] = '' + props.modelValue[key]
|
||||
}
|
||||
return modelValueArr
|
||||
}
|
||||
})
|
||||
return createVNode(
|
||||
resolveComponent('el-' + props.type + '-group'),
|
||||
{
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
},
|
||||
() => vNode
|
||||
)
|
||||
}
|
||||
}
|
||||
// select selects
|
||||
const select = () => {
|
||||
let vNode: VNode[] = []
|
||||
if (!props.data || !props.data.content) {
|
||||
console.warn('请传递 ' + props.type + '的 content')
|
||||
}
|
||||
for (const key in props.data.content) {
|
||||
vNode.push(
|
||||
createVNode(resolveComponent('el-option'), {
|
||||
key: key,
|
||||
label: props.data.content[key],
|
||||
value: key,
|
||||
...childrenAttr,
|
||||
})
|
||||
)
|
||||
}
|
||||
return () => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.type == 'select') {
|
||||
if (props.modelValue == undefined) return ''
|
||||
return '' + props.modelValue
|
||||
} else {
|
||||
let modelValueArr: anyObj = []
|
||||
for (const key in props.modelValue) {
|
||||
modelValueArr[key] = '' + props.modelValue[key]
|
||||
}
|
||||
return modelValueArr
|
||||
}
|
||||
})
|
||||
return createVNode(
|
||||
resolveComponent('el-select'),
|
||||
{
|
||||
class: 'w100',
|
||||
multiple: props.type == 'select' ? false : true,
|
||||
clearable: true,
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
},
|
||||
() => vNode
|
||||
)
|
||||
}
|
||||
}
|
||||
// datetime
|
||||
const datetime = () => {
|
||||
let valueFormat = 'YYYY-MM-DD HH:mm:ss'
|
||||
switch (props.type) {
|
||||
case 'date':
|
||||
valueFormat = 'YYYY-MM-DD'
|
||||
break
|
||||
case 'year':
|
||||
valueFormat = 'YYYY'
|
||||
break
|
||||
}
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-date-picker'), {
|
||||
class: 'w100',
|
||||
type: props.type,
|
||||
'value-format': valueFormat,
|
||||
...props.attr,
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
// remoteSelect remoteSelects
|
||||
const remoteSelect = () => {
|
||||
return () =>
|
||||
createVNode(RemoteSelect, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
multiple: props.type == 'remoteSelect' ? false : true,
|
||||
...props.attr,
|
||||
})
|
||||
}
|
||||
|
||||
const buildFun = new Map([
|
||||
['string', sntp],
|
||||
['number', sntp],
|
||||
['textarea', sntp],
|
||||
['password', sntp],
|
||||
['radio', rc],
|
||||
['checkbox', rc],
|
||||
[
|
||||
'switch',
|
||||
() => {
|
||||
const valueType = computed(() => typeof props.modelValue)
|
||||
const valueComputed = computed(() => {
|
||||
if (valueType.value === 'boolean') {
|
||||
return props.modelValue
|
||||
} else {
|
||||
let valueTmp = parseInt(props.modelValue as string)
|
||||
return isNaN(valueTmp) || valueTmp <= 0 ? false : true
|
||||
}
|
||||
})
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-switch'), {
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': (value: boolean) => {
|
||||
let newValue: boolean | string | number = value
|
||||
switch (valueType.value) {
|
||||
case 'string':
|
||||
newValue = value ? '1' : '0'
|
||||
break
|
||||
case 'number':
|
||||
newValue = value ? 1 : 0
|
||||
}
|
||||
emit('update:modelValue', newValue)
|
||||
},
|
||||
})
|
||||
},
|
||||
],
|
||||
['datetime', datetime],
|
||||
[
|
||||
'year',
|
||||
() => {
|
||||
return () => {
|
||||
const valueComputed = computed(() => (!props.modelValue ? null : '' + props.modelValue))
|
||||
return createVNode(resolveComponent('el-date-picker'), {
|
||||
class: 'w100',
|
||||
type: props.type,
|
||||
'value-format': 'YYYY',
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
},
|
||||
],
|
||||
['date', datetime],
|
||||
[
|
||||
'time',
|
||||
() => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.modelValue instanceof Date) {
|
||||
return props.modelValue
|
||||
} else if (!props.modelValue) {
|
||||
return ''
|
||||
} else {
|
||||
let date = new Date()
|
||||
return new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + props.modelValue)
|
||||
}
|
||||
})
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-time-picker'), {
|
||||
class: 'w100',
|
||||
clearable: true,
|
||||
format: 'HH:mm:ss',
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
},
|
||||
],
|
||||
['select', select],
|
||||
['selects', select],
|
||||
[
|
||||
'array',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(Array, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
['remoteSelect', remoteSelect],
|
||||
['remoteSelects', remoteSelect],
|
||||
[
|
||||
'city',
|
||||
() => {
|
||||
type Node = { value?: number; label?: string; leaf?: boolean }
|
||||
let maxLevel = props.data && props.data.level ? props.data.level - 1 : 2
|
||||
const lastLazyValue: {
|
||||
value: string | number[] | unknown
|
||||
nodes: Node[]
|
||||
key: string
|
||||
currentRequest: any
|
||||
} = reactive({
|
||||
value: 'ready',
|
||||
nodes: [],
|
||||
key: '',
|
||||
currentRequest: null,
|
||||
})
|
||||
|
||||
// 请求到的node备份-s
|
||||
let nodeEbak: anyObj = {}
|
||||
const getNodes = (level: number, key: string) => {
|
||||
if (nodeEbak[level] && nodeEbak[level][key]) {
|
||||
return nodeEbak[level][key]
|
||||
}
|
||||
return false
|
||||
}
|
||||
const setNodes = (level: number, key: string, nodes: Node[] = []) => {
|
||||
if (!nodeEbak[level]) {
|
||||
nodeEbak[level] = {}
|
||||
}
|
||||
nodeEbak[level][key] = nodes
|
||||
}
|
||||
// 请求到的node备份-e
|
||||
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-cascader'), {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
class: 'w100',
|
||||
clearable: true,
|
||||
props: {
|
||||
lazy: true,
|
||||
lazyLoad(node: any, resolve: any) {
|
||||
// lazyLoad会频繁触发,在本地存储请求结果,供重复触发时直接读取
|
||||
const { level, pathValues } = node
|
||||
let key = pathValues.join(',')
|
||||
key = key ? key : 'init'
|
||||
|
||||
let locaNode = getNodes(level, key)
|
||||
if (locaNode) {
|
||||
return resolve(locaNode)
|
||||
}
|
||||
|
||||
if (lastLazyValue.key == key && lastLazyValue.value == props.modelValue) {
|
||||
if (lastLazyValue.currentRequest) {
|
||||
return lastLazyValue.currentRequest
|
||||
}
|
||||
return resolve(lastLazyValue.nodes)
|
||||
}
|
||||
|
||||
let nodes: Node[] = []
|
||||
lastLazyValue.key = key
|
||||
lastLazyValue.value = props.modelValue
|
||||
lastLazyValue.currentRequest = getArea(pathValues).then((res) => {
|
||||
let toStr = false
|
||||
if (props.modelValue && typeof (props.modelValue as anyObj)[0] === 'string') {
|
||||
toStr = true
|
||||
}
|
||||
for (const key in res.data) {
|
||||
if (toStr) {
|
||||
res.data[key].value = res.data[key].value.toString()
|
||||
}
|
||||
res.data[key].leaf = level >= maxLevel
|
||||
nodes.push(res.data[key])
|
||||
}
|
||||
lastLazyValue.nodes = nodes
|
||||
lastLazyValue.currentRequest = null
|
||||
setNodes(level, key, nodes)
|
||||
resolve(nodes)
|
||||
})
|
||||
},
|
||||
},
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
['image', upload],
|
||||
['images', upload],
|
||||
['file', upload],
|
||||
['files', upload],
|
||||
[
|
||||
'icon',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(IconSelector, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'color',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-color-picker'), {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'editor',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(Editor, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'default',
|
||||
() => {
|
||||
console.warn('暂不支持' + props.type + '的输入框类型,你可以自行在 BaInput 组件内添加逻辑')
|
||||
},
|
||||
],
|
||||
])
|
||||
|
||||
let action = buildFun.get(props.type) || buildFun.get('default')
|
||||
return action!.call(this)
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ba-upload-image :deep(.el-upload--picture-card) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.ba-upload-file :deep(.el-upload-list) {
|
||||
margin-left: -10px;
|
||||
}
|
||||
</style>
|
||||
<script lang="ts">
|
||||
import type { PropType, VNode } from 'vue'
|
||||
import type { modelValueTypes, InputAttr, InputData } from '@/components/baInput'
|
||||
import { createVNode, resolveComponent, defineComponent, computed, reactive } from 'vue'
|
||||
import { inputTypes } from '@/components/baInput'
|
||||
import Array from '@/components/baInput/components/array.vue'
|
||||
import RemoteSelect from '@/components/baInput/components/remoteSelect.vue'
|
||||
import IconSelector from '@/components/baInput/components/iconSelector.vue'
|
||||
import Editor from '@/components/baInput/components/editor.vue'
|
||||
// import { getArea } from '@/api/common'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'baInput',
|
||||
props: {
|
||||
// 输入框类型,支持的输入框见 inputTypes
|
||||
type: {
|
||||
type: String,
|
||||
required: true,
|
||||
validator: (value: string) => {
|
||||
return inputTypes.includes(value)
|
||||
},
|
||||
},
|
||||
// 双向绑定值
|
||||
modelValue: {
|
||||
type: null,
|
||||
required: true,
|
||||
},
|
||||
// 输入框的附加属性
|
||||
attr: {
|
||||
type: Object as PropType<InputAttr>,
|
||||
default: () => {},
|
||||
},
|
||||
// 额外数据,radio、checkbox的选项等数据
|
||||
data: {
|
||||
type: Object as PropType<InputData>,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
emits: ['update:modelValue'],
|
||||
setup(props, { emit }) {
|
||||
const onValueUpdate = (value: modelValueTypes) => {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
|
||||
// 子级元素属性
|
||||
let childrenAttr = props.data && props.data.childrenAttr ? props.data.childrenAttr : {}
|
||||
|
||||
// string number textarea password
|
||||
const sntp = () => {
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-input'), {
|
||||
type: props.type == 'string' ? 'text' : props.type,
|
||||
...props.attr,
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
// radio checkbox
|
||||
const rc = () => {
|
||||
if (!props.data || !props.data.content) {
|
||||
console.warn('请传递 ' + props.type + '的 content')
|
||||
}
|
||||
let vNode: VNode[] = []
|
||||
for (const key in props.data.content) {
|
||||
vNode.push(
|
||||
createVNode(
|
||||
resolveComponent('el-' + props.type),
|
||||
{
|
||||
label: key,
|
||||
...childrenAttr,
|
||||
},
|
||||
() => props.data.content[key]
|
||||
)
|
||||
)
|
||||
}
|
||||
return () => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.type == 'radio') {
|
||||
if (props.modelValue == undefined) return ''
|
||||
return '' + props.modelValue
|
||||
} else {
|
||||
let modelValueArr: anyObj = []
|
||||
for (const key in props.modelValue) {
|
||||
modelValueArr[key] = '' + props.modelValue[key]
|
||||
}
|
||||
return modelValueArr
|
||||
}
|
||||
})
|
||||
return createVNode(
|
||||
resolveComponent('el-' + props.type + '-group'),
|
||||
{
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
},
|
||||
() => vNode
|
||||
)
|
||||
}
|
||||
}
|
||||
// select selects
|
||||
const select = () => {
|
||||
let vNode: VNode[] = []
|
||||
if (!props.data || !props.data.content) {
|
||||
console.warn('请传递 ' + props.type + '的 content')
|
||||
}
|
||||
for (const key in props.data.content) {
|
||||
vNode.push(
|
||||
createVNode(resolveComponent('el-option'), {
|
||||
key: key,
|
||||
label: props.data.content[key],
|
||||
value: key,
|
||||
...childrenAttr,
|
||||
})
|
||||
)
|
||||
}
|
||||
return () => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.type == 'select') {
|
||||
if (props.modelValue == undefined) return ''
|
||||
return '' + props.modelValue
|
||||
} else {
|
||||
let modelValueArr: anyObj = []
|
||||
for (const key in props.modelValue) {
|
||||
modelValueArr[key] = '' + props.modelValue[key]
|
||||
}
|
||||
return modelValueArr
|
||||
}
|
||||
})
|
||||
return createVNode(
|
||||
resolveComponent('el-select'),
|
||||
{
|
||||
class: 'w100',
|
||||
multiple: props.type == 'select' ? false : true,
|
||||
clearable: true,
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
},
|
||||
() => vNode
|
||||
)
|
||||
}
|
||||
}
|
||||
// datetime
|
||||
const datetime = () => {
|
||||
let valueFormat = 'YYYY-MM-DD HH:mm:ss'
|
||||
switch (props.type) {
|
||||
case 'date':
|
||||
valueFormat = 'YYYY-MM-DD'
|
||||
break
|
||||
case 'year':
|
||||
valueFormat = 'YYYY'
|
||||
break
|
||||
}
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-date-picker'), {
|
||||
class: 'w100',
|
||||
type: props.type,
|
||||
'value-format': valueFormat,
|
||||
...props.attr,
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
// remoteSelect remoteSelects
|
||||
const remoteSelect = () => {
|
||||
return () =>
|
||||
createVNode(RemoteSelect, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
multiple: props.type == 'remoteSelect' ? false : true,
|
||||
...props.attr,
|
||||
})
|
||||
}
|
||||
|
||||
const buildFun = new Map([
|
||||
['string', sntp],
|
||||
['number', sntp],
|
||||
['textarea', sntp],
|
||||
['password', sntp],
|
||||
['radio', rc],
|
||||
['checkbox', rc],
|
||||
[
|
||||
'switch',
|
||||
() => {
|
||||
const valueType = computed(() => typeof props.modelValue)
|
||||
const valueComputed = computed(() => {
|
||||
if (valueType.value === 'boolean') {
|
||||
return props.modelValue
|
||||
} else {
|
||||
let valueTmp = parseInt(props.modelValue as string)
|
||||
return isNaN(valueTmp) || valueTmp <= 0 ? false : true
|
||||
}
|
||||
})
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-switch'), {
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': (value: boolean) => {
|
||||
let newValue: boolean | string | number = value
|
||||
switch (valueType.value) {
|
||||
case 'string':
|
||||
newValue = value ? '1' : '0'
|
||||
break
|
||||
case 'number':
|
||||
newValue = value ? 1 : 0
|
||||
}
|
||||
emit('update:modelValue', newValue)
|
||||
},
|
||||
})
|
||||
},
|
||||
],
|
||||
['datetime', datetime],
|
||||
[
|
||||
'year',
|
||||
() => {
|
||||
return () => {
|
||||
const valueComputed = computed(() => (!props.modelValue ? null : '' + props.modelValue))
|
||||
return createVNode(resolveComponent('el-date-picker'), {
|
||||
class: 'w100',
|
||||
type: props.type,
|
||||
'value-format': 'YYYY',
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
}
|
||||
},
|
||||
],
|
||||
['date', datetime],
|
||||
[
|
||||
'time',
|
||||
() => {
|
||||
const valueComputed = computed(() => {
|
||||
if (props.modelValue instanceof Date) {
|
||||
return props.modelValue
|
||||
} else if (!props.modelValue) {
|
||||
return ''
|
||||
} else {
|
||||
let date = new Date()
|
||||
return new Date(date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' + props.modelValue)
|
||||
}
|
||||
})
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-time-picker'), {
|
||||
class: 'w100',
|
||||
clearable: true,
|
||||
format: 'HH:mm:ss',
|
||||
...props.attr,
|
||||
modelValue: valueComputed.value,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
})
|
||||
},
|
||||
],
|
||||
['select', select],
|
||||
['selects', select],
|
||||
[
|
||||
'array',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(Array, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
['remoteSelect', remoteSelect],
|
||||
['remoteSelects', remoteSelect],
|
||||
[
|
||||
'city',
|
||||
() => {
|
||||
type Node = { value?: number; label?: string; leaf?: boolean }
|
||||
let maxLevel = props.data && props.data.level ? props.data.level - 1 : 2
|
||||
const lastLazyValue: {
|
||||
value: string | number[] | unknown
|
||||
nodes: Node[]
|
||||
key: string
|
||||
currentRequest: any
|
||||
} = reactive({
|
||||
value: 'ready',
|
||||
nodes: [],
|
||||
key: '',
|
||||
currentRequest: null,
|
||||
})
|
||||
|
||||
// 请求到的node备份-s
|
||||
let nodeEbak: anyObj = {}
|
||||
const getNodes = (level: number, key: string) => {
|
||||
if (nodeEbak[level] && nodeEbak[level][key]) {
|
||||
return nodeEbak[level][key]
|
||||
}
|
||||
return false
|
||||
}
|
||||
const setNodes = (level: number, key: string, nodes: Node[] = []) => {
|
||||
if (!nodeEbak[level]) {
|
||||
nodeEbak[level] = {}
|
||||
}
|
||||
nodeEbak[level][key] = nodes
|
||||
}
|
||||
// 请求到的node备份-e
|
||||
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-cascader'), {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
class: 'w100',
|
||||
clearable: true,
|
||||
props: {
|
||||
lazy: true,
|
||||
lazyLoad(node: any, resolve: any) {
|
||||
// lazyLoad会频繁触发,在本地存储请求结果,供重复触发时直接读取
|
||||
const { level, pathValues } = node
|
||||
let key = pathValues.join(',')
|
||||
key = key ? key : 'init'
|
||||
|
||||
let locaNode = getNodes(level, key)
|
||||
if (locaNode) {
|
||||
return resolve(locaNode)
|
||||
}
|
||||
|
||||
if (lastLazyValue.key == key && lastLazyValue.value == props.modelValue) {
|
||||
if (lastLazyValue.currentRequest) {
|
||||
return lastLazyValue.currentRequest
|
||||
}
|
||||
return resolve(lastLazyValue.nodes)
|
||||
}
|
||||
|
||||
let nodes: Node[] = []
|
||||
lastLazyValue.key = key
|
||||
lastLazyValue.value = props.modelValue
|
||||
// lastLazyValue.currentRequest = getArea(pathValues).then((res) => {
|
||||
// let toStr = false
|
||||
// if (props.modelValue && typeof (props.modelValue as anyObj)[0] === 'string') {
|
||||
// toStr = true
|
||||
// }
|
||||
// for (const key in res.data) {
|
||||
// if (toStr) {
|
||||
// res.data[key].value = res.data[key].value.toString()
|
||||
// }
|
||||
// res.data[key].leaf = level >= maxLevel
|
||||
// nodes.push(res.data[key])
|
||||
// }
|
||||
// lastLazyValue.nodes = nodes
|
||||
// lastLazyValue.currentRequest = null
|
||||
// setNodes(level, key, nodes)
|
||||
// resolve(nodes)
|
||||
// })
|
||||
},
|
||||
},
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
['image', upload],
|
||||
['images', upload],
|
||||
['file', upload],
|
||||
['files', upload],
|
||||
[
|
||||
'icon',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(IconSelector, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'color',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(resolveComponent('el-color-picker'), {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'editor',
|
||||
() => {
|
||||
return () =>
|
||||
createVNode(Editor, {
|
||||
modelValue: props.modelValue,
|
||||
'onUpdate:modelValue': onValueUpdate,
|
||||
...props.attr,
|
||||
})
|
||||
},
|
||||
],
|
||||
[
|
||||
'default',
|
||||
() => {
|
||||
console.warn('暂不支持' + props.type + '的输入框类型,你可以自行在 BaInput 组件内添加逻辑')
|
||||
},
|
||||
],
|
||||
])
|
||||
|
||||
let action = buildFun.get(props.type) || buildFun.get('default')
|
||||
return action!.call(this)
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.ba-upload-image :deep(.el-upload--picture-card) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.ba-upload-file :deep(.el-upload-list) {
|
||||
margin-left: -10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
480
src/components/cockpit/F47Curve/index.vue
Normal file
@@ -0,0 +1,480 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--F47曲线 -->
|
||||
<TableHeader :showReset="false" @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
|
||||
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" draggable title="瞬时/RMS波形" append-to-body width="70%">
|
||||
<waveFormAnalysis
|
||||
v-loading="loading"
|
||||
v-if="isWaveCharts"
|
||||
ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false"
|
||||
:wp="wp"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { analyseWave } from '@/api/common'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number]},
|
||||
h: { type: [String, Number]},
|
||||
width: { type: [String, Number]},
|
||||
height: { type: [String, Number]},
|
||||
timeKey: { type: [String, Number]},
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
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: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
const gongData = gongfunction(tableStore.table.data)
|
||||
data.gs = tableStore.table.data.length
|
||||
data.krr = gongData.pointI.length
|
||||
data.bkrr = gongData.pointIun.length
|
||||
// console.log(gongData,'789000')
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: `F47曲线`
|
||||
},
|
||||
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 = ''
|
||||
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[1].toFixed(2) + '%</font>'
|
||||
return relVal
|
||||
}
|
||||
},
|
||||
|
||||
xAxis: [
|
||||
{
|
||||
type: 'log',
|
||||
min: 0.001,
|
||||
max: 1000,
|
||||
splitLine: {
|
||||
show: false
|
||||
},
|
||||
name: 's'
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
max: function (value: any) {
|
||||
return value.max + 20
|
||||
},
|
||||
splitNumber: 10,
|
||||
minInterval: 0.1,
|
||||
name: '%'
|
||||
}
|
||||
],
|
||||
color: ['#DAA520', 'green', 'red'],
|
||||
options: {
|
||||
dataZoom: null,
|
||||
series: [
|
||||
{
|
||||
name: '边界线',
|
||||
type: 'line',
|
||||
data: [
|
||||
[0.05, 0],
|
||||
[0.05, 50],
|
||||
[0.2, 50],
|
||||
[0.2, 70],
|
||||
[0.5, 70],
|
||||
[0.5, 80],
|
||||
[10, 80],
|
||||
[1000, 80]
|
||||
],
|
||||
showSymbol: false,
|
||||
tooltips: {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '可容忍事件',
|
||||
type: 'scatter',
|
||||
symbol: 'circle',
|
||||
symbolSize: 8,
|
||||
data: gongData.pointF,
|
||||
// data: [
|
||||
// [0.2, 10, '2023-01-01 10:00:00'],
|
||||
// [0.4, 50, '2023-01-01 11:00:00']
|
||||
// ],
|
||||
legendSymbol: 'circle',
|
||||
emphasis: {
|
||||
focus: 'series',
|
||||
itemStyle: {
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2,
|
||||
shadowBlur: 10,
|
||||
shadowColor: 'rgba(0, 0, 0, 0.5)'
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
show: true,
|
||||
trigger: 'item',
|
||||
formatter: function (params: any) {
|
||||
return `<strong>可容忍事件</strong><br/>
|
||||
持续时间: ${params.value[0]}s<br/>
|
||||
特征幅值: ${params.value[1].toFixed(2)}%<br/>
|
||||
发生时间: ${params.value[2] || 'N/A'}`
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: '不可容忍事件',
|
||||
type: 'scatter',
|
||||
symbol: 'rect',
|
||||
symbolSize: 8,
|
||||
data: gongData.pointFun,
|
||||
legendSymbol: 'rect'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
function gongfunction(arr: any) {
|
||||
let standI = 0
|
||||
let unstandI = 0
|
||||
let standF = 0
|
||||
let unstandF = 0
|
||||
let total = 0
|
||||
let pointIun = []
|
||||
let pointI = []
|
||||
let pointF = []
|
||||
let pointFun = []
|
||||
total = arr.length
|
||||
if (total == 0) {
|
||||
} else {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
let point = []
|
||||
let xx = arr[i].persistTime
|
||||
let yy = arr[i].eventValue
|
||||
let time = arr[i].time
|
||||
let eventId = arr[i].eventId
|
||||
// let index =arr[i].eventDetailIndex;
|
||||
point = [xx, yy, time, eventId]
|
||||
|
||||
if (xx <= 0.003) {
|
||||
let line = 0
|
||||
line = 250 - 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' } }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (xx < 0.05) {
|
||||
standF++
|
||||
pointF.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'green' } }
|
||||
})
|
||||
} else if (xx < 0.2) {
|
||||
if (yy > 50) {
|
||||
standF++
|
||||
pointF.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'green' } }
|
||||
})
|
||||
} else {
|
||||
unstandF++
|
||||
pointFun.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'red' } }
|
||||
})
|
||||
}
|
||||
} else if (xx < 0.5) {
|
||||
if (yy > 70) {
|
||||
standF++
|
||||
pointF.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'green' } }
|
||||
})
|
||||
} else {
|
||||
unstandF++
|
||||
pointFun.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'red' } }
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (yy > 80) {
|
||||
standF++
|
||||
pointF.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'green' } }
|
||||
})
|
||||
} else {
|
||||
unstandF++
|
||||
pointFun.push({
|
||||
value: point,
|
||||
itemStyle: { normal: { color: 'red' } }
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
standI,
|
||||
unstandI,
|
||||
pointI,
|
||||
pointIun,
|
||||
standF,
|
||||
unstandF,
|
||||
pointF,
|
||||
pointFun
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
}, 100)
|
||||
})
|
||||
|
||||
// 点击事件处理函数
|
||||
const handleChartClick = (params: any) => {
|
||||
if (params.seriesName === '可容忍事件') {
|
||||
// 处理可容忍事件点击
|
||||
ElMessage.info(`点击了可容忍事件: 持续时间${params.value[0]}s, 幅值${params.value[1].toFixed(2)}%`)
|
||||
handleTolerableEventClick(params)
|
||||
} else if (params.seriesName === '不可容忍事件') {
|
||||
// 处理不可容忍事件点击
|
||||
ElMessage.info(`点击了不可容忍事件: 持续时间${params.value[0]}s, 幅值${params.value[1].toFixed(2)}%`)
|
||||
handleIntolerableEventClick(params)
|
||||
}
|
||||
}
|
||||
|
||||
// 可容忍事件点击处理函数
|
||||
const handleTolerableEventClick = async (row: any) => {
|
||||
console.log('可容忍事件详情:', row)
|
||||
isWaveCharts.value = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
boxoList.value.featureAmplitude = row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null
|
||||
boxoList.value.systemType = 'WX'
|
||||
wp.value = res.data
|
||||
}
|
||||
loading.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
row.loading1 = false
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
nextTick(() => {
|
||||
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>
|
||||
176
src/components/cockpit/directionStatistics/index.vue
Normal file
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--暂降方向统计 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<my-echart class="tall" :options="echartList" :style="{ width: prop.width, height: `calc(${prop.height} )` }" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
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 data = [
|
||||
{
|
||||
name: '来自电网',
|
||||
value: 4
|
||||
},
|
||||
{
|
||||
name: '来自负荷',
|
||||
value: 41
|
||||
}
|
||||
]
|
||||
const echartList = ref({
|
||||
title: {},
|
||||
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
top: 'center',
|
||||
right: '5%',
|
||||
formatter: function (e: any) {
|
||||
return e + ' ' + data.filter(item => item.name == e)[0].value + '次'
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
show: false
|
||||
},
|
||||
yAxis: {
|
||||
show: false
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
|
||||
options: {
|
||||
dataZoom: null,
|
||||
title: [
|
||||
{
|
||||
text: '暂降方向统计',
|
||||
left: 'center'
|
||||
},
|
||||
{
|
||||
text: data[0].value + data[1].value + '次',
|
||||
left: 'center',
|
||||
top: 'center'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
center: 'center',
|
||||
radius: ['55%', '75%'],
|
||||
label: {
|
||||
show: false,
|
||||
position: 'outside',
|
||||
textStyle: {
|
||||
//数值样式
|
||||
}
|
||||
},
|
||||
name: '事件统计',
|
||||
data: data
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
const OverLimitDetailsRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/dept/deptTree',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
console.log(row)
|
||||
OverLimitDetailsRef.value.open(row)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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>
|
||||
@@ -0,0 +1,150 @@
|
||||
<template>
|
||||
<!-- 指标日趋势图 -->
|
||||
<el-dialog draggable :title="dialogTitle" v-model="dialogVisible" append-to-body width="70%">
|
||||
<div :style="pageHeight">
|
||||
<my-echart class="tall" :options="echartList" style="width: 100%" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { limitExtentDayData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import { yMethod } from '@/utils/echartMethod'
|
||||
const prop = defineProps({
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const pageHeight = mainHeight(0, 2)
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
|
||||
const dialogTitle = ref('')
|
||||
|
||||
const config = useConfig()
|
||||
|
||||
const dialogText = ref('')
|
||||
|
||||
const echartList = ref()
|
||||
|
||||
const init = () => {
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: dialogText.value
|
||||
},
|
||||
legend: {
|
||||
itemWidth: 20,
|
||||
itemHeight: 20,
|
||||
itemStyle: { opacity: 0 }, //去圆点
|
||||
right: 70
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
if (!params || params.length === 0) return ''
|
||||
|
||||
// 使用第一个项目的轴标签作为时间标题
|
||||
let tooltipText = params[0].axisValueLabel + '<br/>'
|
||||
|
||||
// 遍历所有项目并累加到tooltipText中
|
||||
params.forEach((item: any) => {
|
||||
// 将数值格式化为保留两位小数
|
||||
const formattedValue = Math.round(item.value[1] * 100) / 100
|
||||
tooltipText += `${item.marker} ${item.seriesName}: ${formattedValue}<br/>`
|
||||
})
|
||||
|
||||
return tooltipText
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
yAxis: {},
|
||||
|
||||
options: {
|
||||
series: []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const initData = async (row: any) => {
|
||||
limitExtentDayData({ code: row.code, lineId: row.lineId, time: row.time }).then(res => {
|
||||
if (res.data && res.data.length > 0) {
|
||||
// 重新初始化图表
|
||||
init()
|
||||
let [min, max] = yMethod(res.data.map((item: any) => item.value.split(',')).flat())
|
||||
|
||||
// 从第一条数据中提取时间作为x轴数据
|
||||
const firstItem = res.data[0]
|
||||
const xAxisData = firstItem.time.split(',')
|
||||
|
||||
// 定义相位颜色映射
|
||||
const phaseColors: any = {
|
||||
A: '#DAA520',
|
||||
B: '#2E8B57',
|
||||
C: '#A52a2a'
|
||||
}
|
||||
|
||||
// 处理每条相位数据
|
||||
const seriesData = res.data.map((item: any) => {
|
||||
const values = xAxisData.map((time: string, index: number) => {
|
||||
// 将传入的日期与时间拼接成完整的时间字符串
|
||||
const fullTime = `${row.time} ${time}`
|
||||
const value = parseFloat(item.value.split(',')[index]) || 0
|
||||
return [fullTime, value]
|
||||
})
|
||||
|
||||
return {
|
||||
name: `${item.phasic}相`,
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: values,
|
||||
itemStyle: {
|
||||
normal: {
|
||||
// 根据相位设置对应颜色
|
||||
color: phaseColors[item.phasic] || config.layout.elementUiPrimary[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
echartList.value.yAxis.max = max
|
||||
echartList.value.yAxis.min = min
|
||||
// 更新图表配置
|
||||
echartList.value.options.series = seriesData
|
||||
// 注意:使用时间轴时不需要设置 xAxis.data
|
||||
}
|
||||
})
|
||||
}
|
||||
onMounted(() => {})
|
||||
|
||||
const open = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = row.name + '日趋势图'
|
||||
dialogText.value = `监测点名称:${row.lineName}_越限时间:${row.time}_指标名称:${row.name}`
|
||||
nextTick(() => {
|
||||
initData(row)
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-select) {
|
||||
min-width: 80px;
|
||||
}
|
||||
</style>
|
||||
236
src/components/cockpit/exceedanceLevel/index.vue
Normal file
@@ -0,0 +1,236 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--指标越限程度 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker 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" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import DailyTrendChart from '@/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const dialogTrendChart = ref(false)
|
||||
|
||||
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 dailyTrendChartRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitExtentData',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '指标名称',
|
||||
field: 'name',
|
||||
minWidth: '90'
|
||||
},
|
||||
|
||||
{
|
||||
title: '越限最大值',
|
||||
field: 'maxValue',
|
||||
minWidth: '60',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
const extentValue =
|
||||
row.maxValue !== null && row.maxValue !== undefined && row.maxValue !== ''
|
||||
? Math.floor(row.maxValue * 100) / 100
|
||||
: '/'
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${extentValue}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '国标限值',
|
||||
field: 'internationalValue',
|
||||
minWidth: '60'
|
||||
},
|
||||
{
|
||||
title: '越限程度(%)',
|
||||
field: 'extent',
|
||||
minWidth: '60',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
// 保留两个小数
|
||||
const extentValue =
|
||||
row.extent !== null && row.extent !== undefined && row.extent !== ''
|
||||
? Math.floor(row.extent * 100) / 100
|
||||
: '/'
|
||||
return `<span>${extentValue}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '越限时间',
|
||||
field: 'time',
|
||||
minWidth: '60',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
if (row.time !== null && row.time !== undefined && row.time !== '') {
|
||||
return `<span>${row.time}</span>`
|
||||
} else {
|
||||
return `<span>/</span>`
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '越限最高监测点',
|
||||
field: 'lineName',
|
||||
minWidth: '90',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
if (row.lineName !== null && row.lineName !== undefined && row.lineName !== '') {
|
||||
return `<span>${row.lineName}</span>`
|
||||
} else {
|
||||
return `<span>/</span>`
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
// 定义 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 = {
|
||||
title: {
|
||||
text: '指标越限严重度'
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
data: xAxisLabels
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
name: '%' // 给X轴加单位
|
||||
// interval: 20
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
name: '越限占比',
|
||||
data: chartData,
|
||||
barMaxWidth: 30
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
dialogTrendChart.value = true
|
||||
if (column.field == 'maxValue' && row.lineId) {
|
||||
nextTick(() => {
|
||||
dailyTrendChartRef.value.open(row)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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>
|
||||
1
src/components/cockpit/governanceReport/index.json
Normal file
177
src/components/cockpit/governanceReport/index.vue
Normal file
@@ -0,0 +1,177 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--治理效果报表 -->
|
||||
<TableHeader :showReset="false" datePicker @selectChange="selectChange" v-if="fullscreen">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="报表模板">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.tempId"
|
||||
placeholder="请选择报表模板"
|
||||
clearable
|
||||
>
|
||||
<el-option v-for="item in templateList" :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.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">导出excel</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>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h, computed } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { exportExcel } from '@/views/govern/reportForms/export.js'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import Json from './index.json'
|
||||
import JsonAfter from './index.json'
|
||||
import { getTemplateList } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.power = '1'
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 报表模板列表
|
||||
const templateList = 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) {
|
||||
tableStore.table.params.sensitiveUserId = idList.value[0].id
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const templateListData = () => {
|
||||
getTemplateList({}).then(res => {
|
||||
templateList.value = res.data
|
||||
if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
|
||||
tableStore.table.params.tempId = res.data[0].id
|
||||
}
|
||||
})
|
||||
}
|
||||
// 下载表格
|
||||
const downloadExcel = () => {
|
||||
exportExcel(luckysheet.getAllSheets(), '治理效果报表')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
initListByIds()
|
||||
templateListData()
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
allowEdit: false, // 禁止所有编辑操作(必填)
|
||||
data: Json
|
||||
})
|
||||
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
||||
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
|
||||
}
|
||||
})
|
||||
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
|
||||
}
|
||||
)
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
// :deep(.el-select) {
|
||||
// min-width: 80px;
|
||||
// }
|
||||
</style>
|
||||
238
src/components/cockpit/governanceReport/index1.vue
Normal file
@@ -0,0 +1,238 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--治理效果报表 -->
|
||||
<TableHeader :showReset="false" datePicker @selectChange="selectChange" v-if="fullscreen">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测对象">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.power"
|
||||
placeholder="请选择监测对象"
|
||||
clearable
|
||||
style="width: 130px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in powerList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template v-slot:operation>
|
||||
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出excel</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
|
||||
<!-- 左右布局展示治理前后报表 -->
|
||||
<div class="report-container">
|
||||
<!-- 治理前报表 -->
|
||||
<div class="report-panel before">
|
||||
<div class="panel-header">治理前报表</div>
|
||||
<div
|
||||
id="luckysheet-before"
|
||||
:style="{
|
||||
width: '100%',
|
||||
height: `calc(${prop.height} - ${fullscreen ? '114px' : '57px'} + ${fullscreen ? 0 : 56}px)`
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
|
||||
<!-- 治理后报表 -->
|
||||
<div class="report-panel after">
|
||||
<div class="panel-header">治理后报表</div>
|
||||
<div
|
||||
id="luckysheet-after"
|
||||
:style="{
|
||||
width: '100%',
|
||||
height: `calc(${prop.height} - ${fullscreen ? '114px' : '57px'} + ${fullscreen ? 0 : 56}px)`
|
||||
}"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, watch, computed } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { exportExcel } from '@/views/govern/reportForms/export.js'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import Json from './index.json'
|
||||
import JsonAfter from './index1.json'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const powerList: any = ref([
|
||||
{
|
||||
label: '1#变压器',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '2#变压器',
|
||||
value: '2'
|
||||
}
|
||||
])
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
exportName: '治理效果报表',
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.power = '1'
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 下载表格
|
||||
const downloadExcel = () => {
|
||||
// 可以选择导出治理前、治理后或两个报表
|
||||
const beforeSheets = luckysheetBefore.getAllSheets()
|
||||
const afterSheets = luckysheetAfter.getAllSheets()
|
||||
exportExcel([...beforeSheets, ...afterSheets], '治理效果对比报表')
|
||||
}
|
||||
|
||||
// 治理前和治理后的Luckysheet实例
|
||||
let luckysheetBefore: any
|
||||
let luckysheetAfter: any
|
||||
|
||||
onMounted(() => {
|
||||
// 创建治理前报表
|
||||
luckysheetBefore = luckysheet.create({
|
||||
container: 'luckysheet-before',
|
||||
title: '治理前',
|
||||
lang: 'zh',
|
||||
showtoolbar: false,
|
||||
showinfobar: false,
|
||||
showsheetbar: true,
|
||||
allowEdit: false,
|
||||
data: Json
|
||||
})
|
||||
|
||||
// 创建治理后报表
|
||||
luckysheetAfter = luckysheet.create({
|
||||
container: 'luckysheet-after',
|
||||
title: '治理后',
|
||||
lang: 'zh',
|
||||
showtoolbar: false,
|
||||
showinfobar: false,
|
||||
showsheetbar: true,
|
||||
allowEdit: false,
|
||||
data: JsonAfter // 使用治理后的数据
|
||||
})
|
||||
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
||||
if (datePickerValue && datePickerValue.timeValue) {
|
||||
// 更新时间参数
|
||||
tableStore.table.params.searchBeginTime = datePickerValue.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = datePickerValue.timeValue[1]
|
||||
|
||||
// 可以在这里更新报表数据
|
||||
updateReportData()
|
||||
}
|
||||
}
|
||||
|
||||
// 更新报表数据的方法
|
||||
const updateReportData = () => {
|
||||
// 这里可以根据时间参数更新治理前后的报表数据
|
||||
// 示例:重新加载数据或更新现有数据
|
||||
console.log('更新报表数据:', {
|
||||
beginTime: tableStore.table.params.searchBeginTime,
|
||||
endTime: tableStore.table.params.searchEndTime
|
||||
})
|
||||
}
|
||||
|
||||
// 计算是否全屏展示
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
updateReportData()
|
||||
}
|
||||
)
|
||||
|
||||
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()
|
||||
updateReportData()
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.report-container {
|
||||
display: flex;
|
||||
height: calc(100% - 57px);
|
||||
|
||||
.report-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: 1px solid var(--el-border-color);
|
||||
|
||||
&.before {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
&.after {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
padding: 10px 15px;
|
||||
background-color: var(--el-color-primary-light-9);
|
||||
font-weight: bold;
|
||||
border-bottom: 1px solid var(--el-border-color);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
// 确保Luckysheet容器占满剩余空间
|
||||
:deep(#luckysheet-before),
|
||||
:deep(#luckysheet-after) {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-select) {
|
||||
min-width: 80px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,705 @@
|
||||
<template>
|
||||
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%">
|
||||
<!-- 总体指标占比详情谐波含有率 -->
|
||||
<div>
|
||||
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
|
||||
<template v-slot:select>
|
||||
<el-form-item>
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计指标" label-width="80px">
|
||||
<el-select
|
||||
multiple
|
||||
:multiple-limit="2"
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
v-model="searchForm.index"
|
||||
placeholder="请选择统计指标"
|
||||
@change="onIndexChange($event)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indexOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-radio-group v-model="searchForm.dataLevel" @change="init()">
|
||||
<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="searchForm.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
|
||||
class="history_count"
|
||||
v-for="(item, index) in countData"
|
||||
:key="index"
|
||||
v-show="item.countOptions.length != 0"
|
||||
>
|
||||
<span class="mr12">
|
||||
{{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }}
|
||||
</span>
|
||||
<el-select
|
||||
v-model="item.count"
|
||||
@change="onCountChange($event, index)"
|
||||
placeholder="请选择谐波次数"
|
||||
style="width: 100px"
|
||||
class="mr20"
|
||||
>
|
||||
<el-option
|
||||
v-for="vv in item.countOptions"
|
||||
:key="vv"
|
||||
:label="vv"
|
||||
:value="vv"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
<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>
|
||||
</TableHeader>
|
||||
</div>
|
||||
<div class="history_chart" :style="pageHeight" v-loading="loading">
|
||||
<MyEchart
|
||||
ref="historyChart"
|
||||
:options="echartsData"
|
||||
v-if="showEchart"
|
||||
/>
|
||||
<el-empty :style="pageHeight" v-else description="暂无数据" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { queryStatistical } from '@/api/system-boot/csstatisticalset'
|
||||
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import { color } from '@/components/echarts/color'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const dictData = useDictData()
|
||||
defineOptions({
|
||||
// name: 'govern/device/control'
|
||||
})
|
||||
const props = defineProps({
|
||||
TrendList: {
|
||||
type: Array
|
||||
}
|
||||
})
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
// console.log("🚀 ~ props:", props.TrendList)
|
||||
const showEchart = ref(true)
|
||||
const num = ref(0)
|
||||
const timeControl = ref(false)
|
||||
//值类型
|
||||
const pageHeight = ref(mainHeight(57 * 1.6, 1.6))
|
||||
const loading = ref(true)
|
||||
const searchForm: any = ref({})
|
||||
const tableHeaderRef = ref()
|
||||
const typeOptions = [
|
||||
{
|
||||
name: '平均值',
|
||||
id: 'avg'
|
||||
},
|
||||
{
|
||||
name: '最大值',
|
||||
id: 'max'
|
||||
},
|
||||
{
|
||||
name: '最小值',
|
||||
id: 'min'
|
||||
},
|
||||
{
|
||||
name: 'CP95值',
|
||||
id: 'cp95'
|
||||
}
|
||||
]
|
||||
searchForm.value = {
|
||||
index: [],
|
||||
type: typeOptions[0].id,
|
||||
count: '',
|
||||
searchBeginTime: '',
|
||||
searchEndTime: '',
|
||||
dataLevel: 'Primary',
|
||||
valueType: 'avg'
|
||||
}
|
||||
//统计指标
|
||||
const indexOptions: any = ref([])
|
||||
//谐波次数
|
||||
const countOptions: any = ref([])
|
||||
// Harmonic_Type
|
||||
// portable-harmonic
|
||||
const legendDictList: any = ref([])
|
||||
|
||||
const initCode = (field: string, title: string) => {
|
||||
queryByCode('steady_state_limit_trend').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
//排序
|
||||
indexOptions.value = item.data.sort((a: any, b: any) => {
|
||||
return a.sort - b.sort
|
||||
})
|
||||
const titleMap: Record<string, number> = {
|
||||
flickerOvertime: 0,
|
||||
uaberranceOvertime: 3,
|
||||
ubalanceOvertime: 4,
|
||||
freqDevOvertime: 5
|
||||
}
|
||||
|
||||
let defaultIndex = 0 // 默认值
|
||||
|
||||
if (field in titleMap) {
|
||||
defaultIndex = titleMap[field]
|
||||
} else if (field.includes('uharm')) {
|
||||
defaultIndex = 1
|
||||
} else if (field.includes('iharm')) {
|
||||
defaultIndex = 2
|
||||
}
|
||||
|
||||
searchForm.value.index[0] = indexOptions.value[defaultIndex].id
|
||||
})
|
||||
queryStatistical(res.data.id).then(vv => {
|
||||
legendDictList.value = vv.data
|
||||
indexOptions.value.map((item: any, index: any) => {
|
||||
if (!countDataCopy.value[index]) {
|
||||
countDataCopy.value[index] = {
|
||||
index: item.id,
|
||||
countOptions: [],
|
||||
count: [],
|
||||
name: indexOptions.value.find((vv: any) => {
|
||||
return vv.id == item.id
|
||||
})?.name
|
||||
}
|
||||
}
|
||||
legendDictList.value?.selectedList?.map((vv: any, vvs: any) => {
|
||||
//查找相等的指标
|
||||
if (item.id == vv.dataType) {
|
||||
vv.eleEpdPqdVOS.map((kk: any, kks: any) => {
|
||||
if (kk.harmStart && kk.harmEnd) {
|
||||
range(0, 0, 0)
|
||||
|
||||
if (kk.showName == '间谐波电压含有率') {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1).map(
|
||||
(item: any) => {
|
||||
return item - 0.5
|
||||
}
|
||||
)
|
||||
} else {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
|
||||
}
|
||||
if (title && countDataCopy.value[index].countOptions.includes(Number(title))) {
|
||||
countDataCopy.value[index].count = Number(title)
|
||||
} else if (title && countDataCopy.value[index].countOptions.includes(title)) {
|
||||
countDataCopy.value[index].count = title
|
||||
} else if (
|
||||
!countDataCopy.value[index].count ||
|
||||
countDataCopy.value[index].count.length == 0
|
||||
) {
|
||||
// 只有当count为空时才设置默认值
|
||||
countDataCopy.value[index].count = countDataCopy.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
nextTick(() => {
|
||||
formatCountOptions()
|
||||
})
|
||||
init()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const chartsList = ref<any>([])
|
||||
const chartTitle: any = ref('')
|
||||
const echartsData = ref<any>(null)
|
||||
//加载echarts图表
|
||||
//历史趋势数据
|
||||
const historyDataList: any = ref([])
|
||||
const range = (start: any, end: any, step: any) => {
|
||||
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
|
||||
}
|
||||
//获取请求趋势数据参数
|
||||
const trendRequestData = ref()
|
||||
const getTrendRequest = (val: any) => {
|
||||
trendRequestData.value = val
|
||||
// init()
|
||||
}
|
||||
//初始化趋势图
|
||||
const headerRef = ref()
|
||||
const datePickerRef = ref()
|
||||
const lineStyle = [{ type: 'solid' }, { type: 'dashed' }, { type: 'dotted' }]
|
||||
const init = async () => {
|
||||
loading.value = true
|
||||
// 选择指标的时候切换legend内容和data数据
|
||||
let list: any = []
|
||||
legendDictList.value?.selectedList?.map((item: any) => {
|
||||
searchForm.value.index.map((vv: any) => {
|
||||
if (item.dataType == vv) {
|
||||
list.push(item.eleEpdPqdVOS)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
//颜色数组
|
||||
const colorList = color
|
||||
//选择的指标使用方法处理
|
||||
formatCountOptions()
|
||||
//查询历史趋势
|
||||
historyDataList.value = []
|
||||
chartTitle.value = ''
|
||||
|
||||
searchForm.value.index.map((item: any, indexs: any) => {
|
||||
indexOptions.value.map((vv: any) => {
|
||||
if (vv.id == item) {
|
||||
chartTitle.value += indexs == searchForm.value.index.length - 1 ? vv.name : vv.name + '/'
|
||||
}
|
||||
})
|
||||
})
|
||||
let lists: any = []
|
||||
let frequencys: any = null
|
||||
countData.value.map((item: any, index: any) => {
|
||||
if (item.name.includes('谐波含有率')) {
|
||||
frequencys = item.count
|
||||
} else {
|
||||
frequencys = ''
|
||||
}
|
||||
lists[index] = {
|
||||
statisticalId: item.index,
|
||||
frequency: frequencys !== null && frequencys !== undefined ? String(frequencys) : ''
|
||||
}
|
||||
})
|
||||
let obj = {
|
||||
//...trendRequestData.value,
|
||||
lineId: trendRequestData.value.lineId,
|
||||
list: lists,
|
||||
dataLevel: searchForm.value.dataLevel,
|
||||
valueType: searchForm.value.valueType,
|
||||
searchBeginTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
||||
searchEndTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
||||
}
|
||||
if (searchForm.value.index.length == 0) {
|
||||
ElMessage.warning('请选择统计指标')
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
if (obj.list.length != 0) {
|
||||
try {
|
||||
showEchart.value = true
|
||||
await trendData(obj)
|
||||
.then((res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
if (res.data.length == 0) {
|
||||
loading.value = false
|
||||
showEchart.value = false
|
||||
return
|
||||
}
|
||||
historyDataList.value = res.data
|
||||
chartsList.value = JSON.parse(JSON.stringify(res.data))
|
||||
loading.value = false
|
||||
setEchart()
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
loading.value = false
|
||||
})
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
const setEchart = () => {
|
||||
loading.value = true
|
||||
echartsData.value = {}
|
||||
//icon图标替换legend图例
|
||||
|
||||
// y轴单位数组
|
||||
let unitList: any = []
|
||||
|
||||
let groupedData = chartsList.value.reduce((acc: any, item: any) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.unit
|
||||
} else {
|
||||
key = item.anotherName
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
let result = Object.values(groupedData)
|
||||
if (chartsList.value.length > 0) {
|
||||
unitList = result.map((item: any) => {
|
||||
return item[0].unit
|
||||
})
|
||||
}
|
||||
|
||||
echartsData.value = {
|
||||
legend: {
|
||||
itemWidth: 20,
|
||||
itemHeight: 20,
|
||||
itemStyle: { opacity: 0 }, //去圆点
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
top: 5,
|
||||
right: 70
|
||||
// width: 550,
|
||||
// height: 50
|
||||
},
|
||||
grid: {
|
||||
top: '80px'
|
||||
},
|
||||
tooltip: {
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
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(params: any) {
|
||||
const xname = params[0].value[0]
|
||||
let str = `${xname}<br>`
|
||||
params.forEach((el: any, index: any) => {
|
||||
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>`
|
||||
}
|
||||
let unit = el.value[2] ? el.value[2] : ''
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${el.value[1]}${unit}
|
||||
<br>`
|
||||
})
|
||||
return str
|
||||
}
|
||||
},
|
||||
color: ['#DAA520', '#2E8B57', '#A52a2a', ...color],
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}],
|
||||
toolbox: {
|
||||
featureProps: {
|
||||
myTool1: {
|
||||
show: true,
|
||||
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',
|
||||
onclick: e => {
|
||||
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data))
|
||||
|
||||
let list = echartsData.value.options.series?.map((item: any) => item.data)
|
||||
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'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
series: []
|
||||
}
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ unitList:", unitList)
|
||||
|
||||
if (chartsList.value.length > 0) {
|
||||
let yData: any = []
|
||||
echartsData.value.yAxis = []
|
||||
let setList = [...new Set(unitList)]
|
||||
|
||||
setList.forEach((item: any, index: any) => {
|
||||
if (index > 2) {
|
||||
echartsData.value.grid.right = (index - 1) * 80
|
||||
}
|
||||
yData.push([])
|
||||
let right = {
|
||||
position: 'right',
|
||||
offset: (index - 1) * 80
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ right.index:", index)
|
||||
echartsData.value.yAxis.push({
|
||||
name: item,
|
||||
yAxisIndex: index,
|
||||
splitNumber: 5,
|
||||
minInterval: 1,
|
||||
splitLine: {
|
||||
show: false
|
||||
},
|
||||
...(index > 0 ? right : null)
|
||||
})
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ result:", result)
|
||||
// '电压负序分量', '电压正序分量', '电压零序分量'
|
||||
let ABCName = [
|
||||
...new Set(
|
||||
chartsList.value.map((item: any) => {
|
||||
return item.anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName
|
||||
})
|
||||
)
|
||||
]
|
||||
// console.log("🚀 ~ .then ~ ABCName:", ABCName)
|
||||
result.forEach((item: any, index: any) => {
|
||||
let yMethodList: any = []
|
||||
|
||||
let ABCList = Object.values(
|
||||
item.reduce((acc, item) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.anotherName
|
||||
} else {
|
||||
key = item.phase
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
)
|
||||
// console.log("🚀 ~ ABCList.forEach ~ ABCList:", ABCList)
|
||||
|
||||
ABCList.forEach((kk: any) => {
|
||||
let colorName = kk[0].phase?.charAt(0).toUpperCase()
|
||||
let lineS = ABCName.findIndex(
|
||||
item =>
|
||||
item ===
|
||||
(kk[0].anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName)
|
||||
)
|
||||
|
||||
let seriesList: any = []
|
||||
kk.forEach((cc: any) => {
|
||||
if (cc.statisticalData !== null) {
|
||||
yData[setList.indexOf(kk[0].unit)].push(cc.statisticalData?.toFixed(2))
|
||||
}
|
||||
|
||||
seriesList.push([cc.time, cc.statisticalData?.toFixed(2), cc.unit, lineStyle[lineS].type])
|
||||
})
|
||||
// console.log(kk);
|
||||
|
||||
echartsData.value.options.series.push({
|
||||
name: kk[0].phase ? kk[0].phase + '相' + kk[0].anotherName : kk[0].anotherName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
color:
|
||||
colorName == 'A' ? '#DAA520' : colorName == 'B' ? '#2E8B57' : colorName == 'C' ? '#A52a2a' : '',
|
||||
symbol: 'none',
|
||||
// data: seriesList,
|
||||
data: timeControl.value ? completeTimeSeries(seriesList) : seriesList,
|
||||
lineStyle: lineStyle[lineS],
|
||||
yAxisIndex: setList.indexOf(kk[0].unit)
|
||||
})
|
||||
})
|
||||
})
|
||||
yData.forEach((item: any, index: any) => {
|
||||
let [min, max] = yMethod(item)
|
||||
echartsData.value.yAxis[index].min = min
|
||||
echartsData.value.yAxis[index].max = max
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ echartsData.value:", echartsData.value)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
const setTimeControl = () => {
|
||||
timeControl.value = !timeControl.value
|
||||
setEchart()
|
||||
}
|
||||
|
||||
const selectChange = (flag: boolean, height: any) => {
|
||||
pageHeight.value = mainHeight(height * 1.6, 1.6)
|
||||
}
|
||||
//导出
|
||||
const historyChart = ref()
|
||||
|
||||
const countData: any = ref([])
|
||||
const countDataCopy: any = ref([])
|
||||
|
||||
//根据选择的指标处理谐波次数
|
||||
const formatCountOptions = () => {
|
||||
countData.value = []
|
||||
if (searchForm.value.index.length != 0) {
|
||||
searchForm.value.index.forEach((item: any, index: any) => {
|
||||
countDataCopy.value.forEach((vv: any, vvs: any) => {
|
||||
if (vv.index == item) {
|
||||
countData.value.push(vv)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
countData.value.map((item: any, key: any) => {
|
||||
if (item.name == '谐波电流有效值') {
|
||||
item.name = '谐波电流次数'
|
||||
} else if (item.name == '谐波电压含有率') {
|
||||
item.name = '谐波电压次数'
|
||||
} else if (item.name == '间谐波电压含有率') {
|
||||
item.name = '间谐波电压次数'
|
||||
}
|
||||
})
|
||||
}
|
||||
// setTimeout(() => {
|
||||
// tableHeaderRef.value.computedSearchRow()
|
||||
// }, 500)
|
||||
}
|
||||
// 判断下拉框是否存在
|
||||
const onCountChange = (val: any, index: any) => {
|
||||
if (val.length == 0) {
|
||||
countData.value[index].count = countData.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
const flag = ref(true)
|
||||
const onIndexChange = (val: any) => {
|
||||
num.value += 1
|
||||
let pp: any = []
|
||||
indexOptions.value.forEach((item: any) => {
|
||||
const filteredResult = val.filter(vv => item.id == vv)
|
||||
if (filteredResult.length > 0) {
|
||||
pp.push(filteredResult[0])
|
||||
}
|
||||
})
|
||||
searchForm.value.index = pp
|
||||
flag.value = true
|
||||
formatCountOptions()
|
||||
}
|
||||
watch(
|
||||
() => searchForm.value.index,
|
||||
(val: any, oldval: any) => {},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
|
||||
const openDialog = async (row: any, field: any, title: any) => {
|
||||
dialogVisible.value = true
|
||||
trendRequestData.value = row
|
||||
|
||||
nextTick(() => {
|
||||
// 默认当天
|
||||
datePickerRef.value.setInterval(5)
|
||||
datePickerRef.value.timeValue = [row.time, row.time]
|
||||
initCode(field, title)
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ getTrendRequest, openDialog })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.history_header {
|
||||
display: flex;
|
||||
|
||||
// flex-wrap: wrap;
|
||||
#history_select {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
// justify-content: flex-start;
|
||||
// overflow-x: auto;
|
||||
height: auto;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.el-form-item {
|
||||
flex: none !important;
|
||||
// max-width: 380px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
// #history_select::-webkit-scrollbar {
|
||||
// width: 0 !important;
|
||||
// display: none !important;
|
||||
// }
|
||||
|
||||
.history_searchBtn {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.history_chart {
|
||||
width: 100%;
|
||||
|
||||
// flex: 1;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.history_count {
|
||||
.el-select {
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 指标越限详情 -->
|
||||
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.lineId"
|
||||
placeholder="请选择监测点"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 谐波电流、谐波电压占有率 -->
|
||||
<HarmonicRatio ref="harmonicRatioRef" v-if="dialogFlag" @close="onHarmonicRatioClose" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide,nextTick } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import HarmonicRatio from '@/components/cockpit/gridSideStatistics/components/harmonicRatio.vue'
|
||||
import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
|
||||
const options = ref()
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableHeaderRef = ref()
|
||||
const dialogFlag = ref(false)
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 26; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
field: key + i + 'Overtime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row[key + i + 'Overtime']}</span>`
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/totalLimitStatistics/details',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '每日越限占比统计',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(%)',
|
||||
field: 'flickerOvertime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(%)',
|
||||
children: loop50('uharm')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(%)',
|
||||
children: loop50('iharm')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(%)',
|
||||
field: 'ubalanceOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(%)',
|
||||
field: 'voltageDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uaberranceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(%)',
|
||||
field: 'freqDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.freqDevOvertime}</span>`
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
},
|
||||
loadCallback: () => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.sortBy = ''
|
||||
tableStore.table.params.orderBy = ''
|
||||
const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
|
||||
dialogVisible.value = true
|
||||
initCSlineList()
|
||||
tableStore.table.params.lineId = row.lineId
|
||||
|
||||
nextTick(() => {
|
||||
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
|
||||
tableStore.table.params.searchBeginTime =searchBeginTime
|
||||
tableStore.table.params.searchEndTime = searchEndTime
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name' && column.field != 'time') {
|
||||
dialogFlag.value = true
|
||||
dialogVisible.value = false
|
||||
nextTick(() => {
|
||||
harmonicRatioRef.value.openDialog(row,column.field,column.title.replace(/次/g, ""))
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 谐波弹窗关闭时的回调
|
||||
const onHarmonicRatioClose = () => {
|
||||
dialogFlag.value = false
|
||||
// 重新打开指标越限详情弹窗
|
||||
nextTick(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
}
|
||||
|
||||
const initCSlineList = async () => {
|
||||
const res = await cslineList({})
|
||||
options.value = res.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
243
src/components/cockpit/gridSideStatistics/index.vue
Normal file
@@ -0,0 +1,243 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--电网侧指标越限统计 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker 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>
|
||||
<!-- 指标越限详情 -->
|
||||
<OverLimitDetails ref="OverLimitDetailsRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import OverLimitDetails from '@/components/cockpit/gridSideStatistics/components/overLimitDetails.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { gridSideLimitStatisticsData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const echartList = 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 initEcharts = () => {
|
||||
gridSideLimitStatisticsData({
|
||||
searchBeginTime: tableStore.table.params.searchBeginTime,
|
||||
searchEndTime: tableStore.table.params.searchEndTime
|
||||
}).then((res: any) => {
|
||||
const dataArray = [res.data.flicker, res.data.uharm, res.data.iharm, res.data.voltageDev, res.data.ubalance]
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: '指标越限占比'
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
// name: '(区域)',
|
||||
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
name: '%', // 给X轴加单位
|
||||
interval: 20
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
// name: '暂降次数',
|
||||
type: 'bar',
|
||||
name: '越限占比',
|
||||
data: dataArray,
|
||||
barMaxWidth: 30
|
||||
|
||||
// label: {
|
||||
// show: true,
|
||||
// position: 'top',
|
||||
// textStyle: {
|
||||
// //数值样式
|
||||
// color: '#000'
|
||||
// },
|
||||
// fontSize: 12
|
||||
// }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const OverLimitDetailsRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/gridSideLimitStatistics/list',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
minWidth: '90'
|
||||
},
|
||||
{
|
||||
title: '越限占比(%)',
|
||||
children: [
|
||||
{
|
||||
title: '闪变',
|
||||
field: 'flicker',
|
||||
minWidth: '70',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压',
|
||||
field: 'uharm',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uharm}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电流',
|
||||
field: 'iharm',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.iharm}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差',
|
||||
field: 'voltageDev',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.voltageDev}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '三相不平衡',
|
||||
field: 'ubalance',
|
||||
minWidth: '90',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalance}</span>`
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
initEcharts()
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
OverLimitDetailsRef.value.open(
|
||||
row,
|
||||
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
initEcharts()
|
||||
}
|
||||
)
|
||||
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>
|
||||
235
src/components/cockpit/indicatorDetails/index.vue
Normal file
@@ -0,0 +1,235 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--指标越限明细 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<el-calendar
|
||||
v-model="value"
|
||||
:style="{
|
||||
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
|
||||
overflow: 'auto'
|
||||
}"
|
||||
v-loading="tableStore.table.loading"
|
||||
>
|
||||
<template #date-cell="{ data }">
|
||||
<div
|
||||
style="padding: 8px"
|
||||
:style="{
|
||||
background: setBackground(data.day),
|
||||
height: `calc((${prop.height} - 100px - ${headerHeight}px + ${fullscreen ? 0 : 56}px) / 5 )`
|
||||
}"
|
||||
>
|
||||
<p :class="data.isSelected ? 'is-selected' : ''">
|
||||
{{ data.day.split('-').slice(2).join('-') }}
|
||||
</p>
|
||||
<el-tooltip effect="dark" placement="top" :hide-after="0" v-if="getTextForDate(data.day)">
|
||||
<template #content>
|
||||
<span v-html="getTextForDate(data.day)"></span>
|
||||
</template>
|
||||
<div class="details" v-html="getTextForDate(data.day)"></div>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-calendar>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { dayjs } from 'element-plus'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const list = ref()
|
||||
|
||||
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
|
||||
const value = ref(new Date())
|
||||
|
||||
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 getTextForDate = (date: string) => {
|
||||
const item = list.value?.find((item: any) => item.time === date)
|
||||
return item ? item.text : ''
|
||||
}
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
// url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
url: '/harmonic-boot/limitRateDetailD/limitCalendarData',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
value.value = tableStore.table.params.searchBeginTime
|
||||
// 将后端返回的数据整合到 list 中
|
||||
// tableStore.table.data = [
|
||||
// {
|
||||
// "time": "2025-11-13",
|
||||
// "items": [
|
||||
// "闪变越限",
|
||||
// "谐波电流越限"
|
||||
// ],
|
||||
// "status": 1
|
||||
// },
|
||||
// {
|
||||
// "time": "2025-11-14",
|
||||
// "items": [
|
||||
// "频率偏差越限",
|
||||
// "三相电压不平衡越限",
|
||||
// "谐波电压越限",
|
||||
// "谐波电流越限",
|
||||
// "频率偏差越限",
|
||||
// "三相电压不平衡越限",
|
||||
// "谐波电压越限",
|
||||
// "谐波电流越限",
|
||||
// "频率偏差越限",
|
||||
// "三相电压不平衡越限",
|
||||
// "谐波电压越限",
|
||||
// "谐波电流越限"
|
||||
// ],
|
||||
// "status": 2
|
||||
// }
|
||||
// ]
|
||||
if (tableStore.table.data && tableStore.table.data.length > 0) {
|
||||
list.value = tableStore.table.data.map((item: any) => {
|
||||
// 将 items 数组转换为带换行的文本
|
||||
const text = item.items && item.items.length > 0 ? item.items.join('<br/>') : ''
|
||||
|
||||
return {
|
||||
time: item.time,
|
||||
key: item.status || 0,
|
||||
text: text
|
||||
}
|
||||
})
|
||||
} else {
|
||||
list.value = []
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const setBackground = (value: string) => {
|
||||
const data = list.value?.find((item: any) => item.time === value)
|
||||
|
||||
if (data) {
|
||||
// 根据 status 值返回对应的颜色
|
||||
switch (data.key) {
|
||||
case 0: // 无越限
|
||||
return '#33996690'
|
||||
case 1: // 一般越限
|
||||
return '#FFCC3390'
|
||||
case 2: // 严重越限
|
||||
return '#Ff660090'
|
||||
default:
|
||||
return '#fff' // 默认白色背景
|
||||
}
|
||||
}
|
||||
|
||||
return '#fff' // 默认白色背景
|
||||
}
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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>
|
||||
:deep(.el-calendar) {
|
||||
.el-calendar__button-group {
|
||||
display: none;
|
||||
}
|
||||
.el-calendar__body {
|
||||
padding: 0px !important;
|
||||
height: calc(100% - 46px);
|
||||
.el-calendar-table {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.el-calendar-day {
|
||||
// height: calc(912px / 5 );
|
||||
height: 100%;
|
||||
padding: 0px;
|
||||
overflow: hidden;
|
||||
.details {
|
||||
height: calc(100% - 20px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
.el-calendar-table__row {
|
||||
.next {
|
||||
pointer-events: none;
|
||||
}
|
||||
.prev {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
.el-calendar-table .el-calendar-day:hover {
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
.el-calendar-table td.is-selected {
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
}
|
||||
|
||||
// /*calendar_class 是el-calendar所在父标签的css*/
|
||||
// .calendar_class >>> .el-calendar-table:not(.is-range) td.next {
|
||||
// pointer-events: none;
|
||||
// }
|
||||
// .calendar_class >>> .el-calendar-table:not(.is-range) td.prev {
|
||||
// pointer-events: none;
|
||||
// }
|
||||
</style>
|
||||
480
src/components/cockpit/indicatorDistribution/index.vue
Normal file
@@ -0,0 +1,480 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--指标越限概率分布 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select size="small" v-model="tableStore.table.params.lineId">
|
||||
<el-option
|
||||
v-for="item in lineList"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<div v-loading="tableStore.table.loading">
|
||||
<my-echart
|
||||
class="tall"
|
||||
:options="echartList"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
|
||||
}"
|
||||
/>
|
||||
<my-echart
|
||||
class="mt10"
|
||||
:options="echartList1"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { limitProbabilityData, cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
// const options = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]'))
|
||||
|
||||
const lineList = ref()
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
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 echartList1 = ref()
|
||||
|
||||
const probabilityData = ref()
|
||||
|
||||
const initLineList = async () => {
|
||||
cslineList({}).then(res => {
|
||||
lineList.value = res.data
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
|
||||
// 越限程度概率分布
|
||||
const initProbabilityData = () => {
|
||||
// 只有当 lineList 已加载且有数据时才设置默认 lineId
|
||||
if (!tableStore.table.params.lineId && lineList.value && lineList.value.length > 0) {
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
}
|
||||
const params = {
|
||||
searchBeginTime: tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
searchEndTime: tableStore.table.params.searchEndTime || prop.timeValue?.[1],
|
||||
lineId: tableStore.table.params.lineId
|
||||
}
|
||||
limitProbabilityData(params).then((res: any) => {
|
||||
probabilityData.value = res.data
|
||||
|
||||
// 处理接口返回的数据,转换为图表所需格式
|
||||
if (res.data && Array.isArray(res.data)) {
|
||||
// 定义指标类型顺序
|
||||
const indicatorOrder = ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相电压不平衡度', '频率偏差']
|
||||
// 按照指定顺序排序数据
|
||||
const sortedData = [...res.data].sort((a, b) => {
|
||||
return indicatorOrder.indexOf(a.indexName) - indicatorOrder.indexOf(b.indexName)
|
||||
})
|
||||
|
||||
// 构造 series 数据
|
||||
const seriesData: any = []
|
||||
let maxValue: any = 0 // 用于存储数据中的最大值
|
||||
// 遍历每个越限程度区间(0-20%, 20-40%, 40-60%, 60-80%, 80-100%)
|
||||
for (let xIndex = 0; xIndex < 5; xIndex++) {
|
||||
// 遍历每个指标类型
|
||||
sortedData.forEach((item, yIndex) => {
|
||||
// 从 extentGrades 中获取对应区间的值
|
||||
const extentGrade = item.extentGrades[xIndex]
|
||||
const value = extentGrade ? (Object.values(extentGrade)[0] as number) : 0
|
||||
seriesData.push([xIndex, yIndex, value])
|
||||
|
||||
// 更新最大值
|
||||
if (value > maxValue) {
|
||||
maxValue = value
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 计算 z 轴最大值(最大值加 5)
|
||||
const zAxisMax = Math.ceil(maxValue) + 5
|
||||
// 构造 yAxis 数据(指标类型名称)
|
||||
const yAxisData = sortedData.map(item => item.indexName)
|
||||
|
||||
echartList.value = {
|
||||
options: {
|
||||
backgroundColor: '#fff',
|
||||
tooltip: {
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontStyle: 'normal',
|
||||
opacity: 0.35,
|
||||
fontSize: 14
|
||||
},
|
||||
backgroundColor: 'rgba(0,0,0,0.55)',
|
||||
borderWidth: 0,
|
||||
formatter: function (params: any) {
|
||||
var yIndex = params.value[1] //获取y轴索引
|
||||
var tips = ''
|
||||
tips += '指标类型: ' + yAxisData[yIndex] + '</br>'
|
||||
tips += '越限程度: ' + params.seriesName + '</br>'
|
||||
tips += '越限次数: ' + params.value[2] + '</br>'
|
||||
return tips
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: '指标越限概率分布',
|
||||
x: 'center',
|
||||
textStyle: {
|
||||
fontSize: 16,
|
||||
fontWeight: 'normal'
|
||||
}
|
||||
},
|
||||
// 移除或隐藏 visualMap 组件
|
||||
visualMap: {
|
||||
show: false, // 设置为 false 隐藏右侧颜色条
|
||||
min: 0,
|
||||
// max: 100,
|
||||
max: zAxisMax, // 使用计算出的最大值加5
|
||||
inRange: {
|
||||
color: ['#313695', '#00BB00', '#ff8000', '#d73027', '#a50026']
|
||||
}
|
||||
},
|
||||
// 添加 legend 配置并设置为不显示
|
||||
legend: {
|
||||
show: false // 隐藏图例
|
||||
},
|
||||
xAxis3D: {
|
||||
type: 'category',
|
||||
name: '越限程度',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
data: ['0-20%', '20-40%', '40-60%', '60-80%', '80-100%'],
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#111',
|
||||
margin: 15
|
||||
},
|
||||
nameTextStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
yAxis3D: {
|
||||
type: 'category',
|
||||
name: '指标类型',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
data: yAxisData,
|
||||
nameTextStyle: {
|
||||
color: '#111'
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#111',
|
||||
margin: 15
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: ['#111'],
|
||||
type: 'dashed',
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
zAxis3D: {
|
||||
type: 'value',
|
||||
name: '越限次数',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
nameTextStyle: {
|
||||
color: '#111'
|
||||
},
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#111'
|
||||
},
|
||||
min: 0,
|
||||
max: zAxisMax // 使用计算出的最大值加5
|
||||
// max: 100
|
||||
},
|
||||
grid3D: {
|
||||
viewControl: {
|
||||
projection: 'perspective',
|
||||
distance: 250,
|
||||
rotateSensitivity: 10,
|
||||
zoomSensitivity: 2
|
||||
},
|
||||
boxWidth: 150,
|
||||
boxDepth: 100,
|
||||
boxHeight: 100,
|
||||
light: {
|
||||
main: {
|
||||
intensity: 1.2
|
||||
},
|
||||
ambient: {
|
||||
intensity: 0.4
|
||||
}
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar3D',
|
||||
name: '0-20%',
|
||||
data: seriesData.filter((item: any) => item[0] === 0),
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 0.9
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff8000'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'bar3D',
|
||||
name: '20-40%',
|
||||
data: seriesData.filter((item: any) => item[0] === 1),
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 0.9
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff8000'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'bar3D',
|
||||
name: '40-60%',
|
||||
data: seriesData.filter((item: any) => item[0] === 2),
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 0.9
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff8000'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'bar3D',
|
||||
name: '60-80%',
|
||||
data: seriesData.filter((item: any) => item[0] === 3),
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 0.9
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff8000'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'bar3D',
|
||||
name: '80-100%',
|
||||
data: seriesData.filter((item: any) => item[0] === 4),
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 0.9
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
textStyle: {
|
||||
fontSize: 14,
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff8000'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/limitRateDetailD/limitTimeProbabilityData',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
// 只有当 lineList 已加载且有数据时才设置默认 lineId
|
||||
if (!tableStore.table.params.lineId && lineList.value && lineList.value.length > 0) {
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
}
|
||||
},
|
||||
loadCallback: () => {
|
||||
// 处理返回的数据,将其转换为图表所需格式
|
||||
const indexNames: any = [...new Set(tableStore.table.data.map((item: any) => item.indexName))]
|
||||
const timePeriods = [...new Set(tableStore.table.data.map((item: any) => item.timePeriod))]
|
||||
|
||||
// 构建系列数据
|
||||
const seriesData = indexNames.map((indexName: string) => {
|
||||
const dataIndex = tableStore.table.data.filter((item: any) => item.indexName === indexName)
|
||||
return {
|
||||
name: indexName,
|
||||
type: 'line',
|
||||
data: dataIndex.map((item: any) => [item.timePeriod, item.times])
|
||||
}
|
||||
})
|
||||
|
||||
echartList1.value = {
|
||||
title: {
|
||||
text: '越限时间概率分布'
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis'
|
||||
},
|
||||
legend: {
|
||||
data: indexNames
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
name: '时间段',
|
||||
data: timePeriods
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
// name: '次数'
|
||||
},
|
||||
series: seriesData
|
||||
}
|
||||
initProbabilityData()
|
||||
}
|
||||
})
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
initLineList()
|
||||
})
|
||||
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>
|
||||
@@ -0,0 +1,706 @@
|
||||
<template>
|
||||
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%">
|
||||
<!-- 总体指标占比详情谐波含有率 -->
|
||||
<div>
|
||||
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
|
||||
<template v-slot:select>
|
||||
<el-form-item>
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计指标" label-width="80px">
|
||||
<el-select
|
||||
multiple
|
||||
:multiple-limit="2"
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
v-model="searchForm.index"
|
||||
placeholder="请选择统计指标"
|
||||
@change="onIndexChange($event)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indexOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-radio-group v-model="searchForm.dataLevel" @change="init()">
|
||||
<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="searchForm.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
|
||||
class="history_count"
|
||||
v-for="(item, index) in countData"
|
||||
:key="index"
|
||||
v-show="item.countOptions.length != 0"
|
||||
>
|
||||
<span class="mr12">
|
||||
{{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }}
|
||||
</span>
|
||||
<el-select
|
||||
v-model="item.count"
|
||||
@change="onCountChange($event, index)"
|
||||
placeholder="请选择谐波次数"
|
||||
style="width: 100px"
|
||||
class="mr20"
|
||||
>
|
||||
<el-option
|
||||
v-for="vv in item.countOptions"
|
||||
:key="vv"
|
||||
:label="vv"
|
||||
:value="vv"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
<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>
|
||||
</TableHeader>
|
||||
</div>
|
||||
<div class="history_chart" :style="pageHeight" v-loading="loading">
|
||||
<MyEchart
|
||||
ref="historyChart"
|
||||
:options="echartsData"
|
||||
v-if="showEchart"
|
||||
/>
|
||||
<el-empty :style="pageHeight" v-else description="暂无数据" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { queryStatistical } from '@/api/system-boot/csstatisticalset'
|
||||
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import { color } from '@/components/echarts/color'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const dictData = useDictData()
|
||||
defineOptions({
|
||||
// name: 'govern/device/control'
|
||||
})
|
||||
const props = defineProps({
|
||||
TrendList: {
|
||||
type: Array
|
||||
}
|
||||
})
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
// console.log("🚀 ~ props:", props.TrendList)
|
||||
const showEchart = ref(true)
|
||||
const num = ref(0)
|
||||
const timeControl = ref(false)
|
||||
//值类型
|
||||
const pageHeight = ref(mainHeight(57 * 1.6, 1.6))
|
||||
const loading = ref(true)
|
||||
const searchForm: any = ref({})
|
||||
const tableHeaderRef = ref()
|
||||
const typeOptions = [
|
||||
{
|
||||
name: '平均值',
|
||||
id: 'avg'
|
||||
},
|
||||
{
|
||||
name: '最大值',
|
||||
id: 'max'
|
||||
},
|
||||
{
|
||||
name: '最小值',
|
||||
id: 'min'
|
||||
},
|
||||
{
|
||||
name: 'CP95值',
|
||||
id: 'cp95'
|
||||
}
|
||||
]
|
||||
searchForm.value = {
|
||||
index: [],
|
||||
type: typeOptions[0].id,
|
||||
count: '',
|
||||
searchBeginTime: '',
|
||||
searchEndTime: '',
|
||||
dataLevel: 'Primary',
|
||||
valueType: 'avg'
|
||||
}
|
||||
//统计指标
|
||||
const indexOptions: any = ref([])
|
||||
//谐波次数
|
||||
const countOptions: any = ref([])
|
||||
// Harmonic_Type
|
||||
// portable-harmonic
|
||||
const legendDictList: any = ref([])
|
||||
|
||||
const initCode = (field: string, title: string) => {
|
||||
queryByCode('steady_state_limit_trend').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
//排序
|
||||
indexOptions.value = item.data.sort((a: any, b: any) => {
|
||||
return a.sort - b.sort
|
||||
})
|
||||
const titleMap: Record<string, number> = {
|
||||
flickerOvertime: 0,
|
||||
uaberranceOvertime: 3,
|
||||
ubalanceOvertime: 4,
|
||||
freqDevOvertime: 5
|
||||
}
|
||||
|
||||
let defaultIndex = 0 // 默认值
|
||||
|
||||
if (field in titleMap) {
|
||||
defaultIndex = titleMap[field]
|
||||
} else if (field.includes('uharm')) {
|
||||
defaultIndex = 1
|
||||
} else if (field.includes('iharm')) {
|
||||
defaultIndex = 2
|
||||
}
|
||||
|
||||
searchForm.value.index[0] = indexOptions.value[defaultIndex].id
|
||||
})
|
||||
queryStatistical(res.data.id).then(vv => {
|
||||
legendDictList.value = vv.data
|
||||
indexOptions.value.map((item: any, index: any) => {
|
||||
if (!countDataCopy.value[index]) {
|
||||
countDataCopy.value[index] = {
|
||||
index: item.id,
|
||||
countOptions: [],
|
||||
count: [],
|
||||
name: indexOptions.value.find((vv: any) => {
|
||||
return vv.id == item.id
|
||||
})?.name
|
||||
}
|
||||
}
|
||||
legendDictList.value?.selectedList?.map((vv: any, vvs: any) => {
|
||||
//查找相等的指标
|
||||
if (item.id == vv.dataType) {
|
||||
vv.eleEpdPqdVOS.map((kk: any, kks: any) => {
|
||||
if (kk.harmStart && kk.harmEnd) {
|
||||
range(0, 0, 0)
|
||||
|
||||
if (kk.showName == '间谐波电压含有率') {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1).map(
|
||||
(item: any) => {
|
||||
return item - 0.5
|
||||
}
|
||||
)
|
||||
} else {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
|
||||
}
|
||||
if (title && countDataCopy.value[index].countOptions.includes(Number(title))) {
|
||||
countDataCopy.value[index].count = Number(title)
|
||||
} else if (title && countDataCopy.value[index].countOptions.includes(title)) {
|
||||
countDataCopy.value[index].count = title
|
||||
} else if (
|
||||
!countDataCopy.value[index].count ||
|
||||
countDataCopy.value[index].count.length == 0
|
||||
) {
|
||||
// 只有当count为空时才设置默认值
|
||||
countDataCopy.value[index].count = countDataCopy.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
nextTick(() => {
|
||||
formatCountOptions()
|
||||
})
|
||||
init()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const chartsList = ref<any>([])
|
||||
const chartTitle: any = ref('')
|
||||
const echartsData = ref<any>(null)
|
||||
//加载echarts图表
|
||||
//历史趋势数据
|
||||
const historyDataList: any = ref([])
|
||||
const range = (start: any, end: any, step: any) => {
|
||||
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
|
||||
}
|
||||
//获取请求趋势数据参数
|
||||
const trendRequestData = ref()
|
||||
const getTrendRequest = (val: any) => {
|
||||
trendRequestData.value = val
|
||||
// init()
|
||||
}
|
||||
//初始化趋势图
|
||||
const headerRef = ref()
|
||||
const datePickerRef = ref()
|
||||
const lineStyle = [{ type: 'solid' }, { type: 'dashed' }, { type: 'dotted' }]
|
||||
const init = async () => {
|
||||
loading.value = true
|
||||
// 选择指标的时候切换legend内容和data数据
|
||||
let list: any = []
|
||||
legendDictList.value?.selectedList?.map((item: any) => {
|
||||
searchForm.value.index.map((vv: any) => {
|
||||
if (item.dataType == vv) {
|
||||
list.push(item.eleEpdPqdVOS)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
//颜色数组
|
||||
const colorList = color
|
||||
//选择的指标使用方法处理
|
||||
formatCountOptions()
|
||||
//查询历史趋势
|
||||
historyDataList.value = []
|
||||
chartTitle.value = ''
|
||||
|
||||
searchForm.value.index.map((item: any, indexs: any) => {
|
||||
indexOptions.value.map((vv: any) => {
|
||||
if (vv.id == item) {
|
||||
chartTitle.value += indexs == searchForm.value.index.length - 1 ? vv.name : vv.name + '/'
|
||||
}
|
||||
})
|
||||
})
|
||||
let lists: any = []
|
||||
let frequencys: any = null
|
||||
countData.value.map((item: any, index: any) => {
|
||||
if (item.name.includes('谐波含有率')) {
|
||||
frequencys = item.count
|
||||
} else {
|
||||
frequencys = ''
|
||||
}
|
||||
lists[index] = {
|
||||
statisticalId: item.index,
|
||||
frequency: frequencys !== null && frequencys !== undefined ? String(frequencys) : ''
|
||||
}
|
||||
})
|
||||
let obj = {
|
||||
//...trendRequestData.value,
|
||||
lineId: trendRequestData.value.lineId,
|
||||
list: lists,
|
||||
dataLevel: searchForm.value.dataLevel,
|
||||
valueType: searchForm.value.valueType,
|
||||
searchBeginTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
||||
searchEndTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
||||
}
|
||||
if (searchForm.value.index.length == 0) {
|
||||
ElMessage.warning('请选择统计指标')
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
if (obj.list.length != 0) {
|
||||
try {
|
||||
showEchart.value = true
|
||||
await trendData(obj)
|
||||
.then((res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
if (res.data.length == 0) {
|
||||
loading.value = false
|
||||
showEchart.value = false
|
||||
return
|
||||
}
|
||||
historyDataList.value = res.data
|
||||
chartsList.value = JSON.parse(JSON.stringify(res.data))
|
||||
loading.value = false
|
||||
setEchart()
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
loading.value = false
|
||||
})
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
const setEchart = () => {
|
||||
loading.value = true
|
||||
echartsData.value = {}
|
||||
//icon图标替换legend图例
|
||||
|
||||
// y轴单位数组
|
||||
let unitList: any = []
|
||||
|
||||
let groupedData = chartsList.value.reduce((acc: any, item: any) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.unit
|
||||
} else {
|
||||
key = item.anotherName
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
let result = Object.values(groupedData)
|
||||
if (chartsList.value.length > 0) {
|
||||
unitList = result.map((item: any) => {
|
||||
return item[0].unit
|
||||
})
|
||||
}
|
||||
|
||||
echartsData.value = {
|
||||
legend: {
|
||||
itemWidth: 20,
|
||||
itemHeight: 20,
|
||||
itemStyle: { opacity: 0 }, //去圆点
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
top: 5,
|
||||
right: 70
|
||||
// width: 550,
|
||||
// height: 50
|
||||
},
|
||||
grid: {
|
||||
top: '80px'
|
||||
},
|
||||
tooltip: {
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
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(params: any) {
|
||||
const xname = params[0].value[0]
|
||||
let str = `${xname}<br>`
|
||||
params.forEach((el: any, index: any) => {
|
||||
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>`
|
||||
}
|
||||
let unit = el.value[2] ? el.value[2] : ''
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${el.value[1]}${unit}
|
||||
<br>`
|
||||
})
|
||||
return str
|
||||
}
|
||||
},
|
||||
color: ['#DAA520', '#2E8B57', '#A52a2a', ...color],
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}],
|
||||
toolbox: {
|
||||
featureProps: {
|
||||
myTool1: {
|
||||
show: true,
|
||||
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',
|
||||
onclick: e => {
|
||||
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data))
|
||||
|
||||
let list = echartsData.value.options.series?.map((item: any) => item.data)
|
||||
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'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
series: []
|
||||
}
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ unitList:", unitList)
|
||||
|
||||
if (chartsList.value.length > 0) {
|
||||
let yData: any = []
|
||||
echartsData.value.yAxis = []
|
||||
let setList = [...new Set(unitList)]
|
||||
|
||||
setList.forEach((item: any, index: any) => {
|
||||
if (index > 2) {
|
||||
echartsData.value.grid.right = (index - 1) * 80
|
||||
}
|
||||
yData.push([])
|
||||
let right = {
|
||||
position: 'right',
|
||||
offset: (index - 1) * 80
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ right.index:", index)
|
||||
echartsData.value.yAxis.push({
|
||||
name: item,
|
||||
yAxisIndex: index,
|
||||
splitNumber: 5,
|
||||
minInterval: 1,
|
||||
splitLine: {
|
||||
show: false
|
||||
},
|
||||
...(index > 0 ? right : null)
|
||||
})
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ result:", result)
|
||||
// '电压负序分量', '电压正序分量', '电压零序分量'
|
||||
let ABCName = [
|
||||
...new Set(
|
||||
chartsList.value.map((item: any) => {
|
||||
return item.anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName
|
||||
})
|
||||
)
|
||||
]
|
||||
// console.log("🚀 ~ .then ~ ABCName:", ABCName)
|
||||
result.forEach((item: any, index: any) => {
|
||||
let yMethodList: any = []
|
||||
|
||||
let ABCList = Object.values(
|
||||
item.reduce((acc, item) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.anotherName
|
||||
} else {
|
||||
key = item.phase
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
)
|
||||
// console.log("🚀 ~ ABCList.forEach ~ ABCList:", ABCList)
|
||||
|
||||
ABCList.forEach((kk: any) => {
|
||||
let colorName = kk[0].phase?.charAt(0).toUpperCase()
|
||||
let lineS = ABCName.findIndex(
|
||||
item =>
|
||||
item ===
|
||||
(kk[0].anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName)
|
||||
)
|
||||
|
||||
let seriesList: any = []
|
||||
kk.forEach((cc: any) => {
|
||||
if (cc.statisticalData !== null) {
|
||||
yData[setList.indexOf(kk[0].unit)].push(cc.statisticalData?.toFixed(2))
|
||||
}
|
||||
|
||||
seriesList.push([cc.time, cc.statisticalData?.toFixed(2), cc.unit, lineStyle[lineS].type])
|
||||
})
|
||||
// console.log(kk);
|
||||
|
||||
echartsData.value.options.series.push({
|
||||
name: kk[0].phase ? kk[0].phase + '相' + kk[0].anotherName : kk[0].anotherName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
color:
|
||||
colorName == 'A' ? '#DAA520' : colorName == 'B' ? '#2E8B57' : colorName == 'C' ? '#A52a2a' : '',
|
||||
symbol: 'none',
|
||||
// data: seriesList,
|
||||
data: timeControl.value ? completeTimeSeries(seriesList) : seriesList,
|
||||
lineStyle: lineStyle[lineS],
|
||||
yAxisIndex: setList.indexOf(kk[0].unit)
|
||||
})
|
||||
})
|
||||
})
|
||||
yData.forEach((item: any, index: any) => {
|
||||
let [min, max] = yMethod(item)
|
||||
echartsData.value.yAxis[index].min = min
|
||||
echartsData.value.yAxis[index].max = max
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ echartsData.value:", echartsData.value)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
const setTimeControl = () => {
|
||||
timeControl.value = !timeControl.value
|
||||
setEchart()
|
||||
}
|
||||
|
||||
const selectChange = (flag: boolean, height: any) => {
|
||||
|
||||
pageHeight.value = mainHeight(height * 1.6, 1.6)
|
||||
}
|
||||
//导出
|
||||
const historyChart = ref()
|
||||
|
||||
const countData: any = ref([])
|
||||
const countDataCopy: any = ref([])
|
||||
|
||||
//根据选择的指标处理谐波次数
|
||||
const formatCountOptions = () => {
|
||||
countData.value = []
|
||||
if (searchForm.value.index.length != 0) {
|
||||
searchForm.value.index.forEach((item: any, index: any) => {
|
||||
countDataCopy.value.forEach((vv: any, vvs: any) => {
|
||||
if (vv.index == item) {
|
||||
countData.value.push(vv)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
countData.value.map((item: any, key: any) => {
|
||||
if (item.name == '谐波电流有效值') {
|
||||
item.name = '谐波电流次数'
|
||||
} else if (item.name == '谐波电压含有率') {
|
||||
item.name = '谐波电压次数'
|
||||
} else if (item.name == '间谐波电压含有率') {
|
||||
item.name = '间谐波电压次数'
|
||||
}
|
||||
})
|
||||
}
|
||||
// setTimeout(() => {
|
||||
// tableHeaderRef.value.computedSearchRow()
|
||||
// }, 500)
|
||||
}
|
||||
// 判断下拉框是否存在
|
||||
const onCountChange = (val: any, index: any) => {
|
||||
if (val.length == 0) {
|
||||
countData.value[index].count = countData.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
const flag = ref(true)
|
||||
const onIndexChange = (val: any) => {
|
||||
num.value += 1
|
||||
let pp: any = []
|
||||
indexOptions.value.forEach((item: any) => {
|
||||
const filteredResult = val.filter(vv => item.id == vv)
|
||||
if (filteredResult.length > 0) {
|
||||
pp.push(filteredResult[0])
|
||||
}
|
||||
})
|
||||
searchForm.value.index = pp
|
||||
flag.value = true
|
||||
formatCountOptions()
|
||||
}
|
||||
watch(
|
||||
() => searchForm.value.index,
|
||||
(val: any, oldval: any) => {},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
|
||||
const openDialog = async (row: any, field: any, title: any) => {
|
||||
dialogVisible.value = true
|
||||
trendRequestData.value = row
|
||||
|
||||
nextTick(() => {
|
||||
// 默认当天
|
||||
datePickerRef.value.setInterval(5)
|
||||
datePickerRef.value.timeValue = [row.time, row.time]
|
||||
initCode(field, title)
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ getTrendRequest, openDialog })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.history_header {
|
||||
display: flex;
|
||||
|
||||
// flex-wrap: wrap;
|
||||
#history_select {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
// justify-content: flex-start;
|
||||
// overflow-x: auto;
|
||||
height: auto;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.el-form-item {
|
||||
flex: none !important;
|
||||
// max-width: 380px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
// #history_select::-webkit-scrollbar {
|
||||
// width: 0 !important;
|
||||
// display: none !important;
|
||||
// }
|
||||
|
||||
.history_searchBtn {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.history_chart {
|
||||
width: 100%;
|
||||
|
||||
// flex: 1;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.history_count {
|
||||
.el-select {
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 指标越限详情 -->
|
||||
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.lineId"
|
||||
placeholder="请选择监测点"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 谐波电流、谐波电压占有率 -->
|
||||
<HarmonicRatio
|
||||
ref="harmonicRatioRef"
|
||||
@close="onHarmonicRatioClose"
|
||||
v-if="dialogFlag"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide,nextTick } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import HarmonicRatio from '@/components/cockpit/indicatorFittingChart/components/harmonicRatio.vue'
|
||||
import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
|
||||
const dialogFlag = ref(false)
|
||||
|
||||
const options = ref()
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableHeaderRef = ref()
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 26; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
field: key + i + 'Overtime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row[key + i + 'Overtime']}</span>`
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/mainLine/statLimitRateDetails',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(分钟)',
|
||||
field: 'flickerOvertime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(分钟)',
|
||||
children: loop50('uharm')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(分钟)',
|
||||
children: loop50('iharm')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(分钟)',
|
||||
field: 'ubalanceOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(分钟)',
|
||||
field: 'uaberranceOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uaberranceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(分钟)',
|
||||
field: 'freqDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.freqDevOvertime}</span>`
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
},
|
||||
loadCallback: () => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.sortBy = ''
|
||||
tableStore.table.params.orderBy = ''
|
||||
const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
|
||||
dialogVisible.value = true
|
||||
initCSlineList()
|
||||
tableStore.table.params.lineId = row.lineId
|
||||
|
||||
nextTick(() => {
|
||||
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
|
||||
tableStore.table.params.searchBeginTime =searchBeginTime
|
||||
tableStore.table.params.searchEndTime = searchEndTime
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name' && column.field != 'time') {
|
||||
dialogFlag.value = true
|
||||
dialogVisible.value = false
|
||||
nextTick(() => {
|
||||
harmonicRatioRef.value.openDialog(row,column.field,column.title.replace(/次/g, ""))
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 谐波弹窗关闭时的回调
|
||||
const onHarmonicRatioClose = () => {
|
||||
dialogFlag.value = false
|
||||
// 重新打开指标越限详情弹窗
|
||||
nextTick(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
}
|
||||
|
||||
const initCSlineList = async () => {
|
||||
const res = await cslineList({})
|
||||
options.value = res.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
158
src/components/cockpit/indicatorFittingChart/index.vue
Normal file
@@ -0,0 +1,158 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--主要监测点列表 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" v-if="fullscreen" datePicker ref="tableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="关键词">
|
||||
<el-input v-model="tableStore.table.params.keywords" clearable placeholder="请输关键字" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table
|
||||
ref="tableRef"
|
||||
@cell-click="cellClickEvent"
|
||||
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
|
||||
></Table>
|
||||
<!-- 指标越限详情 -->
|
||||
<OverLimitDetails ref="OverLimitDetailsRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import OverLimitDetails from '@/components/cockpit/indicatorFittingChart/components/overLimitDetails.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { log } from 'console'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
const OverLimitDetailsRef = ref()
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
const tableHeaderRef = ref()
|
||||
|
||||
// 计算是否全屏展示
|
||||
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 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 tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/mainLine/list',
|
||||
method: 'POST',
|
||||
showPage: fullscreen.value ? true : false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '监测点名称',
|
||||
field: 'lineName',
|
||||
minWidth: '90',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: '监测对象类型',
|
||||
field: 'objType',
|
||||
minWidth: '90'
|
||||
},
|
||||
{
|
||||
title: '是否治理',
|
||||
field: 'govern',
|
||||
minWidth: '70'
|
||||
},
|
||||
|
||||
{ title: '主要存在的电能质量问题', field: 'problems', minWidth: '150', showOverflow: true }
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.keywords = ''
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field == 'lineName') {
|
||||
OverLimitDetailsRef.value.open(
|
||||
row,
|
||||
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 在组件挂载时设置缓存值到 DatePicker
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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>
|
||||
@@ -0,0 +1,449 @@
|
||||
<template>
|
||||
<!-- 总体指标占比详情谐波含有率 -->
|
||||
<el-dialog draggable title="谐波电压/电流含有率" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false" @selectChange="selectChange">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="谐波次数">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.searchValue"
|
||||
placeholder="请选择谐波次数"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in harmonicOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="指标类型" v-show="!tableStore.table.params.checked">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.indicatorType"
|
||||
placeholder="请选择指标类型"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indicatorList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="指标类型1" v-show="tableStore.table.params.checked == true">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.indicatorType1"
|
||||
placeholder="请选择指标类型1"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indicatorList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="指标类型2" v-show="tableStore.table.params.checked == true">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.indicatorType2"
|
||||
placeholder="请选择指标类型2"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indicatorList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-checkbox v-model="tableStore.table.params.checked">指标对比分析</el-checkbox>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<my-echart
|
||||
class="tall"
|
||||
v-if="!tableStore.table.params.checked"
|
||||
:options="echartList"
|
||||
style="width: 98%; height: 320px"
|
||||
/>
|
||||
<my-echart class="tall" v-else :options="echartContrastList" style="width: 98%; height: 320px" />
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
const prop = defineProps({
|
||||
width: { type: [String, Number]},
|
||||
height: { type: [String, Number]},
|
||||
timeKey: { type: [String, Number]},
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: '35kV进线',
|
||||
label: '35kV进线'
|
||||
}
|
||||
]
|
||||
|
||||
const config = useConfig()
|
||||
|
||||
const harmonicOptions = Array.from({ length: 50 }, (_, i) => ({
|
||||
value: String(i + 1),
|
||||
label: `${i + 1}次谐波`
|
||||
}))
|
||||
|
||||
const exceedingTheLimitList: any = ref([
|
||||
{
|
||||
label: '越限',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '不越限',
|
||||
value: '0'
|
||||
}
|
||||
])
|
||||
const indicatorList: any = ref([
|
||||
{
|
||||
label: '谐波电压总畸变率',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '各次谐波电压',
|
||||
value: '2'
|
||||
},
|
||||
{
|
||||
label: '各次谐波电压',
|
||||
value: '3'
|
||||
},
|
||||
{
|
||||
label: '三相电压不平衡',
|
||||
value: '4'
|
||||
}
|
||||
])
|
||||
const echartList = ref({
|
||||
title: {
|
||||
text: '谐波电压含有率'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}, {}],
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
name: 'A相',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 0.5],
|
||||
['2025-10-16 07:15:00', 0.6],
|
||||
['2025-10-16 07:30:00', 0.4],
|
||||
['2025-10-16 07:45:00', 0.7],
|
||||
['2025-10-16 08:00:00', 1.2],
|
||||
['2025-10-16 08:15:00', 1.5],
|
||||
['2025-10-16 08:30:00', 1.8],
|
||||
['2025-10-16 08:45:00', 2.1],
|
||||
['2025-10-16 09:00:00', 2.5],
|
||||
['2025-10-16 09:15:00', 2.8],
|
||||
['2025-10-16 09:30:00', 3.0],
|
||||
['2025-10-16 09:45:00', 2.7],
|
||||
['2025-10-16 10:00:00', 2.2],
|
||||
['2025-10-16 10:15:00', 1.9],
|
||||
['2025-10-16 10:30:00', 1.6],
|
||||
['2025-10-16 10:45:00', 1.3],
|
||||
['2025-10-16 11:00:00', 1.1],
|
||||
['2025-10-16 11:15:00', 0.8],
|
||||
['2025-10-16 11:30:00', 0.6],
|
||||
['2025-10-16 11:45:00', 0.4],
|
||||
['2025-10-16 12:00:00', 0.3],
|
||||
['2025-10-16 12:15:00', 0.2],
|
||||
['2025-10-16 12:30:00', 0.3],
|
||||
['2025-10-16 12:45:00', 0.4]
|
||||
],
|
||||
yAxisIndex: 0
|
||||
},
|
||||
{
|
||||
name: 'B相',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 0.4],
|
||||
['2025-10-16 07:15:00', 0.5],
|
||||
['2025-10-16 07:30:00', 0.3],
|
||||
['2025-10-16 07:45:00', 0.6],
|
||||
['2025-10-16 08:00:00', 1.0],
|
||||
['2025-10-16 08:15:00', 1.3],
|
||||
['2025-10-16 08:30:00', 1.6],
|
||||
['2025-10-16 08:45:00', 1.9],
|
||||
['2025-10-16 09:00:00', 2.2],
|
||||
['2025-10-16 09:15:00', 2.5],
|
||||
['2025-10-16 09:30:00', 2.7],
|
||||
['2025-10-16 09:45:00', 2.4],
|
||||
['2025-10-16 10:00:00', 2.0],
|
||||
['2025-10-16 10:15:00', 1.7],
|
||||
['2025-10-16 10:30:00', 1.4],
|
||||
['2025-10-16 10:45:00', 1.1],
|
||||
['2025-10-16 11:00:00', 0.9],
|
||||
['2025-10-16 11:15:00', 0.7],
|
||||
['2025-10-16 11:30:00', 0.5],
|
||||
['2025-10-16 11:45:00', 0.3],
|
||||
['2025-10-16 12:00:00', 0.2],
|
||||
['2025-10-16 12:15:00', 0.1],
|
||||
['2025-10-16 12:30:00', 0.2],
|
||||
['2025-10-16 12:45:00', 0.3]
|
||||
],
|
||||
yAxisIndex: 0
|
||||
},
|
||||
{
|
||||
name: 'C相',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 0.6],
|
||||
['2025-10-16 07:15:00', 0.7],
|
||||
['2025-10-16 07:30:00', 0.5],
|
||||
['2025-10-16 07:45:00', 0.8],
|
||||
['2025-10-16 08:00:00', 1.4],
|
||||
['2025-10-16 08:15:00', 1.7],
|
||||
['2025-10-16 08:30:00', 2.0],
|
||||
['2025-10-16 08:45:00', 2.3],
|
||||
['2025-10-16 09:00:00', 2.8],
|
||||
['2025-10-16 09:15:00', 3.1],
|
||||
['2025-10-16 09:30:00', 3.3],
|
||||
['2025-10-16 09:45:00', 3.0],
|
||||
['2025-10-16 10:00:00', 2.5],
|
||||
['2025-10-16 10:15:00', 2.1],
|
||||
['2025-10-16 10:30:00', 1.8],
|
||||
['2025-10-16 10:45:00', 1.5],
|
||||
['2025-10-16 11:00:00', 1.3],
|
||||
['2025-10-16 11:15:00', 1.0],
|
||||
['2025-10-16 11:30:00', 0.8],
|
||||
['2025-10-16 11:45:00', 0.6],
|
||||
['2025-10-16 12:00:00', 0.5],
|
||||
['2025-10-16 12:15:00', 0.4],
|
||||
['2025-10-16 12:30:00', 0.5],
|
||||
['2025-10-16 12:45:00', 0.6]
|
||||
],
|
||||
yAxisIndex: 0
|
||||
},
|
||||
{
|
||||
name: '暂降触发点',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 3.14159],
|
||||
['2025-10-16 07:15:00', 3.14159],
|
||||
['2025-10-16 07:30:00', 3.14159],
|
||||
['2025-10-16 07:45:00', 3.14159],
|
||||
['2025-10-16 08:00:00', 3.14159],
|
||||
['2025-10-16 08:15:00', 3.14159],
|
||||
['2025-10-16 08:30:00', 3.14159],
|
||||
['2025-10-16 08:45:00', 3.14159],
|
||||
['2025-10-16 09:00:00', 3.14159],
|
||||
['2025-10-16 09:15:00', 3.14159],
|
||||
['2025-10-16 09:30:00', 3.14159],
|
||||
['2025-10-16 09:45:00', 3.14159],
|
||||
['2025-10-16 10:00:00', 3.14159],
|
||||
['2025-10-16 10:15:00', 3.14159],
|
||||
['2025-10-16 10:30:00', 3.14159],
|
||||
['2025-10-16 10:45:00', 3.14159],
|
||||
['2025-10-16 11:00:00', 3.14159],
|
||||
['2025-10-16 11:15:00', 3.14159],
|
||||
['2025-10-16 11:30:00', 3.14159],
|
||||
['2025-10-16 11:45:00', 3.14159],
|
||||
['2025-10-16 12:00:00', 3.14159],
|
||||
['2025-10-16 12:15:00', 3.14159],
|
||||
['2025-10-16 12:30:00', 3.14159],
|
||||
['2025-10-16 12:45:00', 3.14159]
|
||||
],
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
color: '#ff0000' // 红色
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#ff0000' // 红色
|
||||
},
|
||||
yAxisIndex: 0
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const echartContrastList = ref({
|
||||
title: {
|
||||
text: 'A相谐波电压和A相谐波电流对比趋势图'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}, {}],
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
name: 'A相谐波电压',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 0],
|
||||
['2025-10-16 07:15:00', 0],
|
||||
['2025-10-16 07:30:00', 0],
|
||||
['2025-10-16 07:45:00', 0],
|
||||
['2025-10-16 08:00:00', 0],
|
||||
['2025-10-16 08:15:00', 0.1],
|
||||
['2025-10-16 08:30:00', 0.1],
|
||||
['2025-10-16 08:45:00', 0.1],
|
||||
['2025-10-16 09:00:00', 1],
|
||||
['2025-10-16 09:15:00', 1],
|
||||
['2025-10-16 09:30:00', 1],
|
||||
['2025-10-16 09:45:00', 1],
|
||||
['2025-10-16 10:00:00', 0.8],
|
||||
['2025-10-16 10:15:00', 0.8],
|
||||
['2025-10-16 10:30:00', 0.8],
|
||||
['2025-10-16 10:45:00', 0.8],
|
||||
['2025-10-16 11:00:00', 0.8],
|
||||
['2025-10-16 11:15:00', 0.1],
|
||||
['2025-10-16 11:30:00', 0.1],
|
||||
['2025-10-16 11:45:00', 0.1],
|
||||
['2025-10-16 12:00:00', 0],
|
||||
['2025-10-16 12:15:00', 0],
|
||||
['2025-10-16 12:30:00', 0],
|
||||
['2025-10-16 12:45:00', 0]
|
||||
],
|
||||
yAxisIndex: 0
|
||||
},
|
||||
{
|
||||
name: 'A相谐波电流',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
data: [
|
||||
['2025-10-16 07:00:00', 0],
|
||||
['2025-10-16 07:15:00', 0],
|
||||
['2025-10-16 07:30:00', 0],
|
||||
['2025-10-16 07:45:00', 0],
|
||||
['2025-10-16 08:00:00', 0],
|
||||
['2025-10-16 08:15:00', 0.05],
|
||||
['2025-10-16 08:30:00', 0.05],
|
||||
['2025-10-16 08:45:00', 0.05],
|
||||
['2025-10-16 09:00:00', 0.5],
|
||||
['2025-10-16 09:15:00', 0.5],
|
||||
['2025-10-16 09:30:00', 0.5],
|
||||
['2025-10-16 09:45:00', 0.5],
|
||||
['2025-10-16 10:00:00', 0.4],
|
||||
['2025-10-16 10:15:00', 0.4],
|
||||
['2025-10-16 10:30:00', 0.4],
|
||||
['2025-10-16 10:45:00', 0.4],
|
||||
['2025-10-16 11:00:00', 0.4],
|
||||
['2025-10-16 11:15:00', 0.05],
|
||||
['2025-10-16 11:30:00', 0.05],
|
||||
['2025-10-16 11:45:00', 0.05],
|
||||
['2025-10-16 12:00:00', 0],
|
||||
['2025-10-16 12:15:00', 0],
|
||||
['2025-10-16 12:30:00', 0],
|
||||
['2025-10-16 12:45:00', 0]
|
||||
],
|
||||
yAxisIndex: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
const selectChange = (showSelect: any, height: any) => {
|
||||
headerHeight.value = height
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.power = '1'
|
||||
tableStore.table.params.indicator = '1'
|
||||
tableStore.table.params.exceedingTheLimit = '1'
|
||||
tableStore.table.params.searchValue = ''
|
||||
tableStore.table.params.checked = false
|
||||
tableStore.table.params.indicatorType = '' // 指标类型
|
||||
tableStore.table.params.indicatorType1 = '' // 指标类型1
|
||||
tableStore.table.params.indicatorType2 = '' // 指标类型2
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
||||
(newVal, oldVal) => {
|
||||
tableStore.index()
|
||||
},
|
||||
{
|
||||
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
||||
}
|
||||
)
|
||||
|
||||
const openDialog = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
tableStore.index()
|
||||
}
|
||||
|
||||
defineExpose({ openDialog })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-select) {
|
||||
min-width: 80px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<!-- 综合评估详情 -->
|
||||
<el-dialog draggable title="指标合格率统计" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点名称">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.searchValue"
|
||||
placeholder="请选择监测点名称"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
const dialogVisible: any = ref(false)
|
||||
const options = [
|
||||
{
|
||||
value: '35kV进线',
|
||||
label: '35kV进线'
|
||||
}
|
||||
]
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 51; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
// field: key + i,
|
||||
field: 'flicker',
|
||||
width: '80'
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'name',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '80'
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(分钟)',
|
||||
children: loop50('voltage')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(分钟)',
|
||||
children: loop50('harmonicCurrent')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data = [
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0',
|
||||
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0',
|
||||
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0',
|
||||
|
||||
},
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
tableStore.table.params.searchValue = ''
|
||||
provide('tableStore', tableStore)
|
||||
const open = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
tableStore.index()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,159 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 综合评估详情 -->
|
||||
<el-dialog draggable title="指标合格率统计" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点名称">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.searchValue"
|
||||
placeholder="请选择监测点名称"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 谐波电流、谐波电压占有率 -->
|
||||
<HarmonicRatio ref="harmonicRatioRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import HarmonicRatio from '@/components/cockpit/listOfMainMonitoringPoints/components/harmonicRatio.vue'
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
const options = [
|
||||
{
|
||||
value: '35kV进线',
|
||||
label: '35kV进线'
|
||||
}
|
||||
]
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 51; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
// field: key + i,
|
||||
field: 'flicker',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'name',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(分钟)',
|
||||
children: loop50('voltage')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(分钟)',
|
||||
children: loop50('harmonicCurrent')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(分钟)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data = [
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
tableStore.table.params.searchValue = ''
|
||||
provide('tableStore', tableStore)
|
||||
const open = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
tableStore.index()
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
console.log(row, '1111')
|
||||
if (column.field != 'name' && column.field != 'time') {
|
||||
harmonicRatioRef.value.openDialog(row)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
427
src/components/cockpit/listOfMainMonitoringPoints/index.vue
Normal file
@@ -0,0 +1,427 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--指标拟合图 -->
|
||||
<TableHeader datePicker @selectChange="selectChange" v-if="fullscreen">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select v-model="tableStore.table.params.lineId" placeholder="请选择监测点" clearable>
|
||||
<el-option
|
||||
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 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"
|
||||
>
|
||||
<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 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"
|
||||
>
|
||||
<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"
|
||||
:options="echartList"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`
|
||||
}"
|
||||
v-if="showEchart"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { cslineList, fittingData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const config = useConfig()
|
||||
|
||||
const lineList: any = ref()
|
||||
|
||||
const powerList: any = ref()
|
||||
|
||||
const countData: any = ref([])
|
||||
|
||||
const showEchart = ref(true)
|
||||
|
||||
const chartsList = ref<any>([])
|
||||
|
||||
// 计算是否全屏展示
|
||||
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 exceedingTheLimitList: any = ref([
|
||||
{
|
||||
label: '越限',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '不越限',
|
||||
value: '0'
|
||||
}
|
||||
])
|
||||
|
||||
const indicatorList = ref()
|
||||
|
||||
const initLineList = async () => {
|
||||
cslineList({}).then(res => {
|
||||
lineList.value = res.data
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
})
|
||||
}
|
||||
|
||||
const echartList = ref()
|
||||
|
||||
const headerHeight = ref(57)
|
||||
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 setEchart = () => {
|
||||
// 获取当前选择的功率和指标名称
|
||||
const powerName = powerList.value?.find((item: any) => item.id === tableStore.table.params.power)?.name || '功率'
|
||||
const indicatorName =
|
||||
indicatorList.value?.find((item: any) => item.id === tableStore.table.params.indicator)?.name || '电能质量指标'
|
||||
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: `${indicatorName}与${powerName}负荷曲线拟合图`
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}, {}],
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
name: powerName, // 动态设置功率名称
|
||||
data: [],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: function (params: any) {
|
||||
if (params.value[1] == 0 || params.value[1] == 3.14159) {
|
||||
return '#ccc'
|
||||
} else {
|
||||
return config.layout.elementUiPrimary[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxisIndex: 0
|
||||
},
|
||||
{
|
||||
name: indicatorName, // 动态设置指标名称
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
// smooth: true,
|
||||
data: [],
|
||||
yAxisIndex: 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// 检查是否有数据
|
||||
if (!chartsList.value || chartsList.value.length === 0) {
|
||||
showEchart.value = false // 没有数据时隐藏图表
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
// 用户功率数据和电能质量数据
|
||||
let powerData: any[] = []
|
||||
let qualityData: any[] = []
|
||||
|
||||
chartsList.value.forEach((item: any) => {
|
||||
// 根据统计项ID判断是功率数据还是电能质量数据
|
||||
if (item.statisticalIndex === tableStore.table.params.power) {
|
||||
powerData.push(item)
|
||||
} else if (item.statisticalIndex === tableStore.table.params.indicator) {
|
||||
qualityData.push(item)
|
||||
}
|
||||
})
|
||||
|
||||
// 处理功率数据
|
||||
const processedPowerData = powerData.map((item: any) => {
|
||||
return [
|
||||
item.time,
|
||||
item.statisticalData !== null && item.statisticalData !== undefined
|
||||
? parseFloat(item.statisticalData.toFixed(2))
|
||||
: null
|
||||
]
|
||||
})
|
||||
|
||||
// 处理电能质量数据
|
||||
const processedQualityData = qualityData.map((item: any) => {
|
||||
return [
|
||||
item.time,
|
||||
item.statisticalData !== null && item.statisticalData !== undefined
|
||||
? parseFloat(item.statisticalData.toFixed(2))
|
||||
: null
|
||||
]
|
||||
})
|
||||
|
||||
// 检查是否有有效数据
|
||||
const hasPowerData = processedPowerData.length > 0 && processedPowerData.some(item => item[1] !== null)
|
||||
const hasQualityData = processedQualityData.length > 0 && processedQualityData.some(item => item[1] !== null)
|
||||
|
||||
if (!hasPowerData && !hasQualityData) {
|
||||
showEchart.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// 更新图表配置
|
||||
echartList.value.options.series[0].data = processedPowerData
|
||||
echartList.value.options.series[1].data = processedQualityData
|
||||
|
||||
// 确保图表显示
|
||||
showEchart.value = true
|
||||
} catch (error) {
|
||||
console.error('处理图表数据时出错:', error)
|
||||
showEchart.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const initCode = () => {
|
||||
queryByCode('steady_state_limit_fitting').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
powerList.value = item.data.filter((item: any) => {
|
||||
return item.name == '三相总无功功率' || item.name == '三相总有功功率'
|
||||
})
|
||||
|
||||
indicatorList.value = item.data.filter((item: any) => {
|
||||
return item.name != '三相总无功功率' && item.name != '三相总有功功率'
|
||||
})
|
||||
|
||||
tableStore.table.params.power = powerList.value[0].id
|
||||
tableStore.table.params.indicator = indicatorList.value[0].id
|
||||
nextTick(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-device-boot/csGroup/fittingData',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
// 设置时间参数
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
|
||||
// 只有当 lineList 已加载且有数据时才设置默认 lineId
|
||||
if (!tableStore.table.params.lineId && lineList.value && lineList.value.length > 0) {
|
||||
tableStore.table.params.lineId = lineList.value[0].lineId
|
||||
}
|
||||
|
||||
// 构建请求参数 lists
|
||||
let lists: any = []
|
||||
|
||||
// 处理用户功率指标
|
||||
const selectedPower = powerList.value?.find((item: any) => item.id === tableStore.table.params.power)
|
||||
if (selectedPower) {
|
||||
lists.push({
|
||||
statisticalId: tableStore.table.params.power,
|
||||
valueType: tableStore.table.params.valueType
|
||||
})
|
||||
}
|
||||
|
||||
// 处理电能质量指标
|
||||
const selectedIndicator = indicatorList.value?.find(
|
||||
(item: any) => item.id === tableStore.table.params.indicator
|
||||
)
|
||||
if (selectedIndicator) {
|
||||
let frequencys = ''
|
||||
if (selectedIndicator.name.includes('谐波含有率')) {
|
||||
frequencys = tableStore.table.params.harmonicCount
|
||||
}
|
||||
|
||||
lists.push({
|
||||
statisticalId: tableStore.table.params.indicator,
|
||||
frequency: frequencys !== null && frequencys !== undefined ? String(frequencys) : ''
|
||||
})
|
||||
}
|
||||
|
||||
// 将 lists 添加到请求参数中
|
||||
tableStore.table.params.list = lists
|
||||
tableStore.table.params.dataLevel = 'Primary'
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
// 数据加载完成后的处理
|
||||
if (tableStore.table.data && tableStore.table.data.length > 0) {
|
||||
chartsList.value = JSON.parse(JSON.stringify(tableStore.table.data))
|
||||
setEchart()
|
||||
} else if (tableStore.table.data) {
|
||||
showEchart.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.indicator = '1'
|
||||
tableStore.table.params.exceedingTheLimit = '1'
|
||||
tableStore.table.params.valueType = 'avg'
|
||||
tableStore.table.params.searchValue = ''
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 添加谐波次数选项(2-50)
|
||||
const harmonicCountOptions = ref(Array.from({ length: 49 }, (_, i) => i + 2))
|
||||
|
||||
// 判断是否应该显示谐波次数选择框
|
||||
const shouldShowHarmonicCount = () => {
|
||||
if (!tableStore.table.params.indicator || !indicatorList.value) return false
|
||||
|
||||
const currentIndicator = indicatorList.value.find((item: any) => item.id === tableStore.table.params.indicator)
|
||||
|
||||
return (
|
||||
currentIndicator &&
|
||||
(currentIndicator.name.includes('电压谐波含有率') || currentIndicator.name.includes('电流谐波含有率'))
|
||||
)
|
||||
}
|
||||
|
||||
// 获取谐波类型名称
|
||||
const getHarmonicTypeName = () => {
|
||||
const currentIndicator = indicatorList.value.find((item: any) => item.id === tableStore.table.params.indicator)
|
||||
|
||||
if (currentIndicator) {
|
||||
if (currentIndicator.name.includes('电压谐波含有率')) {
|
||||
return '电压'
|
||||
} else if (currentIndicator.name.includes('电流谐波含有率')) {
|
||||
return '电流'
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
// 监听指标变化,当指标变化时重置谐波次数
|
||||
watch(
|
||||
() => tableStore.table.params.indicator,
|
||||
newVal => {
|
||||
if (shouldShowHarmonicCount()) {
|
||||
// 如果之前没有设置过谐波次数,则默认设置为2
|
||||
if (!tableStore.table.params.harmonicCount) {
|
||||
tableStore.table.params.harmonicCount = 2
|
||||
}
|
||||
} else {
|
||||
// 如果不是谐波含有率指标,则清除谐波次数设置
|
||||
tableStore.table.params.harmonicCount = ''
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
initLineList().then(() => {
|
||||
initCode()
|
||||
})
|
||||
})
|
||||
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>
|
||||
// :deep(.el-select) {
|
||||
// min-width: 80px;
|
||||
// }
|
||||
</style>
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 指标越限详情 -->
|
||||
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.lineId"
|
||||
placeholder="请选择监测点"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 谐波电流、谐波电压占有率 -->
|
||||
<HarmonicRatio ref="harmonicRatioRef" v-if="dialogFlag" @close="onHarmonicRatioClose" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide,nextTick } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import HarmonicRatio from '@/components/cockpit/gridSideStatistics/components/harmonicRatio.vue'
|
||||
import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
|
||||
const options = ref()
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableHeaderRef = ref()
|
||||
const dialogFlag = ref(false)
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 26; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
field: key + i + 'Overtime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row[key + i + 'Overtime']}</span>`
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/totalLimitStatistics/details',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '每日越限占比统计',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(%)',
|
||||
field: 'flickerOvertime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(%)',
|
||||
children: loop50('uharm')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(%)',
|
||||
children: loop50('iharm')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(%)',
|
||||
field: 'ubalanceOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(%)',
|
||||
field: 'voltageDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uaberranceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(%)',
|
||||
field: 'freqDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.freqDevOvertime}</span>`
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
},
|
||||
loadCallback: () => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.sortBy = ''
|
||||
tableStore.table.params.orderBy = ''
|
||||
const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
|
||||
dialogVisible.value = true
|
||||
initCSlineList()
|
||||
tableStore.table.params.lineId = row.lineId
|
||||
|
||||
nextTick(() => {
|
||||
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
|
||||
tableStore.table.params.searchBeginTime =searchBeginTime
|
||||
tableStore.table.params.searchEndTime = searchEndTime
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name' && column.field != 'time') {
|
||||
dialogFlag.value = true
|
||||
dialogVisible.value = false
|
||||
nextTick(() => {
|
||||
harmonicRatioRef.value.openDialog(row,column.field,column.title.replace(/次/g, ""))
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 谐波弹窗关闭时的回调
|
||||
const onHarmonicRatioClose = () => {
|
||||
dialogFlag.value = false
|
||||
// 重新打开指标越限详情弹窗
|
||||
nextTick(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
}
|
||||
|
||||
const initCSlineList = async () => {
|
||||
const res = await cslineList({})
|
||||
options.value = res.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
341
src/components/cockpit/monitoringPointList/index.vue
Normal file
@@ -0,0 +1,341 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 监测点列表 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<Table
|
||||
ref="tableRef"
|
||||
@cell-click="cellClickEvent"
|
||||
:height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`"
|
||||
></Table>
|
||||
<!-- 指标越限详情 -->
|
||||
<OverLimitDetails ref="OverLimitDetailsRef" />
|
||||
|
||||
<!-- 上传对话框 -->
|
||||
<el-dialog v-model="uploadDialogVisible" title="上传报告" width="500px" @closed="handleDialogClosed">
|
||||
<el-upload
|
||||
ref="uploadRef"
|
||||
class="upload-demo"
|
||||
:auto-upload="true"
|
||||
:on-change="handleChange"
|
||||
:before-upload="beforeUpload"
|
||||
:http-request="handleUpload"
|
||||
:limit="1"
|
||||
:on-exceed="handleExceed"
|
||||
:file-list="fileList"
|
||||
>
|
||||
<el-button type="primary">点击上传</el-button>
|
||||
<template #tip>
|
||||
<div class="el-upload__tip">只能上传Word或PDF文件,且不超过10MB</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button @click="uploadDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="uploadDialogVisible = false">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import OverLimitDetails from '@/components/cockpit/monitoringPointList/components/overLimitDetails.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { uploadReport, getReportUrl } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
// 上传相关
|
||||
const uploadDialogVisible = ref(false)
|
||||
const currentUploadRow = ref<any>(null)
|
||||
const uploadRef = ref()
|
||||
const fileList = 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 OverLimitDetailsRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-device-boot/csline/getSensitiveUserLineList',
|
||||
method: 'POST',
|
||||
showPage: fullscreen.value ? true : false,
|
||||
exportName: '监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '治理对象',
|
||||
field: 'sensitiveUser',
|
||||
minWidth: '80'
|
||||
},
|
||||
|
||||
{
|
||||
title: '电压等级',
|
||||
field: 'volGrade',
|
||||
minWidth: '70'
|
||||
},
|
||||
{
|
||||
title: '是否治理',
|
||||
field: 'govern',
|
||||
minWidth: '70'
|
||||
},
|
||||
|
||||
// {
|
||||
// title: '治理前报告',
|
||||
// field: 'reportFileName',
|
||||
// minWidth: '80',
|
||||
// render: 'customTemplate',
|
||||
// customTemplate: (row: any) => {
|
||||
// return `<span style='cursor: pointer;text-decoration: underline;'>${row.reportFileName}</span>`
|
||||
// }
|
||||
// },
|
||||
{
|
||||
title: '监测点名称',
|
||||
field: 'lineName',
|
||||
minWidth: '70',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.lineName}</span>`
|
||||
}
|
||||
},
|
||||
{ title: '监测类型', field: 'position', minWidth: '60' },
|
||||
{
|
||||
title: '监测点状态',
|
||||
field: 'runStatus',
|
||||
minWidth: '60',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='color: ${row.runStatus === '中断' ? '#FF0000' : ''}'>${row.runStatus}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '最新数据时间',
|
||||
field: 'latestTime',
|
||||
minWidth: '140',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
if (row.latestTime) {
|
||||
return `<span>${row.latestTime}</span>`
|
||||
} else {
|
||||
return `<span>/</span>`
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 120,
|
||||
// fixed: 'right',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'productSetting',
|
||||
title: '上传报告',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-upload',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
uploadReportRow(row)
|
||||
},
|
||||
disabled: row => {
|
||||
return row.reportFilePath
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
name: 'productSetting',
|
||||
title: '下载报告',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
downloadTheReport(row.lineId)
|
||||
},
|
||||
disabled: row => {
|
||||
return row.reportFilePath == null || row.reportFilePath.length == 0
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'productSetting',
|
||||
title: '重新上传',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-upload',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
uploadReportRow(row)
|
||||
},
|
||||
disabled: row => {
|
||||
return row.reportFilePath == null || row.reportFilePath.length == 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
tableStore.table.params.keywords = ''
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field == 'lineName') {
|
||||
OverLimitDetailsRef.value.open(
|
||||
row,
|
||||
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 下载报告
|
||||
const downloadTheReport = (lineId: string) => {
|
||||
getReportUrl({ lineId: lineId }).then((res: any) => {
|
||||
const link = document.createElement('a')
|
||||
link.href = res.data
|
||||
link.download = '治理报告'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
})
|
||||
}
|
||||
|
||||
// 上传报告
|
||||
const uploadReportRow = (row: any) => {
|
||||
currentUploadRow.value = row
|
||||
// 打开弹窗前清空文件列表
|
||||
fileList.value = []
|
||||
uploadDialogVisible.value = true
|
||||
}
|
||||
|
||||
// 处理弹窗关闭事件
|
||||
const handleDialogClosed = () => {
|
||||
// 清空文件列表
|
||||
fileList.value = []
|
||||
}
|
||||
|
||||
// 处理文件超出限制
|
||||
const handleExceed = (files: any, fileList: any) => {
|
||||
ElMessage.warning('只能上传一个文件,请先删除已选择的文件')
|
||||
}
|
||||
|
||||
// 文件变更处理函数
|
||||
const handleChange = (file: any, fileList: any) => {
|
||||
// 在这里直接处理文件上传逻辑
|
||||
beforeUpload(file.raw) // 注意使用 file.raw 获取原始文件对象
|
||||
}
|
||||
|
||||
// 处理上传前检查
|
||||
const beforeUpload = (file: any) => {
|
||||
const isWord =
|
||||
file.type === 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' ||
|
||||
file.type === 'application/msword' ||
|
||||
file.name.endsWith('.doc') ||
|
||||
file.name.endsWith('.docx')
|
||||
|
||||
const isPDF = file.type === 'application/pdf' || file.name.endsWith('.pdf')
|
||||
|
||||
const isValidType = isWord || isPDF
|
||||
const isLt10M = file.size / 1024 / 1024 < 10
|
||||
|
||||
if (!isValidType) {
|
||||
ElMessage.error('上传文件只能是 Word 文档(.doc/.docx) 或 PDF 文件(.pdf)!')
|
||||
return false
|
||||
}
|
||||
if (!isLt10M) {
|
||||
ElMessage.error('上传文件大小不能超过 10MB!')
|
||||
return false
|
||||
}
|
||||
|
||||
// 校验通过后允许上传,交由 http-request 处理
|
||||
return true
|
||||
}
|
||||
|
||||
const handleUpload = async (options: any) => {
|
||||
const { file } = options
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
formData.append('lineId', currentUploadRow.value?.lineId || currentUploadRow.value?.id || '')
|
||||
|
||||
try {
|
||||
const result = await uploadReport(formData)
|
||||
ElMessage.success('上传成功')
|
||||
uploadDialogVisible.value = false
|
||||
tableStore.index()
|
||||
return Promise.resolve(result)
|
||||
} catch (error: any) {
|
||||
ElMessage.error('上传失败: ' + (error.message || '未知错误'))
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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
|
||||
}
|
||||
)
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,705 @@
|
||||
<template>
|
||||
<el-dialog draggable title="趋势图" v-model="dialogVisible" append-to-body width="70%">
|
||||
<!-- 总体指标占比详情谐波含有率 -->
|
||||
<div>
|
||||
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
|
||||
<template v-slot:select>
|
||||
<el-form-item>
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计指标" label-width="80px">
|
||||
<el-select
|
||||
multiple
|
||||
:multiple-limit="2"
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
v-model="searchForm.index"
|
||||
placeholder="请选择统计指标"
|
||||
@change="onIndexChange($event)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indexOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-radio-group v-model="searchForm.dataLevel" @change="init()">
|
||||
<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="searchForm.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
|
||||
class="history_count"
|
||||
v-for="(item, index) in countData"
|
||||
:key="index"
|
||||
v-show="item.countOptions.length != 0"
|
||||
>
|
||||
<span class="mr12">
|
||||
{{ item.name.includes('次数') ? item.name : item.name + '谐波次数' }}
|
||||
</span>
|
||||
<el-select
|
||||
v-model="item.count"
|
||||
@change="onCountChange($event, index)"
|
||||
placeholder="请选择谐波次数"
|
||||
style="width: 100px"
|
||||
class="mr20"
|
||||
>
|
||||
<el-option
|
||||
v-for="vv in item.countOptions"
|
||||
:key="vv"
|
||||
:label="vv"
|
||||
:value="vv"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
<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>
|
||||
</TableHeader>
|
||||
</div>
|
||||
<div class="history_chart" :style="pageHeight" v-loading="loading">
|
||||
<MyEchart
|
||||
ref="historyChart"
|
||||
:options="echartsData"
|
||||
v-if="showEchart"
|
||||
/>
|
||||
<el-empty :style="pageHeight" v-else description="暂无数据" />
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { queryStatistical } from '@/api/system-boot/csstatisticalset'
|
||||
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { trendData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import { color } from '@/components/echarts/color'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const dictData = useDictData()
|
||||
defineOptions({
|
||||
// name: 'govern/device/control'
|
||||
})
|
||||
const props = defineProps({
|
||||
TrendList: {
|
||||
type: Array
|
||||
}
|
||||
})
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
// console.log("🚀 ~ props:", props.TrendList)
|
||||
const showEchart = ref(true)
|
||||
const num = ref(0)
|
||||
const timeControl = ref(false)
|
||||
//值类型
|
||||
const pageHeight = ref(mainHeight(57 * 1.6, 1.6))
|
||||
const loading = ref(true)
|
||||
const searchForm: any = ref({})
|
||||
const tableHeaderRef = ref()
|
||||
const typeOptions = [
|
||||
{
|
||||
name: '平均值',
|
||||
id: 'avg'
|
||||
},
|
||||
{
|
||||
name: '最大值',
|
||||
id: 'max'
|
||||
},
|
||||
{
|
||||
name: '最小值',
|
||||
id: 'min'
|
||||
},
|
||||
{
|
||||
name: 'CP95值',
|
||||
id: 'cp95'
|
||||
}
|
||||
]
|
||||
searchForm.value = {
|
||||
index: [],
|
||||
type: typeOptions[0].id,
|
||||
count: '',
|
||||
searchBeginTime: '',
|
||||
searchEndTime: '',
|
||||
dataLevel: 'Primary',
|
||||
valueType: 'avg'
|
||||
}
|
||||
//统计指标
|
||||
const indexOptions: any = ref([])
|
||||
//谐波次数
|
||||
const countOptions: any = ref([])
|
||||
// Harmonic_Type
|
||||
// portable-harmonic
|
||||
const legendDictList: any = ref([])
|
||||
|
||||
const initCode = (field: string, title: string) => {
|
||||
queryByCode('steady_state_limit_trend').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
//排序
|
||||
indexOptions.value = item.data.sort((a: any, b: any) => {
|
||||
return a.sort - b.sort
|
||||
})
|
||||
const titleMap: Record<string, number> = {
|
||||
flickerOvertime: 0,
|
||||
uaberranceOvertime: 3,
|
||||
ubalanceOvertime: 4,
|
||||
freqDevOvertime: 5
|
||||
}
|
||||
|
||||
let defaultIndex = 0 // 默认值
|
||||
|
||||
if (field in titleMap) {
|
||||
defaultIndex = titleMap[field]
|
||||
} else if (field.includes('uharm')) {
|
||||
defaultIndex = 1
|
||||
} else if (field.includes('iharm')) {
|
||||
defaultIndex = 2
|
||||
}
|
||||
|
||||
searchForm.value.index[0] = indexOptions.value[defaultIndex].id
|
||||
})
|
||||
queryStatistical(res.data.id).then(vv => {
|
||||
legendDictList.value = vv.data
|
||||
indexOptions.value.map((item: any, index: any) => {
|
||||
if (!countDataCopy.value[index]) {
|
||||
countDataCopy.value[index] = {
|
||||
index: item.id,
|
||||
countOptions: [],
|
||||
count: [],
|
||||
name: indexOptions.value.find((vv: any) => {
|
||||
return vv.id == item.id
|
||||
})?.name
|
||||
}
|
||||
}
|
||||
legendDictList.value?.selectedList?.map((vv: any, vvs: any) => {
|
||||
//查找相等的指标
|
||||
if (item.id == vv.dataType) {
|
||||
vv.eleEpdPqdVOS.map((kk: any, kks: any) => {
|
||||
if (kk.harmStart && kk.harmEnd) {
|
||||
range(0, 0, 0)
|
||||
|
||||
if (kk.showName == '间谐波电压含有率') {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1).map(
|
||||
(item: any) => {
|
||||
return item - 0.5
|
||||
}
|
||||
)
|
||||
} else {
|
||||
countDataCopy.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
|
||||
}
|
||||
if (title && countDataCopy.value[index].countOptions.includes(Number(title))) {
|
||||
countDataCopy.value[index].count = Number(title)
|
||||
} else if (title && countDataCopy.value[index].countOptions.includes(title)) {
|
||||
countDataCopy.value[index].count = title
|
||||
} else if (
|
||||
!countDataCopy.value[index].count ||
|
||||
countDataCopy.value[index].count.length == 0
|
||||
) {
|
||||
// 只有当count为空时才设置默认值
|
||||
countDataCopy.value[index].count = countDataCopy.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
nextTick(() => {
|
||||
formatCountOptions()
|
||||
})
|
||||
init()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const chartsList = ref<any>([])
|
||||
const chartTitle: any = ref('')
|
||||
const echartsData = ref<any>(null)
|
||||
//加载echarts图表
|
||||
//历史趋势数据
|
||||
const historyDataList: any = ref([])
|
||||
const range = (start: any, end: any, step: any) => {
|
||||
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
|
||||
}
|
||||
//获取请求趋势数据参数
|
||||
const trendRequestData = ref()
|
||||
const getTrendRequest = (val: any) => {
|
||||
trendRequestData.value = val
|
||||
// init()
|
||||
}
|
||||
//初始化趋势图
|
||||
const headerRef = ref()
|
||||
const datePickerRef = ref()
|
||||
const lineStyle = [{ type: 'solid' }, { type: 'dashed' }, { type: 'dotted' }]
|
||||
const init = async () => {
|
||||
loading.value = true
|
||||
// 选择指标的时候切换legend内容和data数据
|
||||
let list: any = []
|
||||
legendDictList.value?.selectedList?.map((item: any) => {
|
||||
searchForm.value.index.map((vv: any) => {
|
||||
if (item.dataType == vv) {
|
||||
list.push(item.eleEpdPqdVOS)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
//颜色数组
|
||||
const colorList = color
|
||||
//选择的指标使用方法处理
|
||||
formatCountOptions()
|
||||
//查询历史趋势
|
||||
historyDataList.value = []
|
||||
chartTitle.value = ''
|
||||
|
||||
searchForm.value.index.map((item: any, indexs: any) => {
|
||||
indexOptions.value.map((vv: any) => {
|
||||
if (vv.id == item) {
|
||||
chartTitle.value += indexs == searchForm.value.index.length - 1 ? vv.name : vv.name + '/'
|
||||
}
|
||||
})
|
||||
})
|
||||
let lists: any = []
|
||||
let frequencys: any = null
|
||||
countData.value.map((item: any, index: any) => {
|
||||
if (item.name.includes('谐波含有率')) {
|
||||
frequencys = item.count
|
||||
} else {
|
||||
frequencys = ''
|
||||
}
|
||||
lists[index] = {
|
||||
statisticalId: item.index,
|
||||
frequency: frequencys !== null && frequencys !== undefined ? String(frequencys) : ''
|
||||
}
|
||||
})
|
||||
let obj = {
|
||||
//...trendRequestData.value,
|
||||
lineId: trendRequestData.value.lineId,
|
||||
list: lists,
|
||||
dataLevel: searchForm.value.dataLevel,
|
||||
valueType: searchForm.value.valueType,
|
||||
searchBeginTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
||||
searchEndTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
||||
}
|
||||
if (searchForm.value.index.length == 0) {
|
||||
ElMessage.warning('请选择统计指标')
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
if (obj.list.length != 0) {
|
||||
try {
|
||||
showEchart.value = true
|
||||
await trendData(obj)
|
||||
.then((res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
if (res.data.length == 0) {
|
||||
loading.value = false
|
||||
showEchart.value = false
|
||||
return
|
||||
}
|
||||
historyDataList.value = res.data
|
||||
chartsList.value = JSON.parse(JSON.stringify(res.data))
|
||||
loading.value = false
|
||||
setEchart()
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
loading.value = false
|
||||
})
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
const setEchart = () => {
|
||||
loading.value = true
|
||||
echartsData.value = {}
|
||||
//icon图标替换legend图例
|
||||
|
||||
// y轴单位数组
|
||||
let unitList: any = []
|
||||
|
||||
let groupedData = chartsList.value.reduce((acc: any, item: any) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.unit
|
||||
} else {
|
||||
key = item.anotherName
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
let result = Object.values(groupedData)
|
||||
if (chartsList.value.length > 0) {
|
||||
unitList = result.map((item: any) => {
|
||||
return item[0].unit
|
||||
})
|
||||
}
|
||||
|
||||
echartsData.value = {
|
||||
legend: {
|
||||
itemWidth: 20,
|
||||
itemHeight: 20,
|
||||
itemStyle: { opacity: 0 }, //去圆点
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
top: 5,
|
||||
right: 70
|
||||
// width: 550,
|
||||
// height: 50
|
||||
},
|
||||
grid: {
|
||||
top: '80px'
|
||||
},
|
||||
tooltip: {
|
||||
axisPointer: {
|
||||
type: 'cross',
|
||||
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(params: any) {
|
||||
const xname = params[0].value[0]
|
||||
let str = `${xname}<br>`
|
||||
params.forEach((el: any, index: any) => {
|
||||
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>`
|
||||
}
|
||||
let unit = el.value[2] ? el.value[2] : ''
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${el.value[1]}${unit}
|
||||
<br>`
|
||||
})
|
||||
return str
|
||||
}
|
||||
},
|
||||
color: ['#DAA520', '#2E8B57', '#A52a2a', ...color],
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: [{}],
|
||||
toolbox: {
|
||||
featureProps: {
|
||||
myTool1: {
|
||||
show: true,
|
||||
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',
|
||||
onclick: e => {
|
||||
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data))
|
||||
|
||||
let list = echartsData.value.options.series?.map((item: any) => item.data)
|
||||
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'
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
options: {
|
||||
series: []
|
||||
}
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ unitList:", unitList)
|
||||
|
||||
if (chartsList.value.length > 0) {
|
||||
let yData: any = []
|
||||
echartsData.value.yAxis = []
|
||||
let setList = [...new Set(unitList)]
|
||||
|
||||
setList.forEach((item: any, index: any) => {
|
||||
if (index > 2) {
|
||||
echartsData.value.grid.right = (index - 1) * 80
|
||||
}
|
||||
yData.push([])
|
||||
let right = {
|
||||
position: 'right',
|
||||
offset: (index - 1) * 80
|
||||
}
|
||||
// console.log("🚀 ~ unitList.forEach ~ right.index:", index)
|
||||
echartsData.value.yAxis.push({
|
||||
name: item,
|
||||
yAxisIndex: index,
|
||||
splitNumber: 5,
|
||||
minInterval: 1,
|
||||
splitLine: {
|
||||
show: false
|
||||
},
|
||||
...(index > 0 ? right : null)
|
||||
})
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ result:", result)
|
||||
// '电压负序分量', '电压正序分量', '电压零序分量'
|
||||
let ABCName = [
|
||||
...new Set(
|
||||
chartsList.value.map((item: any) => {
|
||||
return item.anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: item.anotherName
|
||||
})
|
||||
)
|
||||
]
|
||||
// console.log("🚀 ~ .then ~ ABCName:", ABCName)
|
||||
result.forEach((item: any, index: any) => {
|
||||
let yMethodList: any = []
|
||||
|
||||
let ABCList = Object.values(
|
||||
item.reduce((acc, item) => {
|
||||
let key = ''
|
||||
if (item.phase == null) {
|
||||
key = item.anotherName
|
||||
} else {
|
||||
key = item.phase
|
||||
}
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
)
|
||||
// console.log("🚀 ~ ABCList.forEach ~ ABCList:", ABCList)
|
||||
|
||||
ABCList.forEach((kk: any) => {
|
||||
let colorName = kk[0].phase?.charAt(0).toUpperCase()
|
||||
let lineS = ABCName.findIndex(
|
||||
item =>
|
||||
item ===
|
||||
(kk[0].anotherName == '电压负序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压正序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName == '电压零序分量'
|
||||
? '电压不平衡'
|
||||
: kk[0].anotherName)
|
||||
)
|
||||
|
||||
let seriesList: any = []
|
||||
kk.forEach((cc: any) => {
|
||||
if (cc.statisticalData !== null) {
|
||||
yData[setList.indexOf(kk[0].unit)].push(cc.statisticalData?.toFixed(2))
|
||||
}
|
||||
|
||||
seriesList.push([cc.time, cc.statisticalData?.toFixed(2), cc.unit, lineStyle[lineS].type])
|
||||
})
|
||||
// console.log(kk);
|
||||
|
||||
echartsData.value.options.series.push({
|
||||
name: kk[0].phase ? kk[0].phase + '相' + kk[0].anotherName : kk[0].anotherName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
color:
|
||||
colorName == 'A' ? '#DAA520' : colorName == 'B' ? '#2E8B57' : colorName == 'C' ? '#A52a2a' : '',
|
||||
symbol: 'none',
|
||||
// data: seriesList,
|
||||
data: timeControl.value ? completeTimeSeries(seriesList) : seriesList,
|
||||
lineStyle: lineStyle[lineS],
|
||||
yAxisIndex: setList.indexOf(kk[0].unit)
|
||||
})
|
||||
})
|
||||
})
|
||||
yData.forEach((item: any, index: any) => {
|
||||
let [min, max] = yMethod(item)
|
||||
echartsData.value.yAxis[index].min = min
|
||||
echartsData.value.yAxis[index].max = max
|
||||
})
|
||||
// console.log("🚀 ~ result.forEach ~ echartsData.value:", echartsData.value)
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
const setTimeControl = () => {
|
||||
timeControl.value = !timeControl.value
|
||||
setEchart()
|
||||
}
|
||||
|
||||
const selectChange = (flag: boolean, height: any) => {
|
||||
pageHeight.value = mainHeight(height * 1.6, 1.6)
|
||||
}
|
||||
//导出
|
||||
const historyChart = ref()
|
||||
|
||||
const countData: any = ref([])
|
||||
const countDataCopy: any = ref([])
|
||||
|
||||
//根据选择的指标处理谐波次数
|
||||
const formatCountOptions = () => {
|
||||
countData.value = []
|
||||
if (searchForm.value.index.length != 0) {
|
||||
searchForm.value.index.forEach((item: any, index: any) => {
|
||||
countDataCopy.value.forEach((vv: any, vvs: any) => {
|
||||
if (vv.index == item) {
|
||||
countData.value.push(vv)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
countData.value.map((item: any, key: any) => {
|
||||
if (item.name == '谐波电流有效值') {
|
||||
item.name = '谐波电流次数'
|
||||
} else if (item.name == '谐波电压含有率') {
|
||||
item.name = '谐波电压次数'
|
||||
} else if (item.name == '间谐波电压含有率') {
|
||||
item.name = '间谐波电压次数'
|
||||
}
|
||||
})
|
||||
}
|
||||
// setTimeout(() => {
|
||||
// tableHeaderRef.value.computedSearchRow()
|
||||
// }, 500)
|
||||
}
|
||||
// 判断下拉框是否存在
|
||||
const onCountChange = (val: any, index: any) => {
|
||||
if (val.length == 0) {
|
||||
countData.value[index].count = countData.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
const flag = ref(true)
|
||||
const onIndexChange = (val: any) => {
|
||||
num.value += 1
|
||||
let pp: any = []
|
||||
indexOptions.value.forEach((item: any) => {
|
||||
const filteredResult = val.filter(vv => item.id == vv)
|
||||
if (filteredResult.length > 0) {
|
||||
pp.push(filteredResult[0])
|
||||
}
|
||||
})
|
||||
searchForm.value.index = pp
|
||||
flag.value = true
|
||||
formatCountOptions()
|
||||
}
|
||||
watch(
|
||||
() => searchForm.value.index,
|
||||
(val: any, oldval: any) => {},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
|
||||
const openDialog = async (row: any, field: any, title: any) => {
|
||||
dialogVisible.value = true
|
||||
trendRequestData.value = row
|
||||
|
||||
nextTick(() => {
|
||||
// 默认当天
|
||||
datePickerRef.value.setInterval(5)
|
||||
datePickerRef.value.timeValue = [row.time, row.time]
|
||||
initCode(field, title)
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ getTrendRequest, openDialog })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.history_header {
|
||||
display: flex;
|
||||
|
||||
// flex-wrap: wrap;
|
||||
#history_select {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
// justify-content: flex-start;
|
||||
// overflow-x: auto;
|
||||
height: auto;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.el-form-item {
|
||||
flex: none !important;
|
||||
// max-width: 380px;
|
||||
}
|
||||
|
||||
.el-select {
|
||||
margin-right: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
// #history_select::-webkit-scrollbar {
|
||||
// width: 0 !important;
|
||||
// display: none !important;
|
||||
// }
|
||||
|
||||
.history_searchBtn {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.history_chart {
|
||||
width: 100%;
|
||||
|
||||
// flex: 1;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.history_count {
|
||||
.el-select {
|
||||
min-width: 100px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 指标越限详情 -->
|
||||
<el-dialog draggable title="指标越限详情" v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false" ref="tableHeaderRef">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.lineId"
|
||||
placeholder="请选择监测点"
|
||||
style="width: 150px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 谐波电流、谐波电压占有率 -->
|
||||
<HarmonicRatio ref="harmonicRatioRef" v-if="dialogFlag" @close="onHarmonicRatioClose" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide,nextTick } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import HarmonicRatio from '@/components/cockpit/overLimitStatistics/components/harmonicRatio.vue'
|
||||
import { cslineList } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
|
||||
const options = ref()
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableHeaderRef = ref()
|
||||
const dialogFlag = ref(false)
|
||||
const loop50 = (key: string) => {
|
||||
let list: any[] = []
|
||||
for (let i = 2; i < 26; i++) {
|
||||
list.push({
|
||||
title: i + '次',
|
||||
field: key + i + 'Overtime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row[key + i + 'Overtime']}</span>`
|
||||
}
|
||||
})
|
||||
}
|
||||
return list
|
||||
}
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/totalLimitStatistics/details',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '每日越限占比统计',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '日期',
|
||||
field: 'time',
|
||||
width: '150',
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '闪变越限(%)',
|
||||
field: 'flickerOvertime',
|
||||
width: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flickerOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压越限(%)',
|
||||
children: loop50('uharm')
|
||||
},
|
||||
{
|
||||
title: '谐波电流越限(%)',
|
||||
children: loop50('iharm')
|
||||
},
|
||||
{
|
||||
title: '三相不平衡度越限(%)',
|
||||
field: 'ubalanceOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalanceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差越限(%)',
|
||||
field: 'voltageDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uaberranceOvertime}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '频率偏差越限(%)',
|
||||
field: 'freqDevOvertime',
|
||||
width: '100',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.freqDevOvertime}</span>`
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
},
|
||||
loadCallback: () => {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.sortBy = ''
|
||||
tableStore.table.params.orderBy = ''
|
||||
const open = async (row: any,searchBeginTime:any,searchEndTime:any) => {
|
||||
dialogVisible.value = true
|
||||
initCSlineList()
|
||||
tableStore.table.params.lineId = row.lineId
|
||||
|
||||
nextTick(() => {
|
||||
tableHeaderRef.value.setTimeInterval([searchBeginTime, searchEndTime])
|
||||
tableStore.table.params.searchBeginTime =searchBeginTime
|
||||
tableStore.table.params.searchEndTime = searchEndTime
|
||||
tableStore.index()
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name' && column.field != 'time') {
|
||||
dialogFlag.value = true
|
||||
dialogVisible.value = false
|
||||
nextTick(() => {
|
||||
harmonicRatioRef.value.openDialog(row,column.field,column.title.replace(/次/g, ""))
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 谐波弹窗关闭时的回调
|
||||
const onHarmonicRatioClose = () => {
|
||||
dialogFlag.value = false
|
||||
// 重新打开指标越限详情弹窗
|
||||
nextTick(() => {
|
||||
dialogVisible.value = true
|
||||
})
|
||||
}
|
||||
|
||||
const initCSlineList = async () => {
|
||||
const res = await cslineList({})
|
||||
options.value = res.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
246
src/components/cockpit/overLimitStatistics/index.vue
Normal file
@@ -0,0 +1,246 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--总体指标越限统计 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker 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>
|
||||
<!-- 指标越限详情 -->
|
||||
<OverLimitDetails ref="OverLimitDetailsRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import OverLimitDetails from '@/components/cockpit/overLimitStatistics/components/overLimitDetails.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { totalLimitStatisticsData } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
const echartList = 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 initEcharts = () => {
|
||||
totalLimitStatisticsData({
|
||||
searchBeginTime: tableStore.table.params.searchBeginTime,
|
||||
searchEndTime: tableStore.table.params.searchEndTime
|
||||
}).then((res: any) => {
|
||||
const dataArray = [res.data.flicker, res.data.uharm, res.data.iharm, res.data.voltageDev, res.data.ubalance]
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: '指标越限占比'
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
// name: '(区域)',
|
||||
data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
name: '%', // 给X轴加单位
|
||||
interval: 20
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
options: {
|
||||
series: [
|
||||
{
|
||||
// name: '暂降次数',
|
||||
type: 'bar',
|
||||
name: '越限占比',
|
||||
data: dataArray,
|
||||
barMaxWidth: 30
|
||||
|
||||
// label: {
|
||||
// show: true,
|
||||
// position: 'top',
|
||||
// textStyle: {
|
||||
// //数值样式
|
||||
// color: '#000'
|
||||
// },
|
||||
// fontSize: 12
|
||||
// }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const OverLimitDetailsRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/harmonic-boot/totalLimitStatistics/list',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'lineName',
|
||||
minWidth: '90'
|
||||
},
|
||||
{
|
||||
title: '越限占比(%)',
|
||||
children: [
|
||||
{
|
||||
title: '闪变',
|
||||
field: 'flicker',
|
||||
minWidth: '70',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.flicker}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电压',
|
||||
field: 'uharm',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.uharm}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '谐波电流',
|
||||
field: 'iharm',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.iharm}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压偏差',
|
||||
field: 'voltageDev',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.voltageDev}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '三相不平衡',
|
||||
field: 'ubalance',
|
||||
minWidth: '90',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.ubalance}</span>`
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
initEcharts()
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
OverLimitDetailsRef.value.open(
|
||||
row,
|
||||
tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
watch(
|
||||
() => prop.timeKey,
|
||||
val => {
|
||||
tableStore.index()
|
||||
initEcharts()
|
||||
}
|
||||
)
|
||||
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>
|
||||
143
src/components/cockpit/sensitiveLoad/index.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--敏感负荷列表 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" :height="`calc(${prop.height} - ${headerHeight}px + ${fullscreen ? -58 : 56}px )`" isGroup></Table>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number]},
|
||||
h: { type: [String, Number]},
|
||||
width: { type: [String, Number]},
|
||||
height: { type: [String, Number]},
|
||||
timeKey: { type: [String, Number]},
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const dictData = useDictData()
|
||||
const sensitiveUserType = dictData.getBasicData('Sensitive_User_Type')
|
||||
|
||||
|
||||
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 OverLimitDetailsRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-harmonic-boot/pqSensitiveUser/getList',
|
||||
method: 'POST',
|
||||
showPage: fullscreen.value ? true : false,
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '敏感负荷名称',
|
||||
field: 'name',
|
||||
minWidth: '90'
|
||||
},
|
||||
|
||||
{
|
||||
title: '敏感负荷类型',
|
||||
field: 'loadType',
|
||||
minWidth: '70',
|
||||
formatter: row => {
|
||||
return sensitiveUserType.filter(item => item.id == row.cellValue)[0]?.name
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '是否监测',
|
||||
field: 'isMonitor',
|
||||
minWidth: '80'
|
||||
},
|
||||
{
|
||||
title: '是否治理',
|
||||
field: 'isGovern',
|
||||
minWidth: '80'
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
|
||||
loadCallback: () => {
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
console.log(row)
|
||||
OverLimitDetailsRef.value.open(row)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
}, 500)
|
||||
})
|
||||
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
|
||||
}
|
||||
)
|
||||
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 暂态事件列表 -->
|
||||
<el-dialog draggable title="暂态事件列表" v-model="dialogVisible" append-to-body width="70%">
|
||||
<!-- <TableHeader datePicker showExport :showReset="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点名称">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.searchValue"
|
||||
placeholder="请选择监测点名称"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader> -->
|
||||
<Table ref="tableRef" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
const dialogVisible: any = ref(false)
|
||||
const harmonicRatioRef: any = ref(null)
|
||||
const options = [
|
||||
{
|
||||
value: '35kV进线',
|
||||
label: '35kV进线'
|
||||
}
|
||||
]
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '暂态时间',
|
||||
field: 'time',
|
||||
},
|
||||
{
|
||||
title: '测点名称',
|
||||
field: 'name',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '暂态类型',
|
||||
field: 'flicker',
|
||||
width: '100',
|
||||
},
|
||||
{
|
||||
title: '特征幅值(%)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '暂降深度(%)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '持续时间(S)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '严重度',
|
||||
field: 'flicker',
|
||||
width: '80'
|
||||
},
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data = [
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
tableStore.table.params.searchValue = ''
|
||||
provide('tableStore', tableStore)
|
||||
const open = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
tableStore.index()
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
harmonicRatioRef.value.openDialog(row)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
223
src/components/cockpit/transientDetails/index.vue
Normal file
@@ -0,0 +1,223 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--暂态事件明细 -->
|
||||
<TableHeader
|
||||
:showReset="false"
|
||||
ref="TableHeaderRef"
|
||||
@selectChange="selectChange"
|
||||
datePicker
|
||||
v-if="fullscreen"
|
||||
></TableHeader>
|
||||
<el-calendar
|
||||
v-model="value"
|
||||
:style="{
|
||||
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px )`,
|
||||
overflow: 'auto'
|
||||
}"
|
||||
>
|
||||
<template #date-cell="{ data }">
|
||||
<div style="height: 100%; padding: 8px" :style="{ background: setBackground(data.day) }">
|
||||
<p :class="data.isSelected ? 'is-selected' : ''">
|
||||
{{ data.day.split('-').slice(2).join('-') }}
|
||||
</p>
|
||||
<el-tooltip effect="dark" placement="top" :hide-after="0" v-if="hasEventData(data.day)">
|
||||
<template #content>
|
||||
<!-- <span v-html="list?.filter(item => item.time == data.day)[0]?.type || ''"></span> -->
|
||||
<div v-for="item in list?.filter((item:any) => item.name == data.day)">
|
||||
<div>电压暂降:{{ item.eventDown || 0 }}</div>
|
||||
<div>电压中断:{{ item.eventOff || 0 }}</div>
|
||||
<div>电压暂升:{{ item.eventUp || 0 }}</div>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
style="text-decoration: underline"
|
||||
:style="{ height: `calc(${prop.height} / 5 - 40px)`, overflow: 'auto' }"
|
||||
v-for="item in list?.filter((item:any) => item.name == data.day)"
|
||||
>
|
||||
<div @click="descentClick">电压暂降:{{ item.eventDown || 0 }}</div>
|
||||
<div>电压中断:{{ item.eventOff || 0 }}</div>
|
||||
<div>电压暂升:{{ item.eventUp || 0 }}</div>
|
||||
</div>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
</el-calendar>
|
||||
<!-- 暂态事件列表 -->
|
||||
<TransientList ref="transientListRef" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import { dayjs } from 'element-plus'
|
||||
import TransientList from './components/transientList.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
const TableHeaderRef = ref()
|
||||
|
||||
const hasEventData = (day: string) => {
|
||||
const item = list.value?.find((item: any) => item.name == day)
|
||||
if (!item) return false
|
||||
|
||||
return (item.eventDown || item.eventOff || item.eventUp) > 0
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
})
|
||||
|
||||
dayjs.en.weekStart = 1 //设置日历的周起始日为星期一
|
||||
const value = ref(new Date())
|
||||
|
||||
const transientListRef = ref()
|
||||
const list = ref()
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-harmonic-boot/csevent/getEventDate',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [],
|
||||
|
||||
beforeSearchFun: () => {
|
||||
if (prop.timeValue && Array.isArray(prop.timeValue)) {
|
||||
tableStore.table.params.searchBeginTime = prop.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = prop.timeValue[1]
|
||||
}
|
||||
},
|
||||
|
||||
loadCallback: () => {
|
||||
list.value = tableStore.table.data
|
||||
}
|
||||
})
|
||||
|
||||
const setBackground = (value: string) => {
|
||||
let data = []
|
||||
data = list.value?.filter((item: any) => item.name == value)
|
||||
|
||||
if (data && data?.length > 0) {
|
||||
if (data[0].eventDown > 0 || data[0].eventOff > 0 || data[0].eventUp > 0) {
|
||||
return '#Ff660090'
|
||||
}
|
||||
}
|
||||
|
||||
return '#fff'
|
||||
}
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
if (TableHeaderRef.value && typeof TableHeaderRef.value.setDatePicker === 'function') {
|
||||
TableHeaderRef.value.setDatePicker([{ label: '月份', value: 3 }])
|
||||
}
|
||||
if (fullscreen.value) {
|
||||
TableHeaderRef.value.setInterval(3)
|
||||
}
|
||||
tableStore.index()
|
||||
})
|
||||
})
|
||||
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()
|
||||
// }
|
||||
// },
|
||||
val => {
|
||||
tableStore.index()
|
||||
},
|
||||
|
||||
{
|
||||
deep: true
|
||||
}
|
||||
)
|
||||
|
||||
// 电压暂降点击事件
|
||||
const descentClick = () => {
|
||||
transientListRef.value.open()
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-calendar) {
|
||||
.el-calendar__header {
|
||||
display: none;
|
||||
}
|
||||
.el-calendar__body {
|
||||
padding: 0px !important;
|
||||
height: 100%;
|
||||
.el-calendar-table {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
.el-calendar-day {
|
||||
height: 100%;
|
||||
padding: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.el-calendar-table__row {
|
||||
.next {
|
||||
pointer-events: none;
|
||||
}
|
||||
.prev {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
.el-calendar-table .el-calendar-day:hover {
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
.el-calendar-table td.is-selected {
|
||||
background-color: #ffffff00;
|
||||
}
|
||||
}
|
||||
|
||||
// /*calendar_class 是el-calendar所在父标签的css*/
|
||||
// .calendar_class >>> .el-calendar-table:not(.is-range) td.next {
|
||||
// pointer-events: none;
|
||||
// }
|
||||
// .calendar_class >>> .el-calendar-table:not(.is-range) td.prev {
|
||||
// pointer-events: none;
|
||||
// }
|
||||
</style>
|
||||
438
src/components/cockpit/transientDistribution/index.vue
Normal file
@@ -0,0 +1,438 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--暂态事件概率分布 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<my-echart
|
||||
class="tall"
|
||||
:options="echartList"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
|
||||
}"
|
||||
/>
|
||||
<my-echart
|
||||
class="mt10"
|
||||
:options="echartList1"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} / 2 - ${headerHeight / 2}px + ${fullscreen ? 0 : 28}px )`
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
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 config = useConfig()
|
||||
|
||||
const echartList = ref({})
|
||||
|
||||
const echartList1 = ref({})
|
||||
|
||||
// const echartList1 = ref({
|
||||
// title: {
|
||||
// text: '越限时间概率分布'
|
||||
// },
|
||||
|
||||
// xAxis: {
|
||||
// // name: '时间',
|
||||
// // data: ['闪变', '谐波电压', '谐波电流', '电压偏差', '三相不平衡']
|
||||
// type: 'time',
|
||||
// axisLabel: {
|
||||
// formatter: {
|
||||
// day: '{MM}-{dd}',
|
||||
// month: '{MM}',
|
||||
// year: '{yyyy}'
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
// yAxis: {
|
||||
// name: '次' // 给X轴加单位
|
||||
// },
|
||||
// grid: {
|
||||
// left: '10px',
|
||||
// right: '20px'
|
||||
// },
|
||||
// options: {
|
||||
// series: [
|
||||
// {
|
||||
// type: 'line',
|
||||
// showSymbol: false,
|
||||
// // smooth: true,
|
||||
// name: '电压中断',
|
||||
// color: '#FF9100',
|
||||
// data: [
|
||||
// ['2025-10-16 07:00:00', 10],
|
||||
// ['2025-10-16 07:15:00', 10],
|
||||
// ['2025-10-16 07:30:00', 10],
|
||||
// ['2025-10-16 07:45:00', 10],
|
||||
// ['2025-10-16 08:00:00', 30],
|
||||
// ['2025-10-16 08:15:00', 50],
|
||||
// ['2025-10-16 08:30:00', 60],
|
||||
// ['2025-10-16 08:45:00', 70],
|
||||
// ['2025-10-16 09:00:00', 100],
|
||||
// ['2025-10-16 09:15:00', 120],
|
||||
// ['2025-10-16 09:30:00', 130],
|
||||
// ['2025-10-16 09:45:00', 140],
|
||||
// ['2025-10-16 10:00:00', 160],
|
||||
// ['2025-10-16 10:15:00', 160],
|
||||
// ['2025-10-16 10:30:00', 130],
|
||||
// ['2025-10-16 10:45:00', 120],
|
||||
// ['2025-10-16 11:00:00', 140],
|
||||
// ['2025-10-16 11:15:00', 80],
|
||||
// ['2025-10-16 11:30:00', 70],
|
||||
// ['2025-10-16 11:45:00', 90],
|
||||
// ['2025-10-16 12:00:00', 60],
|
||||
// ['2025-10-16 12:15:00', 60],
|
||||
// ['2025-10-16 12:30:00', 60],
|
||||
// ['2025-10-16 12:45:00', 60]
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// type: 'line',
|
||||
// showSymbol: false,
|
||||
// // smooth: true,
|
||||
// color: '#FFBF00',
|
||||
// name: '电压暂降',
|
||||
// data: [
|
||||
// ['2025-10-16 07:00:00', 1],
|
||||
// ['2025-10-16 07:15:00', 1],
|
||||
// ['2025-10-16 07:30:00', 1],
|
||||
// ['2025-10-16 07:45:00', 1],
|
||||
// ['2025-10-16 08:00:00', 3],
|
||||
// ['2025-10-16 08:15:00', 5],
|
||||
// ['2025-10-16 08:30:00', 6],
|
||||
// ['2025-10-16 08:45:00', 7],
|
||||
// ['2025-10-16 09:00:00', 10],
|
||||
// ['2025-10-16 09:15:00', 12],
|
||||
// ['2025-10-16 09:30:00', 13],
|
||||
// ['2025-10-16 09:45:00', 14],
|
||||
// ['2025-10-16 10:00:00', 16],
|
||||
// ['2025-10-16 10:15:00', 16],
|
||||
// ['2025-10-16 10:30:00', 13],
|
||||
// ['2025-10-16 10:45:00', 12],
|
||||
// ['2025-10-16 11:00:00', 14],
|
||||
// ['2025-10-16 11:15:00', 8],
|
||||
// ['2025-10-16 11:30:00', 7],
|
||||
// ['2025-10-16 11:45:00', 9],
|
||||
// ['2025-10-16 12:00:00', 6],
|
||||
// ['2025-10-16 12:15:00', 6],
|
||||
// ['2025-10-16 12:30:00', 6],
|
||||
// ['2025-10-16 12:45:00', 6]
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// type: 'line',
|
||||
// showSymbol: false,
|
||||
// // smooth: true,
|
||||
// name: '电压暂升',
|
||||
// color: config.layout.elementUiPrimary[0],
|
||||
// data: [
|
||||
// ['2025-10-16 07:00:00', 19],
|
||||
// ['2025-10-16 07:15:00', 19],
|
||||
// ['2025-10-16 07:30:00', 19],
|
||||
// ['2025-10-16 07:45:00', 19],
|
||||
// ['2025-10-16 08:00:00', 39],
|
||||
// ['2025-10-16 08:15:00', 59],
|
||||
// ['2025-10-16 08:30:00', 69],
|
||||
// ['2025-10-16 08:45:00', 79],
|
||||
// ['2025-10-16 09:00:00', 109],
|
||||
// ['2025-10-16 09:15:00', 129],
|
||||
// ['2025-10-16 09:30:00', 139],
|
||||
// ['2025-10-16 09:45:00', 149],
|
||||
// ['2025-10-16 10:00:00', 169],
|
||||
// ['2025-10-16 10:15:00', 169],
|
||||
// ['2025-10-16 10:30:00', 139],
|
||||
// ['2025-10-16 10:45:00', 129],
|
||||
// ['2025-10-16 11:00:00', 149],
|
||||
// ['2025-10-16 11:15:00', 89],
|
||||
// ['2025-10-16 11:30:00', 79],
|
||||
// ['2025-10-16 11:45:00', 99],
|
||||
// ['2025-10-16 12:00:00', 69],
|
||||
// ['2025-10-16 12:15:00', 69],
|
||||
// ['2025-10-16 12:30:00', 69],
|
||||
// ['2025-10-16 12:45:00', 69]
|
||||
// ]
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// })
|
||||
const processDataForChart = (rawData: any[]) => {
|
||||
// 将后端返回的扁平数据转换为 ECharts 需要的三维坐标格式 [x, y, z]
|
||||
const chartData = rawData.map(item => [item.x, item.y, item.z])
|
||||
|
||||
return chartData
|
||||
}
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-harmonic-boot/csevent/getEventCoords',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
const processedData = processDataForChart(tableStore.table.data.innerList || [])
|
||||
const trendList = tableStore.table.data.trendList || []
|
||||
const xlist = tableStore.table.data.xlist || []
|
||||
|
||||
// 处理趋势图数据
|
||||
const seriesData = [
|
||||
{
|
||||
name: '电压中断',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
color: '#FF9100',
|
||||
data: trendList[0]?.map((value: number, index: number) => [xlist[index], value]) || []
|
||||
},
|
||||
{
|
||||
name: '电压暂降',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
color: '#FFBF00',
|
||||
data: trendList[1]?.map((value: number, index: number) => [xlist[index], value]) || []
|
||||
},
|
||||
{
|
||||
name: '电压暂升',
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
color: config.layout.elementUiPrimary[0],
|
||||
data: trendList[2]?.map((value: number, index: number) => [xlist[index], value]) || []
|
||||
}
|
||||
]
|
||||
|
||||
// 获取x轴和y轴的标签值
|
||||
const xLabels = [
|
||||
'0-10%',
|
||||
'10%-20%',
|
||||
'20%-30%',
|
||||
'30%-40%',
|
||||
'40%-50%',
|
||||
'50%-60%',
|
||||
'60%-70%',
|
||||
'70%-80%',
|
||||
'80%-90%',
|
||||
'90%-100%'
|
||||
]
|
||||
const yLabels = ['0-0.01s', '0.01s-0.1s', '0.1s-1s', '1s-10s', '10s']
|
||||
|
||||
echartList.value = {
|
||||
options: {
|
||||
xAxis: null,
|
||||
yAxis: null,
|
||||
dataZoom: null,
|
||||
backgroundColor: '#fff',
|
||||
tooltip: {
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontStyle: 'normal',
|
||||
opacity: 0.35,
|
||||
fontSize: 14
|
||||
},
|
||||
backgroundColor: 'rgba(0,0,0,0.55)',
|
||||
borderWidth: 0,
|
||||
formatter: function (params: any) {
|
||||
console.log(params, '99000')
|
||||
var tips = ''
|
||||
|
||||
tips += '持续时间: ' + yLabels[params.value[1]] + '</br>'
|
||||
tips += '特征幅值: ' + xLabels[params.value[0]] + '</br>'
|
||||
tips += '事件次数: ' + params.value[2] + '</br>'
|
||||
return tips
|
||||
}
|
||||
},
|
||||
title: {
|
||||
text: '暂态事件概率分布',
|
||||
x: 'center'
|
||||
},
|
||||
visualMap: {
|
||||
max: 500,
|
||||
show: false,
|
||||
inRange: {
|
||||
color: ['#313695', '#00BB00', '#ff8000', '#a50026']
|
||||
}
|
||||
},
|
||||
xAxis3D: {
|
||||
type: 'category',
|
||||
name: '特征幅值',
|
||||
data: xLabels,
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
yAxis3D: {
|
||||
type: 'category',
|
||||
name: '持续时间',
|
||||
data: yLabels,
|
||||
nameTextStyle: {
|
||||
color: '#111'
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: '#111'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#111'
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: ['#111'],
|
||||
type: 'dashed',
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
},
|
||||
zAxis3D: {
|
||||
type: 'value',
|
||||
splitNumber: 10,
|
||||
minInterval: 10,
|
||||
name: '暂态事件次数'
|
||||
},
|
||||
grid3D: {
|
||||
viewControl: {
|
||||
projection: 'perspective',
|
||||
distance: 250
|
||||
},
|
||||
boxWidth: 200,
|
||||
boxDepth: 80,
|
||||
light: {
|
||||
main: {
|
||||
intensity: 1.2
|
||||
},
|
||||
ambient: {
|
||||
intensity: 0.3
|
||||
}
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar3D',
|
||||
data: processedData,
|
||||
shading: 'realistic',
|
||||
label: {
|
||||
show: false,
|
||||
textStyle: {
|
||||
fontSize: 16,
|
||||
borderWidth: 1
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
opacity: 1
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
textStyle: {
|
||||
fontSize: 20,
|
||||
color: '#900'
|
||||
}
|
||||
},
|
||||
itemStyle: {
|
||||
color: '#900'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
echartList1.value = {
|
||||
title: {
|
||||
text: '越限时间概率分布'
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: xlist,
|
||||
axisLabel: {
|
||||
formatter: '{value}'
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: '次'
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
series: seriesData
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
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>
|
||||
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 暂态事件详情 -->
|
||||
<el-dialog draggable title="暂态事件详情 " v-model="dialogVisible" append-to-body width="70%">
|
||||
<TableHeader datePicker showExport :showReset="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测点名称">
|
||||
<el-select
|
||||
v-model="tableStore.table.params.searchValue"
|
||||
placeholder="请选择监测点名称"
|
||||
style="width: 240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in options"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" @cell-click="cellClickEvent" isGroup :height="height"></Table>
|
||||
</el-dialog>
|
||||
<!-- 查看波形 -->
|
||||
<el-dialog v-model="isWaveCharts" draggable title="瞬时/RMS波形" append-to-body width="70%">
|
||||
<waveFormAnalysis
|
||||
v-loading="loading"
|
||||
v-if="isWaveCharts"
|
||||
ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false"
|
||||
:wp="wp"
|
||||
/>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, provide } from 'vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import waveFormAnalysis from '@/views/govern/device/control/tabs/components/waveFormAnalysis.vue'
|
||||
import { analyseWave } from '@/api/common'
|
||||
const dialogVisible: any = ref(false)
|
||||
const waveFormAnalysisRef: any = ref(null)
|
||||
// 波形
|
||||
const isWaveCharts = ref(false)
|
||||
const loading = ref(false)
|
||||
const wp = ref({})
|
||||
const boxoList: any = ref({})
|
||||
|
||||
const options = [
|
||||
{
|
||||
value: '35kV进线',
|
||||
label: '35kV进线'
|
||||
}
|
||||
]
|
||||
const height = mainHeight(0, 2).height as any
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/user-boot/role/selectRoleDetail?id=0',
|
||||
method: 'POST',
|
||||
publicHeight: 30,
|
||||
showPage: false,
|
||||
exportName: '主要监测点列表',
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '暂态时间',
|
||||
field: 'time'
|
||||
},
|
||||
{
|
||||
title: '测点名称',
|
||||
field: 'name',
|
||||
width: '150'
|
||||
},
|
||||
{
|
||||
title: '暂态类型',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '特征幅值(%)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '暂降深度(%)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '持续时间(S)',
|
||||
field: 'flicker',
|
||||
width: '100'
|
||||
},
|
||||
{
|
||||
title: '严重度',
|
||||
field: 'flicker',
|
||||
width: '80'
|
||||
},
|
||||
{
|
||||
title: '波形',
|
||||
width: '100',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'check',
|
||||
title: '查看波形',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
loading: 'loading1',
|
||||
// disabled: row => {
|
||||
// return !row.wavePath
|
||||
// },
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
boxoList.value.featureAmplitude =
|
||||
row.evtParamVVaDepth != '-' ? row.evtParamVVaDepth - 0 : null
|
||||
boxoList.value.systemType = 'WX'
|
||||
wp.value = res.data
|
||||
}
|
||||
loading.value = false
|
||||
})
|
||||
.catch(() => {
|
||||
row.loading1 = false
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
nextTick(() => {
|
||||
waveFormAnalysisRef.value &&
|
||||
waveFormAnalysisRef.value.getWpData(wp.value, boxoList.value, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data = [
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
},
|
||||
{
|
||||
time: '2024-01-01 00:00:00',
|
||||
name: '35kV进线',
|
||||
flicker: '0'
|
||||
}
|
||||
]
|
||||
}
|
||||
})
|
||||
|
||||
tableStore.table.params.searchValue = ''
|
||||
provide('tableStore', tableStore)
|
||||
const open = async (row: any) => {
|
||||
dialogVisible.value = true
|
||||
tableStore.index()
|
||||
}
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
isWaveCharts.value = true
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
248
src/components/cockpit/transientStatistics/index.vue
Normal file
@@ -0,0 +1,248 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--暂态事件统计 -->
|
||||
<TableHeader :showReset="false" @selectChange="selectChange" datePicker v-if="fullscreen"></TableHeader>
|
||||
<my-echart
|
||||
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>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import TransientStatisticsDetail from '@/components/cockpit/transientStatistics/components/transientStatisticsDetail.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { netEventEcharts } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
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 config = useConfig()
|
||||
|
||||
const data = ref()
|
||||
|
||||
const echartList = ref()
|
||||
|
||||
const eventEcharts = () => {
|
||||
netEventEcharts({
|
||||
searchBeginTime: tableStore.table.params.searchBeginTime || prop.timeValue?.[0],
|
||||
searchEndTime: tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
}).then(res => {
|
||||
// 整理接口数据为图表所需格式
|
||||
const rawData = res.data || {};
|
||||
data.value = [
|
||||
{
|
||||
name: '电压中断',
|
||||
value: rawData.eventOff || 0
|
||||
},
|
||||
{
|
||||
name: '电压暂降',
|
||||
value: rawData.eventDown || 0
|
||||
},
|
||||
{
|
||||
name: '电压暂升',
|
||||
value: rawData.eventUp || 0
|
||||
}
|
||||
];
|
||||
|
||||
echartList.value = {
|
||||
title: {},
|
||||
tooltip: {
|
||||
trigger: 'item'
|
||||
},
|
||||
legend: {
|
||||
orient: 'vertical',
|
||||
top: 'center',
|
||||
right: '5%',
|
||||
formatter: function (e: any) {
|
||||
return e + ' ' + data.value.filter((item: any) => item.name == e)[0].value + '次'
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
show: false
|
||||
},
|
||||
yAxis: {
|
||||
show: false
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
color: ['#FF9100', '#FFBF00', config.layout.elementUiPrimary[0]],
|
||||
options: {
|
||||
dataZoom: null,
|
||||
title: [
|
||||
{
|
||||
text: '暂态事件统计',
|
||||
left: 'center'
|
||||
},
|
||||
{
|
||||
text: (rawData.eventOff + rawData.eventDown + rawData.eventUp) + '次',
|
||||
left: 'center',
|
||||
top: 'center'
|
||||
}
|
||||
],
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
center: 'center',
|
||||
radius: ['50%', '70%'],
|
||||
label: {
|
||||
show: false,
|
||||
position: 'outside'
|
||||
},
|
||||
name: '事件统计',
|
||||
data: data.value
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const transientStatisticsDetailRef = ref()
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-harmonic-boot/csevent/netEventTable',
|
||||
method: 'POST',
|
||||
|
||||
showPage: false,
|
||||
|
||||
column: [
|
||||
{
|
||||
field: 'index',
|
||||
title: '序号',
|
||||
width: '80',
|
||||
formatter: (row: any) => {
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '名称',
|
||||
field: 'name',
|
||||
minWidth: '90'
|
||||
},
|
||||
|
||||
{
|
||||
title: '电压中断(次)',
|
||||
field: 'eventOff',
|
||||
minWidth: '70',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventOff}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压暂降(次)',
|
||||
field: 'eventDown',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventDown}</span>`
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电压暂升(次)',
|
||||
field: 'eventUp',
|
||||
minWidth: '80',
|
||||
render: 'customTemplate',
|
||||
customTemplate: (row: any) => {
|
||||
return `<span style='cursor: pointer;text-decoration: underline;'>${row.eventUp}</span>`
|
||||
}
|
||||
}
|
||||
],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
},
|
||||
loadCallback: () => {
|
||||
eventEcharts()
|
||||
}
|
||||
})
|
||||
|
||||
const tableRef = ref()
|
||||
provide('tableRef', tableRef)
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
// 点击行
|
||||
const cellClickEvent = ({ row, column }: any) => {
|
||||
if (column.field != 'name') {
|
||||
transientStatisticsDetailRef.value.open(row)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
}, 200)
|
||||
})
|
||||
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
|
||||
}
|
||||
)
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
459
src/components/cockpit/trendComparison/index.vue
Normal file
@@ -0,0 +1,459 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--趋势对比 -->
|
||||
<TableHeader datePicker :showReset="false" @selectChange="selectChange" v-if="fullscreen">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="监测对象">
|
||||
<el-select 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>
|
||||
<!-- <el-form-item label="监测点名称">
|
||||
<el-select v-model="tableStore.table.params.lineId" placeholder="请选择监测点名称" clearable>
|
||||
<el-option
|
||||
v-for="item in lineIdList"
|
||||
:key="item.lineId"
|
||||
:label="item.name"
|
||||
:value="item.lineId"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="电能质量指标">
|
||||
<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-select>
|
||||
</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>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<my-echart
|
||||
v-loading="tableStore.table.loading"
|
||||
class="tall"
|
||||
:options="echartList"
|
||||
:style="{
|
||||
width: prop.width,
|
||||
height: `calc(${prop.height} - ${headerHeight}px + ${fullscreen ? 0 : 56}px)`
|
||||
}"
|
||||
v-if="showEchart"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
|
||||
const prop = defineProps({
|
||||
w: { type: [String, Number] },
|
||||
h: { type: [String, Number] },
|
||||
width: { type: [String, Number] },
|
||||
height: { type: [String, Number] },
|
||||
timeKey: { type: [String, Number] },
|
||||
timeValue: { type: Object }
|
||||
})
|
||||
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
const config = useConfig()
|
||||
|
||||
const lineIdList = ref(JSON.parse(window.localStorage.getItem('lineIdList') || '[]'))
|
||||
|
||||
// 计算是否全屏展示
|
||||
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
|
||||
}
|
||||
})
|
||||
// 添加谐波次数选项(2-50)
|
||||
const harmonicCountOptions = ref(Array.from({ length: 49 }, (_, i) => i + 2))
|
||||
|
||||
const indicatorList = ref()
|
||||
|
||||
const echartList = ref()
|
||||
|
||||
const showEchart = ref(true)
|
||||
|
||||
const headerHeight = ref(57)
|
||||
|
||||
// 监测对象
|
||||
const idList = ref()
|
||||
|
||||
// 监测对象
|
||||
const initListByIds = () => {
|
||||
getListByIds({}).then((res: any) => {
|
||||
if (res.data.length > 0) {
|
||||
idList.value = res.data
|
||||
initCode()
|
||||
}
|
||||
})
|
||||
}
|
||||
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 initCode = () => {
|
||||
queryByCode('steady_state_limit_trend').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
indicatorList.value = item.data
|
||||
tableStore.table.params.indicator = indicatorList.value[0].id
|
||||
nextTick(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
// 治理前
|
||||
const chartsListBefore = ref()
|
||||
// 治理后
|
||||
const chartsListAfter = ref()
|
||||
|
||||
const setEchart = () => {
|
||||
// 从接口数据中提取治理前和治理后的数据
|
||||
const beforeData = chartsListBefore.value || []
|
||||
const afterData = chartsListAfter.value || []
|
||||
|
||||
// 按相位分组数据
|
||||
const beforeGroupedByPhase: any = {}
|
||||
const afterGroupedByPhase: any = {}
|
||||
|
||||
// 处理治理前数据
|
||||
beforeData.forEach((item: any) => {
|
||||
const phase = item.phase || 'default'
|
||||
if (!beforeGroupedByPhase[phase]) {
|
||||
beforeGroupedByPhase[phase] = []
|
||||
}
|
||||
beforeGroupedByPhase[phase].push([item.time, item.statisticalData])
|
||||
})
|
||||
|
||||
// 处理治理后数据
|
||||
afterData.forEach((item: any) => {
|
||||
const phase = item.phase || 'default'
|
||||
if (!afterGroupedByPhase[phase]) {
|
||||
afterGroupedByPhase[phase] = []
|
||||
}
|
||||
afterGroupedByPhase[phase].push([item.time, item.statisticalData])
|
||||
})
|
||||
|
||||
// 构建系列数据
|
||||
const series: any = []
|
||||
|
||||
// 定义相位颜色
|
||||
const phaseColors: any = {
|
||||
A: '#DAA520',
|
||||
B: '#2E8B57',
|
||||
C: '#A52a2a'
|
||||
}
|
||||
|
||||
// 添加治理前数据系列(实线)
|
||||
Object.keys(beforeGroupedByPhase).forEach(phase => {
|
||||
const phaseName = phase === 'default' ? '' : `${phase}相`
|
||||
const color = phaseColors[phase] || config.layout.elementUiPrimary[0]
|
||||
|
||||
series.push({
|
||||
name: `治理前${phaseName}`,
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: beforeGroupedByPhase[phase],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: function (params: any) {
|
||||
if (params.value[1] == 0 || params.value[1] == 3.14159) {
|
||||
return '#ccc'
|
||||
} else {
|
||||
return color
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
lineStyle: {
|
||||
type: 'solid', // 实线
|
||||
width: 2 // 线条宽度
|
||||
},
|
||||
yAxisIndex: 0
|
||||
})
|
||||
})
|
||||
|
||||
// 添加治理后数据系列(虚线)
|
||||
Object.keys(afterGroupedByPhase).forEach(phase => {
|
||||
const phaseName = phase === 'default' ? '' : `${phase}相`
|
||||
const color = phaseColors[phase] || config.layout.elementUiPrimary[0]
|
||||
|
||||
series.push({
|
||||
name: `治理后${phaseName}`,
|
||||
type: 'line',
|
||||
showSymbol: false,
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
data: afterGroupedByPhase[phase],
|
||||
itemStyle: {
|
||||
normal: {
|
||||
color: function (params: any) {
|
||||
if (params.value[1] == 0 || params.value[1] == 3.14159) {
|
||||
return '#ccc'
|
||||
} else {
|
||||
return color
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
lineStyle: {
|
||||
type: 'dashed', // 虚线
|
||||
width: 2 // 线条宽度
|
||||
},
|
||||
yAxisIndex: 0
|
||||
})
|
||||
})
|
||||
|
||||
// 获取指标名称用于图表标题
|
||||
let titleText = '治理前后对比'
|
||||
if (beforeData.length > 0 && beforeData[0].anotherName) {
|
||||
titleText = beforeData[0].anotherName
|
||||
} else if (afterData.length > 0 && afterData[0].anotherName) {
|
||||
titleText = afterData[0].anotherName
|
||||
}
|
||||
|
||||
// 构建图例数据
|
||||
const legendData = series.map((item: any, index: number) => {
|
||||
let color = config.layout.elementUiPrimary[0]
|
||||
const name = item.name
|
||||
if (name.includes('A相')) {
|
||||
color = '#DAA520'
|
||||
} else if (name.includes('B相')) {
|
||||
color = '#2E8B57'
|
||||
} else if (name.includes('C相')) {
|
||||
color = '#A52a2a'
|
||||
}
|
||||
|
||||
// 判断是治理前还是治理后,设置不同的线条样式
|
||||
const isBefore = name.includes('治理前')
|
||||
|
||||
return {
|
||||
name: item.name,
|
||||
icon: isBefore
|
||||
? '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', // 矩形组成的粗虚线
|
||||
itemStyle: {
|
||||
color: color // 明确指定图例图标的颜色
|
||||
},
|
||||
lineStyle: {
|
||||
type: isBefore ? 'solid' : 'dashed', // 治理前实线,治理后虚线
|
||||
width: 2
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
echartList.value = {
|
||||
title: {
|
||||
text: titleText
|
||||
},
|
||||
legend: {
|
||||
data: legendData,
|
||||
icon: 'rect',
|
||||
itemWidth: 18,
|
||||
itemHeight: 3,
|
||||
itemStyle: {
|
||||
borderWidth: 0
|
||||
},
|
||||
lineStyle: {
|
||||
width: 2 // 确保图例线条宽度与系列线条宽度一致
|
||||
}
|
||||
},
|
||||
xAxis: {
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: {
|
||||
day: '{MM}-{dd}',
|
||||
month: '{MM}',
|
||||
year: '{yyyy}'
|
||||
}
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
name: beforeData.length > 0 ? beforeData[0].unit : afterData.length > 0 ? afterData[0].unit : ''
|
||||
},
|
||||
grid: {
|
||||
left: '10px',
|
||||
right: '20px'
|
||||
},
|
||||
series: series
|
||||
}
|
||||
}
|
||||
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-device-boot/csGroup/sensitiveUserTrendData',
|
||||
method: 'POST',
|
||||
showPage: false,
|
||||
exportName: '趋势对比',
|
||||
column: [],
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
|
||||
if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) {
|
||||
tableStore.table.params.sensitiveUserId = idList.value[0].id
|
||||
}
|
||||
let lists: any = []
|
||||
// 处理电能质量指标
|
||||
const selectedIndicator = indicatorList.value?.find(
|
||||
(item: any) => item.id === tableStore.table.params.indicator
|
||||
)
|
||||
if (selectedIndicator) {
|
||||
let frequencys = ''
|
||||
if (selectedIndicator.name.includes('谐波含有率')) {
|
||||
frequencys = tableStore.table.params.harmonicCount
|
||||
}
|
||||
|
||||
lists.push({
|
||||
statisticalId: tableStore.table.params.indicator,
|
||||
frequency: frequencys !== null && frequencys !== undefined ? String(frequencys) : ''
|
||||
})
|
||||
}
|
||||
|
||||
// 将 lists 添加到请求参数中
|
||||
tableStore.table.params.list = lists
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.height = `calc(${prop.height} - 80px)`
|
||||
// 数据加载完成后的处理
|
||||
if (tableStore.table.data) {
|
||||
chartsListBefore.value = tableStore.table.data.before
|
||||
chartsListAfter.value = tableStore.table.data.after
|
||||
setEchart()
|
||||
} else if (tableStore.table.data) {
|
||||
showEchart.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
tableStore.table.params.indicator = '1'
|
||||
tableStore.table.params.exceedingTheLimit = '1'
|
||||
tableStore.table.params.dataLevel = 'Primary'
|
||||
tableStore.table.params.valueType = 'avg'
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
initListByIds()
|
||||
})
|
||||
|
||||
// 判断是否应该显示谐波次数选择框
|
||||
const shouldShowHarmonicCount = () => {
|
||||
if (!tableStore.table.params.indicator || !indicatorList.value) return false
|
||||
|
||||
const currentIndicator = indicatorList.value.find((item: any) => item.id === tableStore.table.params.indicator)
|
||||
|
||||
return (
|
||||
currentIndicator &&
|
||||
(currentIndicator.name.includes('电压谐波含有率') || currentIndicator.name.includes('电流谐波含有率'))
|
||||
)
|
||||
}
|
||||
|
||||
// 获取谐波类型名称
|
||||
const getHarmonicTypeName = () => {
|
||||
const currentIndicator = indicatorList.value.find((item: any) => item.id === tableStore.table.params.indicator)
|
||||
|
||||
if (currentIndicator) {
|
||||
if (currentIndicator.name.includes('电压谐波含有率')) {
|
||||
return '电压'
|
||||
} else if (currentIndicator.name.includes('电流谐波含有率')) {
|
||||
return '电流'
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
)
|
||||
|
||||
// 监听指标变化,当指标变化时重置谐波次数
|
||||
watch(
|
||||
() => tableStore.table.params.indicator,
|
||||
newVal => {
|
||||
if (shouldShowHarmonicCount()) {
|
||||
// 如果之前没有设置过谐波次数,则默认设置为2
|
||||
if (!tableStore.table.params.harmonicCount) {
|
||||
tableStore.table.params.harmonicCount = 2
|
||||
}
|
||||
} else {
|
||||
// 如果不是谐波含有率指标,则清除谐波次数设置
|
||||
tableStore.table.params.harmonicCount = ''
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const addMenu = () => {}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
// :deep(.el-select) {
|
||||
// min-width: 80px;
|
||||
// }
|
||||
</style>
|
||||
@@ -1,288 +1,293 @@
|
||||
<template>
|
||||
<div class="chart">
|
||||
<div ref="chartRef" class="my-chart" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted, ref, defineExpose, watch, nextTick } from 'vue'
|
||||
// import echarts from './echarts'
|
||||
import * as echarts from 'echarts' // 全引入
|
||||
import 'echarts-gl'
|
||||
import 'echarts-liquidfill'
|
||||
import 'echarts/lib/component/dataZoom'
|
||||
import { color, gradeColor3 } from './color'
|
||||
import { useConfig } from '@/stores/config'
|
||||
// import { nextTick } from 'process'
|
||||
|
||||
const config = useConfig()
|
||||
color[0] = config.layout.elementUiPrimary[0]
|
||||
const chartRef = ref<HTMLDivElement>()
|
||||
|
||||
const props = defineProps(['options', 'isInterVal', 'pieInterVal'])
|
||||
let chart: echarts.ECharts | any = null
|
||||
const resizeHandler = () => {
|
||||
// 不在视野中的时候不进行resize
|
||||
if (!chartRef.value) return
|
||||
if (chartRef.value.offsetHeight == 0) return
|
||||
chart.getZr().painter.getViewportRoot().style.display = 'none'
|
||||
requestAnimationFrame(() => {
|
||||
chart.resize()
|
||||
chart.getZr().painter.getViewportRoot().style.display = ''
|
||||
})
|
||||
}
|
||||
const initChart = () => {
|
||||
if (!props.isInterVal && !props.pieInterVal) {
|
||||
chart?.dispose()
|
||||
}
|
||||
// chart?.dispose()
|
||||
chart = echarts.init(chartRef.value as HTMLDivElement)
|
||||
const options = {
|
||||
title: {
|
||||
left: 'center',
|
||||
// textStyle: {
|
||||
color: '#000',
|
||||
textStyle: {
|
||||
color: '#000',
|
||||
fontSize: '18'
|
||||
},
|
||||
// },
|
||||
...(props.options?.title || null)
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontStyle: 'normal',
|
||||
opacity: 0.35,
|
||||
fontSize: 14
|
||||
},
|
||||
backgroundColor: 'rgba(0,0,0,0.55)',
|
||||
borderWidth: 0,
|
||||
// confine: true,
|
||||
...(props.options?.tooltip || null)
|
||||
},
|
||||
toolbox: {
|
||||
right: 10,
|
||||
top: 0,
|
||||
feature: {
|
||||
saveAsImage: {
|
||||
title: '保存图片'
|
||||
},
|
||||
...(props.options?.toolbox?.featureProps || null)
|
||||
},
|
||||
// },
|
||||
...(props.options?.toolbox || null)
|
||||
},
|
||||
legend: {
|
||||
right: 40,
|
||||
top: 10,
|
||||
itemGap: 10,
|
||||
itemStyle: {},
|
||||
// textStyle: {
|
||||
fontSize: 12,
|
||||
// padding: [2, 0, 0, 0], //[上、右、下、左]
|
||||
// },
|
||||
itemWidth: 15,
|
||||
itemHeight: 10,
|
||||
...(props.options?.legend || null)
|
||||
},
|
||||
grid: {
|
||||
top: '60px',
|
||||
left: '30px',
|
||||
right: '70px',
|
||||
bottom: props.options?.options?.dataZoom === null ? '10px' : '40px',
|
||||
containLabel: true,
|
||||
...(props.options?.grid || null)
|
||||
},
|
||||
xAxis: props.options?.xAxis ? handlerXAxis() : null,
|
||||
yAxis: props.options?.yAxis ? handlerYAxis() : null,
|
||||
dataZoom: props.options?.dataZoom || [
|
||||
{
|
||||
type: 'inside',
|
||||
height: 13,
|
||||
start: 0,
|
||||
|
||||
bottom: '20px',
|
||||
end: 100
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
height: 13,
|
||||
bottom: '20px',
|
||||
end: 100
|
||||
}
|
||||
// {
|
||||
// show: true,
|
||||
// yAxisIndex: 0,
|
||||
// width: 12,
|
||||
// handleSize: 8,
|
||||
// showDataShadow: false,
|
||||
// right: 12
|
||||
// }
|
||||
],
|
||||
color: props.options?.color || color,
|
||||
series: props.options?.series,
|
||||
...props.options?.options
|
||||
}
|
||||
// console.log(options.series,"获取x轴");
|
||||
handlerBar(options)
|
||||
// 处理柱状图
|
||||
chart.setOption(options, true)
|
||||
chart.group = 'group'
|
||||
setTimeout(() => {
|
||||
chart.resize()
|
||||
}, 0)
|
||||
}
|
||||
const handlerBar = (options: any) => {
|
||||
if (Array.isArray(options.series)) {
|
||||
options.series.forEach((item: any) => {
|
||||
if (item.type === 'bar') {
|
||||
item.barMinHeight = 10
|
||||
item.barMaxWidth = 20
|
||||
item.itemStyle = Object.assign(
|
||||
{
|
||||
color: (params: any) => {
|
||||
if (params.value == 0 || params.value == 3.14159) {
|
||||
return '#ccc'
|
||||
} else {
|
||||
return props.options?.color
|
||||
? props.options?.color[params.seriesIndex]
|
||||
: color[params.seriesIndex]
|
||||
}
|
||||
}
|
||||
},
|
||||
item.itemStyle
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const handlerYAxis = () => {
|
||||
let temp = {
|
||||
type: 'value',
|
||||
nameGap: 15,
|
||||
nameTextStyle: {
|
||||
color: '#000'
|
||||
},
|
||||
splitNumber: 5,
|
||||
minInterval: 1,
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14,
|
||||
formatter: function (value) {
|
||||
return parseFloat(value.toFixed(1)) // 格式化显示为一位小数
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
// 使用深浅的间隔色
|
||||
color: ['#ccc'],
|
||||
type: 'dashed',
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
// props.options?.xAxis 是数组还是对象
|
||||
if (Array.isArray(props.options?.yAxis)) {
|
||||
return props.options?.yAxis.map((item: any) => {
|
||||
return {
|
||||
...temp,
|
||||
...item
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return {
|
||||
...temp,
|
||||
...props.options?.yAxis
|
||||
}
|
||||
}
|
||||
}
|
||||
const handlerXAxis = () => {
|
||||
let temp = {
|
||||
type: 'category',
|
||||
axisTick: { show: false },
|
||||
axisLine: {
|
||||
// lineStyle: {
|
||||
color: '#000'
|
||||
// }
|
||||
},
|
||||
axisLabel: {
|
||||
// textStyle: {
|
||||
fontFamily: 'dinproRegular',
|
||||
color: '#000',
|
||||
fontSize: '12'
|
||||
// }
|
||||
}
|
||||
// boundaryGap: false,
|
||||
}
|
||||
// props.options?.xAxis 是数组还是对象
|
||||
if (Array.isArray(props.options?.xAxis)) {
|
||||
return props.options?.xAxis.map((item: any) => {
|
||||
return {
|
||||
...temp,
|
||||
...item
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return {
|
||||
...temp,
|
||||
...props.options?.xAxis
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let throttle: ReturnType<typeof setTimeout>
|
||||
// 动态计算table高度
|
||||
const resizeObserver = new ResizeObserver(entries => {
|
||||
for (const entry of entries) {
|
||||
if (throttle) {
|
||||
clearTimeout(throttle)
|
||||
}
|
||||
throttle = setTimeout(() => {
|
||||
resizeHandler()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
initChart()
|
||||
resizeObserver.observe(chartRef.value!)
|
||||
})
|
||||
defineExpose({ initChart })
|
||||
onBeforeUnmount(() => {
|
||||
resizeObserver.unobserve(chartRef.value!)
|
||||
chart?.dispose()
|
||||
})
|
||||
watch(
|
||||
() => props.options,
|
||||
(newVal, oldVal) => {
|
||||
initChart()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chart {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
|
||||
.el-button {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: -60px;
|
||||
}
|
||||
|
||||
.my-chart {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div class="chart">
|
||||
<div ref="chartRef" class="my-chart" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted, ref, defineExpose, watch, nextTick } from 'vue'
|
||||
// import echarts from './echarts'
|
||||
import * as echarts from 'echarts' // 全引入
|
||||
import 'echarts-gl'
|
||||
import 'echarts-liquidfill'
|
||||
import 'echarts/lib/component/dataZoom'
|
||||
import { color, gradeColor3 } from './color'
|
||||
import { useConfig } from '@/stores/config'
|
||||
// import { nextTick } from 'process'
|
||||
|
||||
const emit = defineEmits(['chartClick'])
|
||||
const config = useConfig()
|
||||
color[0] = config.layout.elementUiPrimary[0]
|
||||
const chartRef = ref<HTMLDivElement>()
|
||||
|
||||
const props = defineProps(['options', 'isInterVal', 'pieInterVal'])
|
||||
let chart: echarts.ECharts | any = null
|
||||
const resizeHandler = () => {
|
||||
// 不在视野中的时候不进行resize
|
||||
if (!chartRef.value) return
|
||||
if (chartRef.value.offsetHeight == 0) return
|
||||
chart.getZr().painter.getViewportRoot().style.display = 'none'
|
||||
requestAnimationFrame(() => {
|
||||
chart.resize()
|
||||
chart.getZr().painter.getViewportRoot().style.display = ''
|
||||
})
|
||||
}
|
||||
const initChart = () => {
|
||||
if (!props.isInterVal && !props.pieInterVal) {
|
||||
chart?.dispose()
|
||||
}
|
||||
// chart?.dispose()
|
||||
chart = echarts.init(chartRef.value as HTMLDivElement)
|
||||
const options = {
|
||||
title: {
|
||||
left: 'center',
|
||||
// textStyle: {
|
||||
color: '#000',
|
||||
textStyle: {
|
||||
color: '#000',
|
||||
fontSize: '18'
|
||||
},
|
||||
// },
|
||||
...(props.options?.title || null)
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
|
||||
textStyle: {
|
||||
color: '#fff',
|
||||
fontStyle: 'normal',
|
||||
opacity: 0.35,
|
||||
fontSize: 14
|
||||
},
|
||||
backgroundColor: 'rgba(0,0,0,0.55)',
|
||||
borderWidth: 0,
|
||||
// confine: true,
|
||||
...(props.options?.tooltip || null)
|
||||
},
|
||||
toolbox: {
|
||||
right: 20,
|
||||
top: 15,
|
||||
feature: {
|
||||
saveAsImage: {
|
||||
title: '保存图片'
|
||||
},
|
||||
...(props.options?.toolbox?.featureProps || null)
|
||||
},
|
||||
// },
|
||||
...(props.options?.toolbox || null)
|
||||
},
|
||||
legend: {
|
||||
right: 50,
|
||||
top: 25,
|
||||
itemGap: 10,
|
||||
itemStyle: {},
|
||||
// textStyle: {
|
||||
fontSize: 12,
|
||||
// padding: [2, 0, 0, 0], //[上、右、下、左]
|
||||
// },
|
||||
itemWidth: 15,
|
||||
itemHeight: 10,
|
||||
...(props.options?.legend || null)
|
||||
},
|
||||
grid: {
|
||||
top: '50px',
|
||||
left: '30px',
|
||||
right: '70px',
|
||||
bottom: props.options?.options?.dataZoom === null ? '10px' : '40px',
|
||||
containLabel: true,
|
||||
...(props.options?.grid || null)
|
||||
},
|
||||
xAxis: props.options?.xAxis ? handlerXAxis() : null,
|
||||
yAxis: props.options?.yAxis ? handlerYAxis() : null,
|
||||
dataZoom: props.options?.dataZoom || [
|
||||
{
|
||||
type: 'inside',
|
||||
height: 13,
|
||||
start: 0,
|
||||
|
||||
bottom: '20px',
|
||||
end: 100
|
||||
},
|
||||
{
|
||||
start: 0,
|
||||
height: 13,
|
||||
bottom: '20px',
|
||||
end: 100
|
||||
}
|
||||
// {
|
||||
// show: true,
|
||||
// yAxisIndex: 0,
|
||||
// width: 12,
|
||||
// handleSize: 8,
|
||||
// showDataShadow: false,
|
||||
// right: 12
|
||||
// }
|
||||
],
|
||||
color: props.options?.color || color,
|
||||
series: props.options?.series,
|
||||
...props.options?.options
|
||||
}
|
||||
// console.log(options.series,"获取x轴");
|
||||
handlerBar(options)
|
||||
// 处理柱状图
|
||||
chart.setOption(options, true)
|
||||
chart.group = 'group'
|
||||
// 添加点击事件
|
||||
chart.on('click', function (params: any) {
|
||||
emit('chartClick', params)
|
||||
})
|
||||
setTimeout(() => {
|
||||
chart.resize()
|
||||
}, 0)
|
||||
}
|
||||
const handlerBar = (options: any) => {
|
||||
if (Array.isArray(options.series)) {
|
||||
options.series.forEach((item: any) => {
|
||||
if (item.type === 'bar') {
|
||||
item.barMinHeight = 5
|
||||
item.barMaxWidth = 20
|
||||
item.itemStyle = Object.assign(
|
||||
{
|
||||
color: (params: any) => {
|
||||
if (params.value == 0 || params.value == 3.14159) {
|
||||
return '#ccc'
|
||||
} else {
|
||||
return props.options?.color
|
||||
? props.options?.color[params.seriesIndex]
|
||||
: color[params.seriesIndex]
|
||||
}
|
||||
}
|
||||
},
|
||||
item.itemStyle
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const handlerYAxis = () => {
|
||||
let temp = {
|
||||
type: 'value',
|
||||
nameGap: 15,
|
||||
nameTextStyle: {
|
||||
color: '#000'
|
||||
},
|
||||
splitNumber: 5,
|
||||
minInterval: 1,
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: '#000'
|
||||
}
|
||||
},
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14,
|
||||
formatter: function (value) {
|
||||
return parseFloat(value.toFixed(1)) // 格式化显示为一位小数
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
// 使用深浅的间隔色
|
||||
color: ['#ccc'],
|
||||
type: 'dashed',
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
}
|
||||
// props.options?.xAxis 是数组还是对象
|
||||
if (Array.isArray(props.options?.yAxis)) {
|
||||
return props.options?.yAxis.map((item: any) => {
|
||||
return {
|
||||
...temp,
|
||||
...item
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return {
|
||||
...temp,
|
||||
...props.options?.yAxis
|
||||
}
|
||||
}
|
||||
}
|
||||
const handlerXAxis = () => {
|
||||
let temp = {
|
||||
type: 'category',
|
||||
axisTick: { show: false },
|
||||
axisLine: {
|
||||
// lineStyle: {
|
||||
color: '#000'
|
||||
// }
|
||||
},
|
||||
axisLabel: {
|
||||
// textStyle: {
|
||||
fontFamily: 'dinproRegular',
|
||||
color: '#000',
|
||||
fontSize: '12'
|
||||
// }
|
||||
}
|
||||
// boundaryGap: false,
|
||||
}
|
||||
// props.options?.xAxis 是数组还是对象
|
||||
if (Array.isArray(props.options?.xAxis)) {
|
||||
return props.options?.xAxis.map((item: any) => {
|
||||
return {
|
||||
...temp,
|
||||
...item
|
||||
}
|
||||
})
|
||||
} else {
|
||||
return {
|
||||
...temp,
|
||||
...props.options?.xAxis
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let throttle: ReturnType<typeof setTimeout>
|
||||
// 动态计算table高度
|
||||
const resizeObserver = new ResizeObserver(entries => {
|
||||
for (const entry of entries) {
|
||||
if (throttle) {
|
||||
clearTimeout(throttle)
|
||||
}
|
||||
throttle = setTimeout(() => {
|
||||
resizeHandler()
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
onMounted(() => {
|
||||
initChart()
|
||||
resizeObserver.observe(chartRef.value!)
|
||||
})
|
||||
defineExpose({ initChart })
|
||||
onBeforeUnmount(() => {
|
||||
resizeObserver.unobserve(chartRef.value!)
|
||||
chart?.dispose()
|
||||
})
|
||||
watch(
|
||||
() => props.options,
|
||||
(newVal, oldVal) => {
|
||||
initChart()
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.chart {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
|
||||
.el-button {
|
||||
position: absolute;
|
||||
right: 0px;
|
||||
top: -60px;
|
||||
}
|
||||
|
||||
.my-chart {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export let color = [ '#07CCCA','#00BFF5', '#FFBF00', '#77DA63', '#D5FF6B', '#Ff6600', '#FF9100', '#5B6E96', '#66FFCC', '#B3B3B3']
|
||||
export const gradeColor3 = ['#339966', '#FFCC33', '#A52a2a']
|
||||
export const gradeColor5 = ['#00CC00', '#99CC99', '#FF9900','#996600','#A52a2a']
|
||||
|
||||
export let color = [ '#07CCCA','#00BFF5', '#FFBF00', '#77DA63', '#Ff6600', '#FF9100', '#5B6E96', '#66FFCC', '#B3B3B3']
|
||||
export const gradeColor3 = ['#339966', '#FFCC33', '#A52a2a']
|
||||
export const gradeColor5 = ['#00CC00', '#99CC99', '#FF9900','#996600','#A52a2a']
|
||||
|
||||
|
||||
311
src/components/echarts/rmsWorker.js
Normal file
@@ -0,0 +1,311 @@
|
||||
// 辅助函数
|
||||
const getMax = (temp, tempA, tempB, tempC) => {
|
||||
temp = temp > tempA ? temp : tempA;
|
||||
temp = temp > tempB ? temp : tempB;
|
||||
if (tempC !== undefined) {
|
||||
temp = temp > tempC ? temp : tempC;
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
const getMaxTwo = (temp, tempA, tempB) => {
|
||||
temp = temp > tempA ? temp : tempA;
|
||||
temp = temp > tempB ? temp : tempB;
|
||||
return temp;
|
||||
};
|
||||
|
||||
const getMin = (temp, tempA, tempB, tempC) => {
|
||||
temp = temp < tempA ? temp : tempA;
|
||||
temp = temp < tempB ? temp : tempB;
|
||||
if (tempC !== undefined) {
|
||||
temp = temp < tempC ? temp : tempC;
|
||||
}
|
||||
return temp;
|
||||
};
|
||||
|
||||
const getMinOpen = (temp, tempA, tempB) => {
|
||||
temp = temp < tempA ? temp : tempA;
|
||||
temp = temp < tempB ? temp : tempB;
|
||||
return temp;
|
||||
};
|
||||
|
||||
// 数据处理函数
|
||||
const fliteWaveData = (wp, step, iphasicValue, isOpen) => {
|
||||
const rmsData = wp.listRmsData;
|
||||
const pt = Number(wp.pt) / 1000;
|
||||
const ct = Number(wp.ct);
|
||||
const titleList = wp.waveTitle;
|
||||
let xishu = pt;
|
||||
let aTitle = "",
|
||||
bTitle = "",
|
||||
cTitle = "",
|
||||
unit = "电压";
|
||||
let rmsvFirstX = 0,
|
||||
rmsvFirstY = 0,
|
||||
rmsvSecondX = 0,
|
||||
rmsvSecondY = 0,
|
||||
firstZhou = "a",
|
||||
secondeZhou = "a";
|
||||
let ifmax = 0,
|
||||
ifmin = 0,
|
||||
ismax = 0,
|
||||
ismin = 0,
|
||||
rfmax = 0,
|
||||
rfmin = 0,
|
||||
rsmax = 0,
|
||||
rsmin = 0;
|
||||
|
||||
const shunshiFA = [];
|
||||
const shunshiFB = [];
|
||||
const shunshiFC = [];
|
||||
const shunshiSA = [];
|
||||
const shunshiSB = [];
|
||||
const shunshiSC = [];
|
||||
const rmsFA = [];
|
||||
const rmsFB = [];
|
||||
const rmsFC = [];
|
||||
const rmsSA = [];
|
||||
const rmsSB = [];
|
||||
const rmsSC = [];
|
||||
|
||||
|
||||
|
||||
if (titleList[iphasicValue * step + 1]?.substring(0, 1) !== "U") {
|
||||
xishu = ct;
|
||||
unit = "电流";
|
||||
}
|
||||
|
||||
for (let i = 1; i <= iphasicValue; i++) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
aTitle = titleList[iphasicValue * step + i]?.substring(1) || "";
|
||||
break;
|
||||
case 2:
|
||||
bTitle = titleList[iphasicValue * step + i]?.substring(1) || "";
|
||||
break;
|
||||
case 3:
|
||||
cTitle = titleList[iphasicValue * step + i]?.substring(1) || "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (rmsData[0] && rmsData[0][iphasicValue * step + 1] !== undefined) {
|
||||
rfmax = rmsData[0][iphasicValue * step + 1] * xishu;
|
||||
rfmin = rmsData[0][iphasicValue * step + 1] * xishu;
|
||||
rmsvFirstY = rmsData[0][iphasicValue * step + 1] * xishu;
|
||||
rmsvFirstX = rmsData[0][0];
|
||||
rsmax = rmsData[0][iphasicValue * step + 1];
|
||||
rsmin = rmsData[0][iphasicValue * step + 1];
|
||||
rmsvSecondY = rmsData[0][iphasicValue * step + 1];
|
||||
rmsvSecondX = rmsData[0][0];
|
||||
}
|
||||
|
||||
for (let rms = 0; rms < rmsData.length; rms++) {
|
||||
if (!rmsData[rms] || rmsData[rms][iphasicValue * step + 1] === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (iphasicValue) {
|
||||
case 1:
|
||||
const rmsFirstA = rmsData[rms][iphasicValue * step + 1] * xishu;
|
||||
rmsFA.push([rmsData[rms][0], rmsFirstA]);
|
||||
rfmax = rfmax > rmsFirstA ? rfmax : rmsFirstA;
|
||||
rfmin = rfmin < rmsFirstA ? rfmin : rmsFirstA;
|
||||
if (rfmin < rmsvFirstY) {
|
||||
rmsvFirstY = rfmin;
|
||||
firstZhou = "a";
|
||||
rmsvFirstX = rmsData[rms][0];
|
||||
}
|
||||
|
||||
const rmsSecondA = rmsData[rms][iphasicValue * step + 1];
|
||||
rmsSA.push([rmsData[rms][0], rmsSecondA]);
|
||||
rsmax = rsmax > rmsSecondA ? rsmax : rmsSecondA;
|
||||
rsmin = rsmin < rmsSecondA ? rsmin : rmsSecondA;
|
||||
if (rsmin < rmsvSecondY) {
|
||||
rmsvSecondY = rsmin;
|
||||
secondeZhou = "a";
|
||||
rmsvSecondX = rmsData[rms][0];
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
const rmsFirstA2 = rmsData[rms][iphasicValue * step + 1] * xishu;
|
||||
const rmsFirstB2 = rmsData[rms][iphasicValue * step + 2] * xishu;
|
||||
rmsFA.push([rmsData[rms][0], rmsFirstA2]);
|
||||
rmsFB.push([rmsData[rms][0], rmsFirstB2]);
|
||||
rfmax = getMaxTwo(rfmax, rmsFirstA2, rmsFirstB2);
|
||||
rfmin = getMinOpen(rfmin, rmsFirstA2, rmsFirstB2);
|
||||
if (rfmin < rmsvFirstY) {
|
||||
rmsvFirstY = rfmin;
|
||||
if (rfmin === rmsFirstA2) {
|
||||
firstZhou = "a";
|
||||
} else if (rfmin === rmsFirstB2) {
|
||||
firstZhou = "b";
|
||||
}
|
||||
rmsvFirstX = rmsData[rms][0];
|
||||
}
|
||||
|
||||
const rmsSecondA2 = rmsData[rms][iphasicValue * step + 1];
|
||||
const rmsSecondB2 = rmsData[rms][iphasicValue * step + 2];
|
||||
rmsSA.push([rmsData[rms][0], rmsSecondA2]);
|
||||
rmsSB.push([rmsData[rms][0], rmsSecondB2]);
|
||||
rsmax = getMaxTwo(rsmax, rmsSecondA2, rmsSecondB2);
|
||||
rsmin = getMinOpen(rsmin, rmsSecondA2, rmsSecondB2);
|
||||
if (rsmin < rmsvSecondY) {
|
||||
rmsvSecondY = rsmin;
|
||||
if (rsmin === rmsSecondA2) {
|
||||
secondeZhou = "a";
|
||||
} else if (rsmin === rmsSecondB2) {
|
||||
secondeZhou = "b";
|
||||
}
|
||||
rmsvSecondX = rmsData[rms][0];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
const rmsFirstA3 = rmsData[rms][iphasicValue * step + 1] * xishu;
|
||||
const rmsFirstB3 = rmsData[rms][iphasicValue * step + 2] * xishu;
|
||||
const rmsFirstC3 = rmsData[rms][iphasicValue * step + 3] * xishu;
|
||||
rmsFA.push([rmsData[rms][0], rmsFirstA3]);
|
||||
rmsFB.push([rmsData[rms][0], rmsFirstB3]);
|
||||
rmsFC.push([rmsData[rms][0], rmsFirstC3]);
|
||||
rfmax = getMax(rfmax, rmsFirstA3, rmsFirstB3, rmsFirstC3);
|
||||
rfmin = isOpen
|
||||
? getMinOpen(rfmin, rmsFirstA3, rmsFirstC3)
|
||||
: getMin(rfmin, rmsFirstA3, rmsFirstB3, rmsFirstC3);
|
||||
if (rfmin < rmsvFirstY) {
|
||||
rmsvFirstY = rfmin;
|
||||
if (rfmin === rmsFirstA3) {
|
||||
firstZhou = "a";
|
||||
} else if (rfmin === rmsFirstB3) {
|
||||
firstZhou = "b";
|
||||
} else {
|
||||
firstZhou = "c";
|
||||
}
|
||||
rmsvFirstX = rmsData[rms][0];
|
||||
}
|
||||
|
||||
const rmsSecondA3 = rmsData[rms][iphasicValue * step + 1];
|
||||
const rmsSecondB3 = rmsData[rms][iphasicValue * step + 2];
|
||||
const rmsSecondC3 = rmsData[rms][iphasicValue * step + 3];
|
||||
rmsSA.push([rmsData[rms][0], rmsSecondA3]);
|
||||
rmsSB.push([rmsData[rms][0], rmsSecondB3]);
|
||||
rmsSC.push([rmsData[rms][0], rmsSecondC3]);
|
||||
rsmax = getMax(rsmax, rmsSecondA3, rmsSecondB3, rmsSecondC3);
|
||||
rsmin = isOpen
|
||||
? getMinOpen(rsmin, rmsSecondA3, rmsSecondC3)
|
||||
: getMin(rsmin, rmsSecondA3, rmsSecondB3, rmsSecondC3);
|
||||
if (rsmin < rmsvSecondY) {
|
||||
rmsvSecondY = rsmin;
|
||||
if (rsmin === rmsSecondA3) {
|
||||
secondeZhou = "a";
|
||||
} else if (rsmin === rmsSecondB3) {
|
||||
secondeZhou = "b";
|
||||
} else {
|
||||
secondeZhou = "c";
|
||||
}
|
||||
rmsvSecondX = rmsData[rms][0];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const instantF = { max: ifmax, min: ifmin };
|
||||
const instantS = { max: ismax, min: ismin };
|
||||
const RMSF = { max: rfmax, min: rfmin };
|
||||
const RMSS = { max: rsmax, min: rsmin };
|
||||
const RMSFMinDetail = { rmsvFirstX, rmsvFirstY, firstZhou };
|
||||
const RMSSMinDetail = { rmsvSecondX, rmsvSecondY, secondeZhou };
|
||||
const shunshiF = { shunshiFA, shunshiFB, shunshiFC };
|
||||
const shunshiS = { shunshiSA, shunshiSB, shunshiSC };
|
||||
const RMSFWave = { rmsFA, rmsFB, rmsFC };
|
||||
const RMSSWave = { rmsSA, rmsSB, rmsSC };
|
||||
const title = { aTitle, bTitle, cTitle, unit };
|
||||
|
||||
|
||||
return {
|
||||
|
||||
instantF,
|
||||
instantS,
|
||||
RMSF,
|
||||
RMSS,
|
||||
RMSFMinDetail,
|
||||
RMSSMinDetail,
|
||||
shunshiF,
|
||||
shunshiS,
|
||||
RMSFWave,
|
||||
RMSSWave,
|
||||
title,
|
||||
unit,
|
||||
};
|
||||
};
|
||||
|
||||
// 监听消息
|
||||
self.onmessage = function (e) {
|
||||
const { wp, isOpen, value, boxoList } = JSON.parse(e.data);
|
||||
|
||||
try {
|
||||
const iphasicValue = wp.iphasic || 1;
|
||||
|
||||
const picCounts = (wp.waveTitle.length - 1) / iphasicValue;
|
||||
const waveDatas = [];
|
||||
|
||||
for (let i = 0; i < picCounts; i++) {
|
||||
const data = fliteWaveData(wp, i, iphasicValue, isOpen,boxoList);
|
||||
waveDatas.push(data);
|
||||
}
|
||||
// 处理标题
|
||||
let titles = "";
|
||||
if (boxoList.systemType == "pms") {
|
||||
titles =
|
||||
"变电站名称:" +
|
||||
boxoList.powerStationName +
|
||||
" 监测点名称:" +
|
||||
boxoList.measurementPointName +
|
||||
" 发生时刻:" +
|
||||
boxoList.startTime +
|
||||
" 残余电压:" +
|
||||
(boxoList.featureAmplitude * 100).toFixed(2) +
|
||||
"% 持续时间:" +
|
||||
boxoList.duration +
|
||||
"s";
|
||||
} else if (boxoList.systemType == "ZL") {
|
||||
titles =
|
||||
" 监测点名称:" +
|
||||
boxoList.equipmentName +
|
||||
" 发生时刻:" +
|
||||
boxoList.startTime +
|
||||
" 残余电压:" +
|
||||
boxoList.evtParamVVaDepth +
|
||||
" 持续时间:" +
|
||||
boxoList.evtParamTm +
|
||||
"s";
|
||||
} else {
|
||||
titles =
|
||||
"变电站名称:" +
|
||||
boxoList.subName +
|
||||
" 监测点名称:" +
|
||||
boxoList.lineName +
|
||||
" 发生时刻:" +
|
||||
boxoList.startTime +
|
||||
" 残余电压:" +
|
||||
(boxoList.featureAmplitude * 100).toFixed(2) +
|
||||
"% 持续时间:" +
|
||||
boxoList.duration +
|
||||
"s";
|
||||
}
|
||||
// 发送处理结果回主线程
|
||||
self.postMessage({
|
||||
titles: titles,
|
||||
success: true,
|
||||
waveDatas,
|
||||
time: wp.time,
|
||||
type: wp.waveType,
|
||||
severity: wp.yzd,
|
||||
iphasic: iphasicValue,
|
||||
});
|
||||
} catch (error) {
|
||||
self.postMessage({
|
||||
success: false,
|
||||
error: error.message,
|
||||
});
|
||||
}
|
||||
};
|
||||
1596
src/components/echarts/rmsboxi1.vue
Normal file
179
src/components/echarts/shuWorker.js
Normal file
@@ -0,0 +1,179 @@
|
||||
// waveData.worker.js
|
||||
self.addEventListener('message', function(e) {
|
||||
const { wp, value, iphasic, isOpen, boxoList } = JSON.parse(e.data);
|
||||
|
||||
// 处理波形数据的函数
|
||||
const fliteWaveData = (wp, step) => {
|
||||
// 将原有的fliteWaveData函数实现复制到这里
|
||||
const shunData = wp.listWaveData;
|
||||
const pt = Number(wp.pt) / 1000;
|
||||
const ct = Number(wp.ct);
|
||||
const titleList = wp.waveTitle;
|
||||
let xishu = pt;
|
||||
let aTitle = '', bTitle = '', cTitle = '', unit = '电压';
|
||||
let ifmax = 0, ifmin = 0, ismax = 0, ismin = 0;
|
||||
|
||||
const shunshiFA = [];
|
||||
const shunshiFB = [];
|
||||
const shunshiFC = [];
|
||||
const shunshiSA = [];
|
||||
const shunshiSB = [];
|
||||
const shunshiSC = [];
|
||||
|
||||
if (shunData.length > 0) {
|
||||
if (titleList[iphasic * step + 1]?.substring(0, 1) !== 'U') {
|
||||
xishu = ct;
|
||||
unit = '电流';
|
||||
}
|
||||
|
||||
for (let i = 1; i <= iphasic; i++) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
aTitle = titleList[iphasic * step + i]?.substring(1) || '';
|
||||
break;
|
||||
case 2:
|
||||
bTitle = titleList[iphasic * step + i]?.substring(1) || '';
|
||||
break;
|
||||
case 3:
|
||||
cTitle = titleList[iphasic * step + i]?.substring(1) || '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (shunData[0][iphasic * step + 1] !== undefined) {
|
||||
ifmax = shunData[0][iphasic * step + 1] * xishu;
|
||||
ifmin = shunData[0][iphasic * step + 1] * xishu;
|
||||
ismax = shunData[0][iphasic * step + 1];
|
||||
ismin = shunData[0][iphasic * step + 1];
|
||||
}
|
||||
|
||||
for (let shun = 0; shun < shunData.length; shun++) {
|
||||
if (shunData[shun][iphasic * step + 1] === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (iphasic) {
|
||||
case 1:
|
||||
const shunFirstA = shunData[shun][iphasic * step + 1] * xishu;
|
||||
shunshiFA.push([shunData[shun][0], shunFirstA]);
|
||||
ifmax = Math.max(ifmax, shunFirstA);
|
||||
ifmin = Math.min(ifmin, shunFirstA);
|
||||
|
||||
const shunSecondA = shunData[shun][iphasic * step + 1];
|
||||
shunshiSA.push([shunData[shun][0], shunSecondA]);
|
||||
ismax = Math.max(ismax, shunSecondA);
|
||||
ismin = Math.min(ismin, shunSecondA);
|
||||
break;
|
||||
case 2:
|
||||
const shunFirstA2 = shunData[shun][iphasic * step + 1] * xishu;
|
||||
const shunFirstB2 = shunData[shun][iphasic * step + 2] * xishu;
|
||||
shunshiFA.push([shunData[shun][0], shunFirstA2]);
|
||||
shunshiFB.push([shunData[shun][0], shunFirstB2]);
|
||||
ifmax = Math.max(ifmax, shunFirstA2, shunFirstB2);
|
||||
ifmin = Math.min(ifmin, shunFirstA2, shunFirstB2);
|
||||
|
||||
const shunSecondA2 = shunData[shun][iphasic * step + 1];
|
||||
const shunSecondB2 = shunData[shun][iphasic * step + 2];
|
||||
shunshiSA.push([shunData[shun][0], shunSecondA2]);
|
||||
shunshiSB.push([shunData[shun][0], shunSecondB2]);
|
||||
ismax = Math.max(ismax, shunSecondA2, shunSecondB2);
|
||||
ismin = Math.min(ismin, shunSecondA2, shunSecondB2);
|
||||
break;
|
||||
case 3:
|
||||
const shunFirstA3 = shunData[shun][iphasic * step + 1] * xishu;
|
||||
const shunFirstB3 = shunData[shun][iphasic * step + 2] * xishu;
|
||||
const shunFirstC3 = shunData[shun][iphasic * step + 3] * xishu;
|
||||
shunshiFA.push([shunData[shun][0], shunFirstA3]);
|
||||
shunshiFB.push([shunData[shun][0], shunFirstB3]);
|
||||
shunshiFC.push([shunData[shun][0], shunFirstC3]);
|
||||
ifmax = Math.max(ifmax, shunFirstA3, shunFirstB3, shunFirstC3);
|
||||
ifmin = isOpen ? Math.min(ifmin, shunFirstA3, shunFirstC3) : Math.min(ifmin, shunFirstA3, shunFirstB3, shunFirstC3);
|
||||
|
||||
const shunSecondA3 = shunData[shun][iphasic * step + 1];
|
||||
const shunSecondB3 = shunData[shun][iphasic * step + 2];
|
||||
const shunSecondC3 = shunData[shun][iphasic * step + 3];
|
||||
shunshiSA.push([shunData[shun][0], shunSecondA3]);
|
||||
shunshiSB.push([shunData[shun][0], shunSecondB3]);
|
||||
shunshiSC.push([shunData[shun][0], shunSecondC3]);
|
||||
ismax = Math.max(ismax, shunSecondA3, shunSecondB3, shunSecondC3);
|
||||
ismin = isOpen ? Math.min(ismin, shunSecondA3, shunSecondC3) : Math.min(ismin, shunSecondA3, shunSecondB3, shunSecondC3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const instantF = { max: ifmax, min: ifmin };
|
||||
const instantS = { max: ismax, min: ismin };
|
||||
const shunshiF = { shunshiFA, shunshiFB, shunshiFC };
|
||||
const shunshiS = { shunshiSA, shunshiSB, shunshiSC };
|
||||
const title = { aTitle, bTitle, cTitle, unit };
|
||||
|
||||
return { instantF, instantS, shunshiF, shunshiS, title, unit };
|
||||
};
|
||||
|
||||
// 处理标题
|
||||
let titles = '';
|
||||
if (boxoList.systemType == 'pms') {
|
||||
titles = '变电站名称:' +
|
||||
boxoList.powerStationName +
|
||||
' 监测点名称:' +
|
||||
boxoList.measurementPointName +
|
||||
' 发生时刻:' +
|
||||
boxoList.startTime +
|
||||
' 残余电压:' +
|
||||
(boxoList.featureAmplitude * 100).toFixed(2) +
|
||||
'% 持续时间:' +
|
||||
boxoList.duration +
|
||||
's';
|
||||
} else if (boxoList.systemType == 'ZL') {
|
||||
titles = ' 监测点名称:' +
|
||||
boxoList.equipmentName +
|
||||
' 发生时刻:' +
|
||||
boxoList.startTime +
|
||||
' 残余电压:' +
|
||||
boxoList.evtParamVVaDepth +
|
||||
' 持续时间:' +
|
||||
boxoList.evtParamTm +
|
||||
's';
|
||||
} else {
|
||||
titles = '变电站名称:' +
|
||||
boxoList.subName +
|
||||
' 监测点名称:' +
|
||||
boxoList.lineName +
|
||||
' 发生时刻:' +
|
||||
boxoList.startTime +
|
||||
' 残余电压:' +
|
||||
(boxoList.featureAmplitude * 100).toFixed(2) +
|
||||
'% 持续时间:' +
|
||||
boxoList.duration +
|
||||
's';
|
||||
}
|
||||
|
||||
const iphasicValue = wp.iphasic || 1;
|
||||
const picCounts = (wp.waveTitle.length - 1) / iphasicValue;
|
||||
const waveDatas = [];
|
||||
|
||||
for (let i = 0; i < picCounts; i++) {
|
||||
const data = fliteWaveData(wp, i);
|
||||
waveDatas.push(data);
|
||||
}
|
||||
|
||||
const time = wp.time;
|
||||
const type = wp.waveType;
|
||||
let severity = wp.yzd;
|
||||
|
||||
if (severity < 0) {
|
||||
severity = '/';
|
||||
type = '/';
|
||||
}
|
||||
|
||||
// 将处理结果发送回主线程
|
||||
self.postMessage({
|
||||
waveDatas,
|
||||
time,
|
||||
type,
|
||||
severity,
|
||||
titles,
|
||||
iphasic: iphasicValue
|
||||
});
|
||||
});
|
||||
1201
src/components/echarts/shushiboxi1.vue
Normal file
@@ -1,13 +1,25 @@
|
||||
<template>
|
||||
<div style="width: 540px">
|
||||
<el-select v-model.trim="interval" style="min-width: 90px; width: 90px; margin-right: 10px"
|
||||
@change="timeChange">
|
||||
<el-select
|
||||
v-model.trim="interval"
|
||||
style="min-width: 90px; width: 90px; margin-right: 10px"
|
||||
@change="timeChange"
|
||||
>
|
||||
<el-option v-for="item in timeOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
|
||||
<el-date-picker v-model.trim="timeValue" type="daterange" :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-date-picker
|
||||
v-model.trim="timeValue"
|
||||
type="daterange"
|
||||
: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 type="primary" :icon="VideoPause" @click="nowTime">当前</el-button>
|
||||
<el-button :disabled="preDisabled" type="primary" :icon="DArrowRight" @click="next"></el-button>
|
||||
@@ -21,13 +33,19 @@ import { ref, onMounted, nextTick, watch } from 'vue'
|
||||
interface Props {
|
||||
nextFlag?: boolean
|
||||
theCurrentTime?: boolean
|
||||
initialInterval?: number
|
||||
initialTimeValue?: any
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
nextFlag: false,
|
||||
theCurrentTime: true
|
||||
theCurrentTime: true,
|
||||
initialInterval: 3,
|
||||
initialTimeValue: undefined
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change'])
|
||||
|
||||
const interval = ref(3)
|
||||
const timeFlag = ref(1)
|
||||
const count = ref(0)
|
||||
@@ -72,16 +90,52 @@ const shortcuts = [
|
||||
}
|
||||
]
|
||||
onMounted(() => {
|
||||
// 使用传入的初始值
|
||||
if (props.initialInterval !== undefined) {
|
||||
interval.value = props.initialInterval
|
||||
}
|
||||
|
||||
if (props.initialTimeValue) {
|
||||
timeValue.value = props.initialTimeValue
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
// 初始化时检查按钮状态
|
||||
checkInitialButtonStatus()
|
||||
})
|
||||
|
||||
timeChange(3)
|
||||
})
|
||||
|
||||
// 添加初始化按钮状态检查方法
|
||||
const checkInitialButtonStatus = () => {
|
||||
if (timeValue.value && timeValue.value.length >= 2) {
|
||||
const endTime = timeValue.value[1]
|
||||
const currentDate = window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd')
|
||||
|
||||
// 如果结束时间小于当前日期,则不禁用"下一个"按钮
|
||||
if (new Date(endTime + ' 00:00:00').getTime() < new Date(currentDate + ' 00:00:00').getTime()) {
|
||||
preDisabled.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加统一的事件触发方法
|
||||
const emitChange = () => {
|
||||
nextTick(() => {
|
||||
emit('change', {
|
||||
interval: interval.value,
|
||||
timeValue: timeValue.value,
|
||||
timeFlag: timeFlag.value
|
||||
})
|
||||
})
|
||||
}
|
||||
// 选择时间范围
|
||||
const timeChange = (e: number) => {
|
||||
backDisabled.value = false
|
||||
preDisabled.value = true
|
||||
count.value = 0
|
||||
if (e == 1) {
|
||||
disabledPicker.value = true
|
||||
|
||||
timeValue.value = [setTime(1), setTime()]
|
||||
} else if (e == 2) {
|
||||
disabledPicker.value = true
|
||||
@@ -102,7 +156,6 @@ const timeChange = (e: number) => {
|
||||
} else if (e == 5) {
|
||||
disabledPicker.value = false
|
||||
backDisabled.value = true
|
||||
preDisabled.value = true
|
||||
timeValue.value = [setTime(), setTime()]
|
||||
}
|
||||
if (e == 1 || e == 2) {
|
||||
@@ -110,6 +163,29 @@ const timeChange = (e: number) => {
|
||||
} else {
|
||||
timeFlag.value = 1
|
||||
}
|
||||
|
||||
// 检查按钮状态
|
||||
checkButtonStatus()
|
||||
|
||||
// 触发 change 事件
|
||||
emitChange()
|
||||
}
|
||||
|
||||
// 添加按钮状态检查方法
|
||||
const checkButtonStatus = () => {
|
||||
if (timeValue.value && timeValue.value.length >= 2) {
|
||||
const endTime = timeValue.value[1]
|
||||
const currentDate = window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd')
|
||||
|
||||
// 如果结束时间大于等于当前日期,且 nextFlag 为 false,则禁用"下一个"按钮
|
||||
if (!props.nextFlag) {
|
||||
if (new Date(endTime + ' 00:00:00').getTime() >= new Date(currentDate + ' 00:00:00').getTime()) {
|
||||
preDisabled.value = true
|
||||
} else {
|
||||
preDisabled.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 当前
|
||||
@@ -178,6 +254,9 @@ const preClick = () => {
|
||||
// 判断向后键的状态
|
||||
// var temp = NowgetEndTime()
|
||||
// timeStatus(temp, endTime)
|
||||
|
||||
// 触发 change 事件
|
||||
emitChange()
|
||||
}
|
||||
//下一个
|
||||
const next = () => {
|
||||
@@ -383,7 +462,6 @@ const next = () => {
|
||||
if (year >= presentY && !props.nextFlag) {
|
||||
startTime = presentY + '-01-01'
|
||||
if (presentM < 10) {
|
||||
|
||||
if (presentD < 10) {
|
||||
endTime = presentY + '-0' + presentM + '-0' + presentD
|
||||
} else {
|
||||
@@ -400,18 +478,31 @@ const next = () => {
|
||||
startTime = year + '-01-01'
|
||||
endTime = year + '-12-31'
|
||||
}
|
||||
|
||||
}
|
||||
if (!props.nextFlag) {
|
||||
if (new Date(endTime + ' 00:00:00').getTime() >= new Date(window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd ') + ' 00:00:00').getTime()) {
|
||||
if (
|
||||
new Date(endTime + ' 00:00:00').getTime() >=
|
||||
new Date(window.XEUtils.toDateString(new Date(), 'yyyy-MM-dd ') + ' 00:00:00').getTime()
|
||||
) {
|
||||
preDisabled.value = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
timeValue.value = [startTime, endTime]
|
||||
|
||||
// 触发 change 事件
|
||||
emitChange()
|
||||
}
|
||||
|
||||
// 监听值变化并触发事件
|
||||
watch(
|
||||
[interval, timeValue],
|
||||
() => {
|
||||
emitChange()
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const setTime = (flag = 0, e = 0) => {
|
||||
let dd = window.XEUtils.toDateString(new Date().getTime() - e * 3600 * 1000 * 24, 'dd')
|
||||
|
||||
|
||||
@@ -1,25 +1,22 @@
|
||||
<template>
|
||||
<div class="mac-address-input" :class="{ disabled: disabled }">
|
||||
<template v-for="n in 6" :key="n">
|
||||
<el-input
|
||||
ref="inputRefs"
|
||||
v-model="segments[n - 1]"
|
||||
type="text"
|
||||
maxlength="2"
|
||||
:disabled="disabled"
|
||||
@input="handleInput(n - 1)"
|
||||
@keydown="handleKeydown(n - 1,$event)"
|
||||
@focus="handleFocus(n - 1)"
|
||||
@blur="handleBlur"
|
||||
@paste="handlePaste(n - 1, $event)"
|
||||
/>
|
||||
<span v-if="n < 6" class="separator">:</span>
|
||||
</template>
|
||||
<el-input
|
||||
ref="inputRef"
|
||||
v-model="macValue"
|
||||
type="text"
|
||||
maxlength="17"
|
||||
:disabled="disabled"
|
||||
@input="handleInput"
|
||||
@keydown="handleKeydown"
|
||||
@focus="handleFocus"
|
||||
@blur="handleBlur"
|
||||
@paste="handlePaste"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, nextTick } from 'vue'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
interface Props {
|
||||
modelValue?: string
|
||||
@@ -37,117 +34,85 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
// 创建6个输入框的引用
|
||||
const inputRefs = ref<InstanceType<typeof import('element-plus').ElInput>[]>([])
|
||||
// 创建单个输入框的引用
|
||||
const inputRef = ref<InstanceType<typeof import('element-plus').ElInput> | null>(null)
|
||||
|
||||
// MAC地址的6个段
|
||||
const segments = ref<string[]>(Array(6).fill(''))
|
||||
// MAC地址值
|
||||
const macValue = ref<string>('')
|
||||
|
||||
// 解析传入的MAC地址
|
||||
const parseMacAddress = (mac: string): string[] => {
|
||||
if (!mac) return Array(6).fill('')
|
||||
const parseMacAddress = (mac: string): string => {
|
||||
if (!mac) return ''
|
||||
|
||||
// 移除非十六进制字符并转为大写
|
||||
const cleanMac = mac.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 分割成6段,每段2个字符
|
||||
const result: string[] = []
|
||||
for (let i = 0; i < 6; i++) {
|
||||
result.push(cleanMac.substr(i * 2, 2))
|
||||
// 按每2个字符分割并用冒号连接
|
||||
let result = ''
|
||||
for (let i = 0; i < cleanMac.length; i += 2) {
|
||||
if (i > 0) result += ':'
|
||||
result += cleanMac.substr(i, 2)
|
||||
}
|
||||
return result
|
||||
return result.substring(0, 17) // 最多17个字符 (12个数字+5个冒号)
|
||||
}
|
||||
|
||||
// 格式化MAC地址段
|
||||
const formatSegment = (value: string): string => {
|
||||
// 只保留前两个十六进制字符并转为大写
|
||||
return value.replace(/[^0-9a-fA-F]/g, '').toUpperCase().substr(0, 2)
|
||||
// 格式化MAC地址 - 改进版
|
||||
const formatMac = (value: string): string => {
|
||||
// 移除所有冒号
|
||||
const cleanValue = value.replace(/:/g, '')
|
||||
// 只保留十六进制字符并转为大写
|
||||
const hexOnly = cleanValue.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
|
||||
// 按每两个字符添加冒号,最多6段
|
||||
let formatted = ''
|
||||
for (let i = 0; i < Math.min(hexOnly.length, 12); i += 2) {
|
||||
if (i > 0) formatted += ':'
|
||||
formatted += hexOnly.substr(i, 2)
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
// 当前聚焦的输入框索引
|
||||
const focusedIndex = ref<number | null>(null)
|
||||
|
||||
// 处理输入事件
|
||||
const handleInput = (index: number) => {
|
||||
// 格式化输入值
|
||||
const formatted = formatSegment(segments.value[index])
|
||||
segments.value[index] = formatted
|
||||
|
||||
// 如果当前段已满2个字符且不是最后一段,自动跳转到下一个输入框
|
||||
if (formatted.length === 2 && index < 5) {
|
||||
// 获取下一个输入框的DOM元素
|
||||
setTimeout(() => {
|
||||
const nextInput = inputRefs.value[index + 1]
|
||||
if (nextInput) {
|
||||
const inputEl = nextInput.$el.querySelector('input')
|
||||
if (inputEl) {
|
||||
inputEl.focus()
|
||||
inputEl.select()
|
||||
}
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// 更新v-model值
|
||||
updateModelValue()
|
||||
const handleInput = (value: string) => {
|
||||
const formatted = formatMac(value)
|
||||
macValue.value = formatted
|
||||
// 发出不带冒号的纯净值
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
}
|
||||
|
||||
// 处理键盘事件
|
||||
const handleKeydown = (index: number, event: KeyboardEvent) => {
|
||||
const handleKeydown = (event: KeyboardEvent) => {
|
||||
const target = event.target as HTMLInputElement
|
||||
|
||||
// 处理退格键
|
||||
if (event.key === 'Backspace' && target.selectionStart === 0 && target.selectionEnd === 0) {
|
||||
if (segments.value[index] === '' && index > 0) {
|
||||
// 如果当前段为空,跳转到前一个输入框
|
||||
if (event.key === 'Backspace') {
|
||||
// 处理在冒号前删除的情况
|
||||
const cursorPos = target.selectionStart || 0
|
||||
if (cursorPos > 0 && macValue.value[cursorPos - 1] === ':' &&
|
||||
target.selectionStart === target.selectionEnd) {
|
||||
event.preventDefault()
|
||||
const prevInput = inputRefs.value[index - 1]
|
||||
if (prevInput) {
|
||||
const inputEl = prevInput.$el.querySelector('input')
|
||||
if (inputEl) {
|
||||
inputEl.focus()
|
||||
// 将光标移到末尾
|
||||
setTimeout(() => {
|
||||
inputEl.selectionStart = inputEl.value.length
|
||||
inputEl.selectionEnd = inputEl.value.length
|
||||
}, 0)
|
||||
// 删除冒号前的两个字符
|
||||
const newValue = macValue.value.substring(0, cursorPos - 3) +
|
||||
macValue.value.substring(cursorPos)
|
||||
macValue.value = newValue
|
||||
// 设置光标位置
|
||||
setTimeout(() => {
|
||||
if (target.setSelectionRange) {
|
||||
target.setSelectionRange(cursorPos - 3, cursorPos - 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理左箭头键
|
||||
if (event.key === 'ArrowLeft' && target.selectionStart === 0) {
|
||||
if (index > 0) {
|
||||
event.preventDefault()
|
||||
const prevInput = inputRefs.value[index - 1]
|
||||
if (prevInput) {
|
||||
const inputEl = prevInput.$el.querySelector('input')
|
||||
if (inputEl) {
|
||||
inputEl.focus()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理右箭头键和制表符
|
||||
if ((event.key === 'ArrowRight' && target.selectionStart === target.value.length) || event.key === 'Tab') {
|
||||
if (index < 5) {
|
||||
event.preventDefault()
|
||||
const nextInput = inputRefs.value[index + 1]
|
||||
if (nextInput) {
|
||||
const inputEl = nextInput.$el.querySelector('input')
|
||||
if (inputEl) {
|
||||
inputEl.focus()
|
||||
}
|
||||
}
|
||||
}, 0)
|
||||
emit('update:modelValue', newValue.replace(/:/g, ''))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理焦点事件
|
||||
const handleFocus = (index: number) => {
|
||||
focusedIndex.value = index
|
||||
const handleFocus = () => {
|
||||
focusedIndex.value = 0
|
||||
}
|
||||
|
||||
// 处理失焦事件
|
||||
@@ -156,56 +121,26 @@ const handleBlur = () => {
|
||||
}
|
||||
|
||||
// 处理粘贴事件
|
||||
const handlePaste = (index: number, event: ClipboardEvent) => {
|
||||
const handlePaste = (event: ClipboardEvent) => {
|
||||
event.preventDefault()
|
||||
const pastedText = event.clipboardData?.getData('text') || ''
|
||||
|
||||
// 清理粘贴的文本
|
||||
const cleanText = parseMacAddress(pastedText)
|
||||
|
||||
// 填充各段
|
||||
for (let i = 0; i < 6; i++) {
|
||||
segments.value[i] = cleanText[i] || ''
|
||||
}
|
||||
|
||||
// 更新v-model值
|
||||
updateModelValue()
|
||||
|
||||
// 聚焦到最后一个非空段或最后一个段
|
||||
setTimeout(() => {
|
||||
let focusIndex = 5
|
||||
for (let i = 5; i >= 0; i--) {
|
||||
if (segments.value[i] !== '') {
|
||||
focusIndex = i
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
const inputToFocus = inputRefs.value[focusIndex]
|
||||
if (inputToFocus) {
|
||||
const inputEl = inputToFocus.$el.querySelector('input')
|
||||
if (inputEl) {
|
||||
inputEl.focus()
|
||||
inputEl.select()
|
||||
}
|
||||
}
|
||||
}, 0)
|
||||
}
|
||||
|
||||
// 更新v-model值
|
||||
const updateModelValue = () => {
|
||||
// 过滤掉空段,然后用冒号连接
|
||||
const nonEmptySegments = segments.value.filter(s => s !== '')
|
||||
const mac = nonEmptySegments.join(':')
|
||||
emit('update:modelValue', mac)
|
||||
const cleanPastedText = pastedText.replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const formatted = formatMac(cleanPastedText)
|
||||
macValue.value = formatted
|
||||
emit('update:modelValue', formatted.replace(/:/g, ''))
|
||||
}
|
||||
|
||||
// 监听modelValue变化
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
if (newVal !== segments.value.filter(s => s !== '').join(':')) {
|
||||
segments.value = parseMacAddress(newVal || '')
|
||||
const cleanNewVal = (newVal || '').replace(/[^0-9a-fA-F]/g, '').toUpperCase()
|
||||
const currentCleanValue = macValue.value.replace(/:/g, '')
|
||||
|
||||
if (cleanNewVal !== currentCleanValue) {
|
||||
macValue.value = parseMacAddress(cleanNewVal)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
@@ -214,37 +149,17 @@ watch(
|
||||
|
||||
<style scoped lang="scss">
|
||||
.mac-address-input {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
width: 100%;
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
input {
|
||||
width: 40px;
|
||||
height: 32px;
|
||||
text-align: center;
|
||||
border: 1px solid #dcdfe6;
|
||||
border-radius: 4px;
|
||||
outline: none;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
|
||||
&:focus {
|
||||
border-color: #409eff;
|
||||
:deep(.el-input__wrapper) {
|
||||
input {
|
||||
text-transform: uppercase;
|
||||
font-family: inherit; // 使用继承的字体而不是等宽字体
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
background-color: #f5f7fa;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.separator {
|
||||
user-select: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,3 +1,9 @@
|
||||
<template>
|
||||
<div>
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { createVNode, resolveComponent, defineComponent, computed, type CSSProperties } from 'vue'
|
||||
import svg from '@/components/icon/svg/index.vue'
|
||||
@@ -27,7 +33,7 @@ export default defineComponent({
|
||||
color: color
|
||||
}
|
||||
})
|
||||
if(props.name){
|
||||
if (props.name) {
|
||||
if (props.name.indexOf('el-icon-') === 0) {
|
||||
return () =>
|
||||
createVNode('el-icon', { class: 'icon el-icon', style: iconStyle.value }, [
|
||||
|
||||
@@ -1,295 +1,303 @@
|
||||
<template>
|
||||
<!-- Icon -->
|
||||
<Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" />
|
||||
|
||||
<!-- switch -->
|
||||
<div v-if="field.render == 'switch' && fieldValue != undefined">
|
||||
<el-switch
|
||||
@change="onChangeField(field, $event)"
|
||||
:model-value="fieldValue.toString()"
|
||||
:loading="row.loading"
|
||||
inline-prompt
|
||||
:active-value="field.activeValue"
|
||||
:active-text="field.activeText"
|
||||
:inactive-value="field.inactiveValue"
|
||||
:inactive-text="field.inactiveText"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- image -->
|
||||
<div v-if="field.render == 'image' && fieldValue" class="ba-render-image">
|
||||
<el-image
|
||||
:hide-on-click-modal="true"
|
||||
:preview-teleported="true"
|
||||
:preview-src-list="[fullUrl(fieldValue)]"
|
||||
:src="fieldValue.length > 100 ? fieldValue : fullUrl(fieldValue)"
|
||||
></el-image>
|
||||
</div>
|
||||
|
||||
<!-- tag -->
|
||||
<div v-if="field.render == 'tag' && fieldValue !== ''">
|
||||
<el-tag :type="getTagType(fieldValue, field.custom)" size="small">
|
||||
{{ field.replaceValue ? field.replaceValue[fieldValue] : fieldValue }}
|
||||
</el-tag>
|
||||
</div>
|
||||
|
||||
<!-- datetime -->
|
||||
<div v-if="field.render == 'datetime'">
|
||||
{{ !fieldValue ? '/' : timeFormat(fieldValue, field.timeFormat ?? undefined) }}
|
||||
</div>
|
||||
|
||||
<!-- color -->
|
||||
<div v-if="field.render == 'color'">
|
||||
<div :style="{ background: fieldValue }" class="ba-render-color"></div>
|
||||
</div>
|
||||
|
||||
<!-- customTemplate 自定义模板 -->
|
||||
<div
|
||||
v-if="field.render == 'customTemplate'"
|
||||
v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"
|
||||
></div>
|
||||
|
||||
<!-- 自定义组件/函数渲染 -->
|
||||
<component
|
||||
v-if="field.render == 'customRender'"
|
||||
:is="field.customRender"
|
||||
:renderRow="row"
|
||||
:renderField="field"
|
||||
:renderValue="fieldValue"
|
||||
:renderColumn="column"
|
||||
:renderIndex="index"
|
||||
/>
|
||||
|
||||
<!-- 按钮组 -->
|
||||
<div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons">
|
||||
<template v-for="(btn, idx) in buttons" :key="idx">
|
||||
<!-- 常规按钮 -->
|
||||
|
||||
<el-button
|
||||
link
|
||||
v-if="btn.render == 'basicButton'"
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:loading="props.row[btn.loading] || props.row.loading || false"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div>
|
||||
</el-button>
|
||||
|
||||
<!-- 带提示信息的按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'tipButton'"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
link
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">
|
||||
{{ btn.text || btn.title }}
|
||||
</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 带确认框的按钮 -->
|
||||
<el-popconfirm
|
||||
v-if="btn.render == 'confirmButton'"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.popconfirm"
|
||||
@confirm="onButtonClick(btn)"
|
||||
>
|
||||
<template #reference>
|
||||
<div style="display: inline-block">
|
||||
<el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr">
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">
|
||||
{{ btn.text || btn.title }}
|
||||
</div>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<el-dropdown v-if="btn.render == 'dropdown'" trigger="click" @command="handlerCommand">
|
||||
<el-button link type="primary" class="table-operate">
|
||||
<div class="table-operate-text">更多</div>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="item in btn.buttons"
|
||||
:key="item.text"
|
||||
:command="item"
|
||||
:style="{
|
||||
color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger'
|
||||
}"
|
||||
>
|
||||
{{ item.text }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, inject } from 'vue'
|
||||
import { ElMessageBox, type TagProps } from 'element-plus'
|
||||
import type TableStoreClass from '@/utils/tableStore'
|
||||
import { fullUrl, timeFormat } from '@/utils/common'
|
||||
import type { VxeColumnProps } from 'vxe-table'
|
||||
|
||||
const TableStore = inject('tableStore') as TableStoreClass
|
||||
|
||||
interface Props {
|
||||
row: TableRow
|
||||
field: TableColumn
|
||||
column: VxeColumnProps
|
||||
index: number
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// 字段值(单元格值)
|
||||
const fieldName = ref(props.field.field)
|
||||
const fieldValue = ref(fieldName.value ? props.row[fieldName.value] : '')
|
||||
if (fieldName.value && fieldName.value.indexOf('.') > -1) {
|
||||
let fieldNameArr = fieldName.value.split('.')
|
||||
let val: any = ref(props.row[fieldNameArr[0]])
|
||||
for (let index = 1; index < fieldNameArr.length; index++) {
|
||||
val.value = val.value ? val.value[fieldNameArr[index]] ?? '' : ''
|
||||
}
|
||||
fieldValue.value = val.value
|
||||
}
|
||||
|
||||
if (props.field.renderFormatter && typeof props.field.renderFormatter == 'function') {
|
||||
fieldValue.value = props.field.renderFormatter(props.row, props.field, fieldValue.value, props.column, props.index)
|
||||
}
|
||||
|
||||
const onChangeField = (row: any, value: any) => {
|
||||
row.onChangeField && row.onChangeField(props.row, value)
|
||||
|
||||
// TableStore.onTableAction('field-change', { value: value, ...props })
|
||||
}
|
||||
|
||||
const onButtonClick = (btn: OptButton) => {
|
||||
btn.click && btn.click(props.row, props.field)
|
||||
}
|
||||
|
||||
const getTagType = (value: string, custom: any): TagProps['type'] => {
|
||||
return custom && custom[value] ? custom[value] : ''
|
||||
}
|
||||
|
||||
// 按钮组处理 最多显示三个按钮 多余的显示为下拉
|
||||
const buttonsFilter = props.field.buttons?.filter(btn => !(btn.disabled && btn.disabled(props.row, props.field))) || []
|
||||
const buttons = ref<any[]>([])
|
||||
if (buttonsFilter.length > 3) {
|
||||
buttonsFilter?.forEach((btn, index) => {
|
||||
btn.text = btn.text || btn.title
|
||||
if (index < 2) {
|
||||
buttons.value.push(btn)
|
||||
} else {
|
||||
if (buttons.value.length > 2) {
|
||||
buttons.value[buttons.value.length - 1].buttons.push(btn)
|
||||
} else {
|
||||
buttons.value.push({
|
||||
render: 'dropdown',
|
||||
buttons: [btn]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
buttons.value = buttonsFilter
|
||||
}
|
||||
const handlerCommand = (item: OptButton) => {
|
||||
switch (item.render) {
|
||||
case 'basicButton':
|
||||
onButtonClick(item)
|
||||
break
|
||||
case 'confirmButton':
|
||||
ElMessageBox.confirm(item.popconfirm?.title || '提示', {
|
||||
confirmButtonText: item.popconfirm?.confirmButtonText || '确认',
|
||||
cancelButtonText: item.popconfirm?.cancelButtonText || '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
onButtonClick(item)
|
||||
})
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.m-10 {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
.ba-render-image {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.images-item {
|
||||
width: 50px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.el-image {
|
||||
height: 36px;
|
||||
// width: 36px;
|
||||
}
|
||||
|
||||
.table-operate-text {
|
||||
padding-left: 5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.table-operate {
|
||||
padding: 4px 5px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.cn-render-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
font-size: 12px !important;
|
||||
// color: var(--ba-bg-color-overlay) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.move-button {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ml-6 {
|
||||
display: inline-flex;
|
||||
vertical-align: middle;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.ml-6 + .el-button {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.ba-render-color {
|
||||
height: 25px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cn-render-buttons {
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<!-- Icon -->
|
||||
<Icon class="ba-icon-dark" v-if="field.render == 'icon'" :name="fieldValue ? fieldValue : field.default ?? ''" />
|
||||
|
||||
<!-- switch -->
|
||||
<div v-if="field.render == 'switch' && fieldValue != undefined">
|
||||
<el-switch
|
||||
@change="onChangeField(field, $event)"
|
||||
:model-value="fieldValue.toString()"
|
||||
:loading="row.loading"
|
||||
inline-prompt
|
||||
:active-value="field.activeValue"
|
||||
:active-text="field.activeText"
|
||||
:inactive-value="field.inactiveValue"
|
||||
:inactive-text="field.inactiveText"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- image -->
|
||||
<div v-if="field.render == 'image' && fieldValue" class="ba-render-image">
|
||||
<el-image
|
||||
:hide-on-click-modal="true"
|
||||
:preview-teleported="true"
|
||||
:preview-src-list="[fieldValue]"
|
||||
:src="fieldValue.length > 100 ? fieldValue : getUrl(fieldValue)"
|
||||
></el-image>
|
||||
</div>
|
||||
|
||||
<!-- tag -->
|
||||
<div v-if="field.render == 'tag' && fieldValue !== ''">
|
||||
<el-tag :type="getTagType(fieldValue, field.custom)" size="small">
|
||||
{{ field.replaceValue ? field.replaceValue[fieldValue] : fieldValue }}
|
||||
</el-tag>
|
||||
</div>
|
||||
|
||||
<!-- datetime -->
|
||||
<div v-if="field.render == 'datetime'">
|
||||
{{ !fieldValue ? '/' : timeFormat(fieldValue, field.timeFormat ?? undefined) }}
|
||||
</div>
|
||||
|
||||
<!-- color -->
|
||||
<div v-if="field.render == 'color'">
|
||||
<div :style="{ background: fieldValue }" class="ba-render-color"></div>
|
||||
</div>
|
||||
|
||||
<!-- customTemplate 自定义模板 -->
|
||||
<div
|
||||
v-if="field.render == 'customTemplate'"
|
||||
v-html="field.customTemplate ? field.customTemplate(row, field, fieldValue, column, index) : ''"
|
||||
></div>
|
||||
|
||||
<!-- 自定义组件/函数渲染 -->
|
||||
<component
|
||||
v-if="field.render == 'customRender'"
|
||||
:is="field.customRender"
|
||||
:renderRow="row"
|
||||
:renderField="field"
|
||||
:renderValue="fieldValue"
|
||||
:renderColumn="column"
|
||||
:renderIndex="index"
|
||||
/>
|
||||
|
||||
<!-- 按钮组 -->
|
||||
<div v-if="field.render == 'buttons' && buttons" class="cn-render-buttons">
|
||||
<template v-for="(btn, idx) in buttons" :key="idx">
|
||||
<!-- 常规按钮 -->
|
||||
|
||||
<el-button
|
||||
link
|
||||
v-if="btn.render == 'basicButton'"
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
:loading="props.row[btn.loading] || props.row.loading || false"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">{{ btn.text || btn.title }}</div>
|
||||
</el-button>
|
||||
|
||||
<!-- 带提示信息的按钮 -->
|
||||
<el-tooltip
|
||||
v-if="btn.render == 'tipButton'"
|
||||
:disabled="btn.title && !btn.disabledTip ? false : true"
|
||||
:content="btn.title"
|
||||
placement="top"
|
||||
>
|
||||
<el-button
|
||||
link
|
||||
@click="onButtonClick(btn)"
|
||||
:class="btn.class"
|
||||
class="table-operate"
|
||||
:type="btn.type"
|
||||
v-bind="btn.attr"
|
||||
>
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">
|
||||
{{ btn.text || btn.title }}
|
||||
</div>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 带确认框的按钮 -->
|
||||
<el-popconfirm
|
||||
v-if="btn.render == 'confirmButton'"
|
||||
:disabled="btn.disabled && btn.disabled(row, field)"
|
||||
v-bind="btn.popconfirm"
|
||||
@confirm="onButtonClick(btn)"
|
||||
>
|
||||
<template #reference>
|
||||
<div style="display: inline-block">
|
||||
<el-button link :class="btn.class" class="table-operate" :type="btn.type" v-bind="btn.attr">
|
||||
<div v-if="btn.text || btn.title" class="table-operate-text">
|
||||
{{ btn.text || btn.title }}
|
||||
</div>
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-popconfirm>
|
||||
|
||||
<el-dropdown v-if="btn.render == 'dropdown'" trigger="click" @command="handlerCommand">
|
||||
<el-button link type="primary" class="table-operate">
|
||||
<div class="table-operate-text">更多</div>
|
||||
</el-button>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item
|
||||
v-for="item in btn.buttons"
|
||||
:key="item.text"
|
||||
:command="item"
|
||||
:style="{
|
||||
color: item.type === 'primary' ? 'var(--el-color-primary)' : 'var(--el-color-danger'
|
||||
}"
|
||||
>
|
||||
{{ item.text }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, inject } from 'vue'
|
||||
import { ElMessageBox, type TagProps } from 'element-plus'
|
||||
import type TableStoreClass from '@/utils/tableStore'
|
||||
import { fullUrl, timeFormat } from '@/utils/common'
|
||||
import type { VxeColumnProps } from 'vxe-table'
|
||||
import { getFileUrl } from '@/api/system-boot/file'
|
||||
const TableStore = inject('tableStore') as TableStoreClass
|
||||
|
||||
interface Props {
|
||||
row: TableRow
|
||||
field: TableColumn
|
||||
column: VxeColumnProps
|
||||
index: number
|
||||
}
|
||||
const props = defineProps<Props>()
|
||||
|
||||
// 字段值(单元格值)
|
||||
const fieldName = ref(props.field.field)
|
||||
const fieldValue = ref(fieldName.value ? props.row[fieldName.value] : '')
|
||||
if (fieldName.value && fieldName.value.indexOf('.') > -1) {
|
||||
let fieldNameArr = fieldName.value.split('.')
|
||||
let val: any = ref(props.row[fieldNameArr[0]])
|
||||
for (let index = 1; index < fieldNameArr.length; index++) {
|
||||
val.value = val.value ? val.value[fieldNameArr[index]] ?? '' : ''
|
||||
}
|
||||
fieldValue.value = val.value
|
||||
}
|
||||
|
||||
if (props.field.renderFormatter && typeof props.field.renderFormatter == 'function') {
|
||||
fieldValue.value = props.field.renderFormatter(props.row, props.field, fieldValue.value, props.column, props.index)
|
||||
}
|
||||
|
||||
const onChangeField = (row: any, value: any) => {
|
||||
row.onChangeField && row.onChangeField(props.row, value)
|
||||
|
||||
// TableStore.onTableAction('field-change', { value: value, ...props })
|
||||
}
|
||||
|
||||
const onButtonClick = (btn: OptButton) => {
|
||||
btn.click && btn.click(props.row, props.field)
|
||||
}
|
||||
|
||||
const getTagType = (value: string, custom: any): TagProps['type'] => {
|
||||
return custom && custom[value] ? custom[value] : ''
|
||||
}
|
||||
|
||||
// 按钮组处理 最多显示三个按钮 多余的显示为下拉
|
||||
const buttonsFilter = props.field.buttons?.filter(btn => !(btn.disabled && btn.disabled(props.row, props.field))) || []
|
||||
const buttons = ref<any[]>([])
|
||||
if (buttonsFilter.length > 3) {
|
||||
buttonsFilter?.forEach((btn, index) => {
|
||||
btn.text = btn.text || btn.title
|
||||
if (index < 2) {
|
||||
buttons.value.push(btn)
|
||||
} else {
|
||||
if (buttons.value.length > 2) {
|
||||
buttons.value[buttons.value.length - 1].buttons.push(btn)
|
||||
} else {
|
||||
buttons.value.push({
|
||||
render: 'dropdown',
|
||||
buttons: [btn]
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
buttons.value = buttonsFilter
|
||||
}
|
||||
const handlerCommand = (item: OptButton) => {
|
||||
switch (item.render) {
|
||||
case 'basicButton':
|
||||
onButtonClick(item)
|
||||
break
|
||||
case 'confirmButton':
|
||||
ElMessageBox.confirm(item.popconfirm?.title || '提示', {
|
||||
confirmButtonText: item.popconfirm?.confirmButtonText || '确认',
|
||||
cancelButtonText: item.popconfirm?.cancelButtonText || '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
onButtonClick(item)
|
||||
})
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
const getUrl = (url: string) => {
|
||||
getFileUrl({ filePath: url }).then(res => {
|
||||
return res.data
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.m-10 {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
.ba-render-image {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.images-item {
|
||||
width: 50px;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.el-image {
|
||||
height: 36px;
|
||||
// width: 36px;
|
||||
}
|
||||
|
||||
.table-operate-text {
|
||||
padding-left: 5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.table-operate {
|
||||
padding: 4px 5px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.cn-render-buttons {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.icon {
|
||||
font-size: 12px !important;
|
||||
// color: var(--ba-bg-color-overlay) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.move-button {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.ml-6 {
|
||||
display: inline-flex;
|
||||
vertical-align: middle;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.ml-6 + .el-button {
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.ba-render-color {
|
||||
height: 25px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.cn-render-buttons {
|
||||
:deep(.el-button) {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
.ba-render-image {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,306 +1,378 @@
|
||||
<template>
|
||||
<div ref="tableHeader" class="cn-table-header">
|
||||
<div class="table-header ba-scroll-style" :key="num">
|
||||
|
||||
<el-form style="flex: 1; height: 34px; margin-right: 20px; display: flex; flex-wrap: wrap" ref="headerForm"
|
||||
@submit.prevent="" @keyup.enter="onComSearch" label-position="left" :inline="true">
|
||||
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: 570px">
|
||||
<DatePicker ref="datePickerRef" :nextFlag="nextFlag" :theCurrentTime="theCurrentTime"></DatePicker>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="区域" v-if="area">
|
||||
<Area ref="areaRef" v-model.trim="tableStore.table.params.deptIndex" />
|
||||
</el-form-item>
|
||||
<slot name="select"></slot>
|
||||
</el-form>
|
||||
<template v-if="$slots.select || datePicker || showSearch">
|
||||
<el-button type="primary" @click="showSelectChange" v-if="showUnfoldButton">
|
||||
<Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" />
|
||||
<Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else />
|
||||
</el-button>
|
||||
<el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button>
|
||||
<el-button @click="onResetForm" v-if="showSearch && showReset" :icon="RefreshLeft">重置</el-button>
|
||||
<el-button @click="onExport" v-if="showExport" :loading="tableStore.table.loading" type="primary"
|
||||
icon="el-icon-Download">导出</el-button>
|
||||
</template>
|
||||
<slot name="operation"></slot>
|
||||
</div>
|
||||
<el-form :style="showSelect && showUnfoldButton ? headerFormSecondStyleOpen : headerFormSecondStyleClose"
|
||||
ref="headerFormSecond" @submit.prevent="" @keyup.enter="onComSearch" label-position="left"
|
||||
:inline="true"></el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject, ref, onMounted, nextTick, onUnmounted } from 'vue'
|
||||
import type TableStore from '@/utils/tableStore'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import Area from '@/components/form/area/index.vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { Search, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import { defineProps } from 'vue'
|
||||
const emit = defineEmits(['selectChange',])
|
||||
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const tableHeader = ref()
|
||||
const datePickerRef = ref()
|
||||
const dictData = useDictData()
|
||||
const areaRef = ref()
|
||||
const headerForm = ref()
|
||||
const headerFormSecond = ref()
|
||||
const num = ref(0)
|
||||
interface Props {
|
||||
datePicker?: boolean
|
||||
area?: boolean
|
||||
showSearch?: boolean
|
||||
nextFlag?: boolean //控制时间是否可以往后推
|
||||
theCurrentTime?: boolean //控制时间前3天展示上个月时间
|
||||
showReset?: boolean //是否显示重置
|
||||
showExport?: boolean //导出控制
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
datePicker: false,
|
||||
area: false,
|
||||
showSearch: true,
|
||||
nextFlag: false,
|
||||
theCurrentTime: true,
|
||||
showReset: true,
|
||||
showExport:false
|
||||
})
|
||||
// 动态计算table高度
|
||||
let resizeObserver = new ResizeObserver(entries => {
|
||||
for (const entry of entries) {
|
||||
handlerHeight()
|
||||
computedSearchRow()
|
||||
}
|
||||
})
|
||||
const showUnfoldButton = ref(false)
|
||||
const headerFormSecondStyleOpen = {
|
||||
opacity: 1,
|
||||
height: 'auto',
|
||||
padding: '0 15px 0px 15px'
|
||||
}
|
||||
const headerFormSecondStyleClose = {
|
||||
opacity: 0,
|
||||
height: '0',
|
||||
padding: '0'
|
||||
}
|
||||
onMounted(() => {
|
||||
if (props.datePicker && tableStore) {
|
||||
tableStore.table.params.searchBeginTime = datePickerRef.value?.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = datePickerRef.value?.timeValue[1]
|
||||
tableStore.table.params.startTime = datePickerRef.value?.timeValue[0]
|
||||
tableStore.table.params.endTime = datePickerRef.value?.timeValue[1]
|
||||
tableStore.table.params.timeFlag = datePickerRef.value?.timeFlag
|
||||
}
|
||||
if (props.area) {
|
||||
tableStore.table.params.deptIndex = dictData.state.area[0].id
|
||||
}
|
||||
nextTick(() => {
|
||||
resizeObserver.observe(tableHeader.value)
|
||||
computedSearchRow()
|
||||
})
|
||||
})
|
||||
onUnmounted(() => {
|
||||
resizeObserver.disconnect()
|
||||
})
|
||||
|
||||
const handlerHeight = () => {
|
||||
if (tableStore && tableStore.table) {
|
||||
tableStore.table.height = mainHeight(
|
||||
tableStore.table.publicHeight + tableHeader.value.offsetHeight + (tableStore.showPage ? 58 : 0) + 20
|
||||
).height as string
|
||||
}
|
||||
}
|
||||
// 刷新页面handler高度出下拉
|
||||
const computedSearchRow = () => {
|
||||
|
||||
if (!headerForm.value.$el) return
|
||||
|
||||
|
||||
// 清空headerFormSecond.value.$el下的元素
|
||||
while (headerFormSecond.value.$el.firstChild) {
|
||||
headerForm.value.$el.appendChild(headerFormSecond.value.$el.firstChild)
|
||||
}
|
||||
|
||||
// 获取第一行放了几个表单
|
||||
const elFormItem = headerForm.value.$el.querySelectorAll('.el-form-item')
|
||||
|
||||
// 把第一行放不下的复制一份放到headerFormSecond.value.$el
|
||||
let width = 0
|
||||
for (let i = 0; i < elFormItem.length; i++) {
|
||||
width += elFormItem[i].offsetWidth + 32
|
||||
if (width > headerForm.value.$el.offsetWidth) {
|
||||
headerFormSecond.value.$el.appendChild(elFormItem[i])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 判断是否需要折叠
|
||||
if (headerFormSecond.value.$el.scrollHeight > 0) {
|
||||
showUnfoldButton.value = true
|
||||
} else {
|
||||
showUnfoldButton.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const showSelect = ref(false)
|
||||
const showSelectChange = () => {
|
||||
showSelect.value = !showSelect.value
|
||||
emit('selectChange', showSelect.value)
|
||||
}
|
||||
const onComSearch = async () => {
|
||||
if (props.datePicker) {
|
||||
tableStore.table.params.searchBeginTime = datePickerRef.value.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = datePickerRef.value.timeValue[1]
|
||||
tableStore.table.params.startTime = datePickerRef.value.timeValue[0]
|
||||
tableStore.table.params.endTime = datePickerRef.value.timeValue[1]
|
||||
tableStore.table.params.timeFlag = datePickerRef.value.timeFlag
|
||||
}
|
||||
|
||||
await tableStore.onTableAction('search', {})
|
||||
}
|
||||
const setDatePicker = (list: any) => {
|
||||
datePickerRef.value.setTimeOptions(list)
|
||||
}
|
||||
const onResetForm = () => {
|
||||
//时间重置成默认值
|
||||
datePickerRef.value?.setInterval(3)
|
||||
tableStore.onTableAction('reset', {})
|
||||
}
|
||||
const setInterval = (val: any) => {
|
||||
datePickerRef.value.setInterval(val)
|
||||
}
|
||||
// 导出
|
||||
const onExport = () => {
|
||||
tableStore.onTableAction('export', {showAllFlag:true})
|
||||
}
|
||||
|
||||
defineExpose({ onComSearch, areaRef, setDatePicker, setInterval, datePickerRef, showSelectChange, computedSearchRow })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cn-table-header {
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
|
||||
.table-header {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
|
||||
border-bottom: none;
|
||||
padding: 13px 15px 9px;
|
||||
font-size: 14px;
|
||||
|
||||
.table-header-operate-text {
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.table-com-search {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
border: 1px solid var(--ba-border-color);
|
||||
border-bottom: none;
|
||||
padding: 13px 15px 20px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#header-form-second,
|
||||
#header-form {
|
||||
// display: flex;
|
||||
// flex-wrap: wrap;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.mlr-12 {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.mlr-12+.el-button {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.table-search {
|
||||
display: flex;
|
||||
margin-left: auto;
|
||||
|
||||
.quick-search {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.table-search-button-group {
|
||||
display: flex;
|
||||
margin-left: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
overflow: hidden;
|
||||
|
||||
button:focus,
|
||||
button:active {
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--el-color-info-light-7);
|
||||
}
|
||||
|
||||
.table-search-button-item {
|
||||
height: 30px;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.el-button+.el-button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.right-border {
|
||||
border-right: 1px solid var(--el-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
html.dark {
|
||||
.table-search-button-group {
|
||||
|
||||
button:focus,
|
||||
button:active {
|
||||
background-color: var(--el-color-info-dark-2);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--el-color-info-light-7);
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
|
||||
el-icon {
|
||||
color: white !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#header-form,
|
||||
#header-form-second {
|
||||
:deep(.el-select) {
|
||||
--el-select-width: 220px;
|
||||
}
|
||||
|
||||
:deep(.el-input) {
|
||||
--el-input-width: 220px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<div ref="tableHeader" class="cn-table-header">
|
||||
<div class="table-header ba-scroll-style" :key="num">
|
||||
<el-form
|
||||
style="flex: 1; height: 34px; margin-right: 20px; display: flex; flex-wrap: wrap"
|
||||
ref="headerForm"
|
||||
@submit.prevent=""
|
||||
@keyup.enter="onComSearch"
|
||||
label-position="left"
|
||||
:inline="true"
|
||||
>
|
||||
<el-form-item label="日期" v-if="datePicker" style="grid-column: span 2; max-width: 570px">
|
||||
<DatePicker
|
||||
ref="datePickerRef"
|
||||
:nextFlag="nextFlag"
|
||||
:theCurrentTime="theCurrentTime"
|
||||
@change="handleDatePickerChange"
|
||||
></DatePicker>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="区域" v-if="area">
|
||||
<Area ref="areaRef" v-model.trim="tableStore.table.params.deptIndex" />
|
||||
</el-form-item>
|
||||
<slot name="select"></slot>
|
||||
</el-form>
|
||||
<template v-if="$slots.select || datePicker || showSearch">
|
||||
<el-button type="primary" @click="showSelectChange" v-if="showUnfoldButton">
|
||||
<Icon size="14" name="el-icon-ArrowUp" style="color: #fff" v-if="showSelect" />
|
||||
<Icon size="14" name="el-icon-ArrowDown" style="color: #fff" v-else />
|
||||
</el-button>
|
||||
<el-button @click="onComSearch" v-if="showSearch" type="primary" :icon="Search">查询</el-button>
|
||||
<el-button @click="onResetForm" v-if="showSearch && showReset" :icon="RefreshLeft">重置</el-button>
|
||||
<el-button
|
||||
@click="onExport"
|
||||
v-if="showExport"
|
||||
:loading="tableStore.table.loading"
|
||||
type="primary"
|
||||
icon="el-icon-Download"
|
||||
>
|
||||
导出
|
||||
</el-button>
|
||||
</template>
|
||||
<slot name="operation"></slot>
|
||||
</div>
|
||||
<el-form
|
||||
:style="showSelect && showUnfoldButton ? headerFormSecondStyleOpen : headerFormSecondStyleClose"
|
||||
ref="headerFormSecond"
|
||||
@submit.prevent=""
|
||||
@keyup.enter="onComSearch"
|
||||
label-position="left"
|
||||
:inline="true"
|
||||
></el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { inject, ref, onMounted, nextTick, onUnmounted } from 'vue'
|
||||
import type TableStore from '@/utils/tableStore'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import Area from '@/components/form/area/index.vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { Search, RefreshLeft } from '@element-plus/icons-vue'
|
||||
import { defineProps } from 'vue'
|
||||
import { useTimeCacheStore } from '@/stores/timeCache'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
const emit = defineEmits(['selectChange'])
|
||||
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const tableHeader = ref()
|
||||
const datePickerRef = ref()
|
||||
const dictData = useDictData()
|
||||
const areaRef = ref()
|
||||
const headerForm = ref()
|
||||
const headerFormSecond = ref()
|
||||
const num = ref(0)
|
||||
|
||||
// 获取路由和缓存 store
|
||||
const route = useRoute()
|
||||
const timeCacheStore = useTimeCacheStore()
|
||||
|
||||
interface Props {
|
||||
datePicker?: boolean
|
||||
area?: boolean
|
||||
showSearch?: boolean
|
||||
nextFlag?: boolean //控制时间是否可以往后推
|
||||
theCurrentTime?: boolean //控制时间前3天展示上个月时间
|
||||
showReset?: boolean //是否显示重置
|
||||
showExport?: boolean //导出控制
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
datePicker: false,
|
||||
area: false,
|
||||
showSearch: true,
|
||||
nextFlag: false,
|
||||
theCurrentTime: true,
|
||||
showReset: true,
|
||||
showExport: false
|
||||
})
|
||||
|
||||
// 处理 DatePicker 值变化事件
|
||||
const handleDatePickerChange = (value: any) => {
|
||||
// 将值缓存到 timeCache
|
||||
// if (value) {
|
||||
// timeCacheStore.setCache(route.path, value.interval, value.timeValue)
|
||||
// }
|
||||
|
||||
// 将 datePicker 的变化传递给父组件
|
||||
emit('selectChange', true, tableHeader.value.offsetHeight, value)
|
||||
}
|
||||
|
||||
// 动态计算table高度
|
||||
let resizeObserver = new ResizeObserver(entries => {
|
||||
for (const entry of entries) {
|
||||
handlerHeight()
|
||||
computedSearchRow()
|
||||
}
|
||||
})
|
||||
const showUnfoldButton = ref(false)
|
||||
const headerFormSecondStyleOpen = {
|
||||
opacity: 1,
|
||||
height: 'auto',
|
||||
padding: '0 15px 0px 15px'
|
||||
}
|
||||
const headerFormSecondStyleClose = {
|
||||
opacity: 0,
|
||||
height: '0',
|
||||
padding: '0'
|
||||
}
|
||||
onMounted(() => {
|
||||
// 设置初始值到 DatePicker
|
||||
if (props.datePicker && datePickerRef.value) {
|
||||
// 从缓存中获取值并设置
|
||||
const cached = timeCacheStore.getCache(route.path)
|
||||
if (cached) {
|
||||
if (cached.interval !== undefined) {
|
||||
datePickerRef.value.setInterval(cached.interval)
|
||||
}
|
||||
if (cached.timeValue) {
|
||||
datePickerRef.value.timeValue = cached.timeValue
|
||||
}
|
||||
}
|
||||
|
||||
// 更新 tableStore 参数
|
||||
tableStore.table.params.searchBeginTime = datePickerRef.value?.timeValue?.[0]
|
||||
tableStore.table.params.searchEndTime = datePickerRef.value?.timeValue?.[1]
|
||||
tableStore.table.params.startTime = datePickerRef.value?.timeValue?.[0]
|
||||
tableStore.table.params.endTime = datePickerRef.value?.timeValue?.[1]
|
||||
tableStore.table.params.timeFlag = datePickerRef.value?.timeFlag
|
||||
}
|
||||
|
||||
if (props.area) {
|
||||
tableStore.table.params.deptIndex = dictData.state.area[0].id
|
||||
}
|
||||
|
||||
nextTick(() => {
|
||||
resizeObserver.observe(tableHeader.value)
|
||||
computedSearchRow()
|
||||
})
|
||||
})
|
||||
onUnmounted(() => {
|
||||
resizeObserver.disconnect()
|
||||
})
|
||||
|
||||
const handlerHeight = () => {
|
||||
if (tableStore && tableStore.table) {
|
||||
tableStore.table.height = mainHeight(
|
||||
tableStore.table.publicHeight + tableHeader.value.offsetHeight + (tableStore.showPage ? 58 : 0) + 20
|
||||
).height as string
|
||||
}
|
||||
}
|
||||
// 刷新页面handler高度出下拉
|
||||
const computedSearchRow = () => {
|
||||
if (!headerForm.value.$el) return
|
||||
|
||||
// 清空headerFormSecond.value.$el下的元素
|
||||
while (headerFormSecond.value.$el.firstChild) {
|
||||
headerForm.value.$el.appendChild(headerFormSecond.value.$el.firstChild)
|
||||
}
|
||||
|
||||
// 获取第一行放了几个表单
|
||||
const elFormItem = headerForm.value.$el.querySelectorAll('.el-form-item')
|
||||
|
||||
// 把第一行放不下的复制一份放到headerFormSecond.value.$el
|
||||
let width = 0
|
||||
for (let i = 0; i < elFormItem.length; i++) {
|
||||
width += elFormItem[i].offsetWidth + 32
|
||||
if (width > headerForm.value.$el.offsetWidth) {
|
||||
headerFormSecond.value.$el.appendChild(elFormItem[i])
|
||||
}
|
||||
}
|
||||
|
||||
// 判断是否需要折叠
|
||||
if (headerFormSecond.value.$el.scrollHeight > 0) {
|
||||
showUnfoldButton.value = true
|
||||
} else {
|
||||
showUnfoldButton.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const showSelect = ref(false)
|
||||
const showSelectChange = () => {
|
||||
showSelect.value = !showSelect.value
|
||||
setTimeout(() => {
|
||||
emit('selectChange', showSelect.value, tableHeader.value.offsetHeight)
|
||||
}, 20)
|
||||
}
|
||||
const onComSearch = async () => {
|
||||
if (props.datePicker) {
|
||||
tableStore.table.params.searchBeginTime = datePickerRef.value.timeValue[0]
|
||||
tableStore.table.params.searchEndTime = datePickerRef.value.timeValue[1]
|
||||
tableStore.table.params.startTime = datePickerRef.value.timeValue[0]
|
||||
tableStore.table.params.endTime = datePickerRef.value.timeValue[1]
|
||||
tableStore.table.params.timeFlag = datePickerRef.value.timeFlag
|
||||
}
|
||||
|
||||
await tableStore.onTableAction('search', {})
|
||||
}
|
||||
const setDatePicker = (list: any) => {
|
||||
datePickerRef.value.setTimeOptions(list)
|
||||
}
|
||||
const onResetForm = () => {
|
||||
//时间重置成默认值
|
||||
datePickerRef.value?.setInterval(3)
|
||||
tableStore.onTableAction('reset', {})
|
||||
}
|
||||
const setInterval = (val: any) => {
|
||||
datePickerRef.value.setInterval(val)
|
||||
}
|
||||
|
||||
const setTimeInterval = (val: any) => {
|
||||
datePickerRef.value.timeValue = val
|
||||
tableStore.table.params.searchBeginTime = val[0]
|
||||
tableStore.table.params.searchEndTime = val[1]
|
||||
tableStore.table.params.startTime = val[0]
|
||||
tableStore.table.params.endTime = val[1]
|
||||
}
|
||||
// 导出
|
||||
const onExport = () => {
|
||||
tableStore.onTableAction('export', { showAllFlag: true })
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
onComSearch,
|
||||
areaRef,
|
||||
setDatePicker,
|
||||
setInterval,
|
||||
setTimeInterval,
|
||||
datePickerRef,
|
||||
showSelectChange,
|
||||
computedSearchRow
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.cn-table-header {
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
|
||||
.table-header {
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
|
||||
border-bottom: none;
|
||||
padding: 13px 15px 9px;
|
||||
font-size: 14px;
|
||||
|
||||
.table-header-operate-text {
|
||||
margin-left: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.table-com-search {
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
border: 1px solid var(--ba-border-color);
|
||||
border-bottom: none;
|
||||
padding: 13px 15px 20px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#header-form-second,
|
||||
#header-form {
|
||||
// display: flex;
|
||||
// flex-wrap: wrap;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.mlr-12 {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.mlr-12 + .el-button {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
.table-search {
|
||||
display: flex;
|
||||
margin-left: auto;
|
||||
|
||||
.quick-search {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.table-search-button-group {
|
||||
display: flex;
|
||||
margin-left: 12px;
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: var(--el-border-radius-base);
|
||||
overflow: hidden;
|
||||
|
||||
button:focus,
|
||||
button:active {
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--el-color-info-light-7);
|
||||
}
|
||||
|
||||
.table-search-button-item {
|
||||
height: 30px;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.el-button + .el-button {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.right-border {
|
||||
border-right: 1px solid var(--el-border-color);
|
||||
}
|
||||
}
|
||||
|
||||
html.dark {
|
||||
.table-search-button-group {
|
||||
button:focus,
|
||||
button:active {
|
||||
background-color: var(--el-color-info-dark-2);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: var(--el-color-info-light-7);
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: var(--ba-bg-color-overlay);
|
||||
|
||||
el-icon {
|
||||
color: white !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#header-form,
|
||||
#header-form-second {
|
||||
:deep(.el-select) {
|
||||
--el-select-width: 220px;
|
||||
}
|
||||
|
||||
:deep(.el-input) {
|
||||
--el-input-width: 220px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div :style="{ height: tableStore.table.height }">
|
||||
<div :style="{ height: typeof props.height === 'string' ? props.height : tableStore.table.height }">
|
||||
<vxe-table
|
||||
ref="tableRef"
|
||||
height="auto"
|
||||
@@ -13,6 +13,7 @@
|
||||
:sort-config="{ remote: true }"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
|
||||
<!-- Column 组件内部是 el-table-column -->
|
||||
<template v-if="isGroup">
|
||||
<GroupColumn :column="tableStore.table.column" />
|
||||
@@ -81,14 +82,18 @@ const key = ref(0)
|
||||
interface Props extends /* @vue-ignore */ Partial<InstanceType<typeof ElTable>> {
|
||||
isGroup?: boolean
|
||||
showOverflow?: boolean
|
||||
height?: string | number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
isGroup: false,
|
||||
showOverflow: true
|
||||
showOverflow: true,
|
||||
height: undefined
|
||||
})
|
||||
onMounted(() => {
|
||||
tableStore.table.ref = tableRef.value as VxeTableInstance
|
||||
|
||||
|
||||
})
|
||||
// console.log(props)
|
||||
const onTableSizeChange = (val: number) => {
|
||||
@@ -119,7 +124,7 @@ const handleSortChange = ({ field, order }: any) => {
|
||||
return a[field] < b[field] ? 1 : -1
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
if (tableStore.isWebPaging) {
|
||||
tableStore.table.data = JSON.parse(
|
||||
JSON.stringify(
|
||||
@@ -148,6 +153,8 @@ watch(
|
||||
() => tableStore.table.allFlag,
|
||||
newVal => {
|
||||
if (tableStore.table.allFlag) {
|
||||
console.log('🚀 ~ tableStore.table.allData:', tableStore.table.allData)
|
||||
|
||||
tableRef.value?.exportData({
|
||||
filename: tableStore.exportName || document.querySelectorAll('.ba-nav-tab.active')[0].textContent || '', // 文件名字
|
||||
sheetName: 'Sheet1',
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
|
||||
style='cursor: pointer' v-if='props.canExpand' /> -->
|
||||
</div>
|
||||
<el-tree :style="{ height: 'calc(100vh - 200px)' }"
|
||||
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current
|
||||
<el-tree :style="{ height: 'calc(100vh - 110px)' }"
|
||||
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current :default-expand-all="false"
|
||||
@check-change="checkTreeNodeChange" :filter-node-method='filterNode' node-key='id' v-bind='$attrs'>
|
||||
<template #default='{ node, data }'>
|
||||
<span class='custom-tree-node'>
|
||||
@@ -75,7 +75,6 @@ const filterNode = (value: string, data: any, node: any) => {
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。name是中文字符,enName是英文字符.
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<el-tree
|
||||
:style="{ height: bxsDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 278px)' }"
|
||||
ref="treeRef1" :props="defaultProps" highlight-current :filter-node-method="filterNode"
|
||||
node-key="id" default-expand-all v-bind="$attrs" :data="zlDevList" style="overflow: auto">
|
||||
node-key="id" :default-expand-all="false" v-bind="$attrs" :data="zlDevList" style="overflow: auto">
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon :name="data.icon" style="font-size: 16px" :style="{ color: data.color }"
|
||||
@@ -44,7 +44,7 @@
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 280px)' : 'calc(100vh - 238px)' }"
|
||||
ref="treeRef2" :props="defaultProps" highlight-current default-expand-all
|
||||
ref="treeRef2" :props="defaultProps" highlight-current :default-expand-all="false"
|
||||
:filter-node-method="filterNode" node-key="id" :data="bxsDeviceData" v-bind="$attrs"
|
||||
style="overflow: auto">
|
||||
<template #default="{ node, data }">
|
||||
@@ -59,7 +59,7 @@
|
||||
<el-collapse-item title="在线设备" name="2" v-if="frontDeviceData.length != 0">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 280px)' : 'calc(100vh - 238px)' }"
|
||||
ref="treeRef3" :props="defaultProps" highlight-current default-expand-all
|
||||
ref="treeRef3" :props="defaultProps" highlight-current :default-expand-all="false"
|
||||
:filter-node-method="filterNode" node-key="id" :data="frontDeviceData" v-bind="$attrs"
|
||||
style="overflow: auto">
|
||||
<template #default="{ node, data }">
|
||||
@@ -124,6 +124,7 @@ watch(
|
||||
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) => {
|
||||
@@ -156,8 +157,6 @@ watch(filterText, val => {
|
||||
}
|
||||
})
|
||||
watch(process, val => {
|
||||
|
||||
|
||||
if (val == '') {
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else {
|
||||
@@ -177,10 +176,10 @@ function filterProcess(nodes: any) {
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
|
||||
// 如果当前节点的process=4,或者有子节点满足条件,则保留当前节点
|
||||
if (node.process == process.value || children.length > 0) {
|
||||
if ( node.process == process.value || children.length > 0) {
|
||||
return {
|
||||
...node,
|
||||
children: node.children
|
||||
children: children
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<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" @onAdd="onAdd"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
@@ -20,7 +20,7 @@ defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy','onAdd'])
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
@@ -29,7 +29,6 @@ const width = ref('')
|
||||
|
||||
|
||||
const info = (selectedNodeId?: string) => {
|
||||
console.log('tree.value:', selectedNodeId);
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
getCldTree().then(res => {
|
||||
@@ -149,6 +148,10 @@ const info = (selectedNodeId?: string) => {
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
emit('pointTypeChange', val, obj)
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
if (props.template) {
|
||||
getTemplateByDept({ id: dictData.state.area[0].id })
|
||||
.then((res: any) => {
|
||||
|
||||
@@ -50,6 +50,7 @@ getDeviceTree().then(res => {
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 2
|
||||
item3.color = config.getColorVal('elementUiPrimary')
|
||||
if (item3.comFlag === 1) {
|
||||
item3.color = '#e26257 !important'
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getMarketList } from '@/api/user-boot/user'
|
||||
import Tree from '../index.vue'
|
||||
import Tree from '../cloudDevice.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
const config = useConfig()
|
||||
|
||||
29
src/components/tree/govern/officialUserTree.vue
Normal file
@@ -0,0 +1,29 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :data="tree" />
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getFormalUserList } from '@/api/user-boot/official'
|
||||
import Tree from '../cloudDevice.vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { ref, reactive, nextTick } from 'vue'
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
const emit = defineEmits(['selectUser'])
|
||||
getFormalUserList().then((res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
tree.value = res.data.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
icon: 'el-icon-User',
|
||||
color: 'royalblue'
|
||||
}
|
||||
})
|
||||
emit('selectUser', tree.value[0])
|
||||
nextTick(() => {
|
||||
treRef.value.treeRef.setCurrentKey(tree.value[0].id)
|
||||
})
|
||||
}
|
||||
})
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -46,7 +46,7 @@ const info = () => {
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 1
|
||||
item3.level = 2
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item3.children.forEach((item4: any) => {
|
||||
|
||||
105
src/components/tree/govern/selectTree.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :width="width" :data="tree" default-expand-all @checkedNodesChange="handleCheckedNodesChange"/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import Tree from '../select.vue'
|
||||
import { getLineTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { getTemplateByDept } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
// const props = defineProps(['template'])
|
||||
interface Props {
|
||||
template?: boolean
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const width = ref('')
|
||||
|
||||
const info = () => {
|
||||
tree.value = []
|
||||
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 = 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
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 处理子组件传递的勾选节点变化,并转发给父组件
|
||||
const handleCheckedNodesChange = (nodes: any[]) => {
|
||||
// 先给父组件
|
||||
emit('checkChange', nodes)
|
||||
}
|
||||
|
||||
|
||||
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>
|
||||
@@ -10,12 +10,26 @@
|
||||
<Icon name='el-icon-Search' style='font-size: 16px' />
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tooltip placement="bottom" :hide-after="0">
|
||||
<template #content>
|
||||
<span>台账推送</span>
|
||||
</template>
|
||||
|
||||
<Icon
|
||||
name="el-icon-Promotion"
|
||||
size="20"
|
||||
class="fold ml10 menu-collapse"
|
||||
style="cursor: pointer;"
|
||||
:style="{ color: config.getColorVal('elementUiPrimary') }"
|
||||
@click="onAdd" />
|
||||
</el-tooltip>
|
||||
<!-- <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>
|
||||
|
||||
<el-tree :style="{ height: 'calc(100vh - 200px)' }"
|
||||
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current
|
||||
style=' overflow: auto;' ref='treeRef' :props='defaultProps' highlight-current :default-expand-all="false"
|
||||
@check-change="checkTreeNodeChange" :filter-node-method='filterNode' node-key='id' v-bind='$attrs'>
|
||||
<template #default='{ node, data }'>
|
||||
<span class='custom-tree-node'>
|
||||
@@ -35,6 +49,7 @@ import { ElTree } from 'element-plus'
|
||||
import { emit } from 'process';
|
||||
import { ref, watch } from 'vue'
|
||||
import { t } from 'vxe-table';
|
||||
import { useConfig } from '@/stores/config'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
@@ -49,6 +64,7 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true
|
||||
})
|
||||
const config = useConfig()
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
@@ -56,7 +72,7 @@ const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['checkTreeNodeChange'])
|
||||
const emit = defineEmits(['checkTreeNodeChange','onAdd'])
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
})
|
||||
@@ -105,6 +121,11 @@ const checkTreeNodeChange = () => {
|
||||
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
|
||||
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef })
|
||||
</script>
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
<el-tree
|
||||
:style="{ height: bxsDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 278px)' }"
|
||||
ref="treeRef1" :props="defaultProps" highlight-current :filter-node-method="filterNode"
|
||||
node-key="id" default-expand-all v-bind="$attrs" :data="zlDevList" style="overflow: auto">
|
||||
node-key="id" v-bind="$attrs" :data="zlDevList" style="overflow: auto"
|
||||
:default-expand-all="false">
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon :name="data.icon" style="font-size: 16px" :style="{ color: data.color }"
|
||||
@@ -41,9 +42,9 @@
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 330px)' : 'calc(100vh - 238px)' }"
|
||||
ref="treeRef2" :props="defaultProps" highlight-current default-expand-all
|
||||
ref="treeRef2" :props="defaultProps" highlight-current :default-expand-all="false"
|
||||
:filter-node-method="filterNode" node-key="id" :data="bxsDeviceData" v-bind="$attrs"
|
||||
style="overflow: auto">
|
||||
style="overflow: auto" >
|
||||
<template #default="{ node, data }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon :name="data.icon" style="font-size: 16px" :style="{ color: data.color }"
|
||||
@@ -56,7 +57,7 @@
|
||||
<el-collapse-item title="在线设备" name="2" v-if="yqfDeviceData.length != 0">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 330px)' : 'calc(100vh - 238px)' }"
|
||||
ref="treeRef3" :props="defaultProps" highlight-current default-expand-all
|
||||
ref="treeRef3" :props="defaultProps" highlight-current :default-expand-all="false"
|
||||
:filter-node-method="filterNode" node-key="id" :data="yqfDeviceData" v-bind="$attrs"
|
||||
style="overflow: auto">
|
||||
<template #default="{ node, data }">
|
||||
@@ -76,7 +77,7 @@
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { el } from 'element-plus/es/locale'
|
||||
import { el, fa } from 'element-plus/es/locale'
|
||||
import { ref, watch, defineEmits, onMounted, nextTick, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
defineOptions({
|
||||
@@ -117,13 +118,14 @@ watch(
|
||||
() => props.data,
|
||||
(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)
|
||||
})
|
||||
// console.log('🚀 ~ item.children.map ~ zlDeviceData.value:', zlDeviceData.value)
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else if (item.name == '便携式设备') {
|
||||
bxsDeviceData.value = []
|
||||
item.children.map((vv: any) => {
|
||||
@@ -155,18 +157,23 @@ watch(filterText, val => {
|
||||
}
|
||||
})
|
||||
watch(process, val => {
|
||||
|
||||
if (val == '') {
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
changeDevice(activeName.value)
|
||||
}, 0)
|
||||
})
|
||||
|
||||
|
||||
|
||||
const changeDevice = (val: any) => {
|
||||
console.log('changeDevice', val)
|
||||
|
||||
let arr1: any = []
|
||||
//zlDeviceData
|
||||
zlDevList.value.forEach((item: any) => {
|
||||
@@ -231,6 +238,7 @@ const filterNode = (value: string, data: any, node: any) => {
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
|
||||
function filterProcess(nodes: any) {
|
||||
if (process.value == '') {
|
||||
return nodes
|
||||
@@ -240,20 +248,58 @@ function filterProcess(nodes: any) {
|
||||
// 递归处理子节点
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
|
||||
// 如果当前节点的process=4,或者有子节点满足条件,则保留当前节点
|
||||
// 对于装置层级(level=2),只保留 process 值匹配的节点
|
||||
if (node.level === 2) {
|
||||
if (node.process == process.value) {
|
||||
return {
|
||||
...node,
|
||||
children: children
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
if (node.process == process.value || children.length > 0) {
|
||||
// 对于其他节点:
|
||||
// 1. 如果有满足条件的子节点则保留
|
||||
// 2. 如果本身 process 值匹配则保留
|
||||
// 3. 如果是叶子节点也保留(监测点通常没有子节点)
|
||||
if (children.length > 0 || node.process == process.value ||
|
||||
(!node.children || node.children.length === 0)) {
|
||||
return {
|
||||
...node,
|
||||
children: node.children
|
||||
children: children
|
||||
}
|
||||
}
|
||||
|
||||
// 否则过滤掉当前节点
|
||||
return null
|
||||
})
|
||||
.filter(Boolean) // 移除null节点
|
||||
}
|
||||
|
||||
|
||||
// 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: node.children
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 否则过滤掉当前节点
|
||||
// return null
|
||||
// })
|
||||
// .filter(Boolean) // 移除null节点
|
||||
// }
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。name是中文字符,enName是英文字符.
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
@@ -288,7 +334,9 @@ const treeRef2 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef3 = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef1, treeRef2 })
|
||||
onMounted(() => {
|
||||
|
||||
setTimeout(() => {
|
||||
|
||||
if (zlDeviceData.value.length != 0) {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
activeName.value = '0'
|
||||
|
||||
263
src/components/tree/select.vue
Normal file
@@ -0,0 +1,263 @@
|
||||
<template>
|
||||
<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'"
|
||||
:class="menuCollapse ? 'unfold' : ''" size='18' 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>
|
||||
<Icon name='el-icon-Search' style='font-size: 16px' />
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
<el-tree
|
||||
:style="{ height: 'calc(100vh)' }"
|
||||
style='overflow: auto;'
|
||||
ref='treeRef'
|
||||
:props='defaultProps'
|
||||
highlight-current
|
||||
:filter-node-method='filterNode'
|
||||
node-key='id'
|
||||
show-checkbox
|
||||
@check="handleCheckChange"
|
||||
@node-click="handleNodeClick"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
v-bind='$attrs'
|
||||
:default-expand-all="false"
|
||||
>
|
||||
<template #default='{ node, data }'>
|
||||
<span class='custom-tree-node'>
|
||||
<Icon :name='data.icon' style='font-size: 16px' :style='{ color: data.color }'
|
||||
v-if='data.icon' />
|
||||
<span style='margin-left: 4px'>{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElMessage, ElTree } from 'element-plus'
|
||||
import { emit } from 'process';
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
})
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
canExpand?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true
|
||||
})
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['changePointType', 'checkedNodesChange'])
|
||||
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
|
||||
})
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。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 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(
|
||||
(node: any) => !previousCheckedNodes.some((prev: any) => prev.id === node.id)
|
||||
)
|
||||
|
||||
// 如果是从父级勾选导致超过限制,保留前几个直到达到限制数量
|
||||
if (newNodes.length > 0) {
|
||||
const allowedNewCount = 5 - previousCheckedNodes.length
|
||||
if (allowedNewCount > 0) {
|
||||
// 允许添加allowedNewCount个新节点
|
||||
const allowedNewNodes = newNodes.slice(0, allowedNewCount)
|
||||
const finalNodes = [...previousCheckedNodes, ...allowedNewNodes]
|
||||
|
||||
checkedNodes.value = finalNodes
|
||||
|
||||
// 设置树的勾选状态为正确的节点
|
||||
treeRef.value?.setCheckedNodes(finalNodes)
|
||||
|
||||
// 将勾选的监测点节点暴露出去
|
||||
emit('checkedNodesChange', finalNodes)
|
||||
|
||||
// 更新节点的可勾选状态
|
||||
updateNodeCheckStatus(finalNodes.length)
|
||||
|
||||
// 只有在真正超过5个时才提示警告
|
||||
if (monitoringPointNodes.length > 5) {
|
||||
ElMessage.warning('最多只能选择5个监测点')
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 其他情况回滚到之前的状态
|
||||
ElMessage.warning('最多只能选择5个监测点')
|
||||
treeRef.value?.setCheckedNodes(checkedNodes.value)
|
||||
return
|
||||
}
|
||||
|
||||
checkedNodes.value = 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)
|
||||
}
|
||||
|
||||
|
||||
// 更新节点的可勾选状态
|
||||
const updateNodeCheckStatus = (currentCount: number) => {
|
||||
if (!treeRef.value) return
|
||||
|
||||
// 如果已经选了5个,则禁用其他未选中的监测点节点
|
||||
const isMaxSelected = currentCount >= 5
|
||||
|
||||
// 获取所有节点并更新状态
|
||||
const allNodes = treeRef.value.store._getAllNodes()
|
||||
allNodes.forEach((node: any) => {
|
||||
if (node.level === 3) { // 监测点层级
|
||||
// 如果已达到最大数量且该节点未被选中,则禁用勾选
|
||||
if (isMaxSelected && !node.checked) {
|
||||
node.disabled = true
|
||||
} else {
|
||||
node.disabled = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef })
|
||||
</script>
|
||||
|
||||
|
||||
<style lang='scss' scoped>
|
||||
.cn-tree {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
padding: 10px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
|
||||
: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);
|
||||
}
|
||||
|
||||
.menu-collapse {
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
}
|
||||
|
||||
.custom-tree-node {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -1,125 +1,126 @@
|
||||
<template>
|
||||
<component :is='config.layout.layoutMode'></component>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { reactive } from 'vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { useRoute } from 'vue-router'
|
||||
import Default from '@/layouts/admin/container/default.vue'
|
||||
import Classic from '@/layouts/admin/container/classic.vue'
|
||||
import Streamline from '@/layouts/admin/container/streamline.vue'
|
||||
import Double from '@/layouts/admin/container/double.vue'
|
||||
import { onMounted, onBeforeMount } from 'vue'
|
||||
import { handleAdminRoute, getFirstRoute, routePush } from '@/utils/router'
|
||||
import router from '@/router/index'
|
||||
import { useEventListener } from '@vueuse/core'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { setNavTabsWidth } from '@/utils/layout'
|
||||
import { adminBaseRoutePath } from '@/router/static'
|
||||
import { getRouteMenu, dictDataCache } from '@/api/auth'
|
||||
import { getAreaList, areaSelect } from '@/api/common'
|
||||
import { BasicDictData } from '@/stores/interface'
|
||||
import { getAllUserSimpleList, getUserById } from '@/api/user-boot/user'
|
||||
|
||||
defineOptions({
|
||||
components: { Default, Classic, Streamline, Double }
|
||||
})
|
||||
|
||||
const navTabs = useNavTabs()
|
||||
const config = useConfig()
|
||||
const route = useRoute()
|
||||
const adminInfo = useAdminInfo()
|
||||
const dictData = useDictData()
|
||||
const state = reactive({
|
||||
autoMenuCollapseLock: false
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// if (!adminInfo.token) return router.push({ name: 'login' })
|
||||
|
||||
init()
|
||||
setNavTabsWidth()
|
||||
useEventListener(window, 'resize', setNavTabsWidth)
|
||||
})
|
||||
onBeforeMount(() => {
|
||||
onAdaptiveLayout()
|
||||
useEventListener(window, 'resize', onAdaptiveLayout)
|
||||
})
|
||||
|
||||
const init = async () => {
|
||||
await Promise.all([getAreaList(), dictDataCache(), getUserById(), areaSelect(),getAllUserSimpleList()]).then(res => {
|
||||
dictData.state.area = res[0].data
|
||||
dictData.state.basic = res[1].data
|
||||
// dictData.state.userList=res[4].data
|
||||
adminInfo.dataFill(res[2].data)
|
||||
// dictData.state.areaTree = res[3].data
|
||||
})
|
||||
/**
|
||||
* 后台初始化请求,获取站点配置,动态路由等信息
|
||||
*/
|
||||
getRouteMenu().then((res: any) => {
|
||||
const handlerMenu = (data: any) => {
|
||||
data.forEach((item: any) => {
|
||||
item.routePath =
|
||||
item.routePath[0] == '/' ? item.routePath.substring(1, item.routePath.length) : item.routePath
|
||||
item.path = item.routePath
|
||||
item.name = item.routePath
|
||||
item.keepalive = item.routePath
|
||||
item.component = item.routeName
|
||||
? item.routeName.indexOf('/src/views/') > -1
|
||||
? item.routeName
|
||||
: `/src/views/${item.routeName}/index.vue`
|
||||
: ''
|
||||
item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu'
|
||||
item.menu_type = item.children && item.children.length > 0 ? null : 'tab'
|
||||
if (item.children) {
|
||||
handlerMenu(item.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
handlerMenu(res.data)
|
||||
handleAdminRoute(res.data)
|
||||
if (route.params.to) {
|
||||
const lastRoute = JSON.parse(route.params.to as string)
|
||||
if (lastRoute.path != adminBaseRoutePath) {
|
||||
let query = !isEmpty(lastRoute.query) ? lastRoute.query : {}
|
||||
routePush({ path: lastRoute.path, query: query })
|
||||
return
|
||||
}
|
||||
}
|
||||
// 跳转到第一个菜单
|
||||
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
|
||||
if (firstRoute) routePush(firstRoute.path)
|
||||
})
|
||||
}
|
||||
|
||||
const onAdaptiveLayout = () => {
|
||||
let defaultBeforeResizeLayout = {
|
||||
layoutMode: config.layout.layoutMode,
|
||||
menuCollapse: config.layout.menuCollapse
|
||||
}
|
||||
|
||||
const clientWidth = document.body.clientWidth
|
||||
if (clientWidth < 1024) {
|
||||
/**
|
||||
* 锁定窗口改变自动调整 menuCollapse
|
||||
* 避免已是小窗且打开了菜单栏时,意外的自动关闭菜单栏
|
||||
*/
|
||||
if (!state.autoMenuCollapseLock) {
|
||||
state.autoMenuCollapseLock = true
|
||||
config.setLayout('menuCollapse', true)
|
||||
}
|
||||
config.setLayout('shrink', true)
|
||||
config.setLayoutMode('Classic')
|
||||
} else {
|
||||
state.autoMenuCollapseLock = false
|
||||
config.setLayout('menuCollapse', defaultBeforeResizeLayout.menuCollapse)
|
||||
config.setLayout('shrink', false)
|
||||
config.setLayoutMode(defaultBeforeResizeLayout.layoutMode)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<component :is='config.layout.layoutMode'></component>
|
||||
</template>
|
||||
|
||||
<script setup lang='ts'>
|
||||
import { reactive } from 'vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
import { useAdminInfo } from '@/stores/adminInfo'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { useRoute } from 'vue-router'
|
||||
import Default from '@/layouts/admin/container/default.vue'
|
||||
import Classic from '@/layouts/admin/container/classic.vue'
|
||||
import Streamline from '@/layouts/admin/container/streamline.vue'
|
||||
import Double from '@/layouts/admin/container/double.vue'
|
||||
import { onMounted, onBeforeMount } from 'vue'
|
||||
import { handleAdminRoute, getFirstRoute, routePush } from '@/utils/router'
|
||||
import router from '@/router/index'
|
||||
import { useEventListener } from '@vueuse/core'
|
||||
import { isEmpty } from 'lodash-es'
|
||||
import { setNavTabsWidth } from '@/utils/layout'
|
||||
import { adminBaseRoutePath } from '@/router/static'
|
||||
import { getRouteMenu, dictDataCache } from '@/api/auth'
|
||||
import { getAreaList, areaSelect } from '@/api/common'
|
||||
import { BasicDictData } from '@/stores/interface'
|
||||
import { getAllUserSimpleList, getUserById } from '@/api/user-boot/user'
|
||||
|
||||
defineOptions({
|
||||
components: { Default, Classic, Streamline, Double }
|
||||
})
|
||||
|
||||
const navTabs = useNavTabs()
|
||||
const config = useConfig()
|
||||
const route = useRoute()
|
||||
const adminInfo = useAdminInfo()
|
||||
const dictData = useDictData()
|
||||
const state = reactive({
|
||||
autoMenuCollapseLock: false
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// if (!adminInfo.token) return router.push({ name: 'login' })
|
||||
|
||||
init()
|
||||
setNavTabsWidth()
|
||||
useEventListener(window, 'resize', setNavTabsWidth)
|
||||
})
|
||||
onBeforeMount(() => {
|
||||
onAdaptiveLayout()
|
||||
useEventListener(window, 'resize', onAdaptiveLayout)
|
||||
})
|
||||
|
||||
const init = async () => {
|
||||
await Promise.all([getAreaList(), dictDataCache(), getUserById(), areaSelect(),getAllUserSimpleList()]).then(res => {
|
||||
dictData.state.area = res[0].data
|
||||
dictData.state.basic = res[1].data
|
||||
// dictData.state.userList=res[4].data
|
||||
adminInfo.dataFill(res[2].data)
|
||||
// dictData.state.areaTree = res[3].data
|
||||
})
|
||||
/**
|
||||
* 后台初始化请求,获取站点配置,动态路由等信息
|
||||
*/
|
||||
getRouteMenu().then((res: any) => {
|
||||
const handlerMenu = (data: any) => {
|
||||
data.forEach((item: any) => {
|
||||
item.routePath =
|
||||
item.routePath[0] == '/' ? item.routePath.substring(1, item.routePath.length) : item.routePath
|
||||
item.path = item.routePath
|
||||
item.name = item.routePath
|
||||
item.keepalive = item.routePath
|
||||
item.component = item.routeName
|
||||
? item.routeName.indexOf('/src/views/') > -1
|
||||
? item.routeName
|
||||
: `/src/views/${item.routeName}/index.vue`
|
||||
: ''
|
||||
item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu'
|
||||
item.menu_type = item.children && item.children.length > 0 ? null : 'tab'
|
||||
if (item.children) {
|
||||
handlerMenu(item.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
handlerMenu(res.data)
|
||||
handleAdminRoute(res.data)
|
||||
if (route.params.to) {
|
||||
const lastRoute = JSON.parse(route.params.to as string)
|
||||
|
||||
if (lastRoute.path != adminBaseRoutePath) {
|
||||
let query = !isEmpty(lastRoute.query) ? lastRoute.query : {}
|
||||
routePush({ path: lastRoute.path, query: query })
|
||||
return
|
||||
}
|
||||
}
|
||||
// 跳转到第一个菜单
|
||||
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
|
||||
if (firstRoute) routePush(firstRoute.path)
|
||||
})
|
||||
}
|
||||
|
||||
const onAdaptiveLayout = () => {
|
||||
let defaultBeforeResizeLayout = {
|
||||
layoutMode: config.layout.layoutMode,
|
||||
menuCollapse: config.layout.menuCollapse
|
||||
}
|
||||
|
||||
const clientWidth = document.body.clientWidth
|
||||
if (clientWidth < 1024) {
|
||||
/**
|
||||
* 锁定窗口改变自动调整 menuCollapse
|
||||
* 避免已是小窗且打开了菜单栏时,意外的自动关闭菜单栏
|
||||
*/
|
||||
if (!state.autoMenuCollapseLock) {
|
||||
state.autoMenuCollapseLock = true
|
||||
config.setLayout('menuCollapse', true)
|
||||
}
|
||||
config.setLayout('shrink', true)
|
||||
config.setLayoutMode('Classic')
|
||||
} else {
|
||||
state.autoMenuCollapseLock = false
|
||||
config.setLayout('menuCollapse', defaultBeforeResizeLayout.menuCollapse)
|
||||
config.setLayout('shrink', false)
|
||||
config.setLayoutMode(defaultBeforeResizeLayout.layoutMode)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,104 +1,104 @@
|
||||
<template>
|
||||
<el-main class="layout-main" :style="mainHeight()">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition :name="config.layout.mainAnimation" mode="out-in">
|
||||
<keep-alive :include="state.keepAliveComponentNameList">
|
||||
<component :is="Component" :key="state.componentKey" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch, onBeforeMount, onUnmounted, nextTick, provide } from 'vue'
|
||||
import { useRoute, type RouteLocationNormalized } from 'vue-router'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
|
||||
defineOptions({
|
||||
name: 'layout/main'
|
||||
})
|
||||
|
||||
const { proxy } = useCurrentInstance()
|
||||
|
||||
const route = useRoute()
|
||||
const config = useConfig()
|
||||
const navTabs = useNavTabs()
|
||||
|
||||
const state: {
|
||||
componentKey: string
|
||||
keepAliveComponentNameList: string[]
|
||||
} = reactive({
|
||||
componentKey: route.path,
|
||||
keepAliveComponentNameList: []
|
||||
})
|
||||
|
||||
const addKeepAliveComponentName = function (keepAliveName: string | undefined) {
|
||||
if (keepAliveName) {
|
||||
let exist = state.keepAliveComponentNameList.find((name: string) => {
|
||||
return name === keepAliveName
|
||||
})
|
||||
if (exist) return
|
||||
state.keepAliveComponentNameList.push(keepAliveName)
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
proxy.eventBus.on('onTabViewRefresh', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
state.componentKey = ''
|
||||
nextTick(() => {
|
||||
state.componentKey = menu.path
|
||||
addKeepAliveComponentName(menu.meta.keepalive as string)
|
||||
})
|
||||
})
|
||||
proxy.eventBus.on('onTabViewClose', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
proxy.eventBus.off('onTabViewRefresh')
|
||||
proxy.eventBus.off('onTabViewClose')
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 确保刷新页面时也能正确取得当前路由 keepalive 参数
|
||||
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
|
||||
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
state.componentKey = route.path
|
||||
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
|
||||
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.layout-container .layout-main {
|
||||
padding: 0 !important;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.layout-main-scrollbar {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
//overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<el-main class="layout-main" :style="mainHeight()">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition :name="config.layout.mainAnimation" mode="out-in">
|
||||
<keep-alive :include="state.keepAliveComponentNameList">
|
||||
<component :is="Component" :key="state.componentKey" />
|
||||
</keep-alive>
|
||||
</transition>
|
||||
</router-view>
|
||||
</el-main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch, onBeforeMount, onUnmounted, nextTick, provide } from 'vue'
|
||||
import { useRoute, type RouteLocationNormalized } from 'vue-router'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { useNavTabs } from '@/stores/navTabs'
|
||||
|
||||
defineOptions({
|
||||
name: 'layout/main'
|
||||
})
|
||||
|
||||
const { proxy } = useCurrentInstance()
|
||||
|
||||
const route = useRoute()
|
||||
const config = useConfig()
|
||||
const navTabs = useNavTabs()
|
||||
|
||||
const state: {
|
||||
componentKey: string
|
||||
keepAliveComponentNameList: string[]
|
||||
} = reactive({
|
||||
componentKey: route.path,
|
||||
keepAliveComponentNameList: []
|
||||
})
|
||||
|
||||
const addKeepAliveComponentName = function (keepAliveName: string | undefined) {
|
||||
if (keepAliveName) {
|
||||
let exist = state.keepAliveComponentNameList.find((name: string) => {
|
||||
return name === keepAliveName
|
||||
})
|
||||
if (exist) return
|
||||
state.keepAliveComponentNameList.push(keepAliveName)
|
||||
}
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
proxy.eventBus.on('onTabViewRefresh', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
state.componentKey = ''
|
||||
nextTick(() => {
|
||||
state.componentKey = menu.path
|
||||
addKeepAliveComponentName(menu.meta.keepalive as string)
|
||||
})
|
||||
})
|
||||
proxy.eventBus.on('onTabViewClose', (menu: RouteLocationNormalized) => {
|
||||
state.keepAliveComponentNameList = state.keepAliveComponentNameList.filter(
|
||||
(name: string) => menu.meta.keepalive !== name
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
proxy.eventBus.off('onTabViewRefresh')
|
||||
proxy.eventBus.off('onTabViewClose')
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
// 确保刷新页面时也能正确取得当前路由 keepalive 参数
|
||||
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
|
||||
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => route.path,
|
||||
() => {
|
||||
state.componentKey = route.path
|
||||
if (typeof navTabs.state.activeRoute?.meta.keepalive == 'string') {
|
||||
addKeepAliveComponentName(navTabs.state.activeRoute?.meta.keepalive)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.layout-container .layout-main {
|
||||
padding: 0 !important;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.layout-main-scrollbar {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
//overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
55
src/plugins/formCreate/index.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import type { App } from 'vue'
|
||||
// 👇使用 form-create 需额外全局引入 element plus 组件
|
||||
import {
|
||||
ElAlert,
|
||||
ElAside,
|
||||
ElContainer,
|
||||
ElDivider,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElPopconfirm,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTabPane,
|
||||
ElTabs,
|
||||
ElTransfer
|
||||
} from 'element-plus'
|
||||
import FcDesigner from '@form-create/designer'
|
||||
import formCreate from '@form-create/element-ui'
|
||||
import install from '@form-create/element-ui/auto-import'
|
||||
//======================= 自定义组件 =======================
|
||||
import { UploadFile, UploadImg, UploadImgs } from '@/components/UploadFile'
|
||||
import { DictSelect } from '@/components/DictSelect'
|
||||
import UserSelect from '@/views/system/auth/userList/UserSelect.vue'
|
||||
import { Editor } from '@/components/Editor'
|
||||
|
||||
const components = [
|
||||
ElAside,
|
||||
ElPopconfirm,
|
||||
ElHeader,
|
||||
ElMain,
|
||||
ElContainer,
|
||||
ElDivider,
|
||||
ElTransfer,
|
||||
ElAlert,
|
||||
ElTabs,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTabPane,
|
||||
UploadImg,
|
||||
UploadImgs,
|
||||
UploadFile,
|
||||
DictSelect,
|
||||
UserSelect,
|
||||
Editor
|
||||
]
|
||||
|
||||
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
|
||||
export const setupFormCreate = (app: App<Element>) => {
|
||||
components.forEach((component) => {
|
||||
app.component(component.name, component)
|
||||
})
|
||||
formCreate.use(install)
|
||||
app.use(formCreate)
|
||||
app.use(FcDesigner)
|
||||
}
|
||||