Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f907a80c4 | ||
|
|
4f32f84132 | ||
|
|
c2805d7e9e | ||
|
|
7deafa6d69 | ||
|
|
c2f23aa957 | ||
|
|
9466141bff | ||
|
|
faac12615d |
42
src/api/algorithm-boot/scopeConfig.ts
Normal file
42
src/api/algorithm-boot/scopeConfig.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import createAxios from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 删除数据合理范围
|
||||
**/
|
||||
export const pqDelete = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/algorithm-boot/pqReasonableRange/delete',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 按条件获取数据合理范围
|
||||
**/
|
||||
export const getData = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/algorithm-boot/pqReasonableRange/getData',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 新增数据合理范围
|
||||
**/
|
||||
export const save = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/algorithm-boot/pqReasonableRange/save',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 更新数据合理范围
|
||||
**/
|
||||
export const update = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/algorithm-boot/pqReasonableRange/update',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
@@ -150,3 +150,4 @@ export function getRawData(data?: any) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -17,14 +17,53 @@ export const queryAppInfo = (type: string) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增app基础信息
|
||||
**/
|
||||
export const addAppInfo = (data: { type: string, content: string }) => {
|
||||
export const addAppInfo = (data: { type: string; content: string }) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/appinfo/addAppInfo',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 切换告警配置启用状态
|
||||
**/
|
||||
export const toggleActive = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/csAlarmSet/toggleActive',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 切换告警配置启用状态
|
||||
**/
|
||||
export const csDelete = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/csAlarmSet/delete',
|
||||
method: 'post',
|
||||
params: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 新增告警配置
|
||||
**/
|
||||
export const add = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/csAlarmSet/add',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 修改告警配置
|
||||
**/
|
||||
export const update = (data: any) => {
|
||||
return createAxios({
|
||||
url: '/cs-system-boot/csAlarmSet/update',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ const tableStore: any = new TableStore({
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
name: '越限占比',
|
||||
name: '指标越限严重度',
|
||||
data: tableStore.table.data.map((item: any) => Math.floor(item.extent * 100) / 100),
|
||||
barMaxWidth: 30
|
||||
}
|
||||
|
||||
@@ -1,15 +1,37 @@
|
||||
<template>
|
||||
<div>
|
||||
<!--治理效果报表 -->
|
||||
<TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef" datePicker @selectChange="selectChange" v-if="fullscreen">
|
||||
<TableHeader
|
||||
:showReset="false"
|
||||
:timeKeyList="prop.timeKey"
|
||||
ref="TableHeaderRef"
|
||||
datePicker
|
||||
@selectChange="selectChange"
|
||||
v-if="fullscreen"
|
||||
>
|
||||
<template v-slot:select>
|
||||
<el-form-item label="模板策略">
|
||||
<el-select filterable v-model="tableStore.table.params.tempId" placeholder="请选择模板策略" clearable>
|
||||
<el-option v-for="item in templateList" :key="item.id" :label="item.excelName" :value="item.id" />
|
||||
<el-select
|
||||
filterable
|
||||
v-model="tableStore.table.params.tempId"
|
||||
placeholder="请选择模板策略"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="item in templateList"
|
||||
:key="item.id"
|
||||
:label="item.excelName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="监测对象">
|
||||
<el-select filterable v-model="tableStore.table.params.sensitiveUserId" placeholder="请选择监测对象" clearable>
|
||||
<el-select
|
||||
filterable
|
||||
v-model="tableStore.table.params.sensitiveUserId"
|
||||
placeholder="请选择监测对象"
|
||||
clearable
|
||||
>
|
||||
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -30,9 +52,10 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import { exportExcel } from '@/views/govern/reportForms/export.js'
|
||||
import { destroyLuckysheet, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
@@ -59,13 +82,21 @@ const idList = ref()
|
||||
// 监测对象
|
||||
const initListByIds = () => {
|
||||
getListByIds({}).then((res: any) => {
|
||||
if (res.data.length > 0) {
|
||||
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
|
||||
}
|
||||
templateListData()
|
||||
} else {
|
||||
querySysExcel({}).then(res => {
|
||||
templateList.value = res.data.filter(item => item.excelType == 4)
|
||||
if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
|
||||
tableStore.table.params.tempId = templateList.value[0].id
|
||||
}
|
||||
})
|
||||
tableStore.table.loading = false
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -89,6 +120,9 @@ const downloadExcel = () => {
|
||||
onMounted(() => {
|
||||
initListByIds()
|
||||
})
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
|
||||
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
||||
if (datePickerValue && datePickerValue.timeValue) {
|
||||
@@ -129,16 +163,7 @@ const tableStore: any = new TableStore({
|
||||
// }
|
||||
},
|
||||
loadCallback: () => {
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
allowEdit: false, // 禁止所有编辑操作(必填)
|
||||
data: tableStore.table.data
|
||||
})
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ const indicatorList = ref()
|
||||
|
||||
const initLineList = async () => {
|
||||
cslineList({}).then(res => {
|
||||
setTime()
|
||||
if (res.data.length == 0) {
|
||||
lineShow.value = false
|
||||
return (tableStore.table.loading = false)
|
||||
|
||||
@@ -167,14 +167,15 @@ const tableStore: any = new TableStore({
|
||||
type: 'primary',
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
loading: 'loading1',
|
||||
disabled: row => {
|
||||
return !row.wavePath
|
||||
},
|
||||
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
|
||||
|
||||
dialogVisible.value = false
|
||||
// 在打开弹窗时立即设置高度
|
||||
nextTick(() => {
|
||||
@@ -185,6 +186,8 @@ const tableStore: any = new TableStore({
|
||||
})
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
isWaveCharts.value = true
|
||||
loading.value = true
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
@@ -217,7 +220,7 @@ const tableStore: any = new TableStore({
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
disabled: row => {
|
||||
return !!row.wavePath
|
||||
return row.wavePath
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -160,15 +160,14 @@ const tableStore: any = new TableStore({
|
||||
type: 'primary',
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
loading: 'loading1',
|
||||
disabled: row => {
|
||||
return !row.wavePath
|
||||
},
|
||||
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
dialogVisible.value = false
|
||||
|
||||
// 在打开弹窗时立即设置高度
|
||||
nextTick(() => {
|
||||
if (waveFormAnalysisRef.value) {
|
||||
@@ -178,6 +177,10 @@ const tableStore: any = new TableStore({
|
||||
})
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
dialogVisible.value = false
|
||||
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
@@ -211,7 +214,7 @@ const tableStore: any = new TableStore({
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
disabled: row => {
|
||||
return !!row.wavePath
|
||||
return row.wavePath
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -69,7 +69,8 @@ const initChart = () => {
|
||||
top: 15,
|
||||
feature: {
|
||||
saveAsImage: {
|
||||
title: '保存图片'
|
||||
title: '下载图片',
|
||||
name: props.options?.title?.text || '图表'
|
||||
},
|
||||
...(props.options?.toolbox?.featureProps || null)
|
||||
},
|
||||
|
||||
@@ -236,7 +236,7 @@ const fliteWaveData = (wp, step, iphasicValue, isOpen) => {
|
||||
|
||||
// 监听消息
|
||||
self.onmessage = function (e) {
|
||||
const { wp, isOpen, value, boxoList } = JSON.parse(e.data)
|
||||
const { wp, isOpen, value, boxoList, requestId } = e.data
|
||||
|
||||
try {
|
||||
const iphasicValue = wp.iphasic || 1
|
||||
@@ -303,6 +303,7 @@ self.onmessage = function (e) {
|
||||
}
|
||||
// 发送处理结果回主线程
|
||||
self.postMessage({
|
||||
requestId,
|
||||
titles: titles,
|
||||
success: true,
|
||||
waveDatas,
|
||||
@@ -313,6 +314,7 @@ self.onmessage = function (e) {
|
||||
})
|
||||
} catch (error) {
|
||||
self.postMessage({
|
||||
requestId,
|
||||
success: false,
|
||||
error: error.message
|
||||
})
|
||||
|
||||
@@ -14,9 +14,15 @@ import html2canvas from 'html2canvas'
|
||||
import $ from 'jquery'
|
||||
import * as echarts from 'echarts'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { calcRmsYAxisRange, formatAxisLabel } from '@/utils/chartAxisHelper'
|
||||
import url from '@/assets/img/point.png'
|
||||
import url2 from '@/assets/img/dw.png'
|
||||
const worker = ref<Worker | null>(null)
|
||||
import { buildWaveCacheKey, getWaveCache, setWaveCache } from '@/utils/waveCache'
|
||||
import { getRmsWorker, buildWorkerPayload } from '@/utils/waveWorkerPool'
|
||||
|
||||
let waveRequestId = 0
|
||||
const pendingCacheKeys = new Map<number, string>()
|
||||
let rmsWorker: Worker | null = null
|
||||
interface WaveData {
|
||||
instantF: { max: number; min: number }
|
||||
instantS: { max: number; min: number }
|
||||
@@ -125,26 +131,19 @@ const vw = computed(() => '100%')
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
newVal => {
|
||||
if (newVal == 2) {
|
||||
initWaves()
|
||||
} else {
|
||||
$('#wave1').remove()
|
||||
initWaves()
|
||||
}
|
||||
() => {
|
||||
query()
|
||||
}
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
const zoomValue = document.body.style.getPropertyValue('zoom')
|
||||
zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1)
|
||||
window.addEventListener('resize', handleResize)
|
||||
watch(
|
||||
() => props.wp,
|
||||
() => {
|
||||
query()
|
||||
}
|
||||
)
|
||||
|
||||
// 初始化 Web Worker
|
||||
worker.value = new Worker(new URL('./rmsWorker.js', import.meta.url))
|
||||
worker.value.onmessage = e => {
|
||||
if (e.data.success) {
|
||||
const data = e.data
|
||||
const applyWorkerResult = (data: any) => {
|
||||
titles.value = data.titles
|
||||
waveDatas.value = data.waveDatas
|
||||
time.value = data.time
|
||||
@@ -152,25 +151,41 @@ onMounted(() => {
|
||||
severity.value = data.severity
|
||||
iphasic.value = data.iphasic
|
||||
|
||||
// 初始化波形图
|
||||
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
|
||||
} else {
|
||||
console.error('Worker error:', e.data.error)
|
||||
loading.value = false
|
||||
}
|
||||
if (Number(severity.value) < 0) {
|
||||
severity.value = '/'
|
||||
type.value = '/'
|
||||
}
|
||||
|
||||
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const zoomValue = document.body.style.getPropertyValue('zoom')
|
||||
zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1)
|
||||
window.addEventListener('resize', handleResize)
|
||||
|
||||
rmsWorker = getRmsWorker(data => {
|
||||
if (data.requestId !== waveRequestId) return
|
||||
if (!data.success) {
|
||||
console.error('Worker error:', data.error)
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
const cacheKey = pendingCacheKeys.get(data.requestId)
|
||||
if (cacheKey) {
|
||||
setWaveCache(cacheKey, data)
|
||||
pendingCacheKeys.delete(data.requestId)
|
||||
}
|
||||
applyWorkerResult(data)
|
||||
})
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
query()
|
||||
}, 500)
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (worker.value) {
|
||||
worker.value.terminate()
|
||||
}
|
||||
backbxlb()
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
@@ -195,23 +210,15 @@ const download = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const EXTRA_PANEL_CLASS = 'wave-extra-panel'
|
||||
|
||||
const resetWaveDom = () => {
|
||||
backbxlb()
|
||||
$('#rmsp').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
|
||||
}
|
||||
|
||||
const query = () => {
|
||||
loading.value = true
|
||||
if (props.wp) {
|
||||
// 使用 Worker 处理数据
|
||||
if (worker.value) {
|
||||
worker.value.postMessage(
|
||||
JSON.stringify({
|
||||
wp: props.wp,
|
||||
isOpen: isOpen.value,
|
||||
value: props.value,
|
||||
boxoList: props.boxoList
|
||||
})
|
||||
)
|
||||
}
|
||||
} else {
|
||||
initWave(null, null, null, null, null)
|
||||
}
|
||||
initWaves()
|
||||
}
|
||||
|
||||
const waveData = (
|
||||
@@ -245,29 +252,31 @@ const waveData = (
|
||||
}
|
||||
|
||||
const initWaves = () => {
|
||||
if (props.wp) {
|
||||
iphasic.value = props.wp.iphasic || 1
|
||||
const picCounts = (props.wp.waveTitle.length - 1) / iphasic.value
|
||||
waveDatas.value = []
|
||||
|
||||
for (let i = 0; i < picCounts; i++) {
|
||||
const data = fliteWaveData(props.wp, i)
|
||||
waveDatas.value.push(data)
|
||||
}
|
||||
|
||||
time.value = props.wp.time
|
||||
type.value = props.wp.waveType
|
||||
severity.value = props.wp.yzd
|
||||
|
||||
if (Number(severity.value) < 0) {
|
||||
severity.value = '/'
|
||||
type.value = '/'
|
||||
}
|
||||
|
||||
initWave(waveDatas.value, time.value, type.value, severity.value, isOpen.value)
|
||||
} else {
|
||||
if (!props.wp?.listRmsData?.length) {
|
||||
initWave(null, null, null, null, null)
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
const cacheKey = buildWaveCacheKey('rms', props.wp, props.value, isOpen.value, props.boxoList)
|
||||
const cached = getWaveCache<any>(cacheKey)
|
||||
if (cached) {
|
||||
applyWorkerResult(cached)
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
iphasic.value = props.wp.iphasic || 1
|
||||
const currentRequestId = ++waveRequestId
|
||||
pendingCacheKeys.set(currentRequestId, cacheKey)
|
||||
|
||||
rmsWorker?.postMessage(
|
||||
buildWorkerPayload('rms', props.wp, props.boxoList, {
|
||||
requestId: currentRequestId,
|
||||
value: props.value,
|
||||
isOpen: isOpen.value
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const fliteWaveData = (wp: any, step: number): WaveData => {
|
||||
@@ -482,7 +491,7 @@ const initWave = (
|
||||
severity: string | null,
|
||||
isOpen: boolean | null
|
||||
) => {
|
||||
$('div.bx').remove()
|
||||
resetWaveDom()
|
||||
|
||||
let picHeight = vh.value
|
||||
const show = !isOpen
|
||||
@@ -594,7 +603,7 @@ const initWave = (
|
||||
for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) {
|
||||
const rmsId = 'rms' + step
|
||||
const newDivRms = $(
|
||||
`<div style="height:${vh.value};overflow: hidden;min-height: 200px;"><div class='bx' id='${rmsId}'></div></div>`
|
||||
`<div class="${EXTRA_PANEL_CLASS}" style="height:${vh.value};overflow: hidden;min-height: 200px;"><div class='bx' id='${rmsId}'></div></div>`
|
||||
)
|
||||
newDivRms.insertAfter($('#rmsp'))
|
||||
$(`#${rmsId}`).css('height', picHeight).css('width', vw.value).css('min-height', '200px')
|
||||
@@ -607,6 +616,12 @@ const initWave = (
|
||||
const rms = document.getElementById('rmsp')
|
||||
|
||||
if (!rms) return
|
||||
|
||||
const yRange = calcRmsYAxisRange(rmscu[0]?.[1] ?? 0, rmscm[0]?.[1] ?? 0)
|
||||
|
||||
const existingChart = echarts.getInstanceByDom(rms)
|
||||
if (existingChart) existingChart.dispose()
|
||||
|
||||
const myChartes = echarts.init(rms)
|
||||
const echartsColor = {
|
||||
WordColor: '#000',
|
||||
@@ -750,8 +765,8 @@ const initWave = (
|
||||
},
|
||||
// max: rmscm[0]?.[1] * 1.06 || 0,
|
||||
// min: rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0,
|
||||
max: Math.floor((rmscm[0]?.[1] * 1.06 || 0) * 1.1 * 10) / 10,
|
||||
min: Math.floor((rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0) * 10) / 10,
|
||||
max: yRange.max,
|
||||
min: yRange.min,
|
||||
boundaryGap: [0, '100%'],
|
||||
showLastLabel: true,
|
||||
opposite: false,
|
||||
@@ -770,7 +785,7 @@ const initWave = (
|
||||
fontSize: '12px',
|
||||
color: props.DColor ? '#000' : echartsColor.WordColor,
|
||||
formatter: function (value: number) {
|
||||
return Math.floor(value * 1000) / 1000
|
||||
return formatAxisLabel(value)
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
@@ -955,6 +970,10 @@ const drawPics = (
|
||||
const rmsIds = document.getElementById(rmsId)
|
||||
if (!rmsIds) return
|
||||
|
||||
const subMin = props.value === 1 ? waveDataTemp.RMSF.min : waveDataTemp.RMSS.min
|
||||
const subMax = props.value === 1 ? waveDataTemp.RMSF.max : waveDataTemp.RMSS.max
|
||||
const yRange = calcRmsYAxisRange(subMin, subMax)
|
||||
|
||||
const myChartes = echarts.init(rmsIds)
|
||||
const echartsColor = {
|
||||
WordColor: '#000',
|
||||
@@ -1078,6 +1097,8 @@ const drawPics = (
|
||||
},
|
||||
boundaryGap: [0, '100%'],
|
||||
showLastLabel: true,
|
||||
max: yRange.max,
|
||||
min: yRange.min,
|
||||
opposite: false,
|
||||
// max: Math.floor((rmscm[0]?.[1] * 1.06 || 0) * 1.1 * 10) / 10,
|
||||
// min: Math.floor((rmscu[0]?.[1] - rmscu[0]?.[1] * 0.2 || 0) * 10) / 10,
|
||||
@@ -1096,8 +1117,7 @@ const drawPics = (
|
||||
fontSize: '12px',
|
||||
color: props.DColor ? '#000' : echartsColor.WordColor,
|
||||
formatter: function (value: number) {
|
||||
// return (value - 0).toFixed(2)
|
||||
return Math.floor(value * 1000) / 1000
|
||||
return formatAxisLabel(value)
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
@@ -1213,12 +1233,7 @@ const backbxlb = () => {
|
||||
myChartess4.value = null
|
||||
myChartess5.value = null
|
||||
|
||||
// echarts.disconnect(charts.filter(Boolean) as echarts.ECharts[])
|
||||
charts.filter(Boolean).forEach(chart => {
|
||||
if (chart && typeof chart.dispose === 'function') {
|
||||
chart.dispose()
|
||||
}
|
||||
})
|
||||
$('#rmsp').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
|
||||
}
|
||||
|
||||
const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
// waveData.worker.js
|
||||
self.addEventListener('message', function (e) {
|
||||
const { wp, value, iphasic, isOpen, boxoList } = JSON.parse(e.data)
|
||||
const { wp, value, iphasic, isOpen, boxoList, requestId } = e.data
|
||||
|
||||
// 处理波形数据的函数
|
||||
const fliteWaveData = (wp, step) => {
|
||||
@@ -195,6 +195,8 @@ self.addEventListener('message', function (e) {
|
||||
|
||||
// 将处理结果发送回主线程
|
||||
self.postMessage({
|
||||
requestId,
|
||||
success: true,
|
||||
waveDatas,
|
||||
time,
|
||||
type,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div v-loading="loading" class="boxbx" style="position: relative; height: 100%">
|
||||
<div id="boxsj">
|
||||
<div id="shushi" :style="`height:${vh};overflow: hidden;min-height: 200px;`">
|
||||
<div class="bx" id="wave" style="min-height: 200px"></div>
|
||||
<div id="shushi" :style="containerStyle">
|
||||
<div class="bx" id="wave" :style="waveStyle"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -14,9 +14,14 @@ import html2canvas from 'html2canvas'
|
||||
import $ from 'jquery'
|
||||
import * as echarts from 'echarts'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { calcShuYAxisRange, formatAxisLabel } from '@/utils/chartAxisHelper'
|
||||
import url from '@/assets/img/point.png'
|
||||
// 创建Worker
|
||||
let waveDataWorker: Worker | null = null
|
||||
import { buildWaveCacheKey, getWaveCache, setWaveCache } from '@/utils/waveCache'
|
||||
import { getShuWorker, buildWorkerPayload } from '@/utils/waveWorkerPool'
|
||||
|
||||
let waveRequestId = 0
|
||||
const pendingCacheKeys = new Map<number, string>()
|
||||
let shuWorker: Worker | null = null
|
||||
interface WaveData {
|
||||
instantF: { max: number; min: number }
|
||||
instantS: { max: number; min: number }
|
||||
@@ -110,38 +115,82 @@ const vh = computed(() => {
|
||||
|
||||
const vw = computed(() => '100%')
|
||||
|
||||
const containerStyle = computed(() => ({
|
||||
height: vh.value,
|
||||
overflow: 'hidden',
|
||||
minHeight: '200px'
|
||||
}))
|
||||
|
||||
const waveStyle = computed(() => ({
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
minHeight: '200px'
|
||||
}))
|
||||
|
||||
const applyChartSize = (el: HTMLElement) => {
|
||||
el.style.width = '100%'
|
||||
el.style.height = vh.value
|
||||
}
|
||||
|
||||
const finishChartRender = (chart: echarts.ECharts, endLoading = false) => {
|
||||
nextTick(() => {
|
||||
chart.resize()
|
||||
if (endLoading) {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
newVal => {
|
||||
if (newVal == 2) {
|
||||
initWaves()
|
||||
} else {
|
||||
$('#wave1').remove()
|
||||
initWaves()
|
||||
}
|
||||
() => {
|
||||
query()
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.wp,
|
||||
() => {
|
||||
query()
|
||||
}
|
||||
)
|
||||
|
||||
const applyWorkerResult = (data: any) => {
|
||||
titles.value = data.titles
|
||||
iphasic.value = data.iphasic
|
||||
time.value = data.time
|
||||
type.value = data.type
|
||||
severity.value = data.severity
|
||||
initWave(data.waveDatas, data.time, data.type, data.severity, isOpen.value)
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const zoomValue = document.body.style.getPropertyValue('zoom')
|
||||
zoom.value = 1 / (zoomValue ? parseFloat(zoomValue) : 1)
|
||||
|
||||
window.addEventListener('resize', handleResize)
|
||||
shuWorker = getShuWorker(data => {
|
||||
if (data.requestId !== waveRequestId) return
|
||||
if (!data.success) {
|
||||
console.error('Worker error:', data.error)
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
const cacheKey = pendingCacheKeys.get(data.requestId)
|
||||
if (cacheKey) {
|
||||
setWaveCache(cacheKey, data)
|
||||
pendingCacheKeys.delete(data.requestId)
|
||||
}
|
||||
applyWorkerResult(data)
|
||||
})
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
query()
|
||||
}, 500)
|
||||
})
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
console.log('组件卸载')
|
||||
|
||||
if (waveDataWorker) {
|
||||
waveDataWorker.terminate()
|
||||
waveDataWorker = null
|
||||
}
|
||||
|
||||
backbxlb()
|
||||
window.removeEventListener('resize', handleResize)
|
||||
})
|
||||
@@ -166,6 +215,13 @@ const download = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const EXTRA_PANEL_CLASS = 'wave-extra-panel'
|
||||
|
||||
const resetWaveDom = () => {
|
||||
backbxlb()
|
||||
$('#shushi').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
|
||||
}
|
||||
|
||||
const query = () => {
|
||||
loading.value = true
|
||||
initWaves()
|
||||
@@ -184,48 +240,32 @@ const waveData = (instantF: any, instantS: any, shunshiF: any, shunshiS: any, ti
|
||||
|
||||
// 在组件中修改initWaves函数
|
||||
const initWaves = () => {
|
||||
if (props.wp) {
|
||||
if (!props.wp?.listWaveData?.length) {
|
||||
initWave(null, null, null, null, null)
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
const cacheKey = buildWaveCacheKey('shu', props.wp, props.value, isOpen.value, props.boxoList)
|
||||
const cached = getWaveCache<any>(cacheKey)
|
||||
if (cached) {
|
||||
applyWorkerResult(cached)
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
iphasic.value = props.wp.iphasic || 1
|
||||
// 使用Web Worker处理数据
|
||||
if (!waveDataWorker) {
|
||||
waveDataWorker = new Worker(new URL('./shuWorker.js', import.meta.url))
|
||||
const currentRequestId = ++waveRequestId
|
||||
pendingCacheKeys.set(currentRequestId, cacheKey)
|
||||
|
||||
waveDataWorker.onmessage = function (e) {
|
||||
const data = e.data
|
||||
|
||||
titles.value = data.titles
|
||||
iphasic.value = data.iphasic
|
||||
time.value = data.time
|
||||
type.value = data.type
|
||||
severity.value = data.severity
|
||||
|
||||
initWave(data.waveDatas, data.time, data.type, data.severity, isOpen.value)
|
||||
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
waveDataWorker.onerror = function (error) {
|
||||
console.error('Worker error:', error)
|
||||
loading.value = false
|
||||
// 备用方案:在主线程处理数据
|
||||
// processDataInMainThread();
|
||||
}
|
||||
}
|
||||
|
||||
// 发送数据到Worker
|
||||
waveDataWorker.postMessage(
|
||||
JSON.stringify({
|
||||
wp: props.wp,
|
||||
shuWorker?.postMessage(
|
||||
buildWorkerPayload('shu', props.wp, props.boxoList, {
|
||||
requestId: currentRequestId,
|
||||
value: props.value,
|
||||
iphasic: iphasic.value,
|
||||
isOpen: isOpen.value,
|
||||
boxoList: props.boxoList
|
||||
iphasic: iphasic.value
|
||||
})
|
||||
)
|
||||
} else {
|
||||
initWave(null, null, null, null, null)
|
||||
}
|
||||
}
|
||||
|
||||
const initWave = (
|
||||
@@ -235,6 +275,7 @@ const initWave = (
|
||||
severity: string | null,
|
||||
isOpen: boolean | null
|
||||
) => {
|
||||
resetWaveDom()
|
||||
$('div.bx1').remove()
|
||||
|
||||
let picHeight = vh.value
|
||||
@@ -327,7 +368,7 @@ const initWave = (
|
||||
|
||||
for (let step = waveDatas.length - 1; step > 0 && step < waveDatas.length; step--) {
|
||||
const waveId = 'wave' + step
|
||||
const newDivShunshi = $(`<div style="height:${vh.value};overflow: hidden;min-height: 200px;">
|
||||
const newDivShunshi = $(`<div class="${EXTRA_PANEL_CLASS}" style="height:${vh.value};overflow: hidden;min-height: 200px;">
|
||||
<div class='bx1' id='${waveId}'></div>
|
||||
</div>`)
|
||||
newDivShunshi.insertAfter($('#shushi'))
|
||||
@@ -342,6 +383,13 @@ const initWave = (
|
||||
const wave = document.getElementById('wave')
|
||||
if (!wave) return
|
||||
|
||||
applyChartSize(wave)
|
||||
|
||||
const yRange = calcShuYAxisRange(Number(min), Number(max))
|
||||
|
||||
const existingChart = echarts.getInstanceByDom(wave)
|
||||
if (existingChart) existingChart.dispose()
|
||||
|
||||
const myChartes = echarts.init(wave)
|
||||
const echartsColor = {
|
||||
WordColor: '#000',
|
||||
@@ -363,11 +411,6 @@ const initWave = (
|
||||
]
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
wave.style.width = '100%'
|
||||
wave.style.height = vh.value
|
||||
}, 0)
|
||||
|
||||
const option = {
|
||||
tooltip: {
|
||||
top: '10px',
|
||||
@@ -481,10 +524,8 @@ const initWave = (
|
||||
},
|
||||
boundaryGap: [0, '100%'],
|
||||
showLastLabel: true,
|
||||
// max: max.toFixed(2) * 1.1,
|
||||
// min: min.toFixed(2) > 0 ? min.toFixed(2) - min.toFixed(2) * 0.1 : min.toFixed(2) * 1.1,
|
||||
max: Math.floor(max.toFixed(2) * 1.1 * 10) / 10,
|
||||
min: Math.floor(min.toFixed(2) > 0 ? min.toFixed(2) - min.toFixed(2) * 0.1 : min.toFixed(2) * 1.1 * 10) / 10 ,
|
||||
max: yRange.max,
|
||||
min: yRange.min,
|
||||
opposite: false,
|
||||
nameTextStyle: {
|
||||
fontSize: '12px',
|
||||
@@ -501,8 +542,7 @@ const initWave = (
|
||||
fontSize: '12px',
|
||||
color: props.DColor ? '#000' : echartsColor.WordColor,
|
||||
formatter: function (value: number) {
|
||||
// return (value - 0).toFixed(2)
|
||||
return Math.floor(value * 1000) / 1000
|
||||
return formatAxisLabel(value)
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
@@ -518,7 +558,6 @@ const initWave = (
|
||||
right: '45px',
|
||||
bottom: '40px',
|
||||
top: '60px'
|
||||
// containLabel: true
|
||||
},
|
||||
dataZoom: [
|
||||
{
|
||||
@@ -578,11 +617,7 @@ const initWave = (
|
||||
|
||||
myChartes.setOption(option)
|
||||
myChartess.value = myChartes
|
||||
|
||||
setTimeout(() => {
|
||||
myChartes.resize()
|
||||
loading.value = false
|
||||
}, 400)
|
||||
finishChartRender(myChartes, true)
|
||||
|
||||
if (waveDatas && waveDatas.length > 1) {
|
||||
const waveDatasTemp = waveDatas.slice(1)
|
||||
@@ -679,6 +714,13 @@ const drawPics = (
|
||||
const waveIds = document.getElementById(waveId)
|
||||
if (!waveIds) return
|
||||
|
||||
applyChartSize(waveIds)
|
||||
|
||||
const yRange = calcShuYAxisRange(Number(min), Number(max))
|
||||
|
||||
const existingChart = echarts.getInstanceByDom(waveIds)
|
||||
if (existingChart) existingChart.dispose()
|
||||
|
||||
const myChartes = echarts.init(waveIds)
|
||||
const echartsColor = {
|
||||
WordColor: '#000',
|
||||
@@ -791,8 +833,8 @@ const drawPics = (
|
||||
},
|
||||
boundaryGap: [0, '100%'],
|
||||
showLastLabel: true,
|
||||
max: Math.floor(max.toFixed(2) * 1.1 * 10) / 10,
|
||||
min: Math.floor(min.toFixed(2) > 0 ? min.toFixed(2) - min.toFixed(2) * 0.1 : min.toFixed(2) * 1.1 * 10) / 10 ,
|
||||
max: yRange.max,
|
||||
min: yRange.min,
|
||||
opposite: false,
|
||||
nameTextStyle: {
|
||||
fontSize: '12px',
|
||||
@@ -809,8 +851,7 @@ const drawPics = (
|
||||
fontSize: '12px',
|
||||
color: props.DColor ? '#000' : echartsColor.WordColor,
|
||||
formatter: function (value: number) {
|
||||
// return (value - 0).toFixed(2)
|
||||
return Math.floor(value * 1000) / 1000
|
||||
return formatAxisLabel(value)
|
||||
}
|
||||
},
|
||||
splitLine: {
|
||||
@@ -897,10 +938,7 @@ const drawPics = (
|
||||
break
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
myChartes.resize()
|
||||
loading.value = false
|
||||
}, 400)
|
||||
finishChartRender(myChartes)
|
||||
|
||||
echarts.connect([myChartes1, myChartes])
|
||||
}
|
||||
@@ -929,12 +967,8 @@ const backbxlb = () => {
|
||||
myChartess4.value = null
|
||||
myChartess5.value = null
|
||||
|
||||
// echarts.disconnect(charts.filter(Boolean) as echarts.ECharts[])
|
||||
charts.filter(Boolean).forEach(chart => {
|
||||
if (chart && typeof chart.dispose === 'function') {
|
||||
chart.dispose()
|
||||
}
|
||||
})
|
||||
$('#shushi').nextAll(`.${EXTRA_PANEL_CLASS}`).remove()
|
||||
$('div.bx1').remove()
|
||||
}
|
||||
|
||||
const getMax = (temp: number, tempA: number, tempB: number, tempC: number): number => {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,10 +10,11 @@
|
||||
@checkbox-all="selectChangeEvent"
|
||||
@checkbox-change="selectChangeEvent"
|
||||
:showOverflow="showOverflow"
|
||||
:sort-config="{ remote: true }"
|
||||
@sort-change="handleSortChange"
|
||||
>
|
||||
|
||||
|
||||
>
|
||||
<!-- :sort-config="{ remote: true }" -->
|
||||
<!-- @sort-change="handleSortChange" -->
|
||||
<!-- Column 组件内部是 el-table-column -->
|
||||
<template v-if="isGroup">
|
||||
<GroupColumn :column="tableStore.table.column" />
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
<div class="mt10 mr10" style="display: flex; justify-content: end" v-if="showBut">
|
||||
<el-button type="primary" icon="el-icon-Select" @click="save" :loading="loading">保存</el-button>
|
||||
</div>
|
||||
<Icon
|
||||
<!-- <Icon
|
||||
v-show="menuCollapse"
|
||||
@click="onMenuCollapse"
|
||||
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''"
|
||||
size="18"
|
||||
size="18px"
|
||||
class="fold ml10 mt20 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
/>
|
||||
/> -->
|
||||
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
|
||||
<div style="display: flex; align-items: center" class="mb10">
|
||||
<el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
@@ -23,19 +23,15 @@
|
||||
<template #content>
|
||||
<span>台账推送</span>
|
||||
</template>
|
||||
|
||||
<Icon
|
||||
name="el-icon-Promotion"
|
||||
size="20"
|
||||
size="20px"
|
||||
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'" v-else
|
||||
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
|
||||
style='cursor: pointer' v-if='props.canExpand' /> -->
|
||||
</div>
|
||||
|
||||
<el-tree
|
||||
@@ -50,13 +46,13 @@
|
||||
node-key="id"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
@@ -69,14 +65,11 @@
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { createTreeFilterNode } from './govern/treeFilterUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
})
|
||||
defineOptions({ name: 'govern/allocation', inheritAttrs: false })
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
@@ -85,7 +78,7 @@ interface Props {
|
||||
showBut?: boolean
|
||||
height?: number
|
||||
}
|
||||
const loading = ref(false)
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true,
|
||||
@@ -93,69 +86,34 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
showBut: true,
|
||||
height: 267
|
||||
})
|
||||
|
||||
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'checkChange'])
|
||||
|
||||
const config = useConfig()
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'checkChange'])
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
})
|
||||
const loading = ref(false)
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
const filterNode = createTreeFilterNode()
|
||||
|
||||
watch(filterText, val => treeRef.value?.filter(val))
|
||||
|
||||
const onMenuCollapse = () => {
|
||||
menuCollapse.value = !menuCollapse.value
|
||||
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
|
||||
}
|
||||
|
||||
const save = () => {
|
||||
loading.value = true
|
||||
emit('checkChange')
|
||||
}
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
console.log(value, data, node, 'filterNode')
|
||||
if (!value) return true
|
||||
// return data.name.includes(value)
|
||||
if (data.name) {
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。name是中文字符,enName是英文字符.
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
const level = node.level
|
||||
// 如果传入的节点本身就是一级节点就不用校验了
|
||||
if (level === 1) {
|
||||
return false
|
||||
}
|
||||
// 先取当前节点的父节点
|
||||
let parentData = node.parent
|
||||
// 遍历当前节点的父节点
|
||||
let index = 0
|
||||
while (index < level - 1) {
|
||||
// 如果匹配到直接返回,此处name值是中文字符,enName是英文字符。判断匹配中英文过滤
|
||||
if (parentData.data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
// 否则的话再往上一层做匹配
|
||||
parentData = parentData.parent
|
||||
index++
|
||||
}
|
||||
// 没匹配到返回false
|
||||
return false
|
||||
}
|
||||
const checkTreeNodeChange = () => {
|
||||
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
|
||||
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
const onAdd = () => emit('onAdd')
|
||||
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef, loading })
|
||||
|
||||
@@ -1,27 +1,43 @@
|
||||
<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" v-model.trim='filterText' placeholder='请输入内容' clearable>
|
||||
<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="18px"
|
||||
class="fold ml10 mt20 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
/> -->
|
||||
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
|
||||
<div style="display: flex; align-items: center" class="mb10">
|
||||
<el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
<template #prefix>
|
||||
<Icon name='el-icon-Search' style='font-size: 16px' />
|
||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||
</template>
|
||||
</el-input>
|
||||
<!-- <Icon @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
|
||||
style='cursor: pointer' v-if='props.canExpand' /> -->
|
||||
</div>
|
||||
<el-tree :style="{ height: 'calc(100vh - 230px)' }"
|
||||
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'>
|
||||
<Icon :name='data.icon' style='font-size: 16px' :style='{ color: data.color }'
|
||||
v-if='data.icon' />
|
||||
<span style='margin-left: 4px'>{{ node.label }}</span>
|
||||
<el-tree
|
||||
:style="{ height: 'calc(100vh - 230px)' }"
|
||||
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: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
@@ -29,14 +45,13 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { ref, watch } from 'vue'
|
||||
import { createTreeFilterNode } from './govern/treeFilterUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
})
|
||||
defineOptions({ name: 'govern/cloudDevice', inheritAttrs: false })
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
@@ -47,66 +62,31 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true
|
||||
})
|
||||
|
||||
const emit = defineEmits(['checkTreeNodeChange'])
|
||||
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['checkTreeNodeChange'])
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
const filterNode = createTreeFilterNode()
|
||||
|
||||
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 checkTreeNodeChange = () => {
|
||||
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
|
||||
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
|
||||
}
|
||||
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef })
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
<style lang="scss" scoped>
|
||||
.cn-tree {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
<!-- 设备管理使用折叠面板渲染多个tree -->
|
||||
<template>
|
||||
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden">
|
||||
<Icon
|
||||
<!-- <Icon
|
||||
v-show="menuCollapse"
|
||||
@click="onMenuCollapse"
|
||||
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''"
|
||||
size="18"
|
||||
size="18px"
|
||||
class="fold ml10 mt20 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
/>
|
||||
/> -->
|
||||
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
|
||||
<div style="display: flex; align-items: center" class="mb10">
|
||||
<!-- <el-form-item> -->
|
||||
|
||||
<el-input
|
||||
maxlength="32"
|
||||
v-model.trim="filterText"
|
||||
@@ -36,39 +34,33 @@
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<!-- </el-form-item> -->
|
||||
<Icon
|
||||
<!-- <Icon
|
||||
@click="onMenuCollapse"
|
||||
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''"
|
||||
size="18"
|
||||
size="18px"
|
||||
class="fold ml10 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
v-if="props.canExpand"
|
||||
/>
|
||||
/> -->
|
||||
</div>
|
||||
|
||||
<el-collapse
|
||||
:accordion="true"
|
||||
v-model.trim="activeName"
|
||||
v-model="activeName"
|
||||
style="flex: 1; height: 100%"
|
||||
@change="changeDevice"
|
||||
v-if="treeType == '1'"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length != 0">
|
||||
<el-select v-model.trim="process" clearable placeholder="请选择状态" class="mb10">
|
||||
<el-option label="功能调试" value="2"></el-option>
|
||||
<el-option label="出厂调试" value="3"></el-option>
|
||||
<el-option label="正式投运" value="4"></el-option>
|
||||
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length">
|
||||
<el-select v-model="process" clearable placeholder="请选择状态" class="mb10">
|
||||
<el-option label="功能调试" value="2" />
|
||||
<el-option label="出厂调试" value="3" />
|
||||
<el-option label="正式投运" value="4" />
|
||||
</el-select>
|
||||
<el-tree
|
||||
:style="{
|
||||
height:
|
||||
treeType.length != 0
|
||||
? `calc(100vh - 380px - ${props.height}px)`
|
||||
: 'calc(100vh - 278px)'
|
||||
}"
|
||||
:style="{ height: governTreeHeight }"
|
||||
ref="treeRef1"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -79,27 +71,22 @@
|
||||
:data="zlDevList"
|
||||
style="overflow: auto"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0">
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length">
|
||||
<el-tree
|
||||
:style="{
|
||||
height:
|
||||
zlDeviceData.length != 0
|
||||
? `calc(100vh - 340px - ${props.height}px)`
|
||||
: 'calc(100vh - 238px)'
|
||||
}"
|
||||
:style="{ height: otherTreeHeight }"
|
||||
ref="treeRef2"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -110,27 +97,22 @@
|
||||
v-bind="$attrs"
|
||||
style="overflow: auto"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="监测设备" name="2" v-if="frontDeviceData.length != 0">
|
||||
<el-collapse-item title="监测设备" name="2" v-if="frontDeviceData.length">
|
||||
<el-tree
|
||||
:style="{
|
||||
height:
|
||||
zlDeviceData.length != 0
|
||||
? `calc(100vh - 340px - ${props.height}px)`
|
||||
: 'calc(100vh - 238px)'
|
||||
}"
|
||||
:style="{ height: otherTreeHeight }"
|
||||
ref="treeRef3"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -141,13 +123,13 @@
|
||||
v-bind="$attrs"
|
||||
style="overflow: auto"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
@@ -157,24 +139,24 @@
|
||||
</el-collapse>
|
||||
<div v-if="treeType == '2'" v-loading="loading">
|
||||
<el-tree
|
||||
:style="{ height: `calc(100vh - 188px - ${props.height}px )` }"
|
||||
:style="{ height: engineeringTreeHeight }"
|
||||
ref="treeRef4"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
:filter-node-method="filterNode"
|
||||
node-key="id"
|
||||
v-bind="$attrs"
|
||||
:data="data"
|
||||
:data="props.data"
|
||||
style="overflow: auto"
|
||||
:default-expand-all="false"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
@@ -187,273 +169,218 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { ref, watch, defineEmits, onMounted, nextTick } from 'vue'
|
||||
import { ElTree, type CollapseModelValue } from 'element-plus'
|
||||
import { ref, watch, onMounted, nextTick, computed } from 'vue'
|
||||
import { collectDeviceLeaves } from './govern/lineTreeUtils'
|
||||
import { collectDeviceApiLeaves } from './govern/deviceTreeUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
name: 'govern/tree',
|
||||
inheritAttrs: false
|
||||
})
|
||||
|
||||
const emit = defineEmits(['changeDeviceType', 'changeTreeType'])
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
canExpand?: boolean
|
||||
type?: string
|
||||
data?: any
|
||||
data?: any[]
|
||||
height?: number
|
||||
engineering: boolean
|
||||
engineering?: boolean
|
||||
/** line: getLineTree 四层叶子;device: getDeviceTree 三层叶子 */
|
||||
leafMode?: 'line' | 'device'
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true,
|
||||
type: '',
|
||||
data: [],
|
||||
data: () => [],
|
||||
height: 0,
|
||||
engineering: false
|
||||
engineering: false,
|
||||
leafMode: 'line'
|
||||
})
|
||||
|
||||
const treeType = ref('1')
|
||||
const options = [
|
||||
{
|
||||
label: '设备',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '工程',
|
||||
value: '2'
|
||||
}
|
||||
{ label: '设备', value: '1' },
|
||||
{ label: '工程', value: '2' }
|
||||
]
|
||||
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const activeName = ref('0')
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const process = ref('')
|
||||
//治理设备数据
|
||||
const zlDeviceData = ref([])
|
||||
const zlDevList = ref<any>([])
|
||||
//便携式设备数据
|
||||
const bxsDeviceData = ref([])
|
||||
//前置设备数据
|
||||
const frontDeviceData = ref([])
|
||||
watch(
|
||||
() => props.data,
|
||||
(val, oldVal) => {
|
||||
if (val && val.length != 0) {
|
||||
val.map((item: any) => {
|
||||
if (item.name == '治理设备') {
|
||||
const loading = ref(false)
|
||||
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
|
||||
const zlDeviceData = ref<any[]>([])
|
||||
const zlDevList = ref<any[]>([])
|
||||
const bxsDeviceData = ref<any[]>([])
|
||||
const frontDeviceData = ref<any[]>([])
|
||||
|
||||
const governTreeHeight = computed(() => `calc(100vh - 380px - ${props.height}px)`)
|
||||
const otherTreeHeight = computed(() =>
|
||||
zlDeviceData.value.length ? `calc(100vh - 340px - ${props.height}px)` : `calc(100vh - 238px - ${props.height}px)`
|
||||
)
|
||||
const engineeringTreeHeight = computed(() => `calc(100vh - 188px - ${props.height}px)`)
|
||||
|
||||
const treeRef1 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef2 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef3 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef4 = ref<InstanceType<typeof ElTree>>()
|
||||
|
||||
defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
|
||||
|
||||
function splitTreeData(val: any[]) {
|
||||
zlDeviceData.value = []
|
||||
item.children.map((vv: any) => {
|
||||
zlDeviceData.value.push(vv)
|
||||
})
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else if (item.name == '便携式设备') {
|
||||
bxsDeviceData.value = []
|
||||
item.children.map((vv: any) => {
|
||||
bxsDeviceData.value.push(vv)
|
||||
})
|
||||
} else if (item.name == '监测设备') {
|
||||
frontDeviceData.value = []
|
||||
|
||||
item.children.map((vv: any) => {
|
||||
frontDeviceData.value.push(vv)
|
||||
})
|
||||
val.forEach(item => {
|
||||
if (item.name === '治理设备') {
|
||||
zlDeviceData.value = item.children ?? []
|
||||
} else if (item.name === '便携式设备') {
|
||||
bxsDeviceData.value = item.children ?? []
|
||||
} else if (item.name === '监测设备') {
|
||||
frontDeviceData.value = item.children ?? []
|
||||
}
|
||||
})
|
||||
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
}
|
||||
|
||||
function filterProcess(nodes: any[]): any[] {
|
||||
if (!process.value) return nodes
|
||||
|
||||
return nodes
|
||||
.map(node => {
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
if (node.process == process.value || children.length > 0) {
|
||||
return { ...node, children }
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function getActiveTreeRef() {
|
||||
if (treeType.value === '2') return treeRef4.value
|
||||
if (activeName.value === '0') return treeRef1.value
|
||||
if (activeName.value === '1') return treeRef2.value
|
||||
return treeRef3.value
|
||||
}
|
||||
|
||||
function resolveActiveName() {
|
||||
if (zlDeviceData.value.length) return '0'
|
||||
if (bxsDeviceData.value.length) return '1'
|
||||
if (frontDeviceData.value.length) return '2'
|
||||
return ''
|
||||
}
|
||||
|
||||
function selectDevicePanel(panelName: string, node?: any) {
|
||||
if (!node) return
|
||||
emit('changeDeviceType', panelName, node)
|
||||
nextTick(() => {
|
||||
getActiveTreeRef()?.setCurrentKey(node.id)
|
||||
})
|
||||
}
|
||||
|
||||
const changeDevice = (val: CollapseModelValue) => {
|
||||
if (Array.isArray(val) || val == null || val === '') return
|
||||
const panelName = String(val)
|
||||
const collectLeaves = props.leafMode === 'device' ? collectDeviceApiLeaves : collectDeviceLeaves
|
||||
const { govern, portable, monitor } = collectLeaves(
|
||||
zlDevList.value,
|
||||
bxsDeviceData.value,
|
||||
frontDeviceData.value
|
||||
)
|
||||
|
||||
const panelMap: Record<string, { nodes: any[]; clearOthers: any[][] }> = {
|
||||
'0': { nodes: govern, clearOthers: [portable, monitor] },
|
||||
'1': { nodes: portable, clearOthers: [govern, monitor] },
|
||||
'2': { nodes: monitor, clearOthers: [govern, portable] }
|
||||
}
|
||||
|
||||
const panel = panelMap[panelName]
|
||||
if (!panel) return
|
||||
|
||||
panel.clearOthers.forEach(list => list.forEach(item => (item.checked = false)))
|
||||
selectDevicePanel(panelName, panel.nodes[0])
|
||||
}
|
||||
|
||||
const setActiveName = () => {
|
||||
activeName.value = resolveActiveName()
|
||||
if (activeName.value) {
|
||||
nextTick(() => changeDevice(activeName.value))
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.data,
|
||||
val => {
|
||||
if (!val?.length) return
|
||||
splitTreeData(val)
|
||||
if (treeType.value === '1') {
|
||||
nextTick(() => setActiveName())
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
watch(filterText, val => {
|
||||
if (treeType.value == '2') {
|
||||
treeRef4.value!.filter(val)
|
||||
} else if (activeName.value == '0') {
|
||||
treeRef1.value!.filter(val)
|
||||
} else if (activeName.value == '1') {
|
||||
treeRef2.value!.filter(val)
|
||||
} else {
|
||||
treeRef3.value!.filter(val)
|
||||
}
|
||||
getActiveTreeRef()?.filter(val)
|
||||
})
|
||||
watch(process, val => {
|
||||
if (val == '' || val == undefined) {
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
console.log('🚀 ~ zlDevList.value:', zlDeviceData.value)
|
||||
} else {
|
||||
|
||||
watch(process, () => {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
if (activeName.value === '0') {
|
||||
nextTick(() => changeDevice(activeName.value))
|
||||
}
|
||||
setTimeout(() => {
|
||||
changeDevice(activeName.value)
|
||||
}, 0)
|
||||
})
|
||||
function filterProcess(nodes: any) {
|
||||
if (process.value == '') {
|
||||
return nodes
|
||||
}
|
||||
return nodes
|
||||
.map(node => {
|
||||
// 递归处理子节点
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
|
||||
// 如果当前节点的process=4,或者有子节点满足条件,则保留当前节点
|
||||
if (node.process == process.value || children.length > 0) {
|
||||
return {
|
||||
...node,
|
||||
children: children
|
||||
}
|
||||
}
|
||||
|
||||
// 否则过滤掉当前节点
|
||||
return null
|
||||
})
|
||||
.filter(Boolean) // 移除null节点
|
||||
}
|
||||
const onMenuCollapse = () => {
|
||||
menuCollapse.value = !menuCollapse.value
|
||||
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
|
||||
}
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
|
||||
const filterNode = (value: string, data: any, node: any): boolean => {
|
||||
if (!value) return true
|
||||
// return data.name.includes(value)
|
||||
if (data.name) {
|
||||
if (!data.name) return false
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。name是中文字符,enName是英文字符.
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
const chooseNode = (value: string, data: any, node: any): boolean => {
|
||||
if (data.name.indexOf(value) !== -1) return true
|
||||
|
||||
const level = node.level
|
||||
// 如果传入的节点本身就是一级节点就不用校验了
|
||||
if (level === 1) {
|
||||
return false
|
||||
}
|
||||
// 先取当前节点的父节点
|
||||
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
|
||||
}
|
||||
// 否则的话再往上一层做匹配
|
||||
for (let i = 0; i < level - 1; i++) {
|
||||
if (parentData?.data?.name?.indexOf(value) !== -1) return true
|
||||
parentData = parentData.parent
|
||||
index++
|
||||
}
|
||||
// 没匹配到返回false
|
||||
return false
|
||||
}
|
||||
|
||||
const changeDevice = (val: any) => {
|
||||
let arr1: any = []
|
||||
|
||||
//zlDeviceData
|
||||
|
||||
zlDevList.value.forEach((item: any) => {
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.children.forEach((item3: any) => {
|
||||
arr1.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
let arr2: any = []
|
||||
bxsDeviceData.value.forEach((item: any) => {
|
||||
// item.children.forEach((item2: any) => {
|
||||
arr2.push(item)
|
||||
// })
|
||||
})
|
||||
let arr3: any = []
|
||||
frontDeviceData.value.forEach((item: any) => {
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.children.forEach((item3: any) => {
|
||||
arr3.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
if (val == '0') {
|
||||
arr2.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
|
||||
emit('changeDeviceType', activeName.value, arr1[0])
|
||||
setTimeout(() => {
|
||||
treeRef1.value?.setCurrentKey(arr1[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
if (val == '1') {
|
||||
arr1.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
emit('changeDeviceType', activeName.value, arr2[0])
|
||||
setTimeout(() => {
|
||||
treeRef2.value?.setCurrentKey(arr2[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
if (val == '2') {
|
||||
arr3.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
|
||||
emit('changeDeviceType', activeName.value, arr3[0])
|
||||
setTimeout(() => {
|
||||
treeRef3.value?.setCurrentKey(arr3[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
}
|
||||
//治理
|
||||
const treeRef1 = ref<InstanceType<typeof ElTree>>()
|
||||
//便携式
|
||||
const treeRef2 = ref<InstanceType<typeof ElTree>>()
|
||||
//前置
|
||||
const treeRef3 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef4 = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
|
||||
onMounted(() => {
|
||||
treeType.value = props.engineering ? '2' : '1'
|
||||
setTimeout(() => {
|
||||
setActiveName()
|
||||
}, 500)
|
||||
})
|
||||
|
||||
const setActiveName = () => {
|
||||
if (zlDeviceData.value.length != 0) {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
activeName.value = '0'
|
||||
}
|
||||
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length != 0) {
|
||||
activeName.value = '1'
|
||||
}
|
||||
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length === 0) {
|
||||
activeName.value = '2'
|
||||
}
|
||||
if (!zlDeviceData.value && !bxsDeviceData.value) {
|
||||
activeName.value = ''
|
||||
}
|
||||
nextTick(() => {
|
||||
changeDevice(activeName.value)
|
||||
})
|
||||
}
|
||||
const loading = ref(false)
|
||||
const changeTreeType = (val: string) => {
|
||||
loading.value = true
|
||||
emit('changeTreeType', val)
|
||||
if (val == '1') {
|
||||
setActiveName()
|
||||
if (val === '1') {
|
||||
nextTick(() => setActiveName())
|
||||
}
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 1000)
|
||||
}, 300)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
treeType.value = props.engineering ? '2' : '1'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@@ -486,4 +413,7 @@ const changeTreeType = (val: string) => {
|
||||
:deep(.el-input-group__prepend) {
|
||||
background-color: var(--el-fill-color-blank);
|
||||
}
|
||||
:deep(.is-disabled) {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
205
src/components/tree/govern/analyzeTree.vue
Normal file
205
src/components/tree/govern/analyzeTree.vue
Normal file
@@ -0,0 +1,205 @@
|
||||
<template>
|
||||
|
||||
<Tree ref="treRef" @check="handleCheck" @check-change="handleCheckChange" :default-checked-keys="defaultCheckedKeys" check-strictly
|
||||
:show-checkbox="props.showCheckbox" :data="tree" :height="props.height" @changeDeviceType="changeDeviceType"
|
||||
@changeTreeType="loadTree" :engineering="props.engineering" />
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<script lang="ts" setup>
|
||||
|
||||
import { ref, nextTick, onMounted } from 'vue'
|
||||
|
||||
import Tree from '../device.vue'
|
||||
|
||||
import { getLineTree } from '@/api/cs-device-boot/csLedger'
|
||||
|
||||
import { useConfig } from '@/stores/config'
|
||||
|
||||
import {
|
||||
|
||||
createLineTreeDecorators,
|
||||
|
||||
decorateLineTree,
|
||||
|
||||
type LineTreeLeaves
|
||||
|
||||
} from './lineTreeUtils'
|
||||
|
||||
|
||||
|
||||
defineOptions({
|
||||
|
||||
name: 'govern/analyzeTree'
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
const props = withDefaults(
|
||||
|
||||
defineProps<{
|
||||
|
||||
showCheckbox?: boolean
|
||||
|
||||
defaultCheckedKeys?: any
|
||||
|
||||
height?: number
|
||||
|
||||
engineering?: boolean
|
||||
|
||||
}>(),
|
||||
|
||||
{
|
||||
|
||||
showCheckbox: false,
|
||||
|
||||
defaultCheckedKeys: () => [],
|
||||
|
||||
height: 0,
|
||||
|
||||
engineering: false
|
||||
|
||||
}
|
||||
|
||||
)
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'check', 'deviceTypeChange'])
|
||||
|
||||
|
||||
|
||||
const config = useConfig()
|
||||
|
||||
const tree = ref<any[]>([])
|
||||
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
|
||||
|
||||
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
|
||||
|
||||
const changeDeviceType = (val: any, obj: any) => {
|
||||
|
||||
emit('deviceTypeChange', val, obj)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
type TreeRefKey = 'treeRef1' | 'treeRef2' | 'treeRef3' | 'treeRef4'
|
||||
|
||||
|
||||
|
||||
async function waitForTreeRef(refKey: TreeRefKey, maxRetries = 20) {
|
||||
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
|
||||
await nextTick()
|
||||
|
||||
if (treRef.value?.[refKey]) return treRef.value[refKey]
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function selectInitialNode(
|
||||
|
||||
type: string | undefined,
|
||||
|
||||
leaves: LineTreeLeaves
|
||||
|
||||
) {
|
||||
|
||||
const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
|
||||
|
||||
type === '2'
|
||||
|
||||
? [{ refKey: 'treeRef4', list: leaves.engineering, level: 3 }]
|
||||
|
||||
: [
|
||||
|
||||
{ refKey: 'treeRef1', list: leaves.govern, level: 2 },
|
||||
|
||||
{ refKey: 'treeRef2', list: leaves.portable, level: 2 },
|
||||
|
||||
{ refKey: 'treeRef3', list: leaves.monitor, level: 2 }
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
for (const { refKey, list, level } of candidates) {
|
||||
|
||||
const node = list[0]
|
||||
|
||||
if (!node) continue
|
||||
|
||||
|
||||
|
||||
const treeInstance = await waitForTreeRef(refKey)
|
||||
|
||||
treeInstance?.setCurrentKey(node.id)
|
||||
|
||||
emit('init', { ...node })
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
emit('init')
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
const loadTree = (type?: string) => {
|
||||
|
||||
getLineTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
|
||||
|
||||
const leaves = decorateLineTree(res.data, type, decorators)
|
||||
|
||||
tree.value = res.data
|
||||
|
||||
selectInitialNode(type, leaves)
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
loadTree(props.engineering ? '2' : '1')
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
const handleCheck = (data: any, state: any) => {
|
||||
emit('check', data, state)
|
||||
}
|
||||
|
||||
const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
|
||||
emit('checkChange', { data, checked, indeterminate })
|
||||
}
|
||||
|
||||
|
||||
|
||||
defineExpose({ treRef })
|
||||
|
||||
</script>
|
||||
@@ -11,102 +11,71 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { getLineTree, getCldTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { getCldTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { decorateCloudTree } from './deviceTreeUtils'
|
||||
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
showPush?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false,
|
||||
showPush: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
defineOptions({ name: 'govern/cloudDeviceEntryTree' })
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const width = ref('')
|
||||
|
||||
const info = (selectedNodeId?: string) => {
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
const changePointType = (_val: any, obj: any) => {
|
||||
emit('pointTypeChange', _val, obj)
|
||||
}
|
||||
|
||||
const onAdd = () => emit('onAdd')
|
||||
|
||||
async function loadTree() {
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
getCldTree().then(res => {
|
||||
res.data.icon = 'el-icon-Menu'
|
||||
res.data.color = config.getColorVal('elementUiPrimary')
|
||||
res.data?.children.map((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-List'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
// item2.icon = 'el-icon-List'
|
||||
// item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.level = 2
|
||||
item2.color = item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr1.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
const res = await getCldTree()
|
||||
const leaves = decorateCloudTree(res.data, decorators)
|
||||
tree.value = [res.data]
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
//初始化选中
|
||||
|
||||
treRef.value?.treeRef.setCurrentKey(arr1[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 3,
|
||||
...arr1[0]
|
||||
})
|
||||
changePointType('4', arr1[0])
|
||||
const node = leaves[0]
|
||||
if (!node) {
|
||||
emit('init')
|
||||
return
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
await selectTreeNode(treRef.value, node, {
|
||||
level: 3,
|
||||
onSelect: selected => {
|
||||
emit('init', { ...selected, level: 3 })
|
||||
changePointType('4', selected)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
// emit('pointTypeChange', val, obj)
|
||||
}
|
||||
bootstrapWithTemplate(
|
||||
props.template,
|
||||
loadTree,
|
||||
() => querySysExcel({ id: dictData.state.area[0]?.id }),
|
||||
data => emit('Policy', data)
|
||||
)
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
if (props.template) {
|
||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
info()
|
||||
})
|
||||
.catch(err => {
|
||||
info()
|
||||
})
|
||||
} else {
|
||||
info()
|
||||
}
|
||||
|
||||
// 暴露 info 方法给父组件调用
|
||||
defineExpose({
|
||||
info
|
||||
})
|
||||
|
||||
onMounted(() => {})
|
||||
defineExpose({ info: loadTree })
|
||||
</script>
|
||||
|
||||
@@ -1,106 +1,70 @@
|
||||
<template>
|
||||
<Tree
|
||||
ref="treRef"
|
||||
:width="width"
|
||||
:showPush="props.showPush"
|
||||
:data="tree"
|
||||
default-expand-all
|
||||
@changePointType="changePointType"
|
||||
@onAdd="onAdd"
|
||||
/>
|
||||
|
||||
<Tree ref="treRef" :width="width" :height="height" :showPush="props.showPush" :data="tree" default-expand-all
|
||||
@changePointType="changePointType" @onAdd="onAdd" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { getLineTree, objTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { objTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { decorateObjTree } from './deviceTreeUtils'
|
||||
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
showPush?: boolean
|
||||
height?: number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false,
|
||||
showPush: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
showPush: false,
|
||||
height: 0
|
||||
})
|
||||
|
||||
defineOptions({ name: 'govern/cloudDeviceEntryTreeZL' })
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const width = ref('')
|
||||
|
||||
const info = (selectedNodeId?: string) => {
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
const changePointType = (val: any, obj: any) => emit('pointTypeChange', val, obj)
|
||||
const onAdd = () => emit('onAdd')
|
||||
|
||||
async function loadTree() {
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
objTree().then(res => {
|
||||
try {
|
||||
res.data.map((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.level = 1
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-List'
|
||||
item.level = 2
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
arr1.push(item2)
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.level = 3
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
})
|
||||
})
|
||||
})
|
||||
const res = await objTree()
|
||||
const leaves = decorateObjTree(res.data, decorators)
|
||||
tree.value = res.data
|
||||
nextTick(() => {
|
||||
if (arr1.length) {
|
||||
//初始化选中
|
||||
treRef.value.treeRef.setCurrentKey(arr1[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', arr1[0])
|
||||
return
|
||||
} else {
|
||||
|
||||
const node = leaves[0]
|
||||
if (!node) {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error in processing getCldTree response:', error)
|
||||
}
|
||||
|
||||
await selectTreeNode(treRef.value, node, {
|
||||
onSelect: selected => emit('init', selected)
|
||||
})
|
||||
}
|
||||
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
emit('pointTypeChange', val, obj)
|
||||
}
|
||||
bootstrapWithTemplate(
|
||||
props.template,
|
||||
loadTree,
|
||||
() => querySysExcel({ id: dictData.state.area[0]?.id }),
|
||||
data => emit('Policy', data)
|
||||
)
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
if (props.template) {
|
||||
querySysExcel({ id: dictData.state.area[0]?.id })
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
info()
|
||||
})
|
||||
.catch(err => {
|
||||
info()
|
||||
})
|
||||
} else {
|
||||
info()
|
||||
}
|
||||
|
||||
// 暴露 info 方法给父组件调用
|
||||
defineExpose({
|
||||
info
|
||||
})
|
||||
|
||||
onMounted(() => {})
|
||||
defineExpose({ info: loadTree })
|
||||
</script>
|
||||
|
||||
@@ -11,177 +11,70 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { getLineTree, lineTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { lineTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { decorateLedgerLineTree, resolveMonitorRoot } from './deviceTreeUtils'
|
||||
import { bootstrapWithTemplate, findNodeById, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
showPush?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false,
|
||||
showPush: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
defineOptions({ name: 'govern/csLedgerLineTree' })
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy', 'onAdd'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const width = ref('')
|
||||
|
||||
const info = (selectedNodeId?: string) => {
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
const changePointType = (val: any, obj: any) => emit('pointTypeChange', val, obj)
|
||||
const onAdd = () => emit('onAdd')
|
||||
|
||||
async function loadTree(selectedNodeId?: string) {
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
lineTree().then(res => {
|
||||
try {
|
||||
// 检查响应数据结构
|
||||
let rootData = null
|
||||
if (Array.isArray(res.data)) {
|
||||
// 旧的数据结构 - 数组
|
||||
rootData = res.data.find((item: any) => item.name == '监测设备')
|
||||
} else if (res.data && res.data.name == '监测设备') {
|
||||
// 新的数据结构 - 单个对象
|
||||
rootData = res.data
|
||||
const res = await lineTree()
|
||||
const rootData = resolveMonitorRoot(res.data)
|
||||
const leaves = decorateLedgerLineTree(rootData, decorators)
|
||||
tree.value = rootData ? [rootData] : []
|
||||
|
||||
if (!leaves.length) {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
|
||||
// 治理设备
|
||||
if (rootData) {
|
||||
rootData.icon = 'el-icon-Menu'
|
||||
rootData.level = 0
|
||||
rootData.color = config.getColorVal('elementUiPrimary')
|
||||
// 确保根节点的 children 是数组
|
||||
if (!Array.isArray(rootData.children)) {
|
||||
rootData.children = []
|
||||
}
|
||||
rootData.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.level = 1
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item.children)) {
|
||||
item.children = []
|
||||
}
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.level = 2
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
const targetNode = selectedNodeId
|
||||
? findNodeById(tree.value, selectedNodeId) ?? leaves[0]
|
||||
: leaves[0]
|
||||
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item2.children)) {
|
||||
item2.children = []
|
||||
}
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 3
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
|
||||
// 确保 children 是数组
|
||||
if (!Array.isArray(item3.children)) {
|
||||
item3.children = []
|
||||
}
|
||||
|
||||
item3.children.forEach((item4: any) => {
|
||||
item4.icon = 'el-icon-Platform'
|
||||
item4.level = 4
|
||||
item4.color =
|
||||
item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr1.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
tree.value = [rootData] // 确保 tree.value 是数组
|
||||
} else {
|
||||
tree.value = []
|
||||
}
|
||||
nextTick(() => {
|
||||
if (arr1.length) {
|
||||
// 安全检查 treRef 和 treeRef 是否存在
|
||||
console.log(
|
||||
'🚀 ~ info ~ treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey:',
|
||||
treRef.value && treRef.value.treeRef1 && treRef.value.treeRef1.setCurrentKey
|
||||
)
|
||||
|
||||
if (treRef.value && treRef.value.treeRef && treRef.value.treeRef.setCurrentKey) {
|
||||
// 如果传入了要选中的节点ID,则选中该节点,否则选中第一个节点
|
||||
console.log('selectedNodeId:', selectedNodeId)
|
||||
if (selectedNodeId) {
|
||||
treRef.value.treeRef.setCurrentKey(selectedNodeId)
|
||||
// 查找对应的节点数据并触发事件
|
||||
let selectedNode = null
|
||||
const findNode = (nodes: any[]) => {
|
||||
for (const node of nodes) {
|
||||
if (node.id === selectedNodeId) {
|
||||
selectedNode = node
|
||||
return true
|
||||
}
|
||||
if (node.children && findNode(node.children)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
findNode(tree.value)
|
||||
|
||||
if (selectedNode) {
|
||||
await selectTreeNode(treRef.value, targetNode, {
|
||||
onSelect: selected =>
|
||||
emit('init', {
|
||||
level: selectedNode.level,
|
||||
...selectedNode
|
||||
level: selected.level ?? 2,
|
||||
...selected
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// 初始化选中第一个节点
|
||||
treRef.value.treeRef.setCurrentKey(arr1[0].id)
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr1[0]
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error in processing getCldTree response:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
emit('pointTypeChange', val, obj)
|
||||
}
|
||||
bootstrapWithTemplate(
|
||||
props.template,
|
||||
() => loadTree(),
|
||||
() => querySysExcel({}),
|
||||
data => emit('Policy', data)
|
||||
)
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
if (props.template) {
|
||||
// id: dictData.state.area[0]?.id
|
||||
querySysExcel({})
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
info()
|
||||
})
|
||||
.catch(err => {
|
||||
info()
|
||||
})
|
||||
} else {
|
||||
info()
|
||||
}
|
||||
|
||||
// 暴露 info 方法给父组件调用
|
||||
defineExpose({
|
||||
info
|
||||
})
|
||||
|
||||
onMounted(() => {})
|
||||
defineExpose({ info: loadTree })
|
||||
</script>
|
||||
|
||||
@@ -9,99 +9,56 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineProps } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import Tree from '../index.vue'
|
||||
import { getDeviceTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { decorateDeviceInfoTree } from './deviceTreeUtils'
|
||||
import { selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
defineOptions({ name: 'govern/deviceInfoTree' })
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
showCheckbox?: boolean
|
||||
defaultCheckedKeys?: any
|
||||
defaultCheckedKeys?: any[]
|
||||
}>(),
|
||||
{
|
||||
showCheckbox: false,
|
||||
defaultCheckedKeys: []
|
||||
defaultCheckedKeys: () => []
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
getDeviceTree().then(res => {
|
||||
return
|
||||
let arr: any[] = []
|
||||
res.data.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.color = config.getColorVal('elementUiPrimary')
|
||||
if (item3.comFlag === 1) {
|
||||
item3.color = '#e26257 !important'
|
||||
}
|
||||
arr.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
tree.value = res.data
|
||||
nextTick(() => {
|
||||
if (arr.length) {
|
||||
treRef.value.treeRef.setCurrentKey(arr[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr[0]
|
||||
})
|
||||
} else {
|
||||
emit('init')
|
||||
}
|
||||
})
|
||||
})
|
||||
const getTreeList = (list: any) => {
|
||||
let arr: any[] = []
|
||||
list.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children?.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.color = config.getColorVal('elementUiPrimary')
|
||||
if (item3.comFlag === 1) {
|
||||
item3.color = '#e26257 !important'
|
||||
item3.color = item3.comFlag == 3 ? '#e26257 !important' : config.getColorVal('elementUiPrimary')
|
||||
}
|
||||
arr.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
async function initTree(list: any[]) {
|
||||
const leaves = decorateDeviceInfoTree(list, decorators)
|
||||
tree.value = list
|
||||
nextTick(() => {
|
||||
if (arr.length) {
|
||||
treRef.value.treeRef.setCurrentKey(arr[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr[0]
|
||||
})
|
||||
} else {
|
||||
|
||||
const node = leaves[0]
|
||||
if (!node) {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
|
||||
await selectTreeNode(treRef.value, node, {
|
||||
onSelect: selected => emit('init', { ...selected, level: 2 })
|
||||
})
|
||||
}
|
||||
//接收tree选择的数据后传递给父级组件
|
||||
|
||||
getDeviceTree().then(res => initTree(res.data))
|
||||
|
||||
const getTreeList = (list: any[]) => initTree(list)
|
||||
|
||||
const handleCheckChange = (data: any) => {
|
||||
emit('checkChange', {
|
||||
data
|
||||
})
|
||||
emit('checkChange', { data })
|
||||
}
|
||||
|
||||
defineExpose({ getTreeList })
|
||||
</script>
|
||||
|
||||
@@ -1,216 +1,81 @@
|
||||
<template>
|
||||
<Tree
|
||||
ref="treRef"
|
||||
@check-change="handleCheckChange"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
:show-checkbox="props.showCheckbox"
|
||||
:data="tree"
|
||||
:height="props.height"
|
||||
@changeDeviceType="changeDeviceType"
|
||||
@changeTreeType="info"
|
||||
:engineering="props.engineering"
|
||||
/>
|
||||
<Tree ref="treRef" @check-change="handleCheckChange" :default-checked-keys="defaultCheckedKeys"
|
||||
:show-checkbox="props.showCheckbox" :data="tree" :height="props.height" @changeDeviceType="changeDeviceType"
|
||||
@changeTreeType="loadTree" :engineering="props.engineering" leaf-mode="device" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { throttle } from 'lodash'
|
||||
import Tree from '../device.vue'
|
||||
import { getDeviceTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { throttle } from 'lodash'
|
||||
import { waitForTreeRef, type TreeRefKey } from './lineTreeUtils'
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { decorateDeviceTree } from './deviceTreeUtils'
|
||||
import type { LineTreeLeaves } from './lineTreeUtils'
|
||||
|
||||
defineOptions({ name: 'govern/deviceTree' })
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
showCheckbox?: boolean
|
||||
defaultCheckedKeys?: any
|
||||
defaultCheckedKeys?: any[]
|
||||
height?: number
|
||||
engineering?: boolean
|
||||
}>(),
|
||||
{
|
||||
showCheckbox: false,
|
||||
defaultCheckedKeys: [],
|
||||
defaultCheckedKeys: () => [],
|
||||
height: 0,
|
||||
engineering: false
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'deviceTypeChange'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
const changeDeviceType = (val: any, obj: any) => {
|
||||
emit('deviceTypeChange', val, obj)
|
||||
}
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
const info = (type?: string) => {
|
||||
getDeviceTree({ type: type == '2' ? 'engineering' : '' }).then(res => {
|
||||
let arr: any[] = []
|
||||
let arr2: any[] = []
|
||||
let arr3: any[] = []
|
||||
let arr4: any[] = []
|
||||
//治理设备
|
||||
res.data.map((item: any) => {
|
||||
if (type == '2') {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-List'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.color =
|
||||
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr4.push(item2)
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (item.name == '治理设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.pName = '治理设备'
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 2
|
||||
item3.color = config.getColorVal('elementUiPrimary')
|
||||
if (item3.comFlag === 1) {
|
||||
item3.color = '#e26257 !important'
|
||||
}
|
||||
arr.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (item.name == '便携式设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-Platform'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.color = '#e26257 !important'
|
||||
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
// item.disabled =true
|
||||
item.pName = '便携式设备'
|
||||
if (item.type == 'device') {
|
||||
arr2.push(item)
|
||||
}
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.color =
|
||||
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item2.pName = '便携式设备'
|
||||
// item2.children.forEach((item3: any) => {
|
||||
// item3.icon = 'el-icon-Platform'
|
||||
// item3.color = config.getColorVal('elementUiPrimary')
|
||||
// if (item3.comFlag === 1) {
|
||||
// item3.color = '#e26257 !important'
|
||||
// }
|
||||
// arr.push(item3)
|
||||
// })
|
||||
})
|
||||
})
|
||||
} else if (item.name == '监测设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.pName = '监测设备'
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.color = config.getColorVal('elementUiPrimary')
|
||||
if (item3.comFlag === 1) {
|
||||
item3.color = '#e26257 !important'
|
||||
}
|
||||
arr3.push(item3)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
tree.value = res.data
|
||||
const changeDeviceType = (val: any, obj: any) => emit('deviceTypeChange', val, obj)
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
if (type == '2') {
|
||||
//初始化选中
|
||||
async function selectInitialNode(type: string | undefined, leaves: LineTreeLeaves) {
|
||||
const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
|
||||
type === '2'
|
||||
? [{ refKey: 'treeRef4', list: leaves.engineering, level: 2 }]
|
||||
: [
|
||||
{ refKey: 'treeRef1', list: leaves.govern, level: 2 },
|
||||
{ refKey: 'treeRef2', list: leaves.portable, level: 2 },
|
||||
{ refKey: 'treeRef3', list: leaves.monitor, level: 2 }
|
||||
]
|
||||
|
||||
treRef.value?.treeRef4.setCurrentKey(arr4[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr4[0]
|
||||
})
|
||||
// changePointType('4', arr4[0])
|
||||
for (const { refKey, list, level } of candidates) {
|
||||
const node = list[0]
|
||||
if (!node) continue
|
||||
const treeInstance = await waitForTreeRef(treRef.value, refKey)
|
||||
treeInstance?.setCurrentKey(node.id)
|
||||
emit('init', { ...node })
|
||||
return
|
||||
}
|
||||
if (arr.length > 0) {
|
||||
treRef.value.treeRef1.setCurrentKey(arr[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr[0]
|
||||
})
|
||||
return
|
||||
} else if (arr2.length > 0) {
|
||||
treRef.value.treeRef2.setCurrentKey(arr2[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr2[0]
|
||||
})
|
||||
return
|
||||
} else if (arr3.length > 0) {
|
||||
console.log('🚀 ~ arr3:', arr3)
|
||||
|
||||
treRef.value.treeRef3.setCurrentKey(arr3[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr3[0]
|
||||
})
|
||||
return
|
||||
} else {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
}
|
||||
|
||||
const loadTree = (type?: string) => {
|
||||
getDeviceTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
|
||||
const leaves = decorateDeviceTree(res.data, type, decorators)
|
||||
tree.value = res.data
|
||||
selectInitialNode(type, leaves)
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
info(props.engineering ? '2' : '1')
|
||||
})
|
||||
onMounted(() => loadTree(props.engineering ? '2' : '1'))
|
||||
|
||||
throttle(
|
||||
const handleCheckChange =
|
||||
(data: any, checked: any, indeterminate: any) => {
|
||||
emit('checkChange', {
|
||||
data,
|
||||
checked,
|
||||
indeterminate
|
||||
})
|
||||
},
|
||||
300,
|
||||
{
|
||||
leading: true, // 首次触发立即执行(可选,默认 true)
|
||||
trailing: false // 节流结束后是否执行最后一次(可选,默认 true,根据需求调整)
|
||||
emit('checkChange', { data, checked, indeterminate })
|
||||
}
|
||||
)
|
||||
|
||||
const handleCheckChange = (data: any, checked: any, indeterminate: any) => {
|
||||
emit('checkChange', {
|
||||
data,
|
||||
checked,
|
||||
indeterminate
|
||||
})
|
||||
}
|
||||
defineExpose({
|
||||
treRef
|
||||
})
|
||||
defineExpose({ treRef })
|
||||
</script>
|
||||
|
||||
224
src/components/tree/govern/deviceTreeUtils.ts
Normal file
224
src/components/tree/govern/deviceTreeUtils.ts
Normal file
@@ -0,0 +1,224 @@
|
||||
import type { LineTreeDecorators, LineTreeLeaves } from './lineTreeUtils'
|
||||
|
||||
/** getDeviceTree 接口专用装饰(与 getLineTree 层级不同) */
|
||||
export function decorateDeviceTree(
|
||||
data: any[],
|
||||
type: string | undefined,
|
||||
decorators: LineTreeDecorators
|
||||
): LineTreeLeaves {
|
||||
const leaves: LineTreeLeaves = { govern: [], portable: [], monitor: [], engineering: [] }
|
||||
const { primary, statusColor, applyMeta } = decorators
|
||||
|
||||
data.forEach(item => {
|
||||
if (type === '2') {
|
||||
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary() })
|
||||
item.children?.forEach((child: any) => {
|
||||
applyMeta(child, { icon: 'el-icon-List', color: primary() })
|
||||
child.children?.forEach((grand: any) => {
|
||||
applyMeta(grand, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(grand.comFlag),
|
||||
level: 3
|
||||
})
|
||||
leaves.engineering.push(grand)
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (item.name === '治理设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
l3.pName = '治理设备'
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
level: 2,
|
||||
color: l3.comFlag === 1 ? '#e26257 !important' : primary()
|
||||
})
|
||||
leaves.govern.push(l3)
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (item.name === '便携式设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l1.comFlag)
|
||||
})
|
||||
l1.pName = '便携式设备'
|
||||
if (l1.type === 'device') {
|
||||
leaves.portable.push(l1)
|
||||
}
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l2.comFlag)
|
||||
})
|
||||
l2.pName = '便携式设备'
|
||||
})
|
||||
})
|
||||
} else if (item.name === '监测设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
l3.pName = '监测设备'
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
level: 3,
|
||||
color: l3.comFlag === 1 ? '#e26257 !important' : primary()
|
||||
})
|
||||
leaves.monitor.push(l3)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** 装饰 getDeviceTree 扁平列表(deviceInfoTree) */
|
||||
export function decorateDeviceInfoTree(list: any[], decorators: LineTreeDecorators): any[] {
|
||||
const { primary, applyMeta } = decorators
|
||||
const leaves: any[] = []
|
||||
|
||||
list.forEach(item => {
|
||||
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary() })
|
||||
item.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: l3.comFlag === 1 || l3.comFlag === 3 ? '#e26257 !important' : primary()
|
||||
})
|
||||
leaves.push(l3)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** 装饰云端设备树 getCldTree */
|
||||
export function decorateCloudTree(root: any, decorators: LineTreeDecorators): any[] {
|
||||
const { primary, statusColor, applyMeta } = decorators
|
||||
const leaves: any[] = []
|
||||
|
||||
applyMeta(root, { icon: 'el-icon-Menu', color: primary() })
|
||||
root.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary() })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary() })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
level: 2,
|
||||
color: statusColor(l3.comFlag)
|
||||
})
|
||||
leaves.push(l3)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** 装饰 objTree(治理对象树) */
|
||||
export function decorateObjTree(data: any[], decorators: LineTreeDecorators): any[] {
|
||||
const { primary, applyMeta } = decorators
|
||||
const leaves: any[] = []
|
||||
|
||||
data.forEach(l1 => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1 })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 2 })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
applyMeta(l3, { icon: 'el-icon-Platform', color: primary(), level: 3 })
|
||||
leaves.push(l3)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** 装饰 lineTree 台账线路树(监测设备根节点) */
|
||||
export function decorateLedgerLineTree(root: any, decorators: LineTreeDecorators): any[] {
|
||||
const { primary, statusColor, applyMeta } = decorators
|
||||
const leaves: any[] = []
|
||||
|
||||
if (!root) return leaves
|
||||
|
||||
applyMeta(root, { icon: 'el-icon-Menu', color: primary(), level: 0 })
|
||||
if (!Array.isArray(root.children)) root.children = []
|
||||
|
||||
root.children.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1 })
|
||||
if (!Array.isArray(l1.children)) l1.children = []
|
||||
l1.children.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 2 })
|
||||
if (!Array.isArray(l2.children)) l2.children = []
|
||||
l2.children.forEach((l3: any) => {
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l3.comFlag),
|
||||
level: 3
|
||||
})
|
||||
if (!Array.isArray(l3.children)) l3.children = []
|
||||
l3.children.forEach((l4: any) => {
|
||||
applyMeta(l4, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l4.comFlag),
|
||||
level: 4
|
||||
})
|
||||
leaves.push(l4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** getDeviceTree 接口叶子收集(3 层结构,便携式为 type=device 节点) */
|
||||
export function collectDeviceApiLeaves(
|
||||
governNodes: any[],
|
||||
portableNodes: any[],
|
||||
monitorNodes: any[]
|
||||
): { govern: any[]; portable: any[]; monitor: any[] } {
|
||||
const govern: any[] = []
|
||||
const portable: any[] = []
|
||||
const monitor: any[] = []
|
||||
|
||||
governNodes.forEach(l1 => {
|
||||
l1.children?.forEach((l2: any) => {
|
||||
l2.children?.forEach((l3: any) => govern.push(l3))
|
||||
})
|
||||
})
|
||||
|
||||
portableNodes.forEach(l1 => {
|
||||
if (l1.type === 'device') portable.push(l1)
|
||||
})
|
||||
|
||||
monitorNodes.forEach(l1 => {
|
||||
l1.children?.forEach((l2: any) => {
|
||||
l2.children?.forEach((l3: any) => monitor.push(l3))
|
||||
})
|
||||
})
|
||||
|
||||
return { govern, portable, monitor }
|
||||
}
|
||||
|
||||
/** 从 lineTree 数据中解析监测设备根节点 */
|
||||
export function resolveMonitorRoot(data: any): any | null {
|
||||
if (Array.isArray(data)) {
|
||||
return data.find(item => item.name === '监测设备') ?? null
|
||||
}
|
||||
if (data?.name === '监测设备') return data
|
||||
return null
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :data="tree" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { getMarketList } from '@/api/user-boot/user'
|
||||
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()
|
||||
import { mapUserTreeNodes, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const emit = defineEmits(['selectUser'])
|
||||
getMarketList().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)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
async function loadTree() {
|
||||
const res: any = await getMarketList()
|
||||
if (res.code !== 'A0000') return
|
||||
|
||||
tree.value = mapUserTreeNodes(res.data)
|
||||
const first = tree.value[0]
|
||||
if (!first) return
|
||||
|
||||
emit('selectUser', first)
|
||||
await selectTreeNode(treRef.value, first)
|
||||
}
|
||||
|
||||
loadTree()
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
203
src/components/tree/govern/lineTreeUtils.ts
Normal file
203
src/components/tree/govern/lineTreeUtils.ts
Normal file
@@ -0,0 +1,203 @@
|
||||
import { nextTick } from 'vue'
|
||||
|
||||
export interface LineTreeLeaves {
|
||||
govern: any[]
|
||||
portable: any[]
|
||||
monitor: any[]
|
||||
engineering: any[]
|
||||
}
|
||||
|
||||
export interface LineTreeDecorators {
|
||||
primary: () => string
|
||||
statusColor: (comFlag: number) => string
|
||||
applyMeta: (
|
||||
node: any,
|
||||
meta: { icon: string; color?: string; level?: number; disabled?: boolean }
|
||||
) => void
|
||||
}
|
||||
|
||||
export function createLineTreeDecorators(getPrimaryColor: () => string): LineTreeDecorators {
|
||||
const offlineColor = '#e26257 !important'
|
||||
const statusColor = (comFlag: number) => (comFlag === 2 ? getPrimaryColor() : offlineColor)
|
||||
|
||||
const applyMeta = (
|
||||
node: any,
|
||||
meta: { icon: string; color?: string; level?: number; disabled?: boolean }
|
||||
) => {
|
||||
node.icon = meta.icon
|
||||
if (meta.color !== undefined) node.color = meta.color
|
||||
if (meta.level !== undefined) node.level = meta.level
|
||||
if (meta.disabled) node.disabled = true
|
||||
}
|
||||
|
||||
return {
|
||||
primary: getPrimaryColor,
|
||||
statusColor,
|
||||
applyMeta
|
||||
}
|
||||
}
|
||||
|
||||
export type TreeRefKey = 'treeRef1' | 'treeRef2' | 'treeRef3' | 'treeRef4'
|
||||
|
||||
/** 线路树可选叶子节点元数据 */
|
||||
export const LINE_LEAF_META = { level: 3, type: 'line' as const }
|
||||
|
||||
/** 是否为线路树可选叶子(监测点/线路) */
|
||||
export function isLineTreeLeaf(node: any): boolean {
|
||||
if (!node?.id) return false
|
||||
return node.type === 'line' || node.level === 3
|
||||
}
|
||||
|
||||
/** 是否为报告/导出可选监测点 */
|
||||
export function isReportMonitorPoint(node: any): boolean {
|
||||
if (!node?.id) return false
|
||||
return isLineTreeLeaf(node) || node.level === 3 || (!node.children?.length && !!node.pid)
|
||||
}
|
||||
|
||||
export interface DecorateLineTreeOptions {
|
||||
/** 是否禁用父级节点(分析树隐藏父节点,测点树不禁用) */
|
||||
disableParents?: boolean
|
||||
}
|
||||
|
||||
/** 装饰线路树节点并收集可选叶子节点 */
|
||||
export function decorateLineTree(
|
||||
data: any[],
|
||||
type: string | undefined,
|
||||
decorators: LineTreeDecorators,
|
||||
options: DecorateLineTreeOptions = {}
|
||||
): LineTreeLeaves {
|
||||
const leaves: LineTreeLeaves = { govern: [], portable: [], monitor: [], engineering: [] }
|
||||
const { primary, statusColor, applyMeta } = decorators
|
||||
const disableParents = options.disableParents ?? true
|
||||
const parentDisabled = disableParents ? ({ disabled: true } as const) : {}
|
||||
|
||||
data.forEach(item => {
|
||||
if (type === '2') {
|
||||
applyMeta(item, { icon: 'el-icon-HomeFilled', color: primary(), ...parentDisabled })
|
||||
item.children?.forEach((child: any) => {
|
||||
applyMeta(child, { icon: 'el-icon-List', color: primary(), ...parentDisabled })
|
||||
child.children?.forEach((grand: any) => {
|
||||
applyMeta(grand, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(grand.comFlag),
|
||||
level: 2,
|
||||
...parentDisabled
|
||||
})
|
||||
grand.children?.forEach((leaf: any) => {
|
||||
applyMeta(leaf, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(leaf.comFlag),
|
||||
...LINE_LEAF_META
|
||||
})
|
||||
leaves.engineering.push(leaf)
|
||||
})
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (item.name === '治理设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1, ...parentDisabled })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 1, ...parentDisabled })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l3.comFlag),
|
||||
level: 2,
|
||||
...parentDisabled
|
||||
})
|
||||
l3.children?.forEach((l4: any) => {
|
||||
applyMeta(l4, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l4.comFlag),
|
||||
...LINE_LEAF_META
|
||||
})
|
||||
leaves.govern.push(l4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (item.name === '便携式设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-Platform', color: statusColor(l1.comFlag) })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l2.comFlag),
|
||||
...LINE_LEAF_META
|
||||
})
|
||||
leaves.portable.push(l2)
|
||||
})
|
||||
})
|
||||
} else if (item.name === '监测设备') {
|
||||
item.children?.forEach((l1: any) => {
|
||||
applyMeta(l1, { icon: 'el-icon-HomeFilled', color: primary(), level: 1, ...parentDisabled })
|
||||
l1.children?.forEach((l2: any) => {
|
||||
applyMeta(l2, { icon: 'el-icon-List', color: primary(), level: 1, ...parentDisabled })
|
||||
l2.children?.forEach((l3: any) => {
|
||||
applyMeta(l3, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l3.comFlag),
|
||||
level: 1,
|
||||
...parentDisabled
|
||||
})
|
||||
l3.children?.forEach((l4: any) => {
|
||||
applyMeta(l4, {
|
||||
icon: 'el-icon-Platform',
|
||||
color: statusColor(l4.comFlag),
|
||||
...LINE_LEAF_META
|
||||
})
|
||||
leaves.monitor.push(l4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
/** 从折叠面板树数据中收集叶子节点(与 decorateLineTree 层级一致) */
|
||||
export function collectDeviceLeaves(
|
||||
governNodes: any[],
|
||||
portableNodes: any[],
|
||||
monitorNodes: any[]
|
||||
): Pick<LineTreeLeaves, 'govern' | 'portable' | 'monitor'> {
|
||||
const govern: any[] = []
|
||||
const portable: any[] = []
|
||||
const monitor: any[] = []
|
||||
|
||||
governNodes.forEach(l1 => {
|
||||
l1.children?.forEach((l2: any) => {
|
||||
l2.children?.forEach((l3: any) => {
|
||||
l3.children?.forEach((l4: any) => govern.push(l4))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
portableNodes.forEach(l1 => {
|
||||
l1.children?.forEach((l2: any) => portable.push(l2))
|
||||
})
|
||||
|
||||
monitorNodes.forEach(l1 => {
|
||||
l1.children?.forEach((l2: any) => {
|
||||
l2.children?.forEach((l3: any) => {
|
||||
l3.children?.forEach((l4: any) => monitor.push(l4))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return { govern, portable, monitor }
|
||||
}
|
||||
|
||||
export async function waitForTreeRef(treRef: any, refKey: TreeRefKey, maxRetries = 20) {
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
await nextTick()
|
||||
if (treRef?.[refKey]) return treRef[refKey]
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -1,29 +1,28 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :data="tree" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
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()
|
||||
import { mapUserTreeNodes, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
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)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
async function loadTree() {
|
||||
const res: any = await getFormalUserList()
|
||||
if (res.code !== 'A0000') return
|
||||
|
||||
tree.value = mapUserTreeNodes(res.data)
|
||||
const first = tree.value[0]
|
||||
if (!first) return
|
||||
|
||||
emit('selectUser', first)
|
||||
await selectTreeNode(treRef.value, first)
|
||||
}
|
||||
|
||||
loadTree()
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
|
||||
@@ -5,204 +5,99 @@
|
||||
:data="tree"
|
||||
default-expand-all
|
||||
@changePointType="changePointType"
|
||||
@changeTreeType="info"
|
||||
@changeTreeType="loadTree"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import { ref, nextTick } from 'vue'
|
||||
import Tree from '../point.vue'
|
||||
import { getLineTree } from '@/api/cs-device-boot/csLedger'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
// const props = defineProps(['template'])
|
||||
import {
|
||||
createLineTreeDecorators,
|
||||
decorateLineTree,
|
||||
waitForTreeRef,
|
||||
type LineTreeLeaves,
|
||||
type TreeRefKey
|
||||
} from './lineTreeUtils'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false
|
||||
})
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
name: 'govern/pointTree'
|
||||
})
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const width = ref('')
|
||||
|
||||
const info = (type?: string) => {
|
||||
tree.value = []
|
||||
let arr1: any[] = []
|
||||
let arr2: any[] = []
|
||||
let arr3: any[] = []
|
||||
let arr4: any[] = []
|
||||
getLineTree({ type: type == '2' ? 'engineering' : '' }).then(res => {
|
||||
//治理设备
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
res.data.map((item: any) => {
|
||||
if (type == '2') {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-List'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
// item2.icon = 'el-icon-List'
|
||||
// item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.level = 2
|
||||
item2.color =
|
||||
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr4.push(item3)
|
||||
// item3.children.forEach((item4: any) => {
|
||||
// item4.icon = 'el-icon-Platform'
|
||||
// item4.color =
|
||||
// item4.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
|
||||
// })
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
if (item.name == '治理设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.level = 1
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.level = 1
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 2
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item3.children.forEach((item4: any) => {
|
||||
item4.icon = 'el-icon-Platform'
|
||||
item4.color =
|
||||
item4.comFlag === 2
|
||||
? config.getColorVal('elementUiPrimary')
|
||||
: '#e26257 !important'
|
||||
// item4.color = '#e26257 !important'
|
||||
arr1.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
} else if (item.name == '便携式设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-Platform'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.color = item.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Platform'
|
||||
item2.color =
|
||||
item2.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
arr2.push(item2)
|
||||
})
|
||||
})
|
||||
} else if (item.name == '监测设备') {
|
||||
item.children.forEach((item: any) => {
|
||||
item.icon = 'el-icon-HomeFilled'
|
||||
item.level = 1
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-List'
|
||||
item2.level = 1
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.icon = 'el-icon-Platform'
|
||||
item3.level = 1
|
||||
item3.color =
|
||||
item3.comFlag === 2 ? config.getColorVal('elementUiPrimary') : '#e26257 !important'
|
||||
item3.children.forEach((item4: any) => {
|
||||
item4.icon = 'el-icon-Platform'
|
||||
item4.color =
|
||||
item4.comFlag === 2
|
||||
? config.getColorVal('elementUiPrimary')
|
||||
: '#e26257 !important'
|
||||
// item4.color = '#e26257 !important'
|
||||
arr3.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
tree.value = res.data
|
||||
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
if (type == '2') {
|
||||
//初始化选中
|
||||
|
||||
treRef.value?.treeRef4.setCurrentKey(arr4[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 3,
|
||||
...arr4[0]
|
||||
})
|
||||
changePointType('4', arr4[0])
|
||||
return
|
||||
} else if (arr1.length > 0) {
|
||||
//初始化选中
|
||||
treRef.value?.treeRef1.setCurrentKey(arr1[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr1[0]
|
||||
})
|
||||
return
|
||||
} else if (arr2.length > 0) {
|
||||
//初始化选中
|
||||
treRef.value?.treeRef2.setCurrentKey(arr2[0].id)
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr2[0]
|
||||
})
|
||||
return
|
||||
} else if (arr3.length > 0) {
|
||||
treRef.value?.treeRef3?.setCurrentKey(arr3[0].id)
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...arr3[0]
|
||||
})
|
||||
return
|
||||
} else {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
}, 500)
|
||||
})
|
||||
})
|
||||
}
|
||||
const changePointType = (val: any, obj: any) => {
|
||||
emit('pointTypeChange', val, obj)
|
||||
}
|
||||
if (props.template) {
|
||||
// id: dictData.state.area[0]?.id
|
||||
|
||||
async function selectInitialNode(type: string | undefined, leaves: LineTreeLeaves) {
|
||||
const candidates: { refKey: TreeRefKey; list: any[]; level: number }[] =
|
||||
type === '2'
|
||||
? [{ refKey: 'treeRef4', list: leaves.engineering, level: 3 }]
|
||||
: [
|
||||
{ refKey: 'treeRef1', list: leaves.govern, level: 2 },
|
||||
{ refKey: 'treeRef2', list: leaves.portable, level: 2 },
|
||||
{ refKey: 'treeRef3', list: leaves.monitor, level: 2 }
|
||||
]
|
||||
|
||||
for (const { refKey, list, level } of candidates) {
|
||||
const node = list[0]
|
||||
if (!node) continue
|
||||
|
||||
const treeInstance = await waitForTreeRef(treRef.value, refKey)
|
||||
treeInstance?.setCurrentKey(node.id)
|
||||
emit('init', { ...node })
|
||||
|
||||
if (type === '2') {
|
||||
changePointType('4', node)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
emit('init')
|
||||
}
|
||||
|
||||
const loadTree = (type?: string) => {
|
||||
tree.value = []
|
||||
getLineTree({ type: type === '2' ? 'engineering' : '' }).then(res => {
|
||||
const leaves = decorateLineTree(res.data, type, decorators, { disableParents: false })
|
||||
tree.value = res.data
|
||||
nextTick(() => selectInitialNode(type, leaves))
|
||||
})
|
||||
}
|
||||
|
||||
function bootstrap() {
|
||||
if (props.template) {
|
||||
querySysExcel({})
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
info()
|
||||
loadTree()
|
||||
})
|
||||
.catch(err => {
|
||||
info()
|
||||
})
|
||||
} else {
|
||||
info()
|
||||
.catch(() => loadTree())
|
||||
} else {
|
||||
loadTree()
|
||||
}
|
||||
}
|
||||
onMounted(() => {})
|
||||
|
||||
bootstrap()
|
||||
|
||||
defineExpose({ treRef })
|
||||
</script>
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
@node-click="clickNode"
|
||||
:expand-on-click-node="false"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<div class="left" style="display: flex; align-items: center">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 5px">{{ node.label }}</span>
|
||||
</div>
|
||||
@@ -42,128 +42,84 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, watch, defineProps, defineEmits } from 'vue'
|
||||
import { getSchemeTree, getTestRecordInfo } from '@/api/cs-device-boot/planData'
|
||||
import { ref, watch } from 'vue'
|
||||
import { getSchemeTree } from '@/api/cs-device-boot/planData'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
defineOptions({
|
||||
name: 'govern/schemeTree'
|
||||
})
|
||||
import { createLineTreeDecorators } from './lineTreeUtils'
|
||||
import { bootstrapWithTemplate } from './treeCommonUtils'
|
||||
import { createTreeFilterNode } from './treeFilterUtils'
|
||||
|
||||
defineOptions({ name: 'govern/schemeTree', inheritAttrs: false })
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
}
|
||||
const dictData = useDictData()
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false
|
||||
})
|
||||
const filterText = ref('')
|
||||
watch(filterText, val => {
|
||||
treRef.value!.filter(val)
|
||||
})
|
||||
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
if (!value) return true
|
||||
// return data.name.includes(value)
|
||||
if (data.name) {
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
const level = node.level
|
||||
// 如果传入的节点本身就是一级节点就不用校验了
|
||||
if (level === 1) {
|
||||
return false
|
||||
}
|
||||
// 先取当前节点的父节点
|
||||
let parentData = node.parent
|
||||
// 遍历当前节点的父节点
|
||||
let index = 0
|
||||
while (index < level - 1) {
|
||||
// 如果匹配到直接返回,此处name值是中文字符,enName是英文字符。判断匹配中英文过滤
|
||||
if (parentData.data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
// 否则的话再往上一层做匹配
|
||||
parentData = parentData.parent
|
||||
index++
|
||||
}
|
||||
// 没匹配到返回false
|
||||
return false
|
||||
}
|
||||
/** 树形结构数据 */
|
||||
const defaultProps = {
|
||||
children: 'children',
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), { template: false })
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'nodeChange', 'node-click', 'editNode', 'getChart', 'Policy'])
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'nodeChange', 'editNode', 'getChart', 'Policy'])
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const treRef = ref()
|
||||
const id: any = ref(null)
|
||||
const treeData = ref({})
|
||||
//获取方案树形数据
|
||||
const getTreeList = () => {
|
||||
getSchemeTree().then(res => {
|
||||
let arr: any[] = []
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof ElTree>>()
|
||||
const filterText = ref('')
|
||||
const id = ref<string | null>(null)
|
||||
const planId = ref('')
|
||||
|
||||
res.data.forEach((item: any) => {
|
||||
item.icon = 'el-icon-Menu'
|
||||
item.color = config.getColorVal('elementUiPrimary')
|
||||
item?.children.forEach((item2: any) => {
|
||||
item2.icon = 'el-icon-Document'
|
||||
item2.color = config.getColorVal('elementUiPrimary')
|
||||
arr.push(item2)
|
||||
const defaultProps = { children: 'children', label: 'name', value: 'id' }
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
const filterNode = createTreeFilterNode()
|
||||
|
||||
watch(filterText, val => treRef.value?.filter(val))
|
||||
|
||||
function decorateSchemeTree(data: any[]): any[] {
|
||||
const { primary, applyMeta } = decorators
|
||||
const leaves: any[] = []
|
||||
|
||||
data.forEach(item => {
|
||||
applyMeta(item, { icon: 'el-icon-Menu', color: primary() })
|
||||
item.children?.forEach((child: any) => {
|
||||
applyMeta(child, { icon: 'el-icon-Document', color: primary() })
|
||||
leaves.push(child)
|
||||
})
|
||||
})
|
||||
|
||||
return leaves
|
||||
}
|
||||
|
||||
function getTreeList() {
|
||||
getSchemeTree().then(res => {
|
||||
const leaves = decorateSchemeTree(res.data)
|
||||
tree.value = res.data
|
||||
nextTick(() => {
|
||||
if (arr.length) {
|
||||
treRef.value.setCurrentKey(id.value || arr[0].id)
|
||||
let list = id.value ? arr.find((item: any) => item.id == id.value) : arr[0]
|
||||
// 注册父组件事件
|
||||
emit('init', {
|
||||
level: 2,
|
||||
...list
|
||||
})
|
||||
} else {
|
||||
|
||||
const node = id.value ? leaves.find(item => item.id == id.value) : leaves[0]
|
||||
if (!node) {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
treRef.value?.setCurrentKey(node.id)
|
||||
emit('init', { level: 2, ...node })
|
||||
})
|
||||
}
|
||||
|
||||
//方案id
|
||||
const planId: any = ref('')
|
||||
|
||||
const clickNode = (e: anyObj) => {
|
||||
e?.children ? (planId.value = e.id) : (planId.value = e.pid)
|
||||
const clickNode = (e: any) => {
|
||||
planId.value = e?.children ? e.id : e.pid
|
||||
id.value = e.id
|
||||
emit('nodeChange', e)
|
||||
emit('node-click', e)
|
||||
}
|
||||
|
||||
if (props.template) {
|
||||
// id: dictData.state.area[0]?.id
|
||||
querySysExcel({})
|
||||
.then((res: any) => {
|
||||
emit('Policy', res.data)
|
||||
getTreeList()
|
||||
})
|
||||
.catch(err => {
|
||||
getTreeList()
|
||||
})
|
||||
} else {
|
||||
getTreeList()
|
||||
}
|
||||
bootstrapWithTemplate(
|
||||
props.template,
|
||||
getTreeList,
|
||||
() => querySysExcel({}),
|
||||
data => emit('Policy', data)
|
||||
)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cn-tree {
|
||||
flex-shrink: 0;
|
||||
|
||||
@@ -1,105 +1,64 @@
|
||||
<template>
|
||||
<Tree ref="treRef" :width="width" :data="tree" default-expand-all @checkedNodesChange="handleCheckedNodesChange"/>
|
||||
<Tree
|
||||
ref="treRef"
|
||||
:width="width"
|
||||
:data="tree"
|
||||
default-expand-all
|
||||
@checkedNodesChange="handleCheckedNodesChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, onMounted, defineProps } from 'vue'
|
||||
import { ref } 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'])
|
||||
import { createLineTreeDecorators, decorateLineTree } from './lineTreeUtils'
|
||||
import { bootstrapWithTemplate, selectTreeNode } from './treeCommonUtils'
|
||||
|
||||
interface Props {
|
||||
template?: boolean
|
||||
}
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
template: false
|
||||
})
|
||||
defineOptions({
|
||||
name: 'govern/deviceTree'
|
||||
})
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), { template: false })
|
||||
|
||||
defineOptions({ name: 'govern/selectTree' })
|
||||
|
||||
const emit = defineEmits(['init', 'checkChange', 'pointTypeChange', 'Policy'])
|
||||
|
||||
const config = useConfig()
|
||||
const tree = ref()
|
||||
const dictData = useDictData()
|
||||
const treRef = ref()
|
||||
const tree = ref<any[]>([])
|
||||
const treRef = ref<InstanceType<typeof Tree>>()
|
||||
const width = ref('')
|
||||
|
||||
const info = () => {
|
||||
const decorators = createLineTreeDecorators(() => config.getColorVal('elementUiPrimary'))
|
||||
|
||||
const handleCheckedNodesChange = (nodes: any[]) => emit('checkChange', nodes)
|
||||
|
||||
async function loadTree() {
|
||||
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 {
|
||||
const res = await getLineTree()
|
||||
const leaves = decorateLineTree(res.data, '1', decorators, { disableParents: false })
|
||||
tree.value = res.data.filter((item: any) => item.name === '监测设备')
|
||||
|
||||
const node = leaves.monitor[0]
|
||||
if (!node) {
|
||||
emit('init')
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
await selectTreeNode(treRef.value, node, {
|
||||
onSelect: selected => emit('init', { level: 2, ...selected })
|
||||
})
|
||||
}
|
||||
|
||||
// 处理子组件传递的勾选节点变化,并转发给父组件
|
||||
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(() => {})
|
||||
bootstrapWithTemplate(
|
||||
props.template,
|
||||
loadTree,
|
||||
() => getTemplateByDept({ id: dictData.state.area[0]?.id }),
|
||||
data => emit('Policy', data)
|
||||
)
|
||||
</script>
|
||||
|
||||
58
src/components/tree/govern/treeCommonUtils.ts
Normal file
58
src/components/tree/govern/treeCommonUtils.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { nextTick } from 'vue'
|
||||
import { createLineTreeDecorators, type LineTreeDecorators } from './lineTreeUtils'
|
||||
|
||||
export { createLineTreeDecorators, type LineTreeDecorators }
|
||||
|
||||
export function findNodeById(nodes: any[], id: string): any | null {
|
||||
for (const node of nodes) {
|
||||
if (node.id === id) return node
|
||||
if (node.children?.length) {
|
||||
const found = findNodeById(node.children, id)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export async function waitForSingleTreeRef(treRef: any, maxRetries = 20) {
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
await nextTick()
|
||||
if (treRef?.treeRef) return treRef.treeRef
|
||||
await new Promise(resolve => setTimeout(resolve, 50))
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export async function selectTreeNode(
|
||||
treRef: any,
|
||||
node: any | undefined,
|
||||
options?: { level?: number; onSelect?: (node: any) => void }
|
||||
) {
|
||||
if (!node) return false
|
||||
const treeInstance = await waitForSingleTreeRef(treRef)
|
||||
treeInstance?.setCurrentKey(node.id)
|
||||
options?.onSelect?.(node)
|
||||
return true
|
||||
}
|
||||
|
||||
export function bootstrapWithTemplate(
|
||||
template: boolean,
|
||||
loadFn: () => void,
|
||||
fetchTemplate: () => Promise<any>,
|
||||
onPolicy: (data: any) => void
|
||||
) {
|
||||
if (template) {
|
||||
fetchTemplate()
|
||||
.then(res => {
|
||||
onPolicy(res.data)
|
||||
loadFn()
|
||||
})
|
||||
.catch(() => loadFn())
|
||||
} else {
|
||||
loadFn()
|
||||
}
|
||||
}
|
||||
|
||||
export function mapUserTreeNodes(data: any[], icon = 'el-icon-User', color = 'royalblue') {
|
||||
return data.map(item => ({ ...item, icon, color }))
|
||||
}
|
||||
20
src/components/tree/govern/treeFilterUtils.ts
Normal file
20
src/components/tree/govern/treeFilterUtils.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/** 树节点搜索:匹配当前节点或任一祖先节点名称 */
|
||||
export function matchTreeNodeName(value: string, data: any, node: any): boolean {
|
||||
if (!value) return true
|
||||
if (!data?.name) return false
|
||||
if (data.name.indexOf(value) !== -1) return true
|
||||
|
||||
const level = node.level
|
||||
if (level === 1) return false
|
||||
|
||||
let parentData = node.parent
|
||||
for (let i = 0; i < level - 1; i++) {
|
||||
if (parentData?.data?.name?.indexOf(value) !== -1) return true
|
||||
parentData = parentData.parent
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
export function createTreeFilterNode() {
|
||||
return (value: string, data: any, node: any): boolean => matchTreeNodeName(value, data, node)
|
||||
}
|
||||
@@ -1,44 +1,50 @@
|
||||
<template>
|
||||
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="transition: all 0.3s; overflow: hidden">
|
||||
<Icon
|
||||
<div
|
||||
class="cn-tree-root"
|
||||
:class="{ 'is-collapsed': menuCollapse, 'is-fill-height': props.fillHeight }"
|
||||
:style="{ width: menuCollapse ? '40px' : props.width }"
|
||||
>
|
||||
<!-- <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" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
size="18px"
|
||||
class="cn-tree-root__collapse-btn cn-tree-root__collapse-btn--float"
|
||||
/> -->
|
||||
<div class="cn-tree" :class="{ 'is-hidden': menuCollapse }">
|
||||
<div class="cn-tree__toolbar">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
v-model.trim="filterText"
|
||||
placeholder="请输入内容"
|
||||
clearable
|
||||
class="cn-tree__search"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||
</template>
|
||||
</el-input>
|
||||
<el-tooltip placement="bottom" :hide-after="0" v-if="props.showPush">
|
||||
<template #content>
|
||||
<span>台账推送</span>
|
||||
</template>
|
||||
|
||||
<el-tooltip v-if="props.showPush" placement="bottom" :hide-after="0" content="台账推送">
|
||||
<Icon
|
||||
name="el-icon-Promotion"
|
||||
size="20"
|
||||
class="fold ml10 mr10 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
size="20px"
|
||||
class="cn-tree__push-btn"
|
||||
:style="{ color: config.getColorVal('elementUiPrimary') }"
|
||||
@click="onAdd"
|
||||
/>
|
||||
</el-tooltip>
|
||||
<!-- <Icon @click='onMenuCollapse' :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'" v-else
|
||||
:class="menuCollapse ? 'unfold' : ''" size='18' class='fold ml10 menu-collapse'
|
||||
style='cursor: pointer' v-if='props.canExpand' /> -->
|
||||
<!-- <Icon
|
||||
v-if="props.canExpand"
|
||||
@click="onMenuCollapse"
|
||||
name="el-icon-Fold"
|
||||
size="18px"
|
||||
class="cn-tree__collapse-btn"
|
||||
/> -->
|
||||
</div>
|
||||
|
||||
<el-tree
|
||||
:style="{ height: 'calc(100vh - 190px)' }"
|
||||
style="overflow: auto"
|
||||
ref="treeRef"
|
||||
:style="{ height: treeHeight }"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
:default-expand-all="false"
|
||||
@@ -47,15 +53,15 @@
|
||||
node-key="id"
|
||||
v-bind="$attrs"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
v-if="nodeData.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
<span class="custom-tree-node__label">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
@@ -66,113 +72,155 @@
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { ref, watch } from 'vue'
|
||||
import { ref, watch, computed } from 'vue'
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { createTreeFilterNode } from './govern/treeFilterUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
})
|
||||
defineOptions({ name: 'govern/indexTree', inheritAttrs: false })
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
canExpand?: boolean
|
||||
showPush?: boolean
|
||||
/** 默认高度基准偏移(100vh - baseOffset) */
|
||||
baseOffset?: number
|
||||
/** 在 baseOffset 基础上额外减去的高度 */
|
||||
height?: number
|
||||
/** 自定义树高度,优先级最高 */
|
||||
treeHeight?: string
|
||||
/** 撑满父容器高度 */
|
||||
fillHeight?: boolean
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true,
|
||||
showPush: false
|
||||
showPush: false,
|
||||
baseOffset: 190,
|
||||
height: 0,
|
||||
treeHeight: '',
|
||||
fillHeight: false
|
||||
})
|
||||
|
||||
const emit = defineEmits(['checkTreeNodeChange', 'onAdd', 'changePointType'])
|
||||
|
||||
const config = useConfig()
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['checkTreeNodeChange', 'onAdd'])
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
const filterNode = createTreeFilterNode()
|
||||
|
||||
const SEARCH_BAR_HEIGHT = 42
|
||||
|
||||
const treeHeight = computed(() => {
|
||||
if (props.treeHeight) return props.treeHeight
|
||||
if (props.fillHeight) return `calc(100% - ${SEARCH_BAR_HEIGHT}px)`
|
||||
return `calc(100vh - ${props.baseOffset}px - ${props.height}px)`
|
||||
})
|
||||
|
||||
watch(filterText, val => treeRef.value?.filter(val))
|
||||
|
||||
const onMenuCollapse = () => {
|
||||
menuCollapse.value = !menuCollapse.value
|
||||
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
|
||||
}
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
console.log(value, data, node, 'filterNode')
|
||||
if (!value) return true
|
||||
// return data.name.includes(value)
|
||||
if (data.name) {
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。name是中文字符,enName是英文字符.
|
||||
const chooseNode = (value: string, data: any, node: any) => {
|
||||
if (data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
const level = node.level
|
||||
// 如果传入的节点本身就是一级节点就不用校验了
|
||||
if (level === 1) {
|
||||
return false
|
||||
}
|
||||
// 先取当前节点的父节点
|
||||
let parentData = node.parent
|
||||
// 遍历当前节点的父节点
|
||||
let index = 0
|
||||
while (index < level - 1) {
|
||||
// 如果匹配到直接返回,此处name值是中文字符,enName是英文字符。判断匹配中英文过滤
|
||||
if (parentData.data.name.indexOf(value) !== -1) {
|
||||
return true
|
||||
}
|
||||
// 否则的话再往上一层做匹配
|
||||
parentData = parentData.parent
|
||||
index++
|
||||
}
|
||||
// 没匹配到返回false
|
||||
return false
|
||||
}
|
||||
const checkTreeNodeChange = () => {
|
||||
// console.log(treeRef.value?.getCheckedNodes(), "ikkkkkiisiiisis");
|
||||
emit('checkTreeNodeChange', treeRef.value?.getCheckedNodes())
|
||||
}
|
||||
|
||||
const onAdd = () => {
|
||||
emit('onAdd')
|
||||
}
|
||||
const onAdd = () => emit('onAdd')
|
||||
|
||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.cn-tree {
|
||||
flex-shrink: 0;
|
||||
.cn-tree-root {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
// padding: 10px;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
transition: width 0.3s;
|
||||
box-sizing: border-box;
|
||||
|
||||
&.is-fill-height {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
&__collapse-btn {
|
||||
color: var(--el-color-primary);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
|
||||
&--float {
|
||||
margin: 20px 0 0 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cn-tree {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
padding: 10px;
|
||||
transition: opacity 0.3s;
|
||||
|
||||
&.is-hidden {
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&__toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-bottom: 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__search {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
&__push-btn,
|
||||
&__collapse-btn {
|
||||
color: var(--el-color-primary);
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:deep(.el-tree) {
|
||||
border: 1px solid var(--el-border-color);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
: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;
|
||||
min-width: 0;
|
||||
|
||||
&__label {
|
||||
margin-left: 4px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
<!-- 设备监控使用折叠面板渲染多个tree -->
|
||||
<template>
|
||||
<div :style="{ width: menuCollapse ? '40px' : props.width }" style="display: flex; overflow: hidden">
|
||||
<Icon
|
||||
<!-- <Icon
|
||||
v-show="menuCollapse"
|
||||
@click="onMenuCollapse"
|
||||
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''"
|
||||
size="18"
|
||||
size="18px"
|
||||
class="fold ml10 mt20 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
v-if="route.path != '/admin/govern/reportCore/statistics/index'"
|
||||
/>
|
||||
/> -->
|
||||
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1, display: menuCollapse ? 'none' : '' }">
|
||||
<div style="display: flex; align-items: center" class="mb10">
|
||||
<!-- <el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
<template #prefix>
|
||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||
</template>
|
||||
</el-input> -->
|
||||
<el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
<template #prepend>
|
||||
<el-select v-model="treeType" @change="changeTreeType" style="min-width: 75px">
|
||||
@@ -33,35 +28,33 @@
|
||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||
</template>
|
||||
</el-input>
|
||||
<!-- -->
|
||||
<Icon
|
||||
<!-- <Icon
|
||||
@click="onMenuCollapse"
|
||||
:name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''"
|
||||
size="18"
|
||||
size="18px"
|
||||
class="fold ml10 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
v-if="props.canExpand && route.path != '/admin/govern/reportCore/statistics/index'"
|
||||
/>
|
||||
/> -->
|
||||
</div>
|
||||
|
||||
<el-collapse
|
||||
:accordion="true"
|
||||
v-model.trim="activeName"
|
||||
v-model="activeName"
|
||||
style="flex: 1; height: 100%"
|
||||
@change="changeDevice"
|
||||
v-if="treeType == '1'"
|
||||
v-loading="loading"
|
||||
>
|
||||
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length != 0">
|
||||
<el-select v-model.trim="process" clearable placeholder="请选择状态" class="mb10">
|
||||
<el-option label="功能调试" value="2"></el-option>
|
||||
<el-option label="出厂调试" value="3"></el-option>
|
||||
<el-option label="正式投运" value="4"></el-option>
|
||||
<el-collapse-item title="治理设备" name="0" v-if="zlDeviceData.length">
|
||||
<el-select v-model="process" clearable placeholder="请选择状态" class="mb10">
|
||||
<el-option label="功能调试" value="2" />
|
||||
<el-option label="出厂调试" value="3" />
|
||||
<el-option label="正式投运" value="4" />
|
||||
</el-select>
|
||||
|
||||
<el-tree
|
||||
:style="{ height: treeType.length != 0 ? 'calc(100vh - 380px)' : 'calc(100vh - 278px)' }"
|
||||
:style="{ height: governTreeHeight }"
|
||||
ref="treeRef1"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -72,22 +65,22 @@
|
||||
style="overflow: auto"
|
||||
:default-expand-all="false"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length != 0">
|
||||
<el-collapse-item title="便携式设备" name="1" v-if="bxsDeviceData.length">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 238px)' }"
|
||||
:style="{ height: otherTreeHeight }"
|
||||
ref="treeRef2"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -98,22 +91,22 @@
|
||||
v-bind="$attrs"
|
||||
style="overflow: auto"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
</el-collapse-item>
|
||||
<el-collapse-item title="监测设备" name="2" v-if="yqfDeviceData.length != 0">
|
||||
<el-collapse-item title="监测设备" name="2" v-if="yqfDeviceData.length">
|
||||
<el-tree
|
||||
:style="{ height: zlDeviceData.length != 0 ? 'calc(100vh - 340px)' : 'calc(100vh - 238px)' }"
|
||||
:style="{ height: otherTreeHeight }"
|
||||
ref="treeRef3"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
@@ -124,13 +117,13 @@
|
||||
v-bind="$attrs"
|
||||
style="overflow: auto"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
@@ -140,7 +133,7 @@
|
||||
</el-collapse>
|
||||
<div v-if="treeType == '2'" v-loading="loading">
|
||||
<el-tree
|
||||
:style="{ height: 'calc(100vh - 188px)' }"
|
||||
:style="{ height: engineeringTreeHeight }"
|
||||
class="pt10"
|
||||
ref="treeRef4"
|
||||
:props="defaultProps"
|
||||
@@ -148,17 +141,17 @@
|
||||
:filter-node-method="filterNode"
|
||||
node-key="id"
|
||||
v-bind="$attrs"
|
||||
:data="data"
|
||||
:data="props.data"
|
||||
style="overflow: auto"
|
||||
:default-expand-all="false"
|
||||
>
|
||||
<template #default="{ node, data }">
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="data.icon"
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: data.color }"
|
||||
v-if="data.icon"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
@@ -171,308 +164,217 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElTree } from 'element-plus'
|
||||
import { el, fa } from 'element-plus/es/locale'
|
||||
import { ref, watch, defineEmits, onMounted, nextTick, computed } from 'vue'
|
||||
import { ElTree, type CollapseModelValue } from 'element-plus'
|
||||
import { ref, watch, nextTick, computed } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { collectDeviceLeaves } from './govern/lineTreeUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
name: 'govern/point',
|
||||
inheritAttrs: false
|
||||
})
|
||||
|
||||
const emit = defineEmits(['changePointType', 'changeTreeType'])
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
canExpand?: boolean
|
||||
type?: string
|
||||
data?: any
|
||||
data?: any[]
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
width: '100%',
|
||||
canExpand: true,
|
||||
type: '',
|
||||
data: []
|
||||
data: () => []
|
||||
})
|
||||
const process = ref('')
|
||||
|
||||
const route = useRoute()
|
||||
const { proxy } = useCurrentInstance()
|
||||
|
||||
const treeType = ref('1')
|
||||
const options = [
|
||||
{ label: '设备', value: '1' },
|
||||
{ label: '工程', value: '2' }
|
||||
]
|
||||
|
||||
const menuCollapse = ref(false)
|
||||
const activeName = ref('0')
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const treeType = ref('1')
|
||||
const options = [
|
||||
{
|
||||
label: '设备',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '工程',
|
||||
value: '2'
|
||||
const process = ref('')
|
||||
const loading = ref(false)
|
||||
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
|
||||
const zlDeviceData = ref<any[]>([])
|
||||
const zlDevList = ref<any[]>([])
|
||||
const bxsDeviceData = ref<any[]>([])
|
||||
const yqfDeviceData = ref<any[]>([])
|
||||
|
||||
const governTreeHeight = computed(() => 'calc(100vh - 380px)')
|
||||
const otherTreeHeight = computed(() =>
|
||||
zlDeviceData.value.length ? 'calc(100vh - 340px)' : 'calc(100vh - 238px)'
|
||||
)
|
||||
const engineeringTreeHeight = computed(() => 'calc(100vh - 188px)')
|
||||
|
||||
const treeRef1 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef2 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef3 = ref<InstanceType<typeof ElTree>>()
|
||||
const treeRef4 = ref<InstanceType<typeof ElTree>>()
|
||||
|
||||
defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
|
||||
|
||||
function splitTreeData(val: any[]) {
|
||||
zlDeviceData.value = []
|
||||
bxsDeviceData.value = []
|
||||
yqfDeviceData.value = []
|
||||
|
||||
val.forEach(item => {
|
||||
if (item.name === '治理设备') {
|
||||
zlDeviceData.value = item.children ?? []
|
||||
} else if (item.name === '便携式设备') {
|
||||
bxsDeviceData.value = item.children ?? []
|
||||
} else if (item.name === '监测设备') {
|
||||
yqfDeviceData.value = item.children ?? []
|
||||
}
|
||||
]
|
||||
//治理设备数据
|
||||
const zlDeviceData = ref<any>([])
|
||||
const zlDevList = ref<any>([])
|
||||
//便携式设备数据
|
||||
const bxsDeviceData = ref<any>([])
|
||||
//监测设备数据
|
||||
const yqfDeviceData = ref<any>([])
|
||||
})
|
||||
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
}
|
||||
|
||||
/** 测点树专用:level=2 按 process 过滤,其余层级保留有子节点或匹配的节点 */
|
||||
function filterProcess(nodes: any[]): any[] {
|
||||
if (!process.value) return nodes
|
||||
|
||||
return nodes
|
||||
.map(node => {
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
|
||||
if (node.level === 2) {
|
||||
if (node.process == process.value) {
|
||||
return { ...node, children }
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
if (children.length > 0 || node.process == process.value || !node.children?.length) {
|
||||
return { ...node, children }
|
||||
}
|
||||
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
function getActiveTreeRef() {
|
||||
if (treeType.value === '2') return treeRef4.value
|
||||
if (activeName.value === '0') return treeRef1.value
|
||||
if (activeName.value === '1') return treeRef2.value
|
||||
return treeRef3.value
|
||||
}
|
||||
|
||||
function resolveActiveName() {
|
||||
if (zlDeviceData.value.length) return '0'
|
||||
if (bxsDeviceData.value.length) return '1'
|
||||
if (yqfDeviceData.value.length) return '2'
|
||||
return ''
|
||||
}
|
||||
|
||||
function selectPointPanel(panelName: string, node?: any) {
|
||||
if (!node) return
|
||||
emit('changePointType', panelName, node)
|
||||
nextTick(() => {
|
||||
getActiveTreeRef()?.setCurrentKey(node.id)
|
||||
})
|
||||
}
|
||||
|
||||
const changeDevice = (val: CollapseModelValue) => {
|
||||
if (Array.isArray(val) || val == null || val === '') return
|
||||
const panelName = String(val)
|
||||
const { govern, portable, monitor } = collectDeviceLeaves(
|
||||
zlDevList.value,
|
||||
bxsDeviceData.value,
|
||||
yqfDeviceData.value
|
||||
)
|
||||
|
||||
const panelMap: Record<string, { nodes: any[]; clearOthers: any[][] }> = {
|
||||
'0': { nodes: govern, clearOthers: [portable, monitor] },
|
||||
'1': { nodes: portable, clearOthers: [govern, monitor] },
|
||||
'2': { nodes: monitor, clearOthers: [govern, portable] }
|
||||
}
|
||||
|
||||
const panel = panelMap[panelName]
|
||||
if (!panel) return
|
||||
|
||||
panel.clearOthers.forEach(list => list.forEach(item => (item.checked = false)))
|
||||
selectPointPanel(panelName, panel.nodes[0])
|
||||
}
|
||||
|
||||
const setActiveName = () => {
|
||||
activeName.value = resolveActiveName()
|
||||
if (activeName.value) {
|
||||
nextTick(() => changeDevice(activeName.value))
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else if (item.name == '便携式设备') {
|
||||
bxsDeviceData.value = []
|
||||
item.children.map((vv: any) => {
|
||||
bxsDeviceData.value.push(vv)
|
||||
})
|
||||
} else if (item.name == '监测设备') {
|
||||
yqfDeviceData.value = []
|
||||
item.children.map((vv: any) => {
|
||||
yqfDeviceData.value.push(vv)
|
||||
})
|
||||
}
|
||||
})
|
||||
val => {
|
||||
if (!val?.length) return
|
||||
splitTreeData(val)
|
||||
if (treeType.value === '1') {
|
||||
nextTick(() => setActiveName())
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
watch(filterText, val => {
|
||||
if (treeType.value == '2') {
|
||||
treeRef4.value!.filter(val)
|
||||
} else if (activeName.value == '0') {
|
||||
treeRef1.value!.filter(val)
|
||||
} else if (activeName.value == '1') {
|
||||
treeRef2.value!.filter(val)
|
||||
} else {
|
||||
treeRef3.value!.filter(val)
|
||||
}
|
||||
getActiveTreeRef()?.filter(val)
|
||||
})
|
||||
watch(process, val => {
|
||||
if (val == '' || val == undefined) {
|
||||
zlDevList.value = JSON.parse(JSON.stringify(zlDeviceData.value))
|
||||
} else {
|
||||
|
||||
watch(process, () => {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
if (activeName.value === '0') {
|
||||
nextTick(() => changeDevice(activeName.value))
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
changeDevice(activeName.value)
|
||||
}, 0)
|
||||
})
|
||||
|
||||
const changeDevice = (val: any) => {
|
||||
let arr1: any = []
|
||||
//zlDeviceData
|
||||
zlDevList.value.forEach((item: any) => {
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.children.forEach((item4: any) => {
|
||||
arr1.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
let arr2: any = []
|
||||
bxsDeviceData.value.forEach((item: any) => {
|
||||
item.children.forEach((item2: any) => {
|
||||
arr2.push(item2)
|
||||
})
|
||||
})
|
||||
let arr3: any = []
|
||||
yqfDeviceData.value.forEach((item: any) => {
|
||||
item.children.forEach((item2: any) => {
|
||||
item2.children.forEach((item3: any) => {
|
||||
item3.children.forEach((item4: any) => {
|
||||
arr3.push(item4)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
activeName.value = val
|
||||
if (val == '0') {
|
||||
arr2.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
emit('changePointType', activeName.value, arr1[0])
|
||||
setTimeout(() => {
|
||||
treeRef1.value?.setCurrentKey(arr1[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
if (val == '1') {
|
||||
arr1.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
emit('changePointType', activeName.value, arr2[0])
|
||||
setTimeout(() => {
|
||||
treeRef2.value?.setCurrentKey(arr2[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
if (val == '2') {
|
||||
arr3.map((item: any) => {
|
||||
item.checked = false
|
||||
})
|
||||
emit('changePointType', activeName.value, arr3[0])
|
||||
setTimeout(() => {
|
||||
treeRef3.value?.setCurrentKey(arr3[0]?.id)
|
||||
}, 100)
|
||||
}
|
||||
// if(activeName.value){
|
||||
// emit('changePointType', activeName.value)
|
||||
// }
|
||||
}
|
||||
const onMenuCollapse = () => {
|
||||
menuCollapse.value = !menuCollapse.value
|
||||
proxy.eventBus.emit('cnTreeCollapse', menuCollapse)
|
||||
}
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
|
||||
const filterNode = (value: string, data: any, node: any): boolean => {
|
||||
if (!value) return true
|
||||
// return data.name.includes(value)
|
||||
if (data.name) {
|
||||
if (!data.name) return false
|
||||
return chooseNode(value, data, node)
|
||||
}
|
||||
}
|
||||
|
||||
function filterProcess(nodes: any) {
|
||||
if (process.value == '') {
|
||||
return nodes
|
||||
}
|
||||
return nodes
|
||||
.map(node => {
|
||||
// 递归处理子节点
|
||||
const children = node.children ? filterProcess(node.children) : []
|
||||
const chooseNode = (value: string, data: any, node: any): boolean => {
|
||||
if (data.name.indexOf(value) !== -1) return true
|
||||
|
||||
// 对于设备层级(level=2),只保留 process 值匹配的节点
|
||||
if (node.level === 2) {
|
||||
if (node.process == process.value) {
|
||||
return {
|
||||
...node,
|
||||
children: children
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
// 对于其他节点:
|
||||
// 1. 如果有满足条件的子节点则保留
|
||||
// 2. 如果本身 process 值匹配则保留
|
||||
// 3. 如果是叶子节点也保留(监测点通常没有子节点)
|
||||
if (children.length > 0 || node.process == process.value || !node.children || node.children.length === 0) {
|
||||
return {
|
||||
...node,
|
||||
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) {
|
||||
return true
|
||||
}
|
||||
const level = node.level
|
||||
// 如果传入的节点本身就是一级节点就不用校验了
|
||||
if (level === 1) {
|
||||
return false
|
||||
}
|
||||
// 先取当前节点的父节点
|
||||
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
|
||||
}
|
||||
// 否则的话再往上一层做匹配
|
||||
for (let i = 0; i < level - 1; i++) {
|
||||
if (parentData?.data?.name?.indexOf(value) !== -1) return true
|
||||
parentData = parentData.parent
|
||||
index++
|
||||
}
|
||||
// 没匹配到返回false
|
||||
return false
|
||||
}
|
||||
//治理
|
||||
const treeRef1 = ref<InstanceType<typeof ElTree>>()
|
||||
//便携式
|
||||
const treeRef2 = ref<InstanceType<typeof ElTree>>()
|
||||
//在线
|
||||
const treeRef3 = ref<InstanceType<typeof ElTree>>()
|
||||
// 工程
|
||||
const treeRef4 = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef1, treeRef2, treeRef3, treeRef4 })
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
setActiveName()
|
||||
}, 500)
|
||||
})
|
||||
const setActiveName = () => {
|
||||
if (zlDeviceData.value.length != 0) {
|
||||
zlDevList.value = filterProcess(JSON.parse(JSON.stringify(zlDeviceData.value)))
|
||||
activeName.value = '0'
|
||||
}
|
||||
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length != 0) {
|
||||
activeName.value = '1'
|
||||
}
|
||||
if (zlDeviceData.value.length === 0 && bxsDeviceData.value.length === 0) {
|
||||
activeName.value = '2'
|
||||
}
|
||||
if (!zlDeviceData.value && !bxsDeviceData.value) {
|
||||
activeName.value = '2'
|
||||
}
|
||||
nextTick(() => {
|
||||
changeDevice(activeName.value)
|
||||
})
|
||||
}
|
||||
const loading = ref(false)
|
||||
|
||||
const changeTreeType = (val: string) => {
|
||||
loading.value = true
|
||||
emit('changeTreeType', val)
|
||||
if (val == '1') {
|
||||
setActiveName()
|
||||
if (val === '1') {
|
||||
nextTick(() => setActiveName())
|
||||
}
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 1000)
|
||||
}, 300)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,36 +1,45 @@
|
||||
<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" v-model.trim='filterText' placeholder='请输入内容' clearable>
|
||||
<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="18px"
|
||||
class="fold ml10 mt20 menu-collapse"
|
||||
style="cursor: pointer"
|
||||
/> -->
|
||||
<div class="cn-tree" :style="{ opacity: menuCollapse ? 0 : 1 }">
|
||||
<div style="display: flex; align-items: center" class="mb10">
|
||||
<el-input maxlength="32" v-model.trim="filterText" placeholder="请输入内容" clearable>
|
||||
<template #prefix>
|
||||
<Icon name='el-icon-Search' style='font-size: 16px' />
|
||||
<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'
|
||||
:style="{ height: 'calc(100vh - 120px)' }"
|
||||
style="overflow: auto"
|
||||
ref="treeRef"
|
||||
:props="defaultProps"
|
||||
highlight-current
|
||||
:filter-node-method='filterNode'
|
||||
node-key='id'
|
||||
:filter-node-method="filterNode"
|
||||
node-key="id"
|
||||
show-checkbox
|
||||
@check="handleCheckChange"
|
||||
@node-click="handleNodeClick"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
v-bind='$attrs'
|
||||
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>
|
||||
<template #default="{ node, data: nodeData }">
|
||||
<span class="custom-tree-node">
|
||||
<Icon
|
||||
:name="nodeData.icon"
|
||||
style="font-size: 16px"
|
||||
:style="{ color: nodeData.color }"
|
||||
v-if="nodeData.icon"
|
||||
/>
|
||||
<span style="margin-left: 4px">{{ node.label }}</span>
|
||||
</span>
|
||||
</template>
|
||||
</el-tree>
|
||||
@@ -38,15 +47,14 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts' setup>
|
||||
<script lang="ts" setup>
|
||||
import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElMessage, ElTree } from 'element-plus'
|
||||
import { emit } from 'process';
|
||||
import { ref, watch } from 'vue'
|
||||
import { createTreeFilterNode } from './govern/treeFilterUtils'
|
||||
import { isLineTreeLeaf } from './govern/lineTreeUtils'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/tree'
|
||||
})
|
||||
defineOptions({ name: 'govern/select', inheritAttrs: false })
|
||||
|
||||
interface Props {
|
||||
width?: string
|
||||
@@ -57,174 +65,67 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
width: '280px',
|
||||
canExpand: true
|
||||
})
|
||||
|
||||
const emit = defineEmits(['changePointType', 'checkedNodesChange'])
|
||||
|
||||
const { proxy } = useCurrentInstance()
|
||||
const menuCollapse = ref(false)
|
||||
const filterText = ref('')
|
||||
const defaultProps = {
|
||||
label: 'name',
|
||||
value: 'id'
|
||||
}
|
||||
const emit = defineEmits(['changePointType', 'checkedNodesChange'])
|
||||
const defaultProps = { label: 'name', value: 'id' }
|
||||
const filterNode = createTreeFilterNode()
|
||||
const checkedNodes = ref<any[]>([])
|
||||
const defaultCheckedKeys = ref<string[]>([])
|
||||
const MAX_CHECK = 5
|
||||
|
||||
watch(filterText, val => {
|
||||
treeRef.value!.filter(val)
|
||||
const isMonitorLeaf = (node: any) => isLineTreeLeaf(node)
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
const handleCheckChange = (_data: any, checkInfo: any) => {
|
||||
const monitoringPointNodes = (checkInfo.checkedNodes as any[]).filter(isMonitorLeaf)
|
||||
|
||||
// 过滤父节点 / 子节点 (如果输入的参数是父节点且能匹配,则返回该节点以及其下的所有子节点;如果参数是子节点,则返回该节点的父节点。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 || []
|
||||
|
||||
// 计算新增的节点
|
||||
if (monitoringPointNodes.length > MAX_CHECK) {
|
||||
const previousCheckedNodes = checkedNodes.value
|
||||
const newNodes = monitoringPointNodes.filter(
|
||||
(node: any) => !previousCheckedNodes.some((prev: any) => prev.id === node.id)
|
||||
node => !previousCheckedNodes.some(prev => prev.id === node.id)
|
||||
)
|
||||
|
||||
// 如果是从父级勾选导致超过限制,保留前几个直到达到限制数量
|
||||
if (newNodes.length > 0) {
|
||||
const allowedNewCount = 5 - previousCheckedNodes.length
|
||||
const allowedNewCount = MAX_CHECK - previousCheckedNodes.length
|
||||
if (allowedNewCount > 0) {
|
||||
// 允许添加allowedNewCount个新节点
|
||||
const allowedNewNodes = newNodes.slice(0, allowedNewCount)
|
||||
const finalNodes = [...previousCheckedNodes, ...allowedNewNodes]
|
||||
|
||||
const finalNodes = [...previousCheckedNodes, ...newNodes.slice(0, allowedNewCount)]
|
||||
checkedNodes.value = finalNodes
|
||||
|
||||
// 设置树的勾选状态为正确的节点
|
||||
treeRef.value?.setCheckedNodes(finalNodes)
|
||||
|
||||
// 将勾选的监测点节点暴露出去
|
||||
emit('checkedNodesChange', finalNodes)
|
||||
|
||||
// 更新节点的可勾选状态
|
||||
updateNodeCheckStatus(finalNodes.length)
|
||||
|
||||
// 只有在真正超过5个时才提示警告
|
||||
if (monitoringPointNodes.length > 5) {
|
||||
ElMessage.warning('最多只能选择5个监测点')
|
||||
if (monitoringPointNodes.length > MAX_CHECK) {
|
||||
ElMessage.warning(`最多只能选择${MAX_CHECK}个监测点`)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 其他情况回滚到之前的状态
|
||||
ElMessage.warning('最多只能选择5个监测点')
|
||||
ElMessage.warning(`最多只能选择${MAX_CHECK}个监测点`)
|
||||
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.data.checked) {
|
||||
node.data.disabled = true
|
||||
} else {
|
||||
node.data.disabled = false
|
||||
}
|
||||
const isMaxSelected = currentCount >= MAX_CHECK
|
||||
treeRef.value.store._getAllNodes().forEach((node: any) => {
|
||||
if (isMonitorLeaf(node.data)) {
|
||||
node.data.disabled = isMaxSelected && !node.checked
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -233,8 +134,7 @@ const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||
defineExpose({ treeRef })
|
||||
</script>
|
||||
|
||||
|
||||
<style lang='scss' scoped>
|
||||
<style lang="scss" scoped>
|
||||
.cn-tree {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="layout-logo">
|
||||
<img v-if="!config.layout.menuCollapse" class="logo-img" :src="getTheme.logoUrl" />
|
||||
<img v-if="!config.layout.menuCollapse && getTheme.logoUrl" class="logo-img" :src="getTheme.logoUrl" />
|
||||
<!-- <div-->
|
||||
<!-- v-if="!config.layout.menuCollapse"-->
|
||||
<!-- :style="{ color: config.getColorVal('menuActiveColor') }"-->
|
||||
@@ -24,11 +24,11 @@
|
||||
<script setup lang="ts">
|
||||
import { useConfig } from '@/stores/config'
|
||||
import { closeShade } from '@/utils/pageShade'
|
||||
import { Session } from '@/utils/storage'
|
||||
import { getStoredTheme } from '@/utils/storage'
|
||||
import { setNavTabsWidth } from '@/utils/layout'
|
||||
|
||||
const config = useConfig()
|
||||
const getTheme = JSON.parse(window.localStorage.getItem('getTheme') as string)
|
||||
const getTheme = getStoredTheme()
|
||||
const onMenuCollapse = function () {
|
||||
if (config.layout.shrink && !config.layout.menuCollapse) {
|
||||
closeShade()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<div class="nav-bar">
|
||||
<div v-if="config.layout.shrink && config.layout.menuCollapse" class="unfold">
|
||||
<Icon @click="onMenuCollapse" name="fa fa-indent" :color="config.getColorVal('menuActiveColor')"
|
||||
size="18" />
|
||||
<!-- <Icon @click="onMenuCollapse" name="fa fa-indent" :color="config.getColorVal('menuActiveColor')"
|
||||
size="18" /> -->
|
||||
</div>
|
||||
<span class="nav-bar-title">{{ getTheme.name }} <span style="font-size: 14px;" v-if="Version?.versionName">
|
||||
<span class="nav-bar-title">{{ themeName }} <span style="font-size: 14px;" v-if="Version?.versionName">
|
||||
({{ Version?.versionName }})
|
||||
</span></span>
|
||||
<NavMenus />
|
||||
@@ -19,8 +19,9 @@ import NavMenus from '../navMenus.vue'
|
||||
import { showShade } from '@/utils/pageShade'
|
||||
import { onMounted } from 'vue'
|
||||
import { getLastData } from '@/api/systerm'
|
||||
import { getStoredThemeName } from '@/utils/storage'
|
||||
const config = useConfig()
|
||||
const getTheme = JSON.parse(window.localStorage.getItem('getTheme') as string)
|
||||
const themeName = getStoredThemeName()
|
||||
const Version: any = ref({})
|
||||
const onMenuCollapse = () => {
|
||||
showShade('ba-aside-menu-shade', () => {
|
||||
@@ -33,7 +34,7 @@ onMounted(() => {
|
||||
Version.value = res.data
|
||||
|
||||
})
|
||||
document.title = getTheme.name
|
||||
document.title = themeName
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog draggable width="600px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-dialog draggable width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
|
||||
<el-form :inline="false" :model="form" label-width="auto" class="form-one">
|
||||
<el-form-item label="用户名称:">
|
||||
|
||||
@@ -51,11 +51,11 @@ onBeforeMount(() => {
|
||||
})
|
||||
|
||||
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
|
||||
await Promise.all([ dictDataCache(), getUserById(), areaSelect(),getAllUserSimpleList()]).then(res => {
|
||||
// dictData.state.area = res[0].data
|
||||
dictData.state.basic = res[0].data
|
||||
// dictData.state.userList=res[4].data
|
||||
adminInfo.dataFill(res[2].data)
|
||||
adminInfo.dataFill(res[1].data)
|
||||
// dictData.state.areaTree = res[3].data
|
||||
})
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog width="600px" v-model.trim='dialogVisible' :title='title'>
|
||||
<el-dialog width="500px" v-model.trim='dialogVisible' :title='title'>
|
||||
<el-scrollbar>
|
||||
<el-form :inline='false' :model='form' label-width='auto' class="form-one" :rules='rules' ref='formRef'>
|
||||
<el-form-item label='角色名称'>
|
||||
|
||||
59
src/utils/chartAxisHelper.ts
Normal file
59
src/utils/chartAxisHelper.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
const AXIS_DECIMALS = 2
|
||||
|
||||
export function roundAxisValue(val: number, decimals = AXIS_DECIMALS): number {
|
||||
if (!Number.isFinite(val)) return 0
|
||||
const factor = 10 ** decimals
|
||||
return Math.round(val * factor) / factor
|
||||
}
|
||||
|
||||
/** Y 轴刻度:最多 2 位小数,末尾 0 去掉(如 1.00 → 1,0.10 → 0.1) */
|
||||
export function formatAxisLabel(value: number): string {
|
||||
if (!Number.isFinite(value)) return '0'
|
||||
return String(Number(roundAxisValue(value).toFixed(AXIS_DECIMALS)))
|
||||
}
|
||||
|
||||
/** 瞬间波形 Y 轴范围 */
|
||||
export function calcShuYAxisRange(dataMin: number, dataMax: number): { min: number; max: number } {
|
||||
const min = Number(dataMin)
|
||||
const max = Number(dataMax)
|
||||
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
||||
return { min: 0, max: 1 }
|
||||
}
|
||||
|
||||
let axisMax = max * 1.1
|
||||
let axisMin = min > 0 ? min - min * 0.1 : min * 1.1
|
||||
|
||||
if (axisMax <= axisMin) {
|
||||
const pad = Math.abs(max) * 0.1 || 0.01
|
||||
axisMax = max + pad
|
||||
axisMin = min - pad
|
||||
}
|
||||
|
||||
return {
|
||||
min: roundAxisValue(axisMin),
|
||||
max: roundAxisValue(axisMax)
|
||||
}
|
||||
}
|
||||
|
||||
/** RMS 波形 Y 轴范围 */
|
||||
export function calcRmsYAxisRange(dataMin: number, dataMax: number): { min: number; max: number } {
|
||||
const min = Number(dataMin)
|
||||
const max = Number(dataMax)
|
||||
if (!Number.isFinite(min) || !Number.isFinite(max)) {
|
||||
return { min: 0, max: 1 }
|
||||
}
|
||||
|
||||
let axisMax = max * 1.06 * 1.1
|
||||
let axisMin = min - min * 0.2
|
||||
|
||||
if (axisMax <= axisMin) {
|
||||
const pad = Math.abs(max - min) * 0.1 || Math.abs(max) * 0.1 || 0.01
|
||||
axisMax = max + pad
|
||||
axisMin = min - pad
|
||||
}
|
||||
|
||||
return {
|
||||
min: roundAxisValue(axisMin),
|
||||
max: roundAxisValue(axisMax)
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
const dataProcessing = (arr: any[]) => {
|
||||
return arr
|
||||
.filter(item => typeof item === 'number' || (typeof item === 'string' && !isNaN(parseFloat(item))))
|
||||
@@ -258,6 +257,32 @@ export const completeTimeSeries = (rawData: string[][]): (string | null)[][] =>
|
||||
}
|
||||
})
|
||||
|
||||
// 补首尾边界:首日 00:00:00、末日 23:59:59
|
||||
const createPadItem = (timeStr: string): (string | null | undefined)[] => {
|
||||
const result: (string | null | undefined)[] = [timeStr, '/']
|
||||
if (template.length > 2) result.push(template[2])
|
||||
if (template.length > 3) result.push(template[3])
|
||||
return result
|
||||
}
|
||||
|
||||
const firstDate = new Date(completedData[0][0] as string)
|
||||
const dayStartStr = formatTime(
|
||||
new Date(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate(), 0, 0, 0)
|
||||
)
|
||||
|
||||
const lastDate = new Date(completedData[completedData.length - 1][0] as string)
|
||||
const dayEndStr = formatTime(new Date(lastDate.getFullYear(), lastDate.getMonth(), lastDate.getDate(), 23, 59, 59))
|
||||
|
||||
const firstTimeStr = formatTime(new Date(completedData[0][0] as string))
|
||||
if (firstTimeStr !== dayStartStr) {
|
||||
completedData.unshift(createPadItem(dayStartStr))
|
||||
}
|
||||
|
||||
const lastTimeStr = formatTime(new Date(completedData[completedData.length - 1][0] as string))
|
||||
if (lastTimeStr !== dayEndStr) {
|
||||
completedData.push(createPadItem(dayEndStr))
|
||||
}
|
||||
|
||||
return completedData
|
||||
}
|
||||
|
||||
|
||||
83
src/utils/luckysheetHelper.ts
Normal file
83
src/utils/luckysheetHelper.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
|
||||
/** 解析 Luckysheet 接口返回的 sheet 数据 */
|
||||
export function parseLuckysheetSheets(sheets: any[]) {
|
||||
sheets.forEach((item: any) => {
|
||||
if (item.data1) {
|
||||
try {
|
||||
item.data = JSON.parse(item.data1)
|
||||
} catch {
|
||||
/* ignore invalid json */
|
||||
}
|
||||
}
|
||||
item.celldata?.forEach((cell: any) => {
|
||||
if (item.data?.[cell.r]?.[cell.c]?.v != null) {
|
||||
item.data[cell.r][cell.c] = cell.v
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
declare const luckysheet: any
|
||||
|
||||
const DEFAULT_REPORT_OPTIONS = {
|
||||
title: '',
|
||||
lang: 'zh',
|
||||
showtoolbar: false,
|
||||
showinfobar: false,
|
||||
showsheetbar: true,
|
||||
}
|
||||
|
||||
/** 销毁已有 Luckysheet 实例,避免重复 create 导致 DOM 堆积 */
|
||||
export function destroyLuckysheet() {
|
||||
try {
|
||||
if (typeof luckysheet !== 'undefined' && luckysheet.destroy) {
|
||||
luckysheet.destroy()
|
||||
}
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/** 解析 sheet 数据、销毁旧实例并渲染报表 */
|
||||
export function renderLuckysheetReport(
|
||||
container: string,
|
||||
sheets: any[],
|
||||
options: Record<string, any> = {}
|
||||
) {
|
||||
parseLuckysheetSheets(sheets)
|
||||
destroyLuckysheet()
|
||||
setTimeout(() => {
|
||||
luckysheet.create({
|
||||
container,
|
||||
...DEFAULT_REPORT_OPTIONS,
|
||||
...options,
|
||||
data: sheets,
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
|
||||
/** 安全导出 Luckysheet,无数据时提示并返回 false */
|
||||
export function exportLuckysheetFile(filename: string, hasData = true): boolean {
|
||||
if (!hasData) {
|
||||
ElMessage.warning('暂无数据')
|
||||
return false
|
||||
}
|
||||
try {
|
||||
if (typeof luckysheet === 'undefined' || !luckysheet.getAllSheets) {
|
||||
ElMessage.warning('暂无数据')
|
||||
return false
|
||||
}
|
||||
const sheets = luckysheet.getAllSheets()
|
||||
if (!sheets?.length) {
|
||||
ElMessage.warning('暂无数据')
|
||||
return false
|
||||
}
|
||||
exportExcel(sheets, filename)
|
||||
return true
|
||||
} catch {
|
||||
ElMessage.warning('导出失败,请先加载报表数据')
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,21 @@ export const Local = {
|
||||
* @method remove 移除会话缓存
|
||||
* @method clear 移除全部会话缓存
|
||||
*/
|
||||
const DEFAULT_THEME_NAME = '电能质量监测系统'
|
||||
|
||||
export function getStoredTheme(): { name?: string; logoUrl?: string; [key: string]: any } {
|
||||
try {
|
||||
const raw = window.localStorage.getItem('getTheme')
|
||||
return raw ? JSON.parse(raw) : {}
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function getStoredThemeName(): string {
|
||||
return getStoredTheme().name || DEFAULT_THEME_NAME
|
||||
}
|
||||
|
||||
export const Session = {
|
||||
set(key: string, val: any) {
|
||||
window.sessionStorage.setItem(key, JSON.stringify(val))
|
||||
|
||||
@@ -19,7 +19,7 @@ interface TableStoreParams {
|
||||
resetCallback?: () => void // 重置
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
exportProcessingData?: () => void //导出处理数据
|
||||
beforeSearchFun?: () => void // 接口调用前的回调
|
||||
beforeSearchFun?: () => void | boolean // 接口调用前的回调,返回 false 中止请求
|
||||
}
|
||||
|
||||
export default class TableStore {
|
||||
@@ -75,7 +75,13 @@ export default class TableStore {
|
||||
}
|
||||
|
||||
index() {
|
||||
this.table.beforeSearchFun && this.table.beforeSearchFun()
|
||||
if (this.table.beforeSearchFun) {
|
||||
const canSearch = this.table.beforeSearchFun()
|
||||
if (canSearch === false) {
|
||||
this.table.loading = false
|
||||
return
|
||||
}
|
||||
}
|
||||
this.table.data = []
|
||||
this.table.loading = true
|
||||
// 重置用的数据数据
|
||||
|
||||
42
src/utils/waveCache.ts
Normal file
42
src/utils/waveCache.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
const MAX_CACHE_SIZE = 30
|
||||
|
||||
const cache = new Map<string, unknown>()
|
||||
|
||||
function dataFingerprint(data: unknown[][] | undefined): string {
|
||||
if (!data?.length) return '0'
|
||||
const first = data[0]
|
||||
const last = data[data.length - 1]
|
||||
return `${data.length}:${first?.[0]}:${last?.[0]}`
|
||||
}
|
||||
|
||||
export function buildWaveCacheKey(
|
||||
type: 'shu' | 'rms',
|
||||
wp: Record<string, any> | undefined,
|
||||
value: number,
|
||||
isOpen: boolean,
|
||||
boxoList: Record<string, any>
|
||||
): string {
|
||||
if (!wp) return ''
|
||||
const waveFp =
|
||||
type === 'shu' ? dataFingerprint(wp.listWaveData) : dataFingerprint(wp.listRmsData)
|
||||
const boxoFp = boxoList?.startTime ?? boxoList?.lineName ?? boxoList?.equipmentName ?? ''
|
||||
return `${type}|${wp.time}|${wp.waveType}|${wp.iphasic}|${value}|${isOpen}|${waveFp}|${boxoFp}`
|
||||
}
|
||||
|
||||
export function getWaveCache<T>(key: string): T | null {
|
||||
if (!key || !cache.has(key)) return null
|
||||
const value = cache.get(key) as T
|
||||
cache.delete(key)
|
||||
cache.set(key, value)
|
||||
return value
|
||||
}
|
||||
|
||||
export function setWaveCache(key: string, value: unknown): void {
|
||||
if (!key) return
|
||||
if (cache.has(key)) cache.delete(key)
|
||||
cache.set(key, value)
|
||||
while (cache.size > MAX_CACHE_SIZE) {
|
||||
const oldest = cache.keys().next().value
|
||||
if (oldest !== undefined) cache.delete(oldest)
|
||||
}
|
||||
}
|
||||
96
src/utils/waveWorkerPool.ts
Normal file
96
src/utils/waveWorkerPool.ts
Normal file
@@ -0,0 +1,96 @@
|
||||
import { toRaw } from 'vue'
|
||||
|
||||
type WorkerMessageHandler = (data: any) => void
|
||||
|
||||
let shuWorker: Worker | null = null
|
||||
let rmsWorker: Worker | null = null
|
||||
|
||||
/** 递归剥离 Vue 响应式代理,得到可 structuredClone 的纯对象 */
|
||||
export function toPlainDeep<T>(value: T): T {
|
||||
const raw = toRaw(value as object) as T
|
||||
if (Array.isArray(raw)) {
|
||||
return raw.map(item => toPlainDeep(item)) as T
|
||||
}
|
||||
if (raw !== null && typeof raw === 'object') {
|
||||
const out: Record<string, unknown> = {}
|
||||
for (const [key, val] of Object.entries(raw)) {
|
||||
out[key] = toPlainDeep(val)
|
||||
}
|
||||
return out as T
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
const BOXO_LIST_KEYS = [
|
||||
'systemType',
|
||||
'powerStationName',
|
||||
'measurementPointName',
|
||||
'startTime',
|
||||
'featureAmplitude',
|
||||
'duration',
|
||||
'engineeringName',
|
||||
'equipmentName',
|
||||
'evtParamVVaDepth',
|
||||
'evtParamTm',
|
||||
'lineName',
|
||||
'persistTime',
|
||||
'subName'
|
||||
] as const
|
||||
|
||||
export function buildWorkerPayload(
|
||||
type: 'shu' | 'rms',
|
||||
wp: Record<string, any>,
|
||||
boxoList: Record<string, any>,
|
||||
extras: { requestId: number; value: number; isOpen: boolean; iphasic?: number }
|
||||
) {
|
||||
const plainWp = toPlainDeep(wp)
|
||||
const wpPayload: Record<string, unknown> = {
|
||||
pt: plainWp.pt,
|
||||
ct: plainWp.ct,
|
||||
waveTitle: plainWp.waveTitle,
|
||||
iphasic: plainWp.iphasic,
|
||||
time: plainWp.time,
|
||||
waveType: plainWp.waveType,
|
||||
yzd: plainWp.yzd
|
||||
}
|
||||
if (type === 'shu') {
|
||||
wpPayload.listWaveData = plainWp.listWaveData
|
||||
} else {
|
||||
wpPayload.listRmsData = plainWp.listRmsData
|
||||
}
|
||||
|
||||
const plainBoxo: Record<string, unknown> = {}
|
||||
const rawBoxo = toPlainDeep(boxoList)
|
||||
for (const key of BOXO_LIST_KEYS) {
|
||||
if (rawBoxo[key] !== undefined) {
|
||||
plainBoxo[key] = rawBoxo[key]
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
requestId: extras.requestId,
|
||||
value: extras.value,
|
||||
isOpen: extras.isOpen,
|
||||
iphasic: extras.iphasic,
|
||||
wp: wpPayload,
|
||||
boxoList: plainBoxo
|
||||
}
|
||||
}
|
||||
|
||||
export function getShuWorker(onMessage: WorkerMessageHandler): Worker {
|
||||
if (!shuWorker) {
|
||||
shuWorker = new Worker(new URL('../components/echarts/shuWorker.js', import.meta.url))
|
||||
}
|
||||
shuWorker.onmessage = e => onMessage(e.data)
|
||||
shuWorker.onerror = error => console.error('Shu worker error:', error)
|
||||
return shuWorker
|
||||
}
|
||||
|
||||
export function getRmsWorker(onMessage: WorkerMessageHandler): Worker {
|
||||
if (!rmsWorker) {
|
||||
rmsWorker = new Worker(new URL('../components/echarts/rmsWorker.js', import.meta.url))
|
||||
}
|
||||
rmsWorker.onmessage = e => onMessage(e.data)
|
||||
rmsWorker.onerror = error => console.error('Rms worker error:', error)
|
||||
return rmsWorker
|
||||
}
|
||||
@@ -57,7 +57,7 @@
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.email" placeholder="请输入描述" />
|
||||
</el-form-item>
|
||||
<el-form-item label="时间段" prop="limitTime">
|
||||
<el-slider v-model.trim="form.limitTime" style="width: 95%" range show-stops :max="24" />
|
||||
<el-slider v-model.trim="form.limitTime" style="width: 95%" range :max="24" />
|
||||
</el-form-item>
|
||||
<el-form-item label="起始IP" prop="limitIpStart">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.limitIpStart" placeholder="请输入描述" />
|
||||
|
||||
@@ -92,8 +92,8 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '设备名称', field: 'ndid', align: 'center' },
|
||||
{ title: '异常时间', field: 'evtTime', align: 'center', sortable: true },
|
||||
{ title: '设备名称', field: 'ndid', align: 'center' },
|
||||
{
|
||||
title: '告警代码',
|
||||
field: 'code',
|
||||
|
||||
@@ -99,16 +99,17 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '设备名称', field: 'equipmentName', align: 'center', width: 120 },
|
||||
{ title: '监测点名称', field: 'lineName', align: 'center', width: 140 },
|
||||
{ title: '工程名称', field: 'engineeringName', align: 'center', width: 120 },
|
||||
{ title: '项目名称', field: 'projectName', align: 'center', width: 120 },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', width: 180, sortable: true },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', minWidth: 180, sortable: true },
|
||||
{ title: '工程名称', field: 'engineeringName', align: 'center', minWidth: 120 },
|
||||
{ title: '项目名称', field: 'projectName', align: 'center', minWidth: 120 },
|
||||
{ title: '设备名称', field: 'equipmentName', align: 'center', minWidth: 120 },
|
||||
{ title: '监测点名称', field: 'lineName', align: 'center', minWidth: 120 },
|
||||
|
||||
{
|
||||
title: '模块信息',
|
||||
field: 'moduleNo',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
minWidth: 100,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue ? row.cellValue : '/'
|
||||
}
|
||||
@@ -117,7 +118,7 @@ const tableStore = new TableStore({
|
||||
title: '告警代码',
|
||||
field: 'code',
|
||||
align: 'center',
|
||||
width: 100,
|
||||
minWidth: 100,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue ? '\u200B' + row.cellValue : '/'
|
||||
},
|
||||
@@ -125,13 +126,13 @@ const tableStore = new TableStore({
|
||||
},
|
||||
{
|
||||
title: '事件描述',
|
||||
minWidth: 250,
|
||||
minWidth: 300,
|
||||
field: 'showName'
|
||||
},
|
||||
{
|
||||
title: '级别',
|
||||
field: 'level',
|
||||
width: 100,
|
||||
width: 110,
|
||||
render: 'tag',
|
||||
custom: {
|
||||
// 1:Ⅰ级 2:Ⅱ级 3:Ⅲ级 4:DEBUG 5:NORMAL 6:WARN 7:ERROR
|
||||
@@ -202,7 +203,7 @@ tableStore.table.params.deviceTypeId = ''
|
||||
tableStore.table.params.deviceTypeName = ''
|
||||
const deviceTreeOptions = ref<any>(props.deviceTree)
|
||||
deviceTreeOptions.value.map((item: any, index: any) => {
|
||||
if (item.children.length == 0) {
|
||||
if (item?.children.length == 0) {
|
||||
deviceTreeOptions.value.splice(index, 1)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -78,10 +78,10 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '前置服务器名称', field: 'lineId', align: 'center', width: 120 },
|
||||
{ title: '前置服务器ip', field: 'wavePath', align: 'center', width: 120 },
|
||||
{ title: '进程号', field: 'clDid', align: 'center', width: 60 },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', width: 180, sortable: true },
|
||||
{ title: '前置服务器名称', field: 'lineId', align: 'center', width: 150 },
|
||||
{ title: '前置服务器ip', field: 'wavePath', align: 'center', width: 150 },
|
||||
{ title: '进程号', field: 'clDid', align: 'center', width: 70 },
|
||||
|
||||
{
|
||||
title: '事件描述',
|
||||
@@ -102,7 +102,7 @@ const tableStore = new TableStore({
|
||||
{
|
||||
title: '级别',
|
||||
field: 'level',
|
||||
width: 100,
|
||||
width: 110,
|
||||
render: 'tag',
|
||||
custom: {
|
||||
// 1:Ⅰ级 2:Ⅱ级 3:Ⅲ级 4:DEBUG 5:NORMAL 6:WARN 7:ERROR
|
||||
@@ -153,7 +153,7 @@ tableStore.table.params.searchValue = ''
|
||||
tableStore.table.params.level = ''
|
||||
const deviceTreeOptions = ref<any>(props.deviceTree)
|
||||
deviceTreeOptions.value.map((item: any, index: any) => {
|
||||
if (item.children.length == 0) {
|
||||
if (item?.children.length == 0) {
|
||||
deviceTreeOptions.value.splice(index, 1)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -2,16 +2,9 @@
|
||||
<TableHeader datePicker ref="refheader" showExport>
|
||||
<template v-slot:select>
|
||||
<el-form-item label="数据来源">
|
||||
<el-cascader
|
||||
v-model.trim="tableStore.table.params.cascader"
|
||||
filterable
|
||||
placeholder="请选择数据来源"
|
||||
@change="sourceChange"
|
||||
:options="deviceTreeOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
||||
clearable
|
||||
></el-cascader>
|
||||
<el-cascader v-model.trim="tableStore.table.params.cascader" filterable placeholder="请选择数据来源"
|
||||
@change="sourceChange" :options="deviceTreeOptions" :show-all-levels="false"
|
||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }" clearable></el-cascader>
|
||||
<!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> -->
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="级别">
|
||||
@@ -83,14 +76,15 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '设备名称', field: 'equipmentName', align: 'center' },
|
||||
{ title: '工程名称', field: 'engineeringName', align: 'center' },
|
||||
{ title: '项目名称', field: 'projectName', align: 'center' },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', sortable: true },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', sortable: true, minWidth: 180, },
|
||||
{ title: '工程名称', field: 'engineeringName', align: 'center', minWidth: 120, },
|
||||
{ title: '项目名称', field: 'projectName', align: 'center', minWidth: 120, },
|
||||
{ title: '设备名称', field: 'equipmentName', align: 'center', minWidth: 120, },
|
||||
|
||||
{ title: '事件描述', field: 'showName', align: 'center' }
|
||||
|
||||
{ title: '事件描述', field: 'showName', align: 'center', minWidth: 250, }
|
||||
],
|
||||
beforeSearchFun: () => {}
|
||||
beforeSearchFun: () => { }
|
||||
})
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
@@ -112,7 +106,7 @@ tableStore.table.params.deviceTypeName = ''
|
||||
|
||||
const deviceTreeOptions = ref<any>(props.deviceTree)
|
||||
deviceTreeOptions.value.map((item: any, index: any) => {
|
||||
if (item.children.length == 0) {
|
||||
if (item?.children.length == 0) {
|
||||
deviceTreeOptions.value.splice(index, 1)
|
||||
}
|
||||
})
|
||||
@@ -143,6 +137,6 @@ onMounted(() => {
|
||||
setTimeout(() => {
|
||||
tableStore.table.height = mainHeight(200).height as any
|
||||
}, 0)
|
||||
const addMenu = () => {}
|
||||
const addMenu = () => { }
|
||||
</script>
|
||||
<style></style>
|
||||
|
||||
@@ -3,16 +3,10 @@
|
||||
<TableHeader datePicker showExport>
|
||||
<template v-slot:select>
|
||||
<el-form-item label="数据来源">
|
||||
<el-cascader
|
||||
placeholder="请选择数据来源"
|
||||
@change="sourceChange"
|
||||
filterable
|
||||
v-model.trim="tableStore.table.params.cascader"
|
||||
:options="deviceTreeOptions"
|
||||
:show-all-levels="false"
|
||||
:props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
||||
clearable
|
||||
></el-cascader>
|
||||
<el-cascader placeholder="请选择数据来源" @change="sourceChange" filterable
|
||||
v-model.trim="tableStore.table.params.cascader" :options="deviceTreeOptions"
|
||||
:show-all-levels="false" :props="{ checkStrictly: true, value: 'id', label: 'name' }"
|
||||
clearable></el-cascader>
|
||||
<!-- <el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue" placeholder="请输入设备名称" /> -->
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="级别">
|
||||
@@ -26,13 +20,8 @@
|
||||
|
||||
<Table></Table>
|
||||
</div>
|
||||
<waveFormAnalysis
|
||||
v-loading="loading"
|
||||
v-if="isWaveCharts"
|
||||
ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false"
|
||||
:wp="wp"
|
||||
/>
|
||||
<waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false" :wp="wp" />
|
||||
<!-- <div style="height: 300px;"> -->
|
||||
|
||||
<!-- <div style="padding: 10px" v-if="!view" v-loading="loading">
|
||||
@@ -129,16 +118,20 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '设备名称', field: 'equipmentName', minWidth: 120, align: 'center' },
|
||||
{ title: '暂降发生时刻', field: 'startTime', align: 'center', minWidth: 180, sortable: true },
|
||||
|
||||
|
||||
{ title: '暂降(骤升)幅值(%)', minWidth: 160, field: 'evtParamVVaDepth', align: 'center', sortable: true },
|
||||
|
||||
{ title: '持续时间(s)', field: 'evtParamTm', minWidth: 110, align: 'center', sortable: true },
|
||||
{ title: '相别', field: 'evtParamPhase', minWidth: 80, align: 'center' },
|
||||
|
||||
{ title: '触发类型', field: 'showName', minWidth: 120, align: 'center' },
|
||||
{ title: '工程名称', field: 'engineeringName', minWidth: 120, align: 'center' },
|
||||
{ title: '项目名称', field: 'projectName', minWidth: 120, align: 'center' },
|
||||
{ title: '发生时刻', field: 'startTime', align: 'center', minWidth: 180, sortable: true },
|
||||
{ title: '设备名称', field: 'equipmentName', minWidth: 120, align: 'center' },
|
||||
{ title: '监测点名称', field: 'lineName', minWidth: 120, align: 'center' },
|
||||
{ title: '事件描述', field: 'showName', minWidth: 120, align: 'center' },
|
||||
{ title: '事件发生位置', field: 'evtParamPosition', minWidth: 150, align: 'center' },
|
||||
{ title: '相别', field: 'evtParamPhase', minWidth: 80, align: 'center' },
|
||||
{ title: '持续时间(s)', field: 'evtParamTm', minWidth: 80, align: 'center', sortable: true },
|
||||
{ title: '暂降(聚升)幅值(%)', minWidth: 100, field: 'evtParamVVaDepth', align: 'center', sortable: true },
|
||||
{ title: '发生位置', field: 'evtParamPosition', minWidth: 150, align: 'center' },
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
@@ -219,6 +212,7 @@ const tableStore = new TableStore({
|
||||
return !row.wavePath
|
||||
},
|
||||
click: row => {
|
||||
ElMessage.info('下载中......')
|
||||
getFileZip({ eventId: row.id }).then(res => {
|
||||
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
@@ -228,6 +222,7 @@ const tableStore = new TableStore({
|
||||
document.body.appendChild(link)
|
||||
link.click() //执行下载
|
||||
document.body.removeChild(link) //释放标签
|
||||
ElMessage.success('波形下载成功')
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -238,7 +233,7 @@ const tableStore = new TableStore({
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
disabled: row => {
|
||||
return row.showName != '未知'
|
||||
return row.wavePath
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -295,7 +290,7 @@ tableStore.table.params.deviceTypeName = ''
|
||||
|
||||
const deviceTreeOptions: any = ref<any>(props.deviceTree)
|
||||
deviceTreeOptions.value.map((item: any, index: any) => {
|
||||
if (item.children.length == 0) {
|
||||
if (item?.children.length == 0) {
|
||||
deviceTreeOptions.value.splice(index, 1)
|
||||
}
|
||||
})
|
||||
@@ -380,6 +375,6 @@ setTimeout(() => {
|
||||
tableStore.table.height = mainHeight(200).height as any
|
||||
}, 0)
|
||||
|
||||
const addMenu = () => {}
|
||||
const addMenu = () => { }
|
||||
</script>
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
129
src/views/govern/alarm/alarmConfig/form.vue
Normal file
129
src/views/govern/alarm/alarmConfig/form.vue
Normal file
@@ -0,0 +1,129 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" draggable v-model="dialogVisible" :title="title" width="500px"
|
||||
@closed="handleClosed">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto" class="form-one">
|
||||
<el-form-item label="方案名称" prop="name">
|
||||
<el-input v-model.trim="form.name" maxlength="64" show-word-limit placeholder="请输入方案名称" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="在线率阈值" prop="onlineRateLimit">
|
||||
<el-input-number v-model="form.onlineRateLimit" :min="0" :max="100" :precision="0" style="width: 100%"
|
||||
placeholder="0-100" />
|
||||
</el-form-item>
|
||||
<el-form-item label="完整性阈值" prop="integrityLimit">
|
||||
<el-input-number v-model="form.integrityLimit" :min="0" :max="100" :precision="0" style="width: 100%"
|
||||
placeholder="0-100" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="是否启用" prop="active">
|
||||
<el-select v-model="form.active" placeholder="请选择" style="width: 100%">
|
||||
<el-option label="启用" value="1" />
|
||||
<el-option label="停用" value="0" />
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { inject } from 'vue'
|
||||
import { add, update } from '@/api/cs-system-boot/appinfo'
|
||||
|
||||
const emit = defineEmits(['Cancels'])
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const formRef = ref()
|
||||
|
||||
const defaultForm = () => ({
|
||||
id: '',
|
||||
name: '',
|
||||
onlineRateLimit: undefined as number | undefined,
|
||||
integrityLimit: undefined as number | undefined,
|
||||
active: '0' as string
|
||||
})
|
||||
|
||||
const form = reactive(defaultForm())
|
||||
|
||||
const percentRule = (label: string) => [
|
||||
{ required: true, message: `请输入${label}`, trigger: 'blur' },
|
||||
{
|
||||
type: 'number',
|
||||
min: 0,
|
||||
max: 100,
|
||||
message: `${label}范围为 0-100`,
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
|
||||
const rules: any = {
|
||||
name: [
|
||||
{ required: true, message: '请输入方案名称', trigger: 'blur' },
|
||||
{ min: 1, max: 64, message: '长度 1-64 个字符', trigger: 'blur' }
|
||||
],
|
||||
onlineRateLimit: percentRule('在线率阈值'),
|
||||
integrityLimit: percentRule('完整性阈值'),
|
||||
active: [{ required: true, message: '请选择是否启用', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const isEdit = () => title.value.includes('修改')
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(form, defaultForm())
|
||||
}
|
||||
|
||||
const open = (e: { text: string; row?: any }) => {
|
||||
formRef.value?.resetFields()
|
||||
title.value = e.text
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
if (e.row) {
|
||||
form.id = e.row.id ?? ''
|
||||
form.name = e.row.name ?? ''
|
||||
form.onlineRateLimit = e.row.onlineRateLimit != null ? Number(e.row.onlineRateLimit) : undefined
|
||||
form.integrityLimit = e.row.integrityLimit != null ? Number(e.row.integrityLimit) : undefined
|
||||
form.active = String(e.row.active ?? '0')
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
dialogVisible.value = false
|
||||
emit('Cancels')
|
||||
}
|
||||
|
||||
const handleClosed = () => {
|
||||
resetForm()
|
||||
}
|
||||
|
||||
const onSubmit = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
const payload = {
|
||||
id: form.id,
|
||||
name: form.name,
|
||||
onlineRateLimit: form.onlineRateLimit,
|
||||
integrityLimit: form.integrityLimit,
|
||||
active: form.active
|
||||
}
|
||||
try {
|
||||
if (isEdit()) {
|
||||
await update(payload)
|
||||
ElMessage.success('修改成功')
|
||||
} else {
|
||||
await add(payload)
|
||||
ElMessage.success('新增成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('Cancels')
|
||||
} catch {
|
||||
/* 请求层一般会统一提示 */
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
152
src/views/govern/alarm/alarmConfig/index.vue
Normal file
152
src/views/govern/alarm/alarmConfig/index.vue
Normal file
@@ -0,0 +1,152 @@
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<TableHeader select :showReset="false" ref="TableHeaderRef">
|
||||
<template #operation>
|
||||
<el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" />
|
||||
<Form ref="formRef" @Cancels="tableStore.index()" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { toggleActive, csDelete } from '@/api/cs-system-boot/appinfo'
|
||||
import Form from './form.vue'
|
||||
defineOptions({
|
||||
name: 'govern/alarmConfig'
|
||||
})
|
||||
const formTabRef = ref()
|
||||
const formRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/cs-system-boot/csAlarmSet/listAll',
|
||||
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
|
||||
}
|
||||
},
|
||||
{ field: 'name', title: '名称' },
|
||||
{ field: 'onlineRateLimit', title: '在线率阈值' },
|
||||
{ field: 'integrityLimit', title: '完整性阈值' },
|
||||
{ field: 'updateTime', title: '创建时间' },
|
||||
{
|
||||
title: '是否启用',
|
||||
render: 'switch',
|
||||
width: 100,
|
||||
field: 'active',
|
||||
activeText: '启用',
|
||||
inactiveText: '停用',
|
||||
inactiveValue: '0',
|
||||
activeValue: '1',
|
||||
onChangeField: (row: any, value: any) => {
|
||||
if (row.active == 1) {
|
||||
return ElMessage({ message: '至少需要保留一条启用的配置!', type: 'warning' })
|
||||
// 至少需要保留一条启用的配置
|
||||
}
|
||||
toggleActive({
|
||||
id: row.id
|
||||
}).then(res => {
|
||||
ElMessage({ message: '启用成功!', type: 'success' })
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
width: '180',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
// {
|
||||
// name: 'edit',
|
||||
// title: '启用 ',
|
||||
// type: 'primary',
|
||||
// icon: 'el-icon-Plus',
|
||||
// render: 'basicButton',
|
||||
// disabled: row => {
|
||||
// return row.active == 1
|
||||
// },
|
||||
// click: row => {
|
||||
// toggleActive({ id: row.id }).then(res => {
|
||||
// ElMessage({
|
||||
// message: '启用成功!',
|
||||
// type: 'success'
|
||||
// })
|
||||
// tableStore.index()
|
||||
// })
|
||||
// }
|
||||
// },
|
||||
{
|
||||
name: 'edit',
|
||||
title: '修改 ',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-Plus',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
setTimeout(() => {
|
||||
formRef.value.open({
|
||||
text: '修改配置',
|
||||
row: row
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
icon: 'el-icon-Delete',
|
||||
render: 'confirmButton',
|
||||
disabled: row => {
|
||||
return row.active == 1
|
||||
},
|
||||
popconfirm: {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonType: 'danger',
|
||||
title: '确定删除吗?'
|
||||
},
|
||||
click: row => {
|
||||
csDelete({ id: row.id }).then(res => {
|
||||
ElMessage({
|
||||
message: '删除成功!',
|
||||
type: 'success'
|
||||
})
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
loadCallback: () => {
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
// 新增主题
|
||||
const add = () => {
|
||||
setTimeout(() => {
|
||||
formRef.value.open({
|
||||
text: '新增配置'
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
</script>
|
||||
@@ -7,15 +7,15 @@
|
||||
<el-tab-pane label="前置告警" name="2">
|
||||
<Front v-if="activeName == '2'" :deviceTree="deviceTree" :key="key" />
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane label="稳态越限告警" name="3">
|
||||
<el-tab-pane label="稳态越限告警" name="3">
|
||||
<Steady v-if="activeName == '3'" :deviceTree="deviceTree" :key="key" />
|
||||
</el-tab-pane> -->
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="暂态事件" name="4">
|
||||
<Transient v-if="activeName == '4'" :deviceTree="deviceTree" :key="key" />
|
||||
</el-tab-pane>
|
||||
<!-- <el-tab-pane label="异常事件" name="5">
|
||||
<el-tab-pane label="异常事件" name="5">
|
||||
<Abnormal v-if="activeName == '5'" :deviceTree="deviceTree" :key="key" />
|
||||
</el-tab-pane> -->
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
270
src/views/govern/alarm/scopeConfig/form.vue
Normal file
270
src/views/govern/alarm/scopeConfig/form.vue
Normal file
@@ -0,0 +1,270 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" draggable v-model="dialogVisible" :title="title" width="900px"
|
||||
@closed="handleClosed">
|
||||
<el-scrollbar max-height="60vh">
|
||||
<el-form ref="formRef" :model="form" :rules="rules" label-width="auto" class="form-two">
|
||||
<el-form-item label="指标名称" prop="indexName">
|
||||
<el-input v-model.trim="form.indexName" placeholder="请输入指标名称" clearable maxlength="128" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="指标code" prop="indexCode">
|
||||
<el-input v-model.trim="form.indexCode" placeholder="请输入指标code" clearable maxlength="64" />
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="表名" prop="influxdbTableName">
|
||||
<el-input v-model.trim="form.influxdbTableName" placeholder="请输入表名" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="列属性" prop="influxdbColumnName">
|
||||
<el-input v-model.trim="form.influxdbColumnName" placeholder="实体类属性名" clearable maxlength="128" />
|
||||
</el-form-item>
|
||||
<el-form-item label="谐波次数">
|
||||
<el-slider v-model.trim="form.harmSlider" range :max="50" style="width: 90%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="相别" prop="phaseList">
|
||||
<el-select v-model.trim="form.phaseList" filterable multiple clearable collapse-tags
|
||||
collapse-tags-tooltip placeholder="请选择相别">
|
||||
<el-option v-for="item in phaseSelect" :key="item.id" :label="item.name"
|
||||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="指标下限" prop="minValue">
|
||||
<el-input-number v-model="form.minValue" style="width: 100%" placeholder="下限" />
|
||||
</el-form-item>
|
||||
<el-form-item label="指标上限" prop="maxValue">
|
||||
<el-input-number v-model="form.maxValue" style="width: 100%" placeholder="上限" />
|
||||
</el-form-item>
|
||||
<el-form-item label="电压等级参与" prop="isVoltage">
|
||||
<el-radio-group v-model="form.isVoltage">
|
||||
<el-radio :value="0">不参与</el-radio>
|
||||
<el-radio :value="1">参与</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="Ct变比参与" prop="ctAttendFlag">
|
||||
<el-radio-group v-model="form.ctAttendFlag">
|
||||
<el-radio :value="0">不参与</el-radio>
|
||||
<el-radio :value="1">参与</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据来源" prop="dataSource">
|
||||
<el-select v-model="form.dataSource" placeholder="请选择" clearable style="width: 100%">
|
||||
<el-option label="InfluxDB" value="InfluxDB" />
|
||||
<!-- <el-option label="oracle" value="oracle" /> -->
|
||||
<el-option label="MySql" value="MySql" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属系统" prop="belongingSystem">
|
||||
<el-select v-model="form.belongingSystem" placeholder="请选择" clearable style="width: 100%">
|
||||
<el-option label="pqs" value="pqs" />
|
||||
<el-option label="govern" value="govern" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="单位" prop="unit">
|
||||
<el-input v-model.trim="form.unit" placeholder="请输入单位" clearable maxlength="32" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="form.sort" :min="0" :precision="0" style="width: 100%" />
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="状态" prop="state">
|
||||
<el-select v-model="form.state" placeholder="请选择" style="width: 100%">
|
||||
<el-option label="正常" :value="1" />
|
||||
<el-option label="删除" :value="0" />
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="条件描述" prop="otherAlgorithm" class="form-item-full">
|
||||
<el-input v-model.trim="form.otherAlgorithm" type="textarea" :rows="2" placeholder="无具体范围时的判断条件描述"
|
||||
maxlength="500" show-word-limit />
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark" class="form-item-full">
|
||||
<el-input v-model.trim="form.remark" type="textarea" :rows="2" placeholder="备注" maxlength="500"
|
||||
show-word-limit />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-scrollbar>
|
||||
<template #footer>
|
||||
<el-button @click="handleCancel">取消</el-button>
|
||||
<el-button type="primary" @click="onSubmit">确定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { save, update } from '@/api/algorithm-boot/scopeConfig'
|
||||
const emit = defineEmits(['Cancels'])
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const formRef = ref()
|
||||
const phaseSelect = [
|
||||
{
|
||||
name: 'A相',
|
||||
id: 'A'
|
||||
},
|
||||
{
|
||||
name: 'B相',
|
||||
id: 'B'
|
||||
},
|
||||
{
|
||||
name: 'C相',
|
||||
id: 'C'
|
||||
},
|
||||
{
|
||||
name: '无相别',
|
||||
id: 'T'
|
||||
},
|
||||
{
|
||||
name: 'AB相',
|
||||
id: 'AB'
|
||||
},
|
||||
{
|
||||
name: 'BC相',
|
||||
id: 'BC'
|
||||
},
|
||||
{
|
||||
name: 'CA相',
|
||||
id: 'CA'
|
||||
},
|
||||
// {
|
||||
// name: '无相别',
|
||||
// id: 'M'
|
||||
// },
|
||||
]
|
||||
const defaultForm = () => ({
|
||||
id: '',
|
||||
indexCode: '',
|
||||
indexName: '',
|
||||
harmSlider: [0, 0],
|
||||
harmStart: undefined as number | undefined,
|
||||
harmEnd: undefined as number | undefined,
|
||||
phaseType: '',
|
||||
phaseList: [] as any,
|
||||
influxdbTableName: '',
|
||||
influxdbColumnName: '',
|
||||
minValue: undefined as number | undefined,
|
||||
maxValue: undefined as number | undefined,
|
||||
isVoltage: 0,
|
||||
ctAttendFlag: 0,
|
||||
dataSource: '',
|
||||
otherAlgorithm: '',
|
||||
remark: '',
|
||||
unit: '',
|
||||
sort: 100,
|
||||
belongingSystem: 'govern',
|
||||
state: 1
|
||||
})
|
||||
|
||||
const form = reactive(defaultForm())
|
||||
|
||||
|
||||
|
||||
const validateMinMax = (_rule: any, _value: any, callback: (e?: Error) => void) => {
|
||||
if (form.minValue == null || form.maxValue == null) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
if (form.minValue > form.maxValue) {
|
||||
callback(new Error('指标下限不能大于指标上限'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const rules: any = {
|
||||
indexCode: [{ required: true, message: '请输入指标code', trigger: 'blur' }],
|
||||
indexName: [{ required: true, message: '请输入指标名称', trigger: 'blur' }],
|
||||
phaseList: [{ required: true, message: '请输入指标名称', trigger: 'change' }],
|
||||
|
||||
influxdbTableName: [{ required: true, message: '请输入表名', trigger: 'blur' }],
|
||||
influxdbColumnName: [{ required: true, message: '请输入列属性', trigger: 'blur' }],
|
||||
minValue: [
|
||||
{ required: true, message: '请输入指标下限', trigger: 'blur' },
|
||||
{ validator: validateMinMax, trigger: 'change' }
|
||||
],
|
||||
maxValue: [
|
||||
{ required: true, message: '请输入指标上限', trigger: 'blur' },
|
||||
{ validator: validateMinMax, trigger: 'change' }
|
||||
],
|
||||
isVoltage: [{ required: true, message: '请选择电压等级是否参与', trigger: 'change' }],
|
||||
ctAttendFlag: [{ required: true, message: '请选择Ct变比是否参与', trigger: 'change' }],
|
||||
dataSource: [{ required: true, message: '请选择数据来源', trigger: 'change' }],
|
||||
belongingSystem: [{ required: true, message: '请选择所属系统', trigger: 'change' }],
|
||||
sort: [{ required: true, message: '请输入排序', trigger: 'blur' }],
|
||||
state: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
||||
}
|
||||
|
||||
const isEdit = () => title.value.includes('修改')
|
||||
|
||||
const resetForm = () => {
|
||||
Object.assign(form, defaultForm())
|
||||
}
|
||||
|
||||
const fillForm = (row: any) => {
|
||||
const keys = Object.keys(defaultForm()) as (keyof ReturnType<typeof defaultForm>)[]
|
||||
keys.forEach(key => {
|
||||
if (row[key] === undefined || row[key] === null) return
|
||||
if (['harmStart', 'harmEnd', 'sort', 'isVoltage', 'ctAttendFlag', 'state'].includes(key)) {
|
||||
; (form as any)[key] = Number(row[key])
|
||||
} else if (['minValue', 'maxValue'].includes(key)) {
|
||||
; (form as any)[key] = Number(row[key])
|
||||
} else {
|
||||
; (form as any)[key] = row[key]
|
||||
}
|
||||
})
|
||||
form.phaseList = form.phaseType.split(',')
|
||||
|
||||
form.harmSlider = [form.harmStart || 0, form.harmEnd || 0]
|
||||
}
|
||||
|
||||
const open = (e: { text: string; row?: any }) => {
|
||||
formRef.value?.resetFields()
|
||||
title.value = e.text
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
if (e.row) {
|
||||
|
||||
fillForm(e.row)
|
||||
}
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
dialogVisible.value = false
|
||||
emit('Cancels')
|
||||
}
|
||||
|
||||
const handleClosed = () => {
|
||||
resetForm()
|
||||
}
|
||||
|
||||
const onSubmit = () => {
|
||||
formRef.value?.validate(async (valid: boolean) => {
|
||||
if (!valid) return
|
||||
form.harmStart = form.harmSlider[0]
|
||||
form.harmEnd = form.harmSlider[1]
|
||||
form.phaseType = form.phaseList.join(',')
|
||||
const payload = { ...form }
|
||||
try {
|
||||
if (isEdit()) {
|
||||
await update(payload)
|
||||
ElMessage.success('修改成功!')
|
||||
} else {
|
||||
await save({ ...payload, id: '' })
|
||||
ElMessage.success('新增成功!')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('Cancels')
|
||||
} catch {
|
||||
/* 统一错误提示 */
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-item-full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
</style>
|
||||
193
src/views/govern/alarm/scopeConfig/index.vue
Normal file
193
src/views/govern/alarm/scopeConfig/index.vue
Normal file
@@ -0,0 +1,193 @@
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<TableHeader ref="TableHeaderRef">
|
||||
<template #select>
|
||||
<el-form-item label="数据来源">
|
||||
<el-select v-model="tableStore.table.params.dataSource" clearable placeholder="请选择数据来源">
|
||||
<el-option v-for="item in dataSourceOptions" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="系统类型">
|
||||
<el-select v-model="tableStore.table.params.systemType" clearable placeholder="请选择系统类型">
|
||||
<el-option v-for="item in systemTypeOptions" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="表名">
|
||||
<el-input v-model.trim="tableStore.table.params.tableName" placeholder="请输入表名" clearable
|
||||
maxlength="64" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
<el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" />
|
||||
<Form ref="formRef" @Cancels="tableStore.index()" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, provide, nextTick } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { pqDelete } from '@/api/algorithm-boot/scopeConfig'
|
||||
import Form from './form.vue'
|
||||
defineOptions({
|
||||
name: 'govern/alarmConfig'
|
||||
})
|
||||
const dataSourceOptions = [
|
||||
{ label: 'InfluxDB', value: 'InfluxDB' },
|
||||
// { label: 'oracle', value: 'oracle' },
|
||||
{ label: 'MySql', value: 'MySql' }
|
||||
]
|
||||
const systemTypeOptions = [
|
||||
{ label: 'pqs', value: 'pqs' },
|
||||
{ label: 'govern', value: 'govern' }
|
||||
]
|
||||
const yesNo = (v: number) => (v === 1 ? '是' : v === 0 ? '否' : '/')
|
||||
const stateMap: Record<number, string> = { 0: '删除', 1: '正常' }
|
||||
const formRef = ref()
|
||||
const tableStore: any = new TableStore({
|
||||
url: '/algorithm-boot/pqReasonableRange/getData',
|
||||
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
|
||||
}
|
||||
},
|
||||
{ field: 'indexName', title: '指标名称', minWidth: 200 },
|
||||
{ field: 'indexCode', title: '指标code', minWidth: 150 },
|
||||
|
||||
{ field: 'influxdbTableName', title: '表名', minWidth: 150 },
|
||||
{ field: 'influxdbColumnName', title: '列属性', minWidth: 150 },
|
||||
{
|
||||
field: 'harmStart', title: '谐波次数', width: 90,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue == null ? '/' : row.cellValue + '-' + row.row.harmEnd
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'phaseType', title: '相别', width: 100, formatter: (row: any) => {
|
||||
return row.cellValue == 'T' ? '/' : row.cellValue
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
{ field: 'minValue', title: '指标下限', width: 100 },
|
||||
{ field: 'maxValue', title: '指标上限', width: 100 },
|
||||
{
|
||||
field: 'isVoltage',
|
||||
title: '电压等级参与',
|
||||
width: 110,
|
||||
formatter: (row: any) => yesNo(row.cellValue)
|
||||
},
|
||||
{
|
||||
field: 'ctAttendFlag',
|
||||
title: 'Ct变比参与',
|
||||
width: 100,
|
||||
formatter: (row: any) => yesNo(row.cellValue)
|
||||
},
|
||||
{ field: 'dataSource', title: '数据来源', width: 100 },
|
||||
{ field: 'belongingSystem', title: '所属系统', width: 100 },
|
||||
|
||||
|
||||
{
|
||||
field: 'unit', title: '单位', width: 80,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue || '/'
|
||||
}
|
||||
},
|
||||
{ field: 'sort', title: '排序', width: 70 },
|
||||
{
|
||||
field: 'otherAlgorithm', title: '条件描述', minWidth: 200,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue || '/'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'remark', title: '备注', minWidth: 200,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue || '/'
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
width: '180',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
|
||||
{
|
||||
name: 'edit',
|
||||
title: '修改 ',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-Plus',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
setTimeout(() => {
|
||||
formRef.value.open({
|
||||
text: '修改配置',
|
||||
row: row
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
icon: 'el-icon-Delete',
|
||||
render: 'confirmButton',
|
||||
disabled: row => {
|
||||
return row.active == 1
|
||||
},
|
||||
popconfirm: {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonType: 'danger',
|
||||
title: '确定删除吗?'
|
||||
},
|
||||
click: row => {
|
||||
pqDelete({ id: row.id }).then(res => {
|
||||
ElMessage({
|
||||
message: '删除成功!',
|
||||
type: 'success'
|
||||
})
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
loadCallback: () => {
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
tableStore.table.params.dataSource = ''
|
||||
tableStore.table.params.tableName = ''
|
||||
tableStore.table.params.systemType = ''
|
||||
provide('tableStore', tableStore)
|
||||
// 新增主题
|
||||
const add = () => {
|
||||
setTimeout(() => {
|
||||
formRef.value.open({
|
||||
text: '新增配置'
|
||||
})
|
||||
}, 10)
|
||||
}
|
||||
onMounted(() => {
|
||||
tableStore.index()
|
||||
})
|
||||
</script>
|
||||
@@ -386,6 +386,7 @@ const saveIndicator = () => {
|
||||
.then((res: any) => {
|
||||
ElMessage.success(`保存成功`)
|
||||
loading.value = false
|
||||
tableStore.index()
|
||||
})
|
||||
.catch(() => {
|
||||
loading.value = false
|
||||
|
||||
@@ -9,44 +9,23 @@
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计指标:">
|
||||
<el-select
|
||||
style="width: 200px"
|
||||
v-model.trim="formInline.statisticalId"
|
||||
filterable
|
||||
@change="frequencyFlag"
|
||||
placeholder="请选择"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in zblist"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
<el-select style="width: 200px" v-model.trim="formInline.statisticalId" filterable
|
||||
@change="frequencyFlag" placeholder="请选择">
|
||||
<el-option v-for="item in zblist" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="谐波次数:" v-show="frequencyShow">
|
||||
<el-select
|
||||
v-model.trim="formInline.frequency"
|
||||
filterable
|
||||
placeholder="请选择"
|
||||
style="width: 100px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in 49"
|
||||
:key="item + 1"
|
||||
:label="item + 1"
|
||||
:value="item + 1"
|
||||
></el-option>
|
||||
<el-select v-model.trim="formInline.frequency" filterable placeholder="请选择"
|
||||
style="width: 100px">
|
||||
<el-option v-for="item in 49" :key="item + 1" :label="item + 1"
|
||||
:value="item + 1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="值类型:">
|
||||
<el-select v-model.trim="formInline.valueType" filterable placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in typelist"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
<el-option v-for="item in typelist" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
@@ -149,7 +128,7 @@ const deviceTypeChange = (val: any, obj: any) => {
|
||||
nodeClick(obj)
|
||||
}
|
||||
const nodeClick = async (e: anyObj) => {
|
||||
if (e.level == 2 && flag.value) {
|
||||
if ((e.level == 2 || e.level == 3) && flag.value) {
|
||||
formInline.devId = e.id
|
||||
loading.value = true
|
||||
if (zblist.value.length === 0) {
|
||||
@@ -245,10 +224,10 @@ const setEchart = () => {
|
||||
for (let j in phaseList) {
|
||||
color.push(j == 'A' ? '#DAA520' : j == 'B' ? '#2E8B57' : j == 'C' ? '#A52a2a' : '#0000CC')
|
||||
legend.push(
|
||||
j == 'M' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j
|
||||
j == 'T' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j
|
||||
)
|
||||
series.push({
|
||||
name: j == 'M' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j,
|
||||
name: j == 'T' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j,
|
||||
symbol: 'none',
|
||||
smooth: true,
|
||||
type: 'line',
|
||||
@@ -315,8 +294,7 @@ const setEchart = () => {
|
||||
marker = `<span style="display:inline-block;border: 2px ${el.color} ${el.value[3]};margin-right:5px;width:40px;height:0px;background-color:#ffffff00;"></span>`
|
||||
}
|
||||
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${
|
||||
el.value[1] != null ? el.value[1] + ' ' + (el.value[2] == 'null' ? '' : el.value[2]) : '-'
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${el.value[1] != null ? el.value[1] + ' ' + (el.value[2] == 'null' ? '' : el.value[2]) : '-'
|
||||
}<br>`
|
||||
})
|
||||
return str
|
||||
|
||||
@@ -6,31 +6,15 @@
|
||||
<TableHeader datePicker showExport>
|
||||
<template v-slot:select>
|
||||
<el-form-item label="事件类型">
|
||||
<el-select
|
||||
v-model.trim="tableStore.table.params.eventType"
|
||||
clearable
|
||||
placeholder="请选择事件类型"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in eventList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
<el-select v-model.trim="tableStore.table.params.eventType" clearable placeholder="请选择事件类型">
|
||||
<el-option v-for="item in eventList" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="位置">
|
||||
<el-select
|
||||
v-model.trim="tableStore.table.params.location"
|
||||
clearable
|
||||
placeholder="请选择位置"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in locationList"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
<el-select v-model.trim="tableStore.table.params.location" clearable placeholder="请选择位置">
|
||||
<el-option v-for="item in locationList" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
@@ -39,14 +23,8 @@
|
||||
</div>
|
||||
<el-empty v-else description="请选择设备" class="analyze-dvr-right" />
|
||||
</div>
|
||||
<waveFormAnalysis
|
||||
v-loading="loading"
|
||||
v-if="isWaveCharts"
|
||||
ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false"
|
||||
:wp="wp"
|
||||
style="padding: 10px"
|
||||
/>
|
||||
<waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false" :wp="wp" style="padding: 10px" />
|
||||
<!-- <div :style="{ height: pageHeight.height }" style="padding: 10px; overflow: hidden" v-if="!view">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
@@ -144,28 +122,43 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ title: '事件描述', field: 'showName', minWidth: 150 },
|
||||
{ title: '发生位置', field: 'evtParamPosition', minWidth: 150 },
|
||||
{ title: '暂降发生时刻', field: 'startTime', sortable: true, minWidth: 180 },
|
||||
{
|
||||
title: '持续时间(s)',
|
||||
field: 'evtParamTm',
|
||||
sortable: true,
|
||||
minWidth: 110,
|
||||
formatter: (row: any) => {
|
||||
return Math.floor(row.cellValue * 10000) / 100
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '暂降(聚升)幅值(%)',
|
||||
title: '暂降(骤升)幅值(%)',
|
||||
field: 'evtParamVVaDepth',
|
||||
minWidth: 150,
|
||||
minWidth: 160,
|
||||
formatter: (row: any) => {
|
||||
let a = row.cellValue.split('%')[0] - 0
|
||||
return a ? a.toFixed(2) : '/'
|
||||
},
|
||||
sortable: true
|
||||
},
|
||||
{ title: '发生时刻', field: 'startTime', sortable: true, minWidth: 180 },
|
||||
{
|
||||
title: '持续时间(s)',
|
||||
field: 'evtParamTm',
|
||||
sortable: true,
|
||||
minWidth: 110,
|
||||
formatter: (row: any) => {
|
||||
const val = row.cellValue
|
||||
if (val === null || val === undefined || val === '' || val === '-') return '/'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return '/'
|
||||
return Math.floor(num * 10000) / 100
|
||||
}
|
||||
},
|
||||
{ title: '触发类型', field: 'showName', minWidth: 150 },
|
||||
{
|
||||
title: '发生位置', field: 'evtParamPosition', minWidth: 150,
|
||||
formatter: (row: any) => {
|
||||
const val = row.cellValue
|
||||
if (val === null || val === undefined || val === '' || val === '-') return '/'
|
||||
|
||||
return val
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
@@ -179,16 +172,19 @@ const tableStore = new TableStore({
|
||||
type: 'primary',
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
loading: 'loading1',
|
||||
disabled: row => {
|
||||
return !row.wavePath && row.evtParamTm < 20
|
||||
},
|
||||
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
|
||||
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
isWaveCharts.value = true
|
||||
loading.value = true
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
@@ -236,6 +232,7 @@ const tableStore = new TableStore({
|
||||
return !row.wavePath
|
||||
},
|
||||
click: row => {
|
||||
ElMessage.info('下载中......')
|
||||
getFileZip({ eventId: row.id }).then(res => {
|
||||
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
@@ -245,6 +242,7 @@ const tableStore = new TableStore({
|
||||
document.body.appendChild(link)
|
||||
link.click() //执行下载
|
||||
document.body.removeChild(link) //释放标签
|
||||
ElMessage.success('波形下载成功')
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -269,7 +267,7 @@ const deviceTypeChange = (val: any, obj: any) => {
|
||||
}
|
||||
const nodeClick = async (e: anyObj) => {
|
||||
// console.log("🚀 ~ nodeClick ~ e:", e)
|
||||
if (e.level == 2 && flag.value) {
|
||||
if ((e.level == 2 || e.level == 3) && flag.value) {
|
||||
loading.value = false
|
||||
tableStore.table.params.deviceId = e.id
|
||||
nextTick(() => {
|
||||
|
||||
392
src/views/govern/analyze/steadyState/components/chart.vue
Normal file
392
src/views/govern/analyze/steadyState/components/chart.vue
Normal file
@@ -0,0 +1,392 @@
|
||||
<template>
|
||||
<div class="analyze-steadyState" v-loading="loading">
|
||||
<analyzeTree ref="treeRef" :showCheckbox="true" :default-checked-keys="checkedKeyIds" @check="onCheck"
|
||||
:height="40" :engineering="true" />
|
||||
<div class="analyze-steadyState-right">
|
||||
<div ref="headerRef">
|
||||
<TableHeader :showSearch="false" ref="tableHeaderRef" @selectChange="selectChange">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="时间:">
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item>
|
||||
<el-form-item label="统计指标:">
|
||||
<el-select style="width: 200px" v-model.trim="formInline.statisticalId" filterable
|
||||
@change="frequencyFlag" placeholder="请选择">
|
||||
<el-option v-for="item in zblist" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="谐波次数:" v-show="frequencyShow">
|
||||
<el-select v-model.trim="formInline.frequency" filterable placeholder="请选择"
|
||||
style="width: 100px">
|
||||
<el-option v-for="item in 49" :key="item + 1" :label="item + 1"
|
||||
:value="item + 1"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="值类型:">
|
||||
<el-select v-model.trim="formInline.valueType" filterable placeholder="请选择">
|
||||
<el-option v-for="item in typelist" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template v-slot:operation>
|
||||
<el-button type="primary" @click="search" icon="el-icon-Search">查询</el-button>
|
||||
<el-button :type="timeControl ? 'primary' : ''" icon="el-icon-Sort" @click="setTimeControl">
|
||||
缺失数据
|
||||
</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
</div>
|
||||
|
||||
<el-empty description="暂无数据" v-if="!echartsData" style="flex: 1;margin-top: 10%"></el-empty>
|
||||
<template v-else>
|
||||
<div :style="echartHeight">
|
||||
<MyEchart :options="echartsData" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, nextTick } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import analyzeTree from '@/components/tree/govern/analyzeTree.vue'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { queryCommonStatisticalByTime } from '@/api/cs-harmonic-boot/stable'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { yMethod, completeTimeSeries } from '@/utils/echartMethod'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
|
||||
const MAX_CHECK = 2
|
||||
const defaultCheckedKeys = ref<any[]>([])
|
||||
const checkedKeyIds = computed(() => defaultCheckedKeys.value.map(item => item.id))
|
||||
const treeRef = ref()
|
||||
const isSyncing = ref(false)
|
||||
const tableHeaderRef = ref()
|
||||
const headerRef = ref()
|
||||
const echartHeight = ref(mainHeight(80))
|
||||
const loading = ref(false)
|
||||
const echartsData = ref<any>(null)
|
||||
const datePickerRef = ref()
|
||||
const timeControl = ref(false)
|
||||
const timeFlag = ref(true)
|
||||
const frequencyShow = ref(false)
|
||||
const dataLists = ref<any[]>([])
|
||||
const zblist = ref<any[]>([])
|
||||
|
||||
const formInline = reactive({
|
||||
statisticalId: '',
|
||||
valueType: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
frequency: '' as string | number
|
||||
})
|
||||
|
||||
const typelist = [
|
||||
{ label: '平均值', value: 'avg' },
|
||||
{ label: '最大值', value: 'max' },
|
||||
{ label: '最小值', value: 'min' },
|
||||
{ label: 'CP95值', value: 'cp95' }
|
||||
]
|
||||
|
||||
const lineStyle = [
|
||||
{ type: 'solid', width: 3 },
|
||||
{ type: 'dotted', width: 3 },
|
||||
{ type: 'dashed', width: 3 }
|
||||
]
|
||||
|
||||
const getEngineeringTree = () => treeRef.value?.treRef?.treeRef4
|
||||
|
||||
const init = () => {
|
||||
return queryByCode('portable-harmonic-jx').then(res => {
|
||||
return queryCsDictTree(res.data?.id).then(res => {
|
||||
zblist.value = res.data.map((item: any) => ({
|
||||
value: item.id,
|
||||
label: item.name,
|
||||
...item
|
||||
}))
|
||||
formInline.statisticalId = zblist.value[0]?.value
|
||||
formInline.valueType = typelist[0].value
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
init()
|
||||
})
|
||||
|
||||
const onCheck = (_data: any, { checkedNodes }: { checkedNodes: any[] }) => {
|
||||
if (isSyncing.value) return
|
||||
|
||||
const tree = getEngineeringTree()
|
||||
if (!tree) return
|
||||
|
||||
if (checkedNodes.length <= MAX_CHECK) {
|
||||
defaultCheckedKeys.value = checkedNodes.map(node => ({ ...node }))
|
||||
if (checkedNodes.length === 0) {
|
||||
echartsData.value = null
|
||||
dataLists.value = []
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
const allowedIds = new Set(defaultCheckedKeys.value.map(item => item.id))
|
||||
const extras = checkedNodes.filter(node => !allowedIds.has(node.id))
|
||||
|
||||
if (defaultCheckedKeys.value.length >= MAX_CHECK) {
|
||||
isSyncing.value = true
|
||||
extras.forEach(node => tree.setChecked(node.id, false, false))
|
||||
nextTick(() => {
|
||||
isSyncing.value = false
|
||||
})
|
||||
ElMessage.warning(`最多只能选择${MAX_CHECK}个`)
|
||||
return
|
||||
}
|
||||
|
||||
const room = MAX_CHECK - defaultCheckedKeys.value.length
|
||||
extras.slice(0, room).forEach(node => {
|
||||
if (!defaultCheckedKeys.value.some(item => item.id === node.id)) {
|
||||
defaultCheckedKeys.value.push({ ...node })
|
||||
}
|
||||
})
|
||||
const rejected = extras.slice(room)
|
||||
if (rejected.length) {
|
||||
isSyncing.value = true
|
||||
rejected.forEach(node => tree.setChecked(node.id, false, false))
|
||||
nextTick(() => {
|
||||
isSyncing.value = false
|
||||
})
|
||||
ElMessage.warning(`最多只能选择${MAX_CHECK}个`)
|
||||
}
|
||||
}
|
||||
|
||||
const search = async () => {
|
||||
if (defaultCheckedKeys.value.length === 0) {
|
||||
ElMessage.warning('请选择设备')
|
||||
return
|
||||
}
|
||||
if (zblist.value.length === 0) {
|
||||
await init()
|
||||
}
|
||||
if (timeFlag.value) {
|
||||
datePickerRef.value?.setInterval(5)
|
||||
timeFlag.value = false
|
||||
}
|
||||
loading.value = true
|
||||
formInline.startTime = datePickerRef.value.timeValue[0]
|
||||
formInline.endTime = datePickerRef.value.timeValue[1]
|
||||
if (!frequencyShow.value) {
|
||||
formInline.frequency = ''
|
||||
}
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
defaultCheckedKeys.value.map(device =>
|
||||
queryCommonStatisticalByTime({
|
||||
...formInline,
|
||||
devId: device.id
|
||||
}).then(({ data }: { data: any[] }) => ({
|
||||
deviceName: device.name,
|
||||
data
|
||||
}))
|
||||
)
|
||||
)
|
||||
dataLists.value = results.flatMap(({ deviceName, data }) =>
|
||||
data.map((item: any) => ({
|
||||
...item,
|
||||
anotherName:
|
||||
defaultCheckedKeys.value.length > 1 ? `${deviceName}_${item.anotherName}` : item.anotherName
|
||||
}))
|
||||
)
|
||||
setEchart()
|
||||
} catch {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const setEchart = () => {
|
||||
loading.value = true
|
||||
const data = JSON.parse(JSON.stringify(dataLists.value))
|
||||
if (data.length) {
|
||||
const list = processingOfData(data, 'unit')
|
||||
echartsData.value = {}
|
||||
const legend: any[] = []
|
||||
const xAxis: any[] = []
|
||||
const yAxis: any[] = []
|
||||
const series: any[] = []
|
||||
const color: any[] = []
|
||||
data.forEach((item: any) => {
|
||||
if (!xAxis.includes(item.time)) {
|
||||
xAxis.push(item.time)
|
||||
}
|
||||
})
|
||||
const units = Object.keys(list)
|
||||
for (const unit in list) {
|
||||
const [min, max] = yMethod(list[unit].map((item: any) => item.statisticalData))
|
||||
yAxis.push({
|
||||
name: unit == 'null' ? '' : unit,
|
||||
type: 'value',
|
||||
min,
|
||||
max,
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: { color: '#333' }
|
||||
}
|
||||
})
|
||||
const anotherList = processingOfData(list[unit], 'anotherName')
|
||||
for (const k in anotherList) {
|
||||
const lineName = lineStyle[Object.keys(anotherList).indexOf(k)]
|
||||
const phaseList = processingOfData(anotherList[k], 'phase')
|
||||
for (const j in phaseList) {
|
||||
color.push(j == 'A' ? '#DAA520' : j == 'B' ? '#2E8B57' : j == 'C' ? '#A52a2a' : '#0000CC')
|
||||
legend.push(
|
||||
j == 'T' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j
|
||||
)
|
||||
series.push({
|
||||
name: j == 'T' ? k : j == 'A' ? `A相_${k}` : j == 'B' ? `B相_${k}` : j == 'C' ? `C相_${k}` : j,
|
||||
symbol: 'none',
|
||||
smooth: true,
|
||||
type: 'line',
|
||||
data: timeControl.value
|
||||
? completeTimeSeries(
|
||||
phaseList[j].map((item: any) => [
|
||||
item.time,
|
||||
Math.floor(item.statisticalData * 100) / 100,
|
||||
unit,
|
||||
lineName.type
|
||||
])
|
||||
)
|
||||
: phaseList[j].map((item: any) => [
|
||||
item.time,
|
||||
Math.floor(item.statisticalData * 100) / 100,
|
||||
unit,
|
||||
lineName.type
|
||||
]),
|
||||
lineStyle: lineName,
|
||||
yAxisIndex: units.indexOf(unit)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echartsData.value = {
|
||||
title: {
|
||||
text: zblist.value.filter(item => item.id == formInline.statisticalId)[0]?.name
|
||||
},
|
||||
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) => {
|
||||
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>`
|
||||
}
|
||||
str += `${marker}${el.seriesName.split('(')[0]}:${el.value[1] != null ? el.value[1] + ' ' + (el.value[2] == 'null' ? '' : el.value[2]) : '-'
|
||||
}<br>`
|
||||
})
|
||||
return str
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
itemWidth: 20,
|
||||
itemHeight: 20,
|
||||
itemStyle: { opacity: 0 },
|
||||
type: 'scroll',
|
||||
top: 25
|
||||
},
|
||||
grid: {
|
||||
left: '20px',
|
||||
right: '40px',
|
||||
bottom: '50px',
|
||||
top: '80px',
|
||||
containLabel: true
|
||||
},
|
||||
toolbox: { feature: { saveAsImage: {} } },
|
||||
color,
|
||||
xAxis: {
|
||||
name: '',
|
||||
type: 'time',
|
||||
axisLabel: {
|
||||
formatter: { day: '{MM}-{dd}', month: '{MM}', year: '{yyyy}' }
|
||||
}
|
||||
},
|
||||
yAxis,
|
||||
options: { series }
|
||||
}
|
||||
} else {
|
||||
echartsData.value = null
|
||||
}
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
const setTimeControl = () => {
|
||||
timeControl.value = !timeControl.value
|
||||
setEchart()
|
||||
}
|
||||
|
||||
const processingOfData = (data: any, type: string) => {
|
||||
const groupedData: any = {}
|
||||
data.forEach((item: any) => {
|
||||
if (!groupedData[item[type]]) {
|
||||
groupedData[item[type]] = []
|
||||
}
|
||||
groupedData[item[type]].push(item)
|
||||
})
|
||||
return groupedData
|
||||
}
|
||||
|
||||
const frequencyFlag = () => {
|
||||
const name = zblist.value.filter(item => item.id == formInline.statisticalId)[0]?.name
|
||||
if (name?.includes('含有率') || name?.includes('幅值')) {
|
||||
frequencyShow.value = true
|
||||
formInline.frequency = 2
|
||||
} else {
|
||||
frequencyShow.value = false
|
||||
}
|
||||
tableHeaderRef.value?.computedSearchRow()
|
||||
}
|
||||
|
||||
const selectChange = () => {
|
||||
setTimeout(() => {
|
||||
echartHeight.value = mainHeight(23 + headerRef.value.offsetHeight)
|
||||
}, 100)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.analyze-steadyState {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
|
||||
&-right {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
padding: 10px 10px 10px 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped>
|
||||
.el-select {
|
||||
min-width: 100px;
|
||||
}
|
||||
</style>
|
||||
192
src/views/govern/analyze/steadyState/components/report.vue
Normal file
192
src/views/govern/analyze/steadyState/components/report.vue
Normal file
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<div class="default-main report-zl-page1" :style="height">
|
||||
<div class="report-zl-sidebar">
|
||||
<!-- <pointTreeWx :default-expand-all="false" template @node-click="handleNodeClick" @init="handleNodeClick"
|
||||
@Policy="stencil">
|
||||
</pointTreeWx> -->
|
||||
<CloudDeviceEntryTree ref="TerminalRef" :height="37" template @Policy="stencil" @node-click="handleNodeClick"
|
||||
@init="handleNodeClick"></CloudDeviceEntryTree>
|
||||
</div>
|
||||
<div class="report-zl-main">
|
||||
<TableHeader datePicker ref="TableHeaderRef" :showReset="false">
|
||||
<template v-slot:select>
|
||||
<!-- <el-form-item label="时间:">
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="模板策略">
|
||||
<el-select v-model.trim="Template" @change="changetype" placeholder="请选择模版" value-key="id">
|
||||
<el-option v-for="item in templatePolicy" :key="item.id" :label="item.excelName"
|
||||
:value="item"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="监测对象">
|
||||
<el-select
|
||||
filterable
|
||||
v-model="tableStore.table.params.sensitiveUserId"
|
||||
placeholder="请选择监测对象"
|
||||
clearable
|
||||
>
|
||||
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
</template>
|
||||
<template #operation>
|
||||
<el-button icon="el-icon-Download" type="primary" @click="exportEvent">导出</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<div class="box" v-loading="tableStore.table.loading">
|
||||
<div id="luckysheet" class="report-zl-sheet" v-if="tableStore.table.data.length > 0"></div>
|
||||
<el-empty class="report-zl-sheet" v-else description="暂无数据" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { destroyLuckysheet, exportLuckysheetFile, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import { isLineTreeLeaf } from '@/components/tree/govern/lineTreeUtils'
|
||||
import DatePicker from '@/components/form/datePicker/time.vue'
|
||||
import CloudDeviceEntryTree from '@/components/tree/govern/cloudDeviceEntryTreeZL.vue'
|
||||
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import { ElMessage } from 'element-plus'
|
||||
// import data from './123.json'
|
||||
|
||||
const height = mainHeight(70)
|
||||
const dictData = useDictData()
|
||||
const TableHeaderRef = ref()
|
||||
const dotList: any = ref({})
|
||||
const Template: any = ref({})
|
||||
const reportForm: any = ref('')
|
||||
const datePickerRef = ref()
|
||||
const templatePolicy: any = ref([])
|
||||
const name = ref('')
|
||||
|
||||
const tableStore = new TableStore({
|
||||
url: '/cs-harmonic-boot/customReport/getSensitiveUserReport',
|
||||
method: 'POST',
|
||||
column: [],
|
||||
showPage: false,
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.tempId = Template.value.id
|
||||
tableStore.table.params.lineId = dotList.value.id
|
||||
tableStore.table.params.sensitiveUserId = dotList.value.id
|
||||
// ;(tableStore.table.params.startTime = datePickerRef.value.timeValue[0]),
|
||||
// (tableStore.table.params.endTime = datePickerRef.value.timeValue[1]),
|
||||
if (!tableStore.table.params.tempId) {
|
||||
ElMessage.warning('请选择模板')
|
||||
return false
|
||||
}
|
||||
if (!dotList.value?.id) {
|
||||
ElMessage.warning('请选择监测点')
|
||||
return false
|
||||
}
|
||||
delete tableStore.table.params.searchBeginTime
|
||||
delete tableStore.table.params.searchEndTime
|
||||
delete tableStore.table.params.timeFlag
|
||||
},
|
||||
loadCallback: () => {
|
||||
name.value = dotList.value.name
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.resourceType = 1
|
||||
tableStore.table.params.customType = 1
|
||||
const flag = ref(true)
|
||||
onMounted(() => {
|
||||
initListByIds()
|
||||
})
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
|
||||
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
|
||||
}
|
||||
// templateListData()
|
||||
}
|
||||
})
|
||||
}
|
||||
const stencil = (val: any) => {
|
||||
templatePolicy.value = val.filter((item: any) => item.excelType == '4')
|
||||
Template.value = templatePolicy.value[0]
|
||||
reportForm.value = templatePolicy.value[0]?.excelType
|
||||
}
|
||||
|
||||
const changetype = (val: any) => {
|
||||
reportForm.value = val.excelType
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
if (isLineTreeLeaf(data) || data?.level == 3) {
|
||||
dotList.value = data
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
}, 500)
|
||||
} else {
|
||||
tableStore.table.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
const exportEvent = () => {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear() // 4位年份
|
||||
const month = now.getMonth() + 1 // 月份0-11,需+1
|
||||
const day = now.getDate() // 日期1-31
|
||||
|
||||
// 格式化YYYY - MM - DD(补零)
|
||||
const formattedDate = `${year}${String(month).padStart(2, '0')}${String(day).padStart(2, '0')}`
|
||||
exportLuckysheetFile(name.value + formattedDate, tableStore.table.data.length > 0)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.report-zl-page1 {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
|
||||
.cn-tree {
|
||||
padding: 0 10px 0 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.report-zl-sidebar {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.box {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 10px 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sheet {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<style></style>
|
||||
37
src/views/govern/analyze/steadyState/index.vue
Normal file
37
src/views/govern/analyze/steadyState/index.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div class="default-main" :style="{ height: pageHeight.height }">
|
||||
|
||||
|
||||
<el-tabs v-model="activeTab" type="border-card">
|
||||
<el-tab-pane label="图表" name="chart">
|
||||
<chart v-if="activeTab === 'chart'"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="报表" name="report">
|
||||
<report v-if="activeTab === 'report'"/>
|
||||
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import chart from './components/chart.vue'
|
||||
import report from './components/report.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'govern/analyze/steadyState'
|
||||
})
|
||||
|
||||
const pageHeight = mainHeight(20)
|
||||
const activeTab = ref('chart')
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
:deep(.el-tabs__content) {
|
||||
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
13
src/views/govern/analyze/transient/index.vue
Normal file
13
src/views/govern/analyze/transient/index.vue
Normal file
@@ -0,0 +1,13 @@
|
||||
<template>
|
||||
<div class="default-main">
|
||||
<h1>暂态治理分析</h1>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineOptions({
|
||||
name: 'govern/analyze/transient'
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
||||
@@ -2710,7 +2710,7 @@ const volGradeChange = (e, row) => {
|
||||
capacity = 750
|
||||
break
|
||||
case '35':
|
||||
capacity = 259
|
||||
capacity = 250
|
||||
break
|
||||
case '10':
|
||||
capacity = 100
|
||||
@@ -2730,9 +2730,7 @@ const volGradeChange = (e, row) => {
|
||||
case '750':
|
||||
capacity = 7000
|
||||
break
|
||||
case '800':
|
||||
capacity = 7000
|
||||
break
|
||||
|
||||
case '1000':
|
||||
capacity = 9000
|
||||
break
|
||||
|
||||
@@ -130,6 +130,7 @@
|
||||
:showSearch="false"
|
||||
v-if="
|
||||
(dataSet.indexOf('_trenddata') == -1 &&
|
||||
dataSet.indexOf('_kilowattHour') == -1 &&
|
||||
dataSet.indexOf('_realtimedata') == -1 &&
|
||||
dataSet.indexOf('_event') == -1) ||
|
||||
realTimeFlag
|
||||
@@ -297,6 +298,7 @@
|
||||
:style="{ height: tableHeight }"
|
||||
v-if="
|
||||
dataSet.indexOf('_trenddata') == -1 &&
|
||||
dataSet.indexOf('_kilowattHour') == -1 &&
|
||||
dataSet.indexOf('_realtimedata') == -1 &&
|
||||
dataSet.indexOf('_event') == -1 &&
|
||||
tableData.length != 0
|
||||
@@ -482,6 +484,10 @@
|
||||
<div style="height: calc(100vh - 340px)" v-if="dataSet.indexOf('_trenddata') != -1">
|
||||
<Trend ref="trendRef" :TrendList="TrendList"></Trend>
|
||||
</div>
|
||||
<!-- 电度数据 -->
|
||||
<div style="height: calc(100vh - 340px)" v-if="dataSet.indexOf('_kilowattHour') != -1">
|
||||
<electroplating ref="electroplatingRef" :TrendList="TrendList"></electroplating>
|
||||
</div>
|
||||
<!-- 实时数据 -->
|
||||
<div
|
||||
:style="`height: calc(100vh - (${sonTab == 1 ? '378px' : sonTab == 2 ? '340px' : '425px'}))`"
|
||||
@@ -579,6 +585,7 @@ import { ElMessage } from 'element-plus'
|
||||
import DatePicker from '@/components/form/datePicker/index.vue'
|
||||
import Trend from './tabs/trend.vue' //趋势数据
|
||||
import realTime from './tabs/realtime.vue' //实时数据-主界面
|
||||
import electroplating from './tabs/electroplating.vue' //电度数据-主界面
|
||||
import realTrend from './tabs/components/realtrend.vue' //实时数据-实时趋势
|
||||
import operatingTrend from './tabs/operatingTrend.vue' //运行趋势
|
||||
import harmonicSpectrum from './tabs/components/harmonicSpectrum.vue' //实时数据-谐波频谱子页面
|
||||
@@ -687,6 +694,7 @@ const volConTypeList = dictData.getBasicData('Dev_Connect')
|
||||
const realTrendRef = ref()
|
||||
const txtContent = ref('')
|
||||
const operatingTrendRef = ref()
|
||||
const electroplatingRef = ref()
|
||||
const changeTrendType = (val: any) => {
|
||||
trendDataTime.value = ''
|
||||
activeTrendName.value = val * 1
|
||||
@@ -697,6 +705,25 @@ const activeTrendName: any = ref(0)
|
||||
const trendTimer: any = ref()
|
||||
const trendDataTime: any = ref()
|
||||
const showButton = ref(false)
|
||||
|
||||
const decodeMqttPayload = (message: any) => {
|
||||
try {
|
||||
return JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
/** 谐波频谱 MQTT 消息(命名函数,便于 off 避免重复注册) */
|
||||
const onMqttTrendMessage = (topic: any, message: any) => {
|
||||
const obj = decodeMqttPayload(message) || {}
|
||||
if ((obj.hasOwnProperty('data1') || obj.hasOwnProperty('data2')) && obj.dataTime) {
|
||||
trendDataTime.value = obj.dataTime
|
||||
realTrendRef.value?.setRealTrendData(obj)
|
||||
tableLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
//谐波频谱方法
|
||||
const handleTrend = async () => {
|
||||
realTimeFlag.value = false
|
||||
@@ -720,21 +747,7 @@ const handleTrend = async () => {
|
||||
// console.log(res, '获取谐波频谱数据')
|
||||
})
|
||||
}, 30000)
|
||||
mqttRef.value.on('message', (topic: any, message: any) => {
|
||||
let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message)))) || {}
|
||||
if ((obj.hasOwnProperty('data1') || obj.hasOwnProperty('data2')) && obj.dataTime) {
|
||||
trendDataTime.value = obj.dataTime
|
||||
realTrendRef.value && realTrendRef.value.setRealTrendData(obj)
|
||||
tableLoading.value = false
|
||||
// console.log(
|
||||
// '谐波频谱---mqtt接收到消息',
|
||||
// JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||
// )
|
||||
}
|
||||
// else {
|
||||
// trendDataTime.value = obj.dataTime
|
||||
// }
|
||||
})
|
||||
bindMqttMessage(onMqttTrendMessage)
|
||||
} else {
|
||||
ElMessage.warning('设备应答失败')
|
||||
}
|
||||
@@ -877,8 +890,8 @@ const lineId: any = ref('')
|
||||
const dataLevel: any = ref('')
|
||||
const dataSource = ref([])
|
||||
const engineeringName = ref('')
|
||||
const nodeClick = async (e: anyObj, node: any) => {
|
||||
if (e == undefined || e.level == 2) {
|
||||
const nodeClick = async (e: anyObj, node?: any) => {
|
||||
if (e == undefined) {
|
||||
return (loading.value = false)
|
||||
}
|
||||
searchValue.value = ''
|
||||
@@ -892,7 +905,7 @@ const nodeClick = async (e: anyObj, node: any) => {
|
||||
}
|
||||
|
||||
//选中设备名称后,点击标签页也能查询数据,要求点击设备名称后,点击标签页默认查询第一个监测点数据
|
||||
if (e.level == 3 || e.level == 2) {
|
||||
if (e.level == 3 ) {
|
||||
engineeringName.value = node?.parent.parent.data.name
|
||||
|
||||
await queryDictType({
|
||||
@@ -932,6 +945,10 @@ const nodeClick = async (e: anyObj, node: any) => {
|
||||
if (item.type === 'trenddata') {
|
||||
item.id = item.id + '_trenddata'
|
||||
}
|
||||
//电度数据
|
||||
if (item.type === 'kilowattHour') {
|
||||
item.id = item.id + '_kilowattHour'
|
||||
}
|
||||
//实时数据
|
||||
if (item.type === 'realtimedata') {
|
||||
item.id = item.id + '_realtimedata'
|
||||
@@ -983,6 +1000,14 @@ const trendRef: any = ref()
|
||||
const eventRef: any = ref()
|
||||
const mqttRef = ref()
|
||||
const url: any = window.localStorage.getItem('MQTTURL')
|
||||
|
||||
/** 同一 handler 先 off 再 on,避免重复 message 监听 */
|
||||
const bindMqttMessage = (handler: (topic: any, message: any) => void) => {
|
||||
if (!mqttRef.value) return
|
||||
mqttRef.value.off('message', handler)
|
||||
mqttRef.value.on('message', handler)
|
||||
}
|
||||
|
||||
const connectMqtt = () => {
|
||||
if (mqttRef.value) {
|
||||
if (mqttRef.value.connected) {
|
||||
@@ -1023,12 +1048,40 @@ const getRealDataMqttMsg = async () => {
|
||||
// console.log(res, '获取基础实时数据')
|
||||
})
|
||||
}, 30000)
|
||||
mqttRef.value.on('message', (topic: any, message: any) => {
|
||||
// console.log(
|
||||
// '实时数据&实时趋势---mqtt接收到消息',
|
||||
// JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||
// )
|
||||
let obj = JSON.parse(JSON.stringify(JSON.parse(new TextDecoder().decode(message))))
|
||||
bindMqttMessage(onMqttRealDataMessage)
|
||||
//2.建立mqtt通讯
|
||||
//每隔30s调用一下接口,通知后台推送mqtt消息
|
||||
|
||||
mqttRef.value.on('error', (error: any) => {
|
||||
console.log('mqtt连接失败...', error)
|
||||
mqttRef.value.end()
|
||||
})
|
||||
|
||||
mqttRef.value.on('close', function () {
|
||||
console.log('mqtt客户端已断开连接.....')
|
||||
})
|
||||
setTimeout(() => {
|
||||
tableLoading.value = false
|
||||
}, 6000)
|
||||
} else {
|
||||
ElMessage.success('设备应答失败')
|
||||
tableLoading.value = false
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
setTimeout(() => {
|
||||
tableLoading.value = false
|
||||
}, 0)
|
||||
})
|
||||
}
|
||||
//tab点击事件
|
||||
|
||||
const realDataTimer: any = ref()
|
||||
const mqttMessage = ref<any>({})
|
||||
|
||||
/** 实时数据 / 实时趋势 MQTT 消息(命名函数,便于 off 避免重复注册) */
|
||||
const onMqttRealDataMessage = (topic: any, message: any) => {
|
||||
let obj = decodeMqttPayload(message)
|
||||
|
||||
if (lineId.value != obj.lineId || adminInfo.userIndex != obj.userId) return
|
||||
|
||||
@@ -1166,33 +1219,8 @@ const getRealDataMqttMsg = async () => {
|
||||
// sonTab.value == 1 &&
|
||||
// realTrendRef.value &&
|
||||
// realTrendRef.value.setRealTrendData(obj)
|
||||
})
|
||||
//2.建立mqtt通讯
|
||||
//每隔30s调用一下接口,通知后台推送mqtt消息
|
||||
|
||||
mqttRef.value.on('error', (error: any) => {
|
||||
console.log('mqtt连接失败...', error)
|
||||
mqttRef.value.end()
|
||||
})
|
||||
|
||||
mqttRef.value.on('close', function () {
|
||||
console.log('mqtt客户端已断开连接.....')
|
||||
})
|
||||
} else {
|
||||
ElMessage.success('设备应答失败')
|
||||
tableLoading.value = false
|
||||
}
|
||||
})
|
||||
.catch(e => {
|
||||
setTimeout(() => {
|
||||
tableLoading.value = false
|
||||
}, 0)
|
||||
})
|
||||
}
|
||||
//tab点击事件
|
||||
|
||||
const realDataTimer: any = ref()
|
||||
const mqttMessage = ref<any>({})
|
||||
const handleClick = async (tab?: any) => {
|
||||
tableLoading.value = true
|
||||
showButton.value = false
|
||||
@@ -1257,6 +1285,26 @@ const handleClick = async (tab?: any) => {
|
||||
tableLoading.value = false
|
||||
}, 0)
|
||||
}
|
||||
//电度数据
|
||||
if (dataSet.value.includes('_kilowattHour')) {
|
||||
let obj = {
|
||||
devId: deviceId.value, //e.id
|
||||
lineId: lineId.value, //e.pid
|
||||
type: 4,
|
||||
list: [
|
||||
{
|
||||
lineId: lineId.value,
|
||||
devId: dataSet.value.replace('_kilowattHour', '')
|
||||
}
|
||||
]
|
||||
// startTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
||||
// endTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
||||
}
|
||||
setTimeout(() => {
|
||||
electroplatingRef.value && electroplatingRef.value.getTrendRequest(obj)
|
||||
tableLoading.value = false
|
||||
}, 0)
|
||||
}
|
||||
//查询实时数据
|
||||
if (dataSet.value.includes('_realtimedata')) {
|
||||
tableLoading.value = true
|
||||
@@ -1440,6 +1488,8 @@ const handleClick = async (tab?: any) => {
|
||||
window.clearInterval(trendTimer.value)
|
||||
}
|
||||
if (mqttRef.value) {
|
||||
mqttRef.value.off('message', onMqttTrendMessage)
|
||||
mqttRef.value.off('message', onMqttRealDataMessage)
|
||||
mqttRef.value.end()
|
||||
}
|
||||
}
|
||||
@@ -1522,6 +1572,8 @@ onBeforeUnmount(() => {
|
||||
realDataTimer.value = 0
|
||||
trendTimer.value = 0
|
||||
if (mqttRef.value) {
|
||||
mqttRef.value.off('message', onMqttTrendMessage)
|
||||
mqttRef.value.off('message', onMqttRealDataMessage)
|
||||
mqttRef.value.end()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -293,31 +293,31 @@ const setRealTrendData = (val: any) => {
|
||||
if (selectValue.value == '2') {
|
||||
if (activeName.value == 2) {
|
||||
if (numberPart % 2 !== 0 && numberPart < 17) {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
} else {
|
||||
if (numberPart % 2 === 0) {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (activeName.value == 2) {
|
||||
if (numberPart % 2 === 0 && numberPart < 17) {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
} else {
|
||||
if (numberPart % 2 !== 0) {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (activeName.value == 2) {
|
||||
if (numberPart < 17) {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
} else {
|
||||
tableData.value[key] = val[key]
|
||||
tableData.value[key] = val[key].toFixed(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,25 +20,15 @@
|
||||
|
||||
<el-button @click="handleBack" :icon="Back">返回</el-button>
|
||||
</div>
|
||||
<!-- v-loading="loading" -->
|
||||
<el-tabs class="home_body" type="border-card" v-model.trim="activeName1" @tab-click="handleClick">
|
||||
<!-- -->
|
||||
<el-tabs class="home_body" v-loading="loading" type="border-card" v-model.trim="activeName1" @tab-click="handleClick">
|
||||
<el-tab-pane label="瞬时波形" name="ssbx" :style="'height:' + bxecharts + ';overflow-y: auto;'">
|
||||
<shushiboxi
|
||||
v-if="isWp && wp && activeName == 'ssbx' && showBoxi"
|
||||
:value="value"
|
||||
:boxoList="boxoList"
|
||||
:parentHeight="parentHeight"
|
||||
:wp="wp"
|
||||
></shushiboxi>
|
||||
<shushiboxi v-if="isWp && wp && activeName == 'ssbx' && showBoxi" :value="value" :boxoList="boxoList"
|
||||
:parentHeight="parentHeight" :wp="wp"></shushiboxi>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="RMS波形" name="rmsbx" :style="'height:' + bxecharts + ';overflow-y: auto;'">
|
||||
<rmsboxi
|
||||
v-if="isWp && wp && activeName == 'rmsbx' && showBoxi"
|
||||
:value="value"
|
||||
:boxoList="boxoList"
|
||||
:parentHeight="parentHeight"
|
||||
:wp="wp"
|
||||
></rmsboxi>
|
||||
<rmsboxi v-if="isWp && wp && activeName == 'rmsbx' && showBoxi" :value="value" :boxoList="boxoList"
|
||||
:parentHeight="parentHeight" :wp="wp"></rmsboxi>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
@@ -117,11 +107,10 @@ const getWpData = (val: any, list: any) => {
|
||||
const changeView = () => {
|
||||
showBoxi.value = false
|
||||
loading.value = true
|
||||
|
||||
setTimeout(() => {
|
||||
value.value = theTypeOfValue.value
|
||||
showBoxi.value = true
|
||||
}, 500)
|
||||
setTimeout(() => {
|
||||
loading.value = false
|
||||
}, 1000)
|
||||
}
|
||||
@@ -148,7 +137,7 @@ const setHeight = (h: any, vh: any, num = 1) => {
|
||||
bxecharts.value = mainHeight(vh, num).height
|
||||
}, 100)
|
||||
}
|
||||
onMounted(() => {})
|
||||
onMounted(() => { })
|
||||
defineExpose({ getWpData, setHeight })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
507
src/views/govern/device/control/tabs/electroplating.vue
Normal file
507
src/views/govern/device/control/tabs/electroplating.vue
Normal file
@@ -0,0 +1,507 @@
|
||||
<template>
|
||||
<div>
|
||||
<!-- 电度数据数据 -->
|
||||
<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 style="width: 200px" multiple :multiple-limit="3" collapse-tags filterable
|
||||
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>
|
||||
<el-radio-group v-model="searchForm.dataModel" @change="init()">
|
||||
<el-radio-button label="全量" value="0" />
|
||||
<el-radio-button label="增量" value="1" />
|
||||
</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> -->
|
||||
</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>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { yMethod, exportCSV, completeTimeSeries } from '@/utils/echartMethod'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { getTabsDataByType } from '@/api/cs-device-boot/EquipmentDelivery'
|
||||
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
|
||||
}
|
||||
})
|
||||
// console.log("🚀 ~ props:", props.TrendList)
|
||||
const showEchart = ref(true)
|
||||
//电压等级
|
||||
const voltageLevelList = dictData.getBasicData('Dev_Voltage_Stand')
|
||||
//接线方式
|
||||
const volConTypeList = dictData.getBasicData('Dev_Connect')
|
||||
const timeControl = ref(false)
|
||||
//值类型
|
||||
const pageHeight = ref(mainHeight(290))
|
||||
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,
|
||||
searchBeginTime: '',
|
||||
searchEndTime: '',
|
||||
dataLevel: 'Primary',
|
||||
dataModel: '0',
|
||||
valueType: 'avg'
|
||||
}
|
||||
//统计指标
|
||||
const indexOptions: any = ref([])
|
||||
queryByCode('Kilowatt_Hour').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
indexOptions.value = item.data.sort((a: any, b: any) => {
|
||||
return a.sort - b.sort
|
||||
})
|
||||
searchForm.value.index[0] = indexOptions.value[0].id
|
||||
init()
|
||||
})
|
||||
})
|
||||
const chartsList = ref<any>([])
|
||||
const activeName: any = ref()
|
||||
const deviceData: any = ref([])
|
||||
//历史趋势devId
|
||||
const historyDevId: any = ref('')
|
||||
const chartTitle: any = ref('')
|
||||
const echartsData = ref<any>(null)
|
||||
//加载echarts图表
|
||||
//历史趋势数据
|
||||
const historyDataList: any = ref([])
|
||||
//获取请求趋势数据参数
|
||||
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
|
||||
echartsData.value = {}
|
||||
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 + '/'
|
||||
}
|
||||
})
|
||||
})
|
||||
const lists = searchForm.value.index.map((id: any) => ({
|
||||
statisticalId: id,
|
||||
frequencys: []
|
||||
}))
|
||||
let obj = {
|
||||
...trendRequestData.value,
|
||||
list: lists,
|
||||
// valueType: searchForm.value.type,
|
||||
dataLevel: searchForm.value.dataLevel,
|
||||
dataModel: searchForm.value.dataModel,
|
||||
// valueType: searchForm.value.valueType,
|
||||
startTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
||||
endTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
||||
}
|
||||
if (searchForm.value.index.length == 0) {
|
||||
ElMessage.warning('请选择统计指标')
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
if (obj.devId && obj.list.length != 0) {
|
||||
try {
|
||||
showEchart.value = true
|
||||
await getTabsDataByType(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 = formatChartData(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) => {
|
||||
const key = item.statisticalName
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(item)
|
||||
return acc
|
||||
}, {})
|
||||
let result = Object.values(groupedData)
|
||||
// console.log("🚀 ~ .then ~ result:", result)
|
||||
// console.log("🚀 ~ .then ~ result:", result)
|
||||
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) => item.statisticalName))]
|
||||
// console.log("🚀 ~ .then ~ ABCName:", ABCName)
|
||||
result.forEach((item: any, index: any) => {
|
||||
let yMethodList: any = []
|
||||
|
||||
let ABCList = Object.values(
|
||||
item.reduce((acc: any, cur: any) => {
|
||||
const key = cur.phase == null ? cur.statisticalIndex : cur.phase
|
||||
|
||||
if (!acc[key]) {
|
||||
acc[key] = []
|
||||
}
|
||||
acc[key].push(cur)
|
||||
return acc
|
||||
}, {})
|
||||
)
|
||||
// console.log("🚀 ~ ABCList.forEach ~ ABCList:", ABCList)
|
||||
|
||||
ABCList.forEach((kk: any) => {
|
||||
let colorName = kk[0].phase?.charAt(0).toUpperCase()
|
||||
let lineS = ABCName.findIndex(name => name === kk[0].statisticalName)
|
||||
const seriesLineStyle = lineStyle[lineS] || lineStyle[0]
|
||||
const seriesColor = kk[0].phase
|
||||
? colorName == 'A'
|
||||
? '#DAA520'
|
||||
: colorName == 'B'
|
||||
? '#2E8B57'
|
||||
: colorName == 'C'
|
||||
? '#A52a2a'
|
||||
: ''
|
||||
: '#082e6c'
|
||||
|
||||
let seriesList: any = []
|
||||
const sortedData = [...kk].sort(
|
||||
(a: any, b: any) => new Date(a.time).getTime() - new Date(b.time).getTime()
|
||||
)
|
||||
sortedData.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, seriesLineStyle.type])
|
||||
})
|
||||
|
||||
echartsData.value.options.series.push({
|
||||
name: kk[0].phase ? kk[0].phase + '相' + kk[0].anotherName : kk[0].anotherName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
color: seriesColor,
|
||||
symbol: 'none',
|
||||
data: timeControl.value ? completeTimeSeries(seriesList) : seriesList,
|
||||
lineStyle: seriesLineStyle,
|
||||
yAxisIndex: setList.indexOf(kk[0].unit)
|
||||
})
|
||||
})
|
||||
// let [min, max] = yMethod(yMethodList)
|
||||
// echartsData.value.yAxis[index].min = min
|
||||
// echartsData.value.yAxis[index].max = max
|
||||
})
|
||||
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) => {
|
||||
if (flag) {
|
||||
pageHeight.value = mainHeight(332)
|
||||
} else {
|
||||
pageHeight.value = mainHeight(290)
|
||||
}
|
||||
}
|
||||
|
||||
// 电度趋势数据预处理:按时间排序
|
||||
const formatChartData = (data: any[]) => {
|
||||
return [...data].sort((a, b) => new Date(a.time).getTime() - new Date(b.time).getTime())
|
||||
}
|
||||
|
||||
const onIndexChange = (val: any) => {
|
||||
let pp: any = []
|
||||
indexOptions.value.forEach((item: any) => {
|
||||
const filteredResult = val.filter((vv: any) => item.id == vv)
|
||||
if (filteredResult.length > 0) {
|
||||
pp.push(filteredResult[0])
|
||||
}
|
||||
})
|
||||
searchForm.value.index = pp
|
||||
}
|
||||
onMounted(() => {
|
||||
datePickerRef.value.setInterval(5)
|
||||
})
|
||||
defineExpose({ getTrendRequest })
|
||||
</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;
|
||||
}
|
||||
|
||||
:deep(.el-select__selected-item) {
|
||||
.is-closable {
|
||||
width: 100px !important;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-form--inline .el-form-item) {
|
||||
margin-right: 15px !important;
|
||||
}
|
||||
</style>
|
||||
@@ -4,13 +4,8 @@
|
||||
<TableHeader datePicker ref="headerRef" :showReset="false"></TableHeader>
|
||||
<Table ref="tableRef" />
|
||||
</div>
|
||||
<waveFormAnalysis
|
||||
v-loading="loading"
|
||||
v-if="isWaveCharts"
|
||||
ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false"
|
||||
:wp="wp"
|
||||
/>
|
||||
<waveFormAnalysis v-loading="loading" v-if="isWaveCharts" ref="waveFormAnalysisRef"
|
||||
@handleHideCharts="isWaveCharts = false" :wp="wp" />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -57,16 +52,23 @@ const tableStore: any = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ field: 'startTime', title: '发生时刻', minWidth: 170, sortable: true },
|
||||
{ field: 'showName', title: '事件描述', minWidth: 120 },
|
||||
{ field: 'startTime', title: '暂降发生时刻', minWidth: 180, sortable: true },
|
||||
|
||||
{
|
||||
field: 'phaseType',
|
||||
title: '相别',
|
||||
minWidth: 80,
|
||||
field: 'featureAmplitude',
|
||||
title: '暂降(骤升)幅值(%)',
|
||||
minWidth: 160,
|
||||
sortable: true,
|
||||
formatter: (row: any) => {
|
||||
return row.cellValue || '/'
|
||||
//row.cellValue = row.cellValue + '' ? row.cellValue.toFixed(2) : '/'
|
||||
row.cellValue = row.cellValue != null ? Number(row.cellValue).toFixed(2) : '/'
|
||||
if (String(row.cellValue).split('.')[1] == '00') {
|
||||
row.cellValue = String(row.cellValue).split('.')[0]
|
||||
}
|
||||
return row.cellValue
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
field: 'persistTime',
|
||||
title: '持续时间(s)',
|
||||
@@ -79,18 +81,17 @@ const tableStore: any = new TableStore({
|
||||
sortable: true
|
||||
},
|
||||
{
|
||||
field: 'featureAmplitude',
|
||||
title: '暂降(聚升)幅值(%)',
|
||||
minWidth: 130,
|
||||
field: 'phaseType',
|
||||
title: '相别',
|
||||
minWidth: 80,
|
||||
formatter: (row: any) => {
|
||||
//row.cellValue = row.cellValue + '' ? row.cellValue.toFixed(2) : '/'
|
||||
row.cellValue = row.cellValue != null ? Number(row.cellValue).toFixed(2) : '/'
|
||||
if (String(row.cellValue).split('.')[1] == '00') {
|
||||
row.cellValue = String(row.cellValue).split('.')[0]
|
||||
}
|
||||
return row.cellValue
|
||||
return row.cellValue || '/'
|
||||
}
|
||||
},
|
||||
{ field: 'showName', title: '触发类型', minWidth: 120 },
|
||||
|
||||
|
||||
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
@@ -111,10 +112,11 @@ const tableStore: any = new TableStore({
|
||||
},
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
isWaveCharts.value = true
|
||||
loading.value = true
|
||||
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
isWaveCharts.value = true
|
||||
loading.value = true
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
@@ -148,7 +150,7 @@ const tableStore: any = new TableStore({
|
||||
icon: 'el-icon-DataLine',
|
||||
render: 'basicButton',
|
||||
disabled: row => {
|
||||
return row.showName != '未知'
|
||||
return row.wavePath
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -163,6 +165,7 @@ const tableStore: any = new TableStore({
|
||||
return !row.wavePath
|
||||
},
|
||||
click: row => {
|
||||
ElMessage.info('下载中......')
|
||||
getFileZip({ eventId: row.id }).then(res => {
|
||||
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
@@ -172,6 +175,7 @@ const tableStore: any = new TableStore({
|
||||
document.body.appendChild(link)
|
||||
link.click() //执行下载
|
||||
document.body.removeChild(link) //释放标签
|
||||
ElMessage.success('波形下载成功')
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -182,7 +186,7 @@ const tableStore: any = new TableStore({
|
||||
icon: 'el-icon-Check',
|
||||
render: 'basicButton',
|
||||
disabled: row => {
|
||||
return (props.deviceType === '2' && row.wavePath) || row.showName === '未知'
|
||||
return !(props.deviceType == '2' && row.wavePath == null)
|
||||
},
|
||||
click: row => {
|
||||
getFileByEventId(row.id).then(res => {
|
||||
@@ -201,7 +205,7 @@ const tableStore: any = new TableStore({
|
||||
tableStore.table.params.list = tableParams.value.list
|
||||
tableStore.table.params.type = 3
|
||||
},
|
||||
loadCallback: () => {}
|
||||
loadCallback: () => { }
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
const isWaveCharts = ref(false)
|
||||
@@ -219,6 +223,8 @@ const handleBack = async () => {
|
||||
}
|
||||
defineExpose({ getTableParams })
|
||||
onMounted(() => {
|
||||
console.log('🚀 ~ props.deviceType:', props.deviceType)
|
||||
|
||||
tableStore.index()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<template>
|
||||
<div class=" device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
|
||||
<div class="device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
|
||||
<GetMarketList @node-click="selectUser" @selectUser="selectUser"></GetMarketList>
|
||||
<div class="device-manage-right" :style="{ height: pageHeight.height }">
|
||||
<el-descriptions title="用户基本信息" class="mb10" :column="2" border>
|
||||
<template #extra>
|
||||
<el-button type="primary" icon="el-icon-Sort" @click="getMarketEnginner">
|
||||
绑定工程
|
||||
</el-button>
|
||||
<el-button type="primary" icon="el-icon-Sort" @click="getMarketEnginner">绑定工程</el-button>
|
||||
</template>
|
||||
<el-descriptions-item label="名称">
|
||||
{{ user.name }}
|
||||
@@ -29,18 +27,36 @@
|
||||
</vxe-table>
|
||||
</div>
|
||||
</div>
|
||||
<el-dialog v-model.trim="dialogVisible" title="绑定工程" class="cn-operate-dialog" :close-on-click-modal="false">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="filterText" icon="el-icon-Search" placeholder="请输入内容"
|
||||
clearable style="margin-bottom: 10px">
|
||||
<el-dialog
|
||||
v-model.trim="dialogVisible"
|
||||
title="绑定工程"
|
||||
class="cn-operate-dialog"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="filterText"
|
||||
icon="el-icon-Search"
|
||||
placeholder="请输入内容"
|
||||
clearable
|
||||
style="margin-bottom: 10px"
|
||||
>
|
||||
<template #prefix>
|
||||
<Icon name="el-icon-Search" style="font-size: 16px" />
|
||||
</template>
|
||||
</el-input>
|
||||
|
||||
<vxe-table ref="tableRef" v-bind="defaultAttribute" :data="tableData2.filter((item: any) => {
|
||||
<vxe-table
|
||||
ref="tableRef"
|
||||
v-bind="defaultAttribute"
|
||||
:data="tableData2.filter((item: any) => {
|
||||
return item.name.includes(filterText)
|
||||
})
|
||||
" height="500px" style="width: 100%">
|
||||
"
|
||||
height="500px"
|
||||
style="width: 100%"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60"></vxe-column>
|
||||
<vxe-column field="name" title="工程名称"></vxe-column>
|
||||
</vxe-table>
|
||||
@@ -77,6 +93,7 @@ const filterText = ref('')
|
||||
const tableRef = ref()
|
||||
|
||||
const selectUser = (e: any) => {
|
||||
if (e == undefined) return (loading.value = false)
|
||||
user.value = e
|
||||
loading.value = true
|
||||
queryByUseId({
|
||||
|
||||
@@ -238,7 +238,7 @@ const deviceTypeChange = (val: any, obj: any) => {
|
||||
nodeClick(obj)
|
||||
}
|
||||
const nodeClick = (e: any) => {
|
||||
if (e && (e.level == 2 || e.type == 'device')) {
|
||||
if (e && (e.level == 2 || e.level == 3 || e.type == 'device')) {
|
||||
loading.value = true
|
||||
nDid.value = e.ndid
|
||||
devId.value = e.id
|
||||
|
||||
@@ -137,12 +137,11 @@ const deviceTypeChange = (val: any, obj: any) => {
|
||||
}
|
||||
// 树节点点击
|
||||
const nodeClick = (e: anyObj) => {
|
||||
console.log('🚀 ~ nodeClick ~ e:', e)
|
||||
if (!e) {
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
if (e.level == 2) {
|
||||
if (e.level == 2 || e.level == 3) {
|
||||
pName.value = e.pName
|
||||
nDid.value = e.ndid
|
||||
loading.value = true
|
||||
|
||||
@@ -171,6 +171,7 @@ const defaultProps = {
|
||||
label: 'name'
|
||||
}
|
||||
const selectUser = (e: any) => {
|
||||
if (e == undefined) return (loading.value = false)
|
||||
user.value = e
|
||||
loading.value = true
|
||||
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
</el-tooltip>
|
||||
|
||||
|
||||
<Icon @click="onMenuCollapse" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
<!-- <Icon @click="onMenuCollapse" :name="menuCollapse ? 'el-icon-Expand' : 'el-icon-Fold'"
|
||||
:class="menuCollapse ? 'unfold' : ''" size="18" class="fold ml10 menu-collapse"
|
||||
style="cursor: pointer" />
|
||||
style="cursor: pointer" /> -->
|
||||
</div>
|
||||
<el-tree style="flex: 1; overflow: auto" :props="defaultProps" highlight-current
|
||||
:filter-node-method="filterNode" node-key="id" v-bind="$attrs" default-expand-all :data="tree"
|
||||
|
||||
@@ -44,8 +44,28 @@ const tableStore = new TableStore({
|
||||
return (tableStore.table.params.pageNum - 1) * tableStore.table.params.pageSize + row.rowIndex + 1
|
||||
}
|
||||
},
|
||||
{ field: 'startTime', title: '发生时刻', minWidth: 170, sortable: true },
|
||||
{ field: 'showName', title: '事件描述', minWidth: 170 },
|
||||
{ field: 'startTime', title: '暂降发生时刻', minWidth: 170, sortable: true },
|
||||
{
|
||||
field: 'featureAmplitude',
|
||||
title: '暂降(骤升)幅值(%)',
|
||||
minWidth: 160,
|
||||
formatter: (row: any) => {
|
||||
row.cellValue = row.cellValue + '' ? row.cellValue.toFixed(2) : '/'
|
||||
if (String(row.cellValue).split('.')[1] == '00') {
|
||||
row.cellValue = String(row.cellValue).split('.')[0]
|
||||
}
|
||||
return row.cellValue
|
||||
}, sortable: true
|
||||
},
|
||||
{
|
||||
field: 'persistTime',
|
||||
title: '持续时间(s)',
|
||||
minWidth: 110,
|
||||
formatter: (row: any) => {
|
||||
row.cellValue = row.cellValue ? row.cellValue.toFixed(2) : '/'
|
||||
return row.cellValue
|
||||
}, sortable: true
|
||||
},
|
||||
{
|
||||
field: 'phaseType',
|
||||
title: '相别',
|
||||
@@ -55,27 +75,9 @@ const tableStore = new TableStore({
|
||||
return row.cellValue
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'persistTime',
|
||||
title: '持续时间(s)',
|
||||
minWidth: 100,
|
||||
formatter: (row: any) => {
|
||||
row.cellValue = row.cellValue ? row.cellValue.toFixed(2) : '/'
|
||||
return row.cellValue
|
||||
}, sortable: true
|
||||
},
|
||||
{
|
||||
field: 'featureAmplitude',
|
||||
title: '暂降(聚升)幅值(%)',
|
||||
minWidth: 100,
|
||||
formatter: (row: any) => {
|
||||
row.cellValue = row.cellValue + '' ? row.cellValue.toFixed(2) : '/'
|
||||
if (String(row.cellValue).split('.')[1] == '00') {
|
||||
row.cellValue = String(row.cellValue).split('.')[0]
|
||||
}
|
||||
return row.cellValue
|
||||
}, sortable: true
|
||||
},
|
||||
|
||||
|
||||
{ field: 'showName', title: '触发类型', minWidth: 170 },
|
||||
{
|
||||
title: '操作', fixed: 'right',
|
||||
width: 180,
|
||||
@@ -95,10 +97,11 @@ const tableStore = new TableStore({
|
||||
},
|
||||
click: async row => {
|
||||
row.loading1 = true
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
|
||||
await analyseWave(row.id)
|
||||
.then(res => {
|
||||
loading.value = true
|
||||
isWaveCharts.value = true
|
||||
row.loading1 = false
|
||||
if (res != undefined) {
|
||||
boxoList.value = row
|
||||
@@ -142,6 +145,7 @@ const tableStore = new TableStore({
|
||||
return !row.wavePath
|
||||
},
|
||||
click: row => {
|
||||
ElMessage.info('下载中......')
|
||||
getFileZip({ eventId: row.id }).then(res => {
|
||||
let blob = new Blob([res], { type: 'application/zip' }) // console.log(blob) // var href = window.URL.createObjectURL(blob); //创建下载的链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
@@ -151,7 +155,7 @@ const tableStore = new TableStore({
|
||||
document.body.appendChild(link)
|
||||
link.click() //执行下载
|
||||
document.body.removeChild(link) //释放标签
|
||||
|
||||
ElMessage.success('波形下载成功')
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
<template>
|
||||
<div class="device-manage" :style="{ height: pageHeight.height }" v-loading="loading">
|
||||
<DeviceTree
|
||||
ref="treeRef"
|
||||
:showCheckbox="true"
|
||||
:default-checked-keys="defaultCheckedKeys"
|
||||
@checkChange="checkChange"
|
||||
:height="35"
|
||||
:engineering="true"
|
||||
></DeviceTree>
|
||||
<DeviceTree ref="treeRef" :showCheckbox="true" :default-checked-keys="defaultCheckedKeys"
|
||||
@checkChange="checkChange" :height="35" :engineering="true"></DeviceTree>
|
||||
<div class="device-manage-right" :style="{ height: pageHeight.height }">
|
||||
<vxe-table v-bind="defaultAttribute" :data="tableData" height="auto" style="width: 100%">
|
||||
<vxe-column field="enginerName" title="工程名称"></vxe-column>
|
||||
@@ -36,7 +30,8 @@ const tableData = ref([])
|
||||
const treeRef = ref(null)
|
||||
const ignoreCheckChange = ref(false)
|
||||
const checkChange = (data: any) => {
|
||||
console.log('🚀 ~ checkChange ~ data:', data)
|
||||
console.log("🚀 ~ checkChange ~ data:", data)
|
||||
if (data == undefined) return (loading.value = false)
|
||||
if (data.data.pName == '便携式设备') {
|
||||
if (ignoreCheckChange.value) {
|
||||
ignoreCheckChange.value = false // 清除标记,不影响后续正常触发
|
||||
@@ -47,7 +42,7 @@ const checkChange = (data: any) => {
|
||||
return treeRef.value?.treRef?.treeRef2?.setCheckedKeys([])
|
||||
}
|
||||
|
||||
if (data.data.level === 2) {
|
||||
if (data.data.level === 2 || data.data.level === 3) {
|
||||
if (data.checked) {
|
||||
defaultCheckedKeys.value.push(data.data.id)
|
||||
} else {
|
||||
@@ -57,7 +52,7 @@ const checkChange = (data: any) => {
|
||||
updateVisitorConfigs()
|
||||
}
|
||||
}
|
||||
const updateVisitorConfigs = debounce (() => {
|
||||
const updateVisitorConfigs = debounce(() => {
|
||||
const result = Array.from(new Set(defaultCheckedKeys.value))
|
||||
updateVisitorConfig(
|
||||
result.map(item => {
|
||||
@@ -70,7 +65,7 @@ const updateVisitorConfigs = debounce (() => {
|
||||
getVisitorConfigs()
|
||||
}
|
||||
})
|
||||
},500)
|
||||
}, 500)
|
||||
const getVisitorConfigs = () => {
|
||||
getVisitorConfig().then((res: any) => {
|
||||
if (res.code === 'A0000') {
|
||||
@@ -100,6 +95,7 @@ onMounted(() => {
|
||||
overflow: hidden;
|
||||
flex: 1;
|
||||
padding: 10px 10px 10px 0;
|
||||
|
||||
.el-descriptions__header {
|
||||
height: 36px;
|
||||
margin-bottom: 7px;
|
||||
|
||||
@@ -3,47 +3,22 @@
|
||||
<TableHeader>
|
||||
<template #select>
|
||||
<el-form-item label="数据分类">
|
||||
<el-select
|
||||
v-model.trim="tableStore.table.params.dataType"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
clearable
|
||||
placeholder="请选择数据分类"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in DataTypeSelect"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
<el-select v-model.trim="tableStore.table.params.dataType" multiple filterable collapse-tags
|
||||
clearable placeholder="请选择数据分类">
|
||||
<el-option v-for="item in DataTypeSelect" :key="item.id" :label="item.name"
|
||||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据存储">
|
||||
<el-select
|
||||
v-model.trim="tableStore.table.params.classId"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
clearable
|
||||
placeholder="请选择数据存储"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in DataSelect"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
<el-select v-model.trim="tableStore.table.params.classId" multiple filterable collapse-tags
|
||||
clearable placeholder="请选择数据存储">
|
||||
<el-option v-for="item in DataSelect" :key="item.id" :label="item.name"
|
||||
:value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关键字筛选">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="tableStore.table.params.searchValue"
|
||||
placeholder="数据名称、别名、展示名称"
|
||||
clearable
|
||||
></el-input>
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="tableStore.table.params.searchValue"
|
||||
placeholder="数据名称、别名、展示名称" clearable></el-input>
|
||||
</el-form-item>
|
||||
</template>
|
||||
<template #operation>
|
||||
@@ -99,7 +74,8 @@ const tableStore = new TableStore({
|
||||
? row.cellValue == '/'
|
||||
? '/'
|
||||
: row.cellValue == 'M'
|
||||
? '无相别'
|
||||
? '/' : row.cellValue == 'T'
|
||||
? '/'
|
||||
: row.cellValue + '相'
|
||||
: '/'
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" draggable v-model.trim="dialogVisible" :title="title" @close="emit('close')">
|
||||
<el-dialog class="cn-operate-dialog" draggable v-model.trim="dialogVisible" width="900px" :title="title" @close="emit('close')">
|
||||
<el-scrollbar>
|
||||
<div style="padding-left: 50px">
|
||||
<el-divider content-position="center">基础数据</el-divider>
|
||||
</div>
|
||||
<el-form :model="form" label-width="140px" ref="formRef" class="form-two" :rules="rules">
|
||||
<el-form :model="form" label-width="130px" ref="formRef" class="form-two" :rules="rules">
|
||||
<el-form-item label="数据分类:" prop="dataType">
|
||||
<el-select v-model.trim="form.dataType" filterable clearable placeholder="请选择数据分类">
|
||||
<el-option
|
||||
@@ -71,7 +71,7 @@
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="开始结束次数:">
|
||||
<el-slider v-model.trim="form.harm" range show-stops :max="50" style="width: 95%" />
|
||||
<el-slider v-model.trim="form.harm" range :max="50" style="width: 90%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="统计方法:">
|
||||
<el-select
|
||||
@@ -155,7 +155,7 @@
|
||||
<div style="padding-left: 50px">
|
||||
<el-divider content-position="center">拓展数据</el-divider>
|
||||
</div>
|
||||
<el-form class="form-two" :model="form" label-width="140px" ref="formRef2">
|
||||
<el-form class="form-two" :model="form" label-width="130px" ref="formRef2">
|
||||
<el-form-item label="告警码(缺省值):">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
@@ -282,7 +282,7 @@ const phaseSelect = [
|
||||
id: 'C'
|
||||
},
|
||||
{
|
||||
name: 'T相',
|
||||
name: '无相别',
|
||||
id: 'T'
|
||||
},
|
||||
{
|
||||
@@ -297,10 +297,10 @@ const phaseSelect = [
|
||||
name: 'CA相',
|
||||
id: 'CA'
|
||||
},
|
||||
{
|
||||
name: '无相别',
|
||||
id: 'M'
|
||||
},
|
||||
// {
|
||||
// name: '无相别',
|
||||
// id: 'M'
|
||||
// },
|
||||
]
|
||||
const StatMethodSelect = [
|
||||
{
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
<TableHeader>
|
||||
<template v-slot:select>
|
||||
<el-form-item label="关键字筛选">
|
||||
<el-input v-model.trim="tableStore.table.params.searchValue" style="width: 200px" clearable
|
||||
placeholder="请输入设备名称/网络设备ID" />
|
||||
<el-input
|
||||
v-model.trim="tableStore.table.params.searchValue"
|
||||
style="width: 200px"
|
||||
clearable
|
||||
placeholder="请输入设备名称/网络设备ID"
|
||||
/>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="流程阶段">
|
||||
<el-select v-model.trim="tableStore.table.params.process" clearable placeholder="请选择状态">
|
||||
@@ -14,7 +18,11 @@
|
||||
</el-select>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="物联状态">
|
||||
<el-select v-model.trim="tableStore.table.params.connectStatus" clearable placeholder="请选择物联状态">
|
||||
<el-select
|
||||
v-model.trim="tableStore.table.params.connectStatus"
|
||||
clearable
|
||||
placeholder="请选择物联状态"
|
||||
>
|
||||
<el-option label="已连接" :value="1"></el-option>
|
||||
<el-option label="未连接" :value="0"></el-option>
|
||||
</el-select>
|
||||
@@ -77,40 +85,77 @@
|
||||
<el-button type="primary" @click="downLoadFile1" class="ml10" icon="el-icon-Download">
|
||||
模版下载
|
||||
</el-button>
|
||||
<el-upload style="display: inline-block" action="" accept=".xlsx" class="upload-demo"
|
||||
:show-file-list="false" :auto-upload="false" :on-change="bulkImport">
|
||||
<el-upload
|
||||
style="display: inline-block"
|
||||
action=""
|
||||
accept=".xlsx"
|
||||
class="upload-demo"
|
||||
:show-file-list="false"
|
||||
:auto-upload="false"
|
||||
:on-change="bulkImport"
|
||||
>
|
||||
<el-button type="primary" class="ml10" icon="el-icon-Tickets">批量导入</el-button>
|
||||
</el-upload>
|
||||
<el-button type="primary" class="ml10" @click="add" icon="el-icon-Plus">新增设备</el-button>
|
||||
<el-button type="primary" class="ml10" icon="el-icon-Download" @click="downLoadQrCode"
|
||||
:disabled="!showQrCode">
|
||||
<el-button
|
||||
type="primary"
|
||||
class="ml10"
|
||||
icon="el-icon-Download"
|
||||
@click="downLoadQrCode"
|
||||
:disabled="!showQrCode"
|
||||
>
|
||||
批量下载二维码
|
||||
</el-button>
|
||||
</template>
|
||||
</TableHeader>
|
||||
<Table ref="tableRef" :checkbox-config="checkboxConfig" :key="tableKey" @sort-change="handleSortChange"></Table>
|
||||
|
||||
<el-dialog :title="dialogTitle" v-model.trim="dialogFormVisible" :close-on-click-modal="false"
|
||||
:before-close="resetForm" draggable width="800px">
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
v-model.trim="dialogFormVisible"
|
||||
:close-on-click-modal="false"
|
||||
:before-close="resetForm"
|
||||
draggable
|
||||
width="800px"
|
||||
>
|
||||
<el-form :model="form" label-width="auto" :rules="rules" ref="ruleFormRef" class="form-two">
|
||||
<el-form-item label="设备名称:" prop="name">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.name" autocomplete="off" clearable
|
||||
placeholder="请输入(项目名称+设备名称)"></el-input>
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="form.name"
|
||||
autocomplete="off"
|
||||
clearable
|
||||
placeholder="请输入(项目名称+设备名称)"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="网络设备ID:" prop="ndid" class="top">
|
||||
<el-input maxlength="32" show-word-limit v-model.trim="form.ndid" autocomplete="off"
|
||||
placeholder="请输入"></el-input>
|
||||
<el-input
|
||||
maxlength="32"
|
||||
show-word-limit
|
||||
v-model.trim="form.ndid"
|
||||
autocomplete="off"
|
||||
placeholder="请输入"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型:" prop="devType" class="top">
|
||||
<el-select v-model.trim="form.devType" placeholder="请选择" @change="formDevTypeChange" clearable>
|
||||
<el-option v-for="item in formDevTypeOptions" :key="item.value" :label="item.label || item.name"
|
||||
:value="item.value || item.id"></el-option>
|
||||
<el-option
|
||||
v-for="item in formDevTypeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label || item.name"
|
||||
:value="item.value || item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备型号:" prop="devModel" class="top">
|
||||
<el-select v-model.trim="form.devModel" filterable placeholder="请选择" clearable>
|
||||
<el-option v-for="item in formDevModelOptionsFilter" :key="item.value" :label="item.label"
|
||||
:value="item.value"></el-option>
|
||||
<el-option
|
||||
v-for="item in formDevModelOptionsFilter"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="通讯协议:" prop="devAccessMethod" class="top">
|
||||
@@ -120,8 +165,13 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="关联项目:" class="top">
|
||||
<el-cascader v-model.trim="form.association" filterable :options="engineeringList" :props="props"
|
||||
clearable />
|
||||
<el-cascader
|
||||
v-model.trim="form.association"
|
||||
filterable
|
||||
:options="engineeringList"
|
||||
:props="props"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="排序:" class="top" prop="sort">
|
||||
<el-input maxlength="32" show-word-limit-number v-model.trim="form.sort" :min="0" />
|
||||
@@ -722,18 +772,24 @@ const tableStore = new TableStore({
|
||||
},
|
||||
{
|
||||
name: 'edit',
|
||||
title: '重启',
|
||||
title: '重置',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
|
||||
click: async row => {
|
||||
ElMessageBox.confirm('确定重置该设备吗?', '提示', {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
resetFactory({
|
||||
nDid: row.ndid
|
||||
}).then(res => {
|
||||
ElMessage.success('重启成功!')
|
||||
ElMessage.success('重置成功!')
|
||||
tableStore.onTableAction('search', {})
|
||||
})
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -754,7 +810,7 @@ const tableStore = new TableStore({
|
||||
tableStore.onTableAction('search', {})
|
||||
})
|
||||
})
|
||||
.catch(e => { })
|
||||
.catch(e => {})
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -985,10 +1041,10 @@ onMounted(() => {
|
||||
})
|
||||
})
|
||||
|
||||
setTimeout(() => { }, 100)
|
||||
setTimeout(() => {}, 100)
|
||||
})
|
||||
|
||||
const addMenu = () => { }
|
||||
const addMenu = () => {}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.qrcode-label {
|
||||
|
||||
569
src/views/govern/manage/process/index.vue
Normal file
569
src/views/govern/manage/process/index.vue
Normal file
@@ -0,0 +1,569 @@
|
||||
<template>
|
||||
<div class="default-main manage-process" :style="{ height: pageHeight.height }">
|
||||
<DeviceTree @node-click="nodeClick" @init="nodeClick" @deviceTypeChange=""></DeviceTree>
|
||||
<div class="manage-process-right">
|
||||
<div class="process-flow-section">
|
||||
<el-descriptions title="数据链路">
|
||||
|
||||
</el-descriptions>
|
||||
<div class="process-flow-wrap">
|
||||
<div class="process-flow">
|
||||
<template v-for="(node, index) in flowNodes" :key="node.label">
|
||||
<div class="process-step">
|
||||
<div class="process-node" :class="`process-node--${getNodeState(index)}`">
|
||||
<div class="process-node__icon" :style="{ color: getNodeColor(index) }">
|
||||
<el-icon v-if="node.isEl"><component :is="node.icon" /></el-icon>
|
||||
<component v-else :is="node.icon" :color="getNodeColor(index)" />
|
||||
</div>
|
||||
<div class="process-node__name">{{ node.label }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="index < flowNodes.length - 1"
|
||||
class="process-bridge"
|
||||
:class="`process-bridge--${getLineState(index)}`"
|
||||
>
|
||||
<svg class="process-bridge__svg" viewBox="0 0 120 16" preserveAspectRatio="none">
|
||||
<line class="process-bridge__bg" x1="0" y1="8" x2="104" y2="8" />
|
||||
<line class="process-bridge__active" x1="0" y1="8" x2="104" y2="8" />
|
||||
<line
|
||||
v-if="getLineState(index) === 'flowing'"
|
||||
class="process-bridge__flow"
|
||||
x1="0"
|
||||
y1="8"
|
||||
x2="104"
|
||||
y2="8"
|
||||
/>
|
||||
<polygon class="process-bridge__head" points="106,4 116,8 106,12" />
|
||||
</svg>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="process-list-section">
|
||||
<el-descriptions title="数据列表" />
|
||||
<div class="process-list-body">
|
||||
<el-table :data="processTableData" border stripe height="100%">
|
||||
<el-table-column type="index" label="序号" width="60" align="center" />
|
||||
<el-table-column prop="name" label="节点" min-width="100" align="center" />
|
||||
<el-table-column prop="link" label="上游链路" min-width="140" align="center" />
|
||||
<el-table-column prop="status" label="连接状态" min-width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
<span :class="`process-table-status process-table-status--${row.state}`">
|
||||
{{ row.status }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { h, watch, onUnmounted, ref, computed, defineComponent } from 'vue'
|
||||
import { Monitor, Coin } from '@element-plus/icons-vue'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import DeviceTree from '@/components/tree/govern/deviceTree.vue'
|
||||
|
||||
defineOptions({
|
||||
name: 'process'
|
||||
})
|
||||
|
||||
const pageHeight = mainHeight(20)
|
||||
|
||||
/** 连接状态:null-初始,0-终端绿/终端↔前置,1-前置绿/前置↔MQTT,2-MQTT绿/MQTT↔数据库,3-数据库绿/数据库↔Web,4-全部完成 */
|
||||
const linkStatus = ref<number | null>(2)
|
||||
|
||||
const COLOR = {
|
||||
pending: '#94a3b8',
|
||||
success: '#009f05',
|
||||
error: '#e05252'
|
||||
}
|
||||
|
||||
const createProcessIcon = (render: (color: string) => ReturnType<typeof h>[]) =>
|
||||
defineComponent({
|
||||
props: {
|
||||
color: { type: String, default: COLOR.pending }
|
||||
},
|
||||
setup(props) {
|
||||
return () =>
|
||||
h(
|
||||
'svg',
|
||||
{
|
||||
viewBox: '0 0 48 48',
|
||||
fill: 'none',
|
||||
xmlns: 'http://www.w3.org/2000/svg',
|
||||
class: 'process-node__svg'
|
||||
},
|
||||
render(props.color)
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
/** 终端:采集设备 */
|
||||
const IconTerminal = createProcessIcon(c => [
|
||||
h('rect', { x: 8, y: 10, width: 32, height: 22, rx: 3, stroke: c, 'stroke-width': 2.2 }),
|
||||
h('rect', { x: 14, y: 15, width: 20, height: 12, rx: 1.5, stroke: c, 'stroke-width': 1.5, opacity: 0.45 }),
|
||||
h('path', { d: 'M4 36h40', stroke: c, 'stroke-width': 2.2, 'stroke-linecap': 'round' }),
|
||||
h('path', { d: 'M22 32v4', stroke: c, 'stroke-width': 2.2, 'stroke-linecap': 'round' }),
|
||||
h('circle', { cx: 38, cy: 8, r: 3, fill: c, opacity: 0.85 })
|
||||
])
|
||||
|
||||
/** 前置:双机服务器 */
|
||||
const IconFrontEnd = createProcessIcon(c => [
|
||||
h('rect', { x: 10, y: 8, width: 28, height: 13, rx: 2.5, stroke: c, 'stroke-width': 2.2, fill: 'rgba(148,163,184,0.08)' }),
|
||||
h('circle', { cx: 16, cy: 14.5, r: 2, fill: c }),
|
||||
h('line', { x1: 22, y1: 14.5, x2: 34, y2: 14.5, stroke: c, 'stroke-width': 1.5, opacity: 0.5 }),
|
||||
h('rect', { x: 10, y: 27, width: 28, height: 13, rx: 2.5, stroke: c, 'stroke-width': 2.2, fill: 'rgba(148,163,184,0.08)' }),
|
||||
h('circle', { cx: 16, cy: 33.5, r: 2, fill: c }),
|
||||
h('line', { x1: 22, y1: 33.5, x2: 34, y2: 33.5, stroke: c, 'stroke-width': 1.5, opacity: 0.5 })
|
||||
])
|
||||
|
||||
/** MQTT:云 + 节点 */
|
||||
const IconMqtt = createProcessIcon(c => [
|
||||
h('circle', { cx: 24, cy: 26, r: 2.5, fill: c }),
|
||||
h('circle', { cx: 12, cy: 16, r: 2, fill: c, opacity: 0.75 }),
|
||||
h('circle', { cx: 36, cy: 16, r: 2, fill: c, opacity: 0.75 }),
|
||||
h('circle', { cx: 12, cy: 36, r: 2, fill: c, opacity: 0.75 }),
|
||||
h('circle', { cx: 36, cy: 36, r: 2, fill: c, opacity: 0.75 }),
|
||||
h('line', { x1: 24, y1: 26, x2: 12, y2: 16, stroke: c, 'stroke-width': 1.4, opacity: 0.55 }),
|
||||
h('line', { x1: 24, y1: 26, x2: 36, y2: 16, stroke: c, 'stroke-width': 1.4, opacity: 0.55 }),
|
||||
h('line', { x1: 24, y1: 26, x2: 12, y2: 36, stroke: c, 'stroke-width': 1.4, opacity: 0.55 }),
|
||||
h('line', { x1: 24, y1: 26, x2: 36, y2: 36, stroke: c, 'stroke-width': 1.4, opacity: 0.55 }),
|
||||
h('path', {
|
||||
d: 'M15 24c0-4.5 3.5-7.5 9-7.5s9 3 9 7.5c3.5 0 6 2.5 6 6s-2.5 6-6 6H15c-3.5 0-6-2.5-6-6s2.5-6 6-6z',
|
||||
stroke: c,
|
||||
'stroke-width': 2,
|
||||
fill: '#fff'
|
||||
}),
|
||||
h('text', { x: 24, y: 27.5, 'text-anchor': 'middle', fill: c, 'font-size': 7.5, 'font-weight': 'bold' }, 'MQTT')
|
||||
])
|
||||
|
||||
const flowNodes = [
|
||||
{ label: '终端', icon: IconTerminal },
|
||||
{ label: '前置', icon: IconFrontEnd },
|
||||
{ label: 'MQTT', icon: IconMqtt },
|
||||
{ label: '数据库', icon: Coin, isEl: true },
|
||||
{ label: 'Web', icon: Monitor, isEl: true }
|
||||
]
|
||||
|
||||
/** 全部完成状态值 */
|
||||
const COMPLETE_STATUS = 4
|
||||
/** 连线数量 */
|
||||
const LINE_COUNT = flowNodes.length - 1
|
||||
|
||||
const createErrorArray = <T,>(length: number, value: T) => Array.from({ length }, () => value)
|
||||
|
||||
type NodeState = 'pending' | 'success' | 'error'
|
||||
type LineState = 'idle' | 'flowing' | 'success' | 'error'
|
||||
|
||||
const lineErrors = ref(createErrorArray(LINE_COUNT, false))
|
||||
const nodeErrors = ref(createErrorArray(flowNodes.length, false))
|
||||
let timeoutTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
const clearTimeoutTimer = () => {
|
||||
if (timeoutTimer) {
|
||||
clearTimeout(timeoutTimer)
|
||||
timeoutTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
const resetErrorsFrom = (fromIndex: number) => {
|
||||
for (let i = fromIndex; i < lineErrors.value.length; i++) {
|
||||
lineErrors.value[i] = false
|
||||
}
|
||||
for (let i = fromIndex + 1; i < nodeErrors.value.length; i++) {
|
||||
nodeErrors.value[i] = false
|
||||
}
|
||||
}
|
||||
|
||||
const resetAllErrors = () => {
|
||||
lineErrors.value = createErrorArray(LINE_COUNT, false)
|
||||
nodeErrors.value = createErrorArray(flowNodes.length, false)
|
||||
}
|
||||
|
||||
const startTimeout = (status: number | null) => {
|
||||
clearTimeoutTimer()
|
||||
if (status === null || status >= COMPLETE_STATUS) return
|
||||
|
||||
const capturedStatus = status
|
||||
timeoutTimer = setTimeout(() => {
|
||||
if (linkStatus.value !== capturedStatus) return
|
||||
lineErrors.value[capturedStatus] = true
|
||||
nodeErrors.value[capturedStatus + 1] = true
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
watch(
|
||||
linkStatus,
|
||||
(val, oldVal) => {
|
||||
const prev = oldVal ?? null
|
||||
if (val !== null && (prev === null || val > prev)) {
|
||||
resetErrorsFrom(val)
|
||||
} else if (val !== null && prev !== null && val < prev) {
|
||||
resetAllErrors()
|
||||
} else if (val === null) {
|
||||
resetAllErrors()
|
||||
}
|
||||
startTimeout(val)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
onUnmounted(clearTimeoutTimer)
|
||||
|
||||
const getNodeState = (index: number): NodeState => {
|
||||
if (nodeErrors.value[index]) return 'error'
|
||||
if (linkStatus.value === null) return 'pending'
|
||||
if (linkStatus.value >= COMPLETE_STATUS) return 'success'
|
||||
if (index <= linkStatus.value) return 'success'
|
||||
return 'pending'
|
||||
}
|
||||
|
||||
const getLineState = (index: number): LineState => {
|
||||
if (lineErrors.value[index]) return 'error'
|
||||
if (linkStatus.value === null) return 'idle'
|
||||
if (linkStatus.value >= COMPLETE_STATUS) return 'success'
|
||||
if (index < linkStatus.value) return 'success'
|
||||
if (index === linkStatus.value) return 'flowing'
|
||||
return 'idle'
|
||||
}
|
||||
|
||||
const getNodeColor = (index: number) => COLOR[getNodeState(index)]
|
||||
|
||||
const getNodeStatusText = (index: number) => {
|
||||
const state = getNodeState(index)
|
||||
if (state === 'error') return '连接失败'
|
||||
if (state === 'success') return '连接成功'
|
||||
if (linkStatus.value !== null && linkStatus.value < COMPLETE_STATUS && index === linkStatus.value + 1) {
|
||||
return '连接中'
|
||||
}
|
||||
return '待连接'
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const processTableData = computed(() =>
|
||||
flowNodes.map((node, index) => ({
|
||||
name: node.label,
|
||||
link: index === 0 ? '-' : `${flowNodes[index - 1].label} → ${node.label}`,
|
||||
status: getNodeStatusText(index),
|
||||
state: getNodeState(index)
|
||||
}))
|
||||
)
|
||||
|
||||
const nodeClick = async (e: anyObj) => {
|
||||
console.log('点击设备树节点')
|
||||
}
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
$green: #009f05;
|
||||
$green-light: #e8f7e9;
|
||||
$red: #e05252;
|
||||
$red-light: #fdeeee;
|
||||
$gray: #cbd5e1;
|
||||
$gray-text: #94a3b8;
|
||||
$node-min: 110px;
|
||||
$node-max: 120px;
|
||||
$bridge-min: 60px;
|
||||
|
||||
.manage-process {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
|
||||
&-right {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
padding: 10px 10px 10px 0;
|
||||
|
||||
:deep(.el-descriptions__header) {
|
||||
height: 36px;
|
||||
margin-bottom: 7px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.process-flow-section {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.process-list-section {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.process-list-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.process-table-status {
|
||||
&--success {
|
||||
color: $green;
|
||||
}
|
||||
|
||||
&--error {
|
||||
color: $red;
|
||||
}
|
||||
|
||||
&--pending {
|
||||
color: $gray-text;
|
||||
}
|
||||
}
|
||||
|
||||
.process-flow-wrap {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding-bottom: 8px;
|
||||
padding: 0 10%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.process-flow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
min-width: min(100%, calc(#{$node-min} * 5 + #{$bridge-min} * 4));
|
||||
min-height: $node-min;
|
||||
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.process-step {
|
||||
flex: 1 1 $node-min;
|
||||
min-width: $node-min;
|
||||
max-width: $node-max;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.process-node {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
min-width: $node-min;
|
||||
min-height: $node-min;
|
||||
max-width: $node-max;
|
||||
aspect-ratio: 1;
|
||||
height: auto;
|
||||
padding: clamp(8px, 8%, 12px);
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
border-radius: 16px;
|
||||
background: #f8fafc;
|
||||
border: 1px solid #e2e8f0;
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
&__index {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
left: 10px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
color: #cbd5e1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
&__icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: clamp(52px, 48%, 60px);
|
||||
height: clamp(52px, 48%, 60px);
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
.el-icon {
|
||||
font-size: clamp(34px, 32%, 40px);
|
||||
}
|
||||
|
||||
.process-node__svg {
|
||||
width: clamp(34px, 32%, 40px);
|
||||
height: clamp(34px, 32%, 40px);
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
&__name {
|
||||
margin-top: 8px;
|
||||
font-size: clamp(13px, 12%, 15px);
|
||||
font-weight: 600;
|
||||
color: #334155;
|
||||
letter-spacing: 1px;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&__status {
|
||||
margin-top: 4px;
|
||||
font-size: clamp(12px, 11%, 13px);
|
||||
color: $gray-text;
|
||||
transition: color 0.3s;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
&--success {
|
||||
background: linear-gradient(160deg, #fff 0%, $green-light 100%);
|
||||
border-color: rgba(0, 159, 5, 0.25);
|
||||
box-shadow: 0 4px 16px rgba(0, 159, 5, 0.1);
|
||||
|
||||
.process-node__index {
|
||||
color: rgba(0, 159, 5, 0.45);
|
||||
}
|
||||
|
||||
.process-node__icon {
|
||||
background: #fff;
|
||||
box-shadow: 0 0 0 2px rgba(0, 159, 5, 0.15);
|
||||
}
|
||||
|
||||
.process-node__status {
|
||||
color: $green;
|
||||
}
|
||||
}
|
||||
|
||||
&--error {
|
||||
background: linear-gradient(160deg, #fff 0%, $red-light 100%);
|
||||
border-color: rgba(224, 82, 82, 0.3);
|
||||
box-shadow: 0 4px 16px rgba(224, 82, 82, 0.1);
|
||||
|
||||
.process-node__index {
|
||||
color: rgba(224, 82, 82, 0.45);
|
||||
}
|
||||
|
||||
.process-node__icon {
|
||||
box-shadow: 0 0 0 2px rgba(224, 82, 82, 0.15);
|
||||
}
|
||||
|
||||
.process-node__status {
|
||||
color: $red;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.process-bridge {
|
||||
flex: 1 1 0;
|
||||
min-width: $bridge-min;
|
||||
height: 25px;
|
||||
padding: 0 2px;
|
||||
align-self: center;
|
||||
|
||||
&__svg {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: visible;
|
||||
display: block;
|
||||
}
|
||||
|
||||
&__bg {
|
||||
stroke: #e8edf3;
|
||||
stroke-width: 5;
|
||||
stroke-linecap: round;
|
||||
transition: stroke 0.4s;
|
||||
}
|
||||
|
||||
&__active {
|
||||
stroke: transparent;
|
||||
stroke-width: 3;
|
||||
stroke-linecap: round;
|
||||
transition: stroke 0.4s;
|
||||
}
|
||||
|
||||
&__flow {
|
||||
stroke: $green;
|
||||
stroke-width: 3;
|
||||
stroke-linecap: round;
|
||||
stroke-dasharray: 5 9;
|
||||
animation: bridge-dash 0.85s linear infinite;
|
||||
}
|
||||
|
||||
&__head {
|
||||
fill: #cbd5e1;
|
||||
transition: fill 0.4s;
|
||||
}
|
||||
|
||||
&--success {
|
||||
.process-bridge__active {
|
||||
stroke: $green;
|
||||
filter: drop-shadow(0 0 3px rgba(0, 159, 5, 0.35));
|
||||
}
|
||||
|
||||
.process-bridge__head {
|
||||
fill: $green;
|
||||
}
|
||||
}
|
||||
|
||||
&--error {
|
||||
.process-bridge__active {
|
||||
stroke: $red;
|
||||
filter: drop-shadow(0 0 3px rgba(224, 82, 82, 0.35));
|
||||
}
|
||||
|
||||
.process-bridge__head {
|
||||
fill: $red;
|
||||
}
|
||||
}
|
||||
|
||||
&--flowing {
|
||||
.process-bridge__active {
|
||||
stroke: #dce3ec;
|
||||
stroke-width: 2;
|
||||
}
|
||||
|
||||
.process-bridge__head {
|
||||
fill: $green;
|
||||
animation: head-pulse 1.2s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
&--idle {
|
||||
.process-bridge__active {
|
||||
stroke: transparent;
|
||||
}
|
||||
|
||||
.process-bridge__head {
|
||||
fill: #cbd5e1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes bridge-dash {
|
||||
to {
|
||||
stroke-dashoffset: -14;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes head-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 0.45;
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
50% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="default-main manage-realTime" :style="{ height: pageHeight.height }">
|
||||
<DeviceTree @node-click="nodeClick" @init="" @deviceTypeChange=""></DeviceTree>
|
||||
<DeviceTree @node-click="nodeClick" @init="nodeClick" @deviceTypeChange=""></DeviceTree>
|
||||
<div class="manage-realTime-right">
|
||||
<div class="time-container">
|
||||
<div>
|
||||
@@ -33,7 +33,7 @@ import DeviceTree from '@/components/tree/govern/deviceTree.vue'
|
||||
import MyEchart from '@/components/echarts/MyEchart.vue'
|
||||
import { formatToDateTime } from '@/utils/dateUtil'
|
||||
defineOptions({
|
||||
name: 'govern/manage/realTime'
|
||||
name: 'manage/realTime'
|
||||
})
|
||||
|
||||
//页面属性
|
||||
|
||||
@@ -16,9 +16,8 @@ import TableStore from '@/utils/tableStore'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { Setting } from '@element-plus/icons-vue'
|
||||
import { eventRecall, fileRecall, logRecall } from '@/api/cs-device-boot/recall'
|
||||
import { eventRecall, fileRecall, } from '@/api/cs-device-boot/recall'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { el } from 'element-plus/es/locale'
|
||||
|
||||
const props = defineProps({
|
||||
checkedNodes: {
|
||||
@@ -147,9 +146,11 @@ const recall1 = async () => {
|
||||
await eventRecall({
|
||||
startTime: tableStore.table.params.startTime,
|
||||
endTime: tableStore.table.params.endTime,
|
||||
lineList: props.checkedNodes.map((node: any) => node.id)
|
||||
lineList: props.checkedNodes.map((node: any) => node.id),
|
||||
|
||||
}).then((res: any) => {
|
||||
ElMessage.success('补召事件成功')
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import Table from '@/components/table/index.vue'
|
||||
import { ElMessage, ElTree } from 'element-plus'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { Setting } from '@element-plus/icons-vue'
|
||||
|
||||
import { eventRecall, fileRecall } from '@/api/cs-device-boot/recall'
|
||||
const props = defineProps({
|
||||
checkedNodes: {
|
||||
type: Array,
|
||||
@@ -68,23 +68,23 @@ const tableStore: any = new TableStore({
|
||||
2: '解析失败',
|
||||
3: '文件不存在'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
fixed: 'right',
|
||||
width: '100',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
title: '详情',
|
||||
type: 'primary',
|
||||
icon: 'el-icon-EditPen',
|
||||
render: 'basicButton',
|
||||
click: row => {}
|
||||
}
|
||||
]
|
||||
}
|
||||
// {
|
||||
// title: '操作',
|
||||
// fixed: 'right',
|
||||
// width: '100',
|
||||
// render: 'buttons',
|
||||
// buttons: [
|
||||
// {
|
||||
// name: 'edit',
|
||||
// title: '详情',
|
||||
// type: 'primary',
|
||||
// icon: 'el-icon-EditPen',
|
||||
// render: 'basicButton',
|
||||
// click: row => {}
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
],
|
||||
beforeSearchFun: () => {},
|
||||
loadCallback: () => {}
|
||||
@@ -92,8 +92,22 @@ const tableStore: any = new TableStore({
|
||||
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
const exportTab = () => {
|
||||
ElMessage.info('稳态补召功能暂未开发!')
|
||||
const exportTab = async () => {
|
||||
// ElMessage.info('稳态补召功能暂未开发!')
|
||||
if (!props.checkedNodes || props.checkedNodes.length === 0) {
|
||||
ElMessage.warning('请先勾选监测点')
|
||||
return
|
||||
}
|
||||
|
||||
await eventRecall({
|
||||
startTime: tableStore.table.params.startTime,
|
||||
endTime: tableStore.table.params.endTime,
|
||||
lineList: props.checkedNodes.map((node: any) => node.id),
|
||||
bzType: 0
|
||||
}).then((res: any) => {
|
||||
ElMessage.success('补召成功')
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
//获取请求参数
|
||||
const getTableParams = (val: any) => {
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="12" class="mTop">
|
||||
<el-checkbox v-model="formd.glfbfz">暂降幅值</el-checkbox>
|
||||
<el-checkbox v-model="formd.glfbfz">暂降(骤升)幅值</el-checkbox>
|
||||
<el-checkbox v-model="formd.glfbsj">持续时间</el-checkbox>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -144,6 +144,7 @@ import { genFileId, ElMessage, ElNotification } from 'element-plus'
|
||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
import { getLineExport } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import { isReportMonitorPoint } from '@/components/tree/govern/lineTreeUtils'
|
||||
defineOptions({
|
||||
name: 'TransientReport/monitoringpointReport'
|
||||
})
|
||||
@@ -212,7 +213,7 @@ const choose = (files: any) => {
|
||||
|
||||
//生成报告
|
||||
const exportEvent = () => {
|
||||
if (dotList.value?.level != 3) {
|
||||
if (!isReportMonitorPoint(dotList.value)) {
|
||||
return ElMessage.warning('请选择监测点进行报告生成!')
|
||||
}
|
||||
let a = ''
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<template>
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<div class="default-main" :style="height" style="display: flex; overflow: hidden">
|
||||
<div style="width: 280px; flex-shrink: 0; height: 100%; overflow: hidden">
|
||||
<pointTree
|
||||
ref="TerminalRef"
|
||||
@node-click="handleNodeClick"
|
||||
@init="handleNodeClick"
|
||||
@pointTypeChange="pointTypeChange"
|
||||
></pointTree>
|
||||
</pane>
|
||||
<pane style="background: #fff" :style="height">
|
||||
</div>
|
||||
<div style="flex: 1; min-width: 0; background: #fff" :style="height">
|
||||
<TableHeader ref="TableHeaderRef" datePicker :show-search="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="客户名称">
|
||||
@@ -58,15 +57,12 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</pane>
|
||||
</splitpanes>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import { ref, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
@@ -77,12 +73,12 @@ import { genFileId, ElMessage, ElNotification } from 'element-plus'
|
||||
import type { UploadProps, UploadUserFile } from 'element-plus'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
import { exportModel } from '@/api/cs-harmonic-boot/datatrend'
|
||||
import { isReportMonitorPoint } from '@/components/tree/govern/lineTreeUtils'
|
||||
defineOptions({
|
||||
name: 'harmonic-boot/report/word'
|
||||
})
|
||||
|
||||
const height = mainHeight(20)
|
||||
const size = ref(0)
|
||||
const dictData = useDictData()
|
||||
const TableHeaderRef = ref()
|
||||
const dotList: any = ref({})
|
||||
@@ -98,18 +94,13 @@ const tableStore = new TableStore({
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
|
||||
onMounted(() => {
|
||||
const dom = document.getElementById('navigation-splitpanes')
|
||||
|
||||
if (dom) {
|
||||
size.value = Math.round((180 / dom.offsetHeight) * 100)
|
||||
}
|
||||
})
|
||||
const pointTypeChange = (val: any, obj: any) => {
|
||||
handleNodeClick(obj)
|
||||
}
|
||||
const handleNodeClick = (data: any) => {
|
||||
if (isReportMonitorPoint(data)) {
|
||||
dotList.value = data
|
||||
}
|
||||
}
|
||||
// 上传
|
||||
const choose = (files: any) => {
|
||||
@@ -127,7 +118,7 @@ const choose = (files: any) => {
|
||||
// 生成
|
||||
const exportEvent = () => {
|
||||
console.log('🚀 ~ exportEvent ~ dotList.value:', dotList.value)
|
||||
if (dotList.value?.level != 3) {
|
||||
if (!isReportMonitorPoint(dotList.value)) {
|
||||
return ElMessage.warning('请选择监测点进行报告生成!')
|
||||
}
|
||||
let form = new FormData()
|
||||
@@ -187,10 +178,6 @@ const exportEvent = () => {
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.splitpanes.default-theme .splitpanes__pane {
|
||||
background: #eaeef1;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
@@ -29,13 +29,14 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import { onMounted, onUnmounted, ref, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import PointTree from '@/components/tree/govern/pointTree.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
import { destroyLuckysheet, exportLuckysheetFile, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import { isLineTreeLeaf } from '@/components/tree/govern/lineTreeUtils'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
// import data from './123.json'
|
||||
@@ -74,25 +75,7 @@ const tableStore = new TableStore({
|
||||
tableStore.table.params.lineId = dotList.value.id
|
||||
},
|
||||
loadCallback: () => {
|
||||
tableStore.table.data.forEach((item: any) => {
|
||||
item.data1 ? (item.data = JSON.parse(item.data1)) : ''
|
||||
item.celldata.forEach((k: any) => {
|
||||
|
||||
item.data[k.r][k.c].v ? (item.data[k.r][k.c] = k.v) : ''
|
||||
})
|
||||
})
|
||||
setTimeout(() => {
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
data: tableStore.table.data
|
||||
// tableStore.table.data
|
||||
})
|
||||
}, 10)
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data)
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
@@ -104,6 +87,9 @@ onMounted(() => {
|
||||
size.value = ((280 / (dom.offsetWidth - 7)) * 100)
|
||||
}
|
||||
})
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
|
||||
|
||||
const stencil = (val: any) => {
|
||||
@@ -118,7 +104,7 @@ const changetype = (val: any) => {
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
if (data?.type == "line") {
|
||||
if (isLineTreeLeaf(data)) {
|
||||
dotList.value = data
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
@@ -127,7 +113,7 @@ const handleNodeClick = (data: any, node: any) => {
|
||||
}
|
||||
|
||||
const exportEvent = () => {
|
||||
exportExcel(luckysheet.getAllSheets(), '统计报表下载')
|
||||
exportLuckysheetFile('统计报表下载', tableStore.table.data.length > 0)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<template>
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" class="default-theme" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<div class="default-main report-zl-page" :style="height">
|
||||
<div class="report-zl-sidebar">
|
||||
<pointTreeWx :default-expand-all="false" template @node-click="handleNodeClick" @init="handleNodeClick"
|
||||
@Policy="stencil">
|
||||
</pointTreeWx>
|
||||
</pane>
|
||||
<pane :size="(100 - size)" style="background: #fff" :style="height">
|
||||
</div>
|
||||
<div class="report-zl-main">
|
||||
<TableHeader ref="TableHeaderRef" :showReset="false">
|
||||
<template v-slot:select>
|
||||
<el-form-item label="时间:">
|
||||
@@ -24,33 +23,29 @@
|
||||
</template>
|
||||
</TableHeader>
|
||||
<div class="box" v-loading="tableStore.table.loading">
|
||||
<div id="luckysheet"
|
||||
:style="`height: calc(${tableStore.table.height} + 45px)`"
|
||||
<div id="luckysheet" class="report-zl-sheet"
|
||||
v-if="tableStore.table.data.length > 0"></div>
|
||||
<el-empty :style="`height: calc(${tableStore.table.height} + 45px)`" v-else description="暂无数据" />
|
||||
<el-empty class="report-zl-sheet" v-else description="暂无数据" />
|
||||
</div>
|
||||
</div>
|
||||
</pane>
|
||||
</splitpanes>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import { ref, provide, onUnmounted } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { destroyLuckysheet, exportLuckysheetFile, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import DatePicker from '@/components/form/datePicker/time.vue'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import { ElMessage } from 'element-plus'
|
||||
const name = ref('')
|
||||
// import data from './123.json'
|
||||
defineOptions({
|
||||
name: 'govern/reportCore/statisticsWx/index'
|
||||
})
|
||||
const height = mainHeight(20)
|
||||
const size = ref(0)
|
||||
const dictData = useDictData()
|
||||
const TableHeaderRef = ref()
|
||||
const dotList: any = ref({})
|
||||
@@ -63,53 +58,29 @@ const tableStore = new TableStore({
|
||||
url: '/harmonic-boot/customReport/getCustomReport',
|
||||
method: 'POST',
|
||||
column: [],
|
||||
showPage: false,
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.tempId = Template.value.id
|
||||
tableStore.table.params.lineId = dotList.value.id
|
||||
tableStore.table.params.startTime = datePickerRef.value.timeValue[0],
|
||||
tableStore.table.params.endTime = datePickerRef.value.timeValue[1],
|
||||
if (!datePickerRef.value?.timeValue?.[0] || !datePickerRef.value?.timeValue?.[1]) {
|
||||
ElMessage.warning('请选择时间')
|
||||
return false
|
||||
}
|
||||
tableStore.table.params.startTime = datePickerRef.value.timeValue[0]
|
||||
tableStore.table.params.endTime = datePickerRef.value.timeValue[1]
|
||||
delete tableStore.table.params.searchBeginTime
|
||||
delete tableStore.table.params.searchEndTime
|
||||
delete tableStore.table.params.timeFlag
|
||||
},
|
||||
loadCallback: () => {
|
||||
name.value = dotList.value.name
|
||||
tableStore.table.data.forEach((item: any) => {
|
||||
item.data1 ? (item.data = JSON.parse(item.data1)) : ''
|
||||
item.celldata.forEach((k: any) => {
|
||||
|
||||
item.data[k.r][k.c].v ? (item.data[k.r][k.c] = k.v) : ''
|
||||
})
|
||||
})
|
||||
setTimeout(() => {
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
data: tableStore.table.data
|
||||
// tableStore.table.data
|
||||
})
|
||||
}, 10)
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.resourceType = 1
|
||||
tableStore.table.params.customType = 1
|
||||
const flag = ref(true)
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
const dom = document.getElementById('navigation-splitpanes')
|
||||
if (dom && dom.offsetHeight > 0) {
|
||||
size.value = ((280 / (dom.offsetWidth - 7)) * 100)
|
||||
} else {
|
||||
// 设置默认值
|
||||
size.value = 20
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
const stencil = (val: any) => {
|
||||
@@ -143,15 +114,43 @@ const exportEvent = () => {
|
||||
|
||||
// 格式化YYYY - MM - DD(补零)
|
||||
const formattedDate = `${year}${String(month).padStart(2, '0')}${String(day).padStart(2, '0')}`
|
||||
exportExcel(luckysheet.getAllSheets(), name.value + formattedDate)
|
||||
exportLuckysheetFile(name.value + formattedDate, tableStore.table.data.length > 0)
|
||||
}
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.splitpanes.default-theme .splitpanes__pane {
|
||||
.report-zl-page {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sidebar {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.box {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sheet {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" class="default-theme" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<div class="default-main report-zl-page" :style="height">
|
||||
<div class="report-zl-sidebar">
|
||||
<!-- <pointTreeWx :default-expand-all="false" template @node-click="handleNodeClick" @init="handleNodeClick"
|
||||
@Policy="stencil">
|
||||
</pointTreeWx> -->
|
||||
@@ -13,8 +12,8 @@
|
||||
@init="handleNodeClick"
|
||||
@pointTypeChange="pointTypeChange"
|
||||
></pointTree>
|
||||
</pane>
|
||||
<pane :size="100 - size" style="background: #fff" :style="height">
|
||||
</div>
|
||||
<div class="report-zl-main">
|
||||
<TableHeader datePicker ref="TableHeaderRef" :showReset="false">
|
||||
<template v-slot:select>
|
||||
<!-- <el-form-item label="时间:">
|
||||
@@ -43,37 +42,34 @@
|
||||
<div class="box" v-loading="tableStore.table.loading">
|
||||
<div
|
||||
id="luckysheet"
|
||||
:style="`height: calc(${tableStore.table.height} + 45px)`"
|
||||
class="report-zl-sheet"
|
||||
v-if="tableStore.table.data.length > 0"
|
||||
></div>
|
||||
<el-empty
|
||||
:style="`height: calc(${tableStore.table.height} + 45px)`"
|
||||
class="report-zl-sheet"
|
||||
v-else
|
||||
description="暂无数据"
|
||||
/>
|
||||
</div>
|
||||
</pane>
|
||||
</splitpanes>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import { ref, provide, onUnmounted } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { destroyLuckysheet, exportLuckysheetFile, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import { isLineTreeLeaf } from '@/components/tree/govern/lineTreeUtils'
|
||||
import DatePicker from '@/components/form/datePicker/time.vue'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import pointTree from '@/components/tree/govern/pointTree.vue'
|
||||
// import data from './123.json'
|
||||
defineOptions({
|
||||
name: 'govern/reportCore/statisticsWx/index'
|
||||
})
|
||||
const height = mainHeight(20)
|
||||
const size = ref(0)
|
||||
const dictData = useDictData()
|
||||
const TableHeaderRef = ref()
|
||||
const dotList: any = ref({})
|
||||
@@ -86,6 +82,7 @@ const tableStore = new TableStore({
|
||||
url: '/cs-harmonic-boot/customReport/getCustomReport',
|
||||
method: 'POST',
|
||||
column: [],
|
||||
showPage: false,
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.tempId = Template.value.id
|
||||
tableStore.table.params.lineId = dotList.value.id
|
||||
@@ -96,53 +93,14 @@ const tableStore = new TableStore({
|
||||
delete tableStore.table.params.timeFlag
|
||||
},
|
||||
loadCallback: () => {
|
||||
console.log('🚀 ~ tableStore.table:', tableStore.table)
|
||||
name.value = dotList.value.name
|
||||
// tableStore.table.data.forEach((item: any) => {
|
||||
// item.data1 ? (item.data = JSON.parse(item.data1)) : ''
|
||||
// item.celldata.forEach((k: any) => {
|
||||
|
||||
// item.data[k.r][k.c].v ? (item.data[k.r][k.c] = k.v) : ''
|
||||
// })
|
||||
// })
|
||||
tableStore.table.data.forEach((item: any) => {
|
||||
item.data1 ? (item.data = JSON.parse(item.data1)) : ''
|
||||
item.celldata.forEach((k: any) => {
|
||||
item.data[k.r][k.c].v ? (item.data[k.r][k.c] = k.v) : ''
|
||||
})
|
||||
})
|
||||
console.log('🚀 ~ tableStore.table:', tableStore.table)
|
||||
|
||||
setTimeout(() => {
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
allowEdit: false, // 禁止所有编辑操作(必填)
|
||||
data: tableStore.table.data
|
||||
// tableStore.table.data
|
||||
})
|
||||
}, 10)
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
tableStore.table.params.resourceType = 1
|
||||
tableStore.table.params.customType = null
|
||||
const flag = ref(true)
|
||||
onMounted(() => {
|
||||
nextTick(() => {
|
||||
const dom = document.getElementById('navigation-splitpanes')
|
||||
if (dom && dom.offsetHeight > 0) {
|
||||
size.value = (280 / (dom.offsetWidth - 7)) * 100
|
||||
} else {
|
||||
// 设置默认值
|
||||
size.value = 20
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
const stencil = (val: any) => {
|
||||
templatePolicy.value = val.filter((item: any) => item.excelType != '4')
|
||||
@@ -158,7 +116,7 @@ const pointTypeChange = (val: any, obj: any) => {
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: any) => {
|
||||
if (data?.level == 3) {
|
||||
if (isLineTreeLeaf(data)) {
|
||||
dotList.value = data
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
@@ -170,21 +128,47 @@ const handleNodeClick = (data: any) => {
|
||||
|
||||
const exportEvent = () => {
|
||||
const now = new Date()
|
||||
const year = now.getFullYear() // 4位年份
|
||||
const month = now.getMonth() + 1 // 月份0-11,需+1
|
||||
const day = now.getDate() // 日期1-31
|
||||
|
||||
// 格式化YYYY - MM - DD(补零)
|
||||
const year = now.getFullYear()
|
||||
const month = now.getMonth() + 1
|
||||
const day = now.getDate()
|
||||
const formattedDate = `${year}${String(month).padStart(2, '0')}${String(day).padStart(2, '0')}`
|
||||
exportExcel(luckysheet.getAllSheets(), name.value + formattedDate)
|
||||
exportLuckysheetFile(name.value + formattedDate, tableStore.table.data.length > 0)
|
||||
}
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.splitpanes.default-theme .splitpanes__pane {
|
||||
.report-zl-page {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sidebar {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.box {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sheet {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,37 +1,22 @@
|
||||
<template>
|
||||
<div class="default-main" :style="height">
|
||||
<splitpanes style="height: 100%" class="default-theme" id="navigation-splitpanes">
|
||||
<pane :size="size">
|
||||
<div class="default-main report-zl-page" :style="height">
|
||||
<div class="report-zl-sidebar">
|
||||
<!-- <pointTreeWx :default-expand-all="false" template @node-click="handleNodeClick" @init="handleNodeClick"
|
||||
@Policy="stencil">
|
||||
</pointTreeWx> -->
|
||||
<CloudDeviceEntryTree
|
||||
ref="TerminalRef"
|
||||
template
|
||||
@Policy="stencil"
|
||||
@node-click="handleNodeClick"
|
||||
@init="handleNodeClick"
|
||||
></CloudDeviceEntryTree>
|
||||
</pane>
|
||||
<pane :size="100 - size" style="background: #fff" :style="height">
|
||||
<CloudDeviceEntryTree ref="TerminalRef" template @Policy="stencil" @node-click="handleNodeClick"
|
||||
@init="handleNodeClick"></CloudDeviceEntryTree>
|
||||
</div>
|
||||
<div class="report-zl-main">
|
||||
<TableHeader datePicker ref="TableHeaderRef" :showReset="false">
|
||||
<template v-slot:select>
|
||||
<!-- <el-form-item label="时间:">
|
||||
<DatePicker ref="datePickerRef"></DatePicker>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="模板策略">
|
||||
<el-select
|
||||
v-model.trim="Template"
|
||||
@change="changetype"
|
||||
placeholder="请选择模版"
|
||||
value-key="id"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in templatePolicy"
|
||||
:key="item.id"
|
||||
:label="item.excelName"
|
||||
:value="item"
|
||||
></el-option>
|
||||
<el-select v-model.trim="Template" @change="changetype" placeholder="请选择模版" value-key="id">
|
||||
<el-option v-for="item in templatePolicy" :key="item.id" :label="item.excelName"
|
||||
:value="item"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="监测对象">
|
||||
@@ -50,32 +35,23 @@
|
||||
</template>
|
||||
</TableHeader>
|
||||
<div class="box" v-loading="tableStore.table.loading">
|
||||
<div
|
||||
id="luckysheet"
|
||||
:style="`height: calc(${tableStore.table.height} + 45px)`"
|
||||
v-if="tableStore.table.data.length > 0"
|
||||
></div>
|
||||
<el-empty
|
||||
:style="`height: calc(${tableStore.table.height} + 45px)`"
|
||||
v-else
|
||||
description="暂无数据"
|
||||
/>
|
||||
<div id="luckysheet" class="report-zl-sheet"
|
||||
v-if="tableStore.table.data.length > 0"></div>
|
||||
<el-empty class="report-zl-sheet" v-else description="暂无数据" />
|
||||
</div>
|
||||
</div>
|
||||
</pane>
|
||||
</splitpanes>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref, provide } from 'vue'
|
||||
import { onMounted, onUnmounted, ref, provide } from 'vue'
|
||||
import TableStore from '@/utils/tableStore'
|
||||
import pointTreeWx from '@/components/tree/govern/pointTreeWx.vue'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import { useDictData } from '@/stores/dictData'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
import { exportExcel } from '@/views/system/reportForms/export.js'
|
||||
import 'splitpanes/dist/splitpanes.css'
|
||||
import { destroyLuckysheet, exportLuckysheetFile, renderLuckysheetReport } from '@/utils/luckysheetHelper'
|
||||
import { isLineTreeLeaf } from '@/components/tree/govern/lineTreeUtils'
|
||||
import DatePicker from '@/components/form/datePicker/time.vue'
|
||||
import { Splitpanes, Pane } from 'splitpanes'
|
||||
import CloudDeviceEntryTree from '@/components/tree/govern/cloudDeviceEntryTreeZL.vue'
|
||||
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
|
||||
import { ElMessage } from 'element-plus'
|
||||
@@ -84,7 +60,6 @@ defineOptions({
|
||||
name: 'govern/reportCore/statisticsWx/indexZL'
|
||||
})
|
||||
const height = mainHeight(20)
|
||||
const size = ref(0)
|
||||
const dictData = useDictData()
|
||||
const TableHeaderRef = ref()
|
||||
const dotList: any = ref({})
|
||||
@@ -98,6 +73,7 @@ const tableStore = new TableStore({
|
||||
url: '/cs-harmonic-boot/customReport/getSensitiveUserReport',
|
||||
method: 'POST',
|
||||
column: [],
|
||||
showPage: false,
|
||||
beforeSearchFun: () => {
|
||||
tableStore.table.params.tempId = Template.value.id
|
||||
tableStore.table.params.lineId = dotList.value.id
|
||||
@@ -105,35 +81,20 @@ const tableStore = new TableStore({
|
||||
// ;(tableStore.table.params.startTime = datePickerRef.value.timeValue[0]),
|
||||
// (tableStore.table.params.endTime = datePickerRef.value.timeValue[1]),
|
||||
if (!tableStore.table.params.tempId) {
|
||||
return ElMessage.warning('请选择模板')
|
||||
ElMessage.warning('请选择模板')
|
||||
return false
|
||||
}
|
||||
if (!dotList.value?.id) {
|
||||
ElMessage.warning('请选择监测点')
|
||||
return false
|
||||
}
|
||||
delete tableStore.table.params.searchBeginTime
|
||||
delete tableStore.table.params.searchEndTime
|
||||
delete tableStore.table.params.timeFlag
|
||||
},
|
||||
loadCallback: () => {
|
||||
console.log('🚀 ~ tableStore.table:', tableStore.table.data)
|
||||
name.value = dotList.value.name
|
||||
// tableStore.table.data.forEach((item: any) => {
|
||||
// item.data1 ? (item.data = JSON.parse(item.data1)) : ''
|
||||
// item.celldata.forEach((k: any) => {
|
||||
// item.data[k.r][k.c].v ? (item.data[k.r][k.c] = k.v) : ''
|
||||
// })
|
||||
// })
|
||||
|
||||
setTimeout(() => {
|
||||
luckysheet.create({
|
||||
container: 'luckysheet',
|
||||
title: '', // 表 头名
|
||||
lang: 'zh', // 中文
|
||||
showtoolbar: false, // 是否显示工具栏
|
||||
showinfobar: false, // 是否显示顶部信息栏
|
||||
showsheetbar: true, // 是否显示底部sheet按钮
|
||||
allowEdit: false, // 禁止所有编辑操作(必填)
|
||||
data: tableStore.table.data
|
||||
// tableStore.table.data
|
||||
})
|
||||
}, 10)
|
||||
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
|
||||
}
|
||||
})
|
||||
provide('tableStore', tableStore)
|
||||
@@ -142,15 +103,9 @@ tableStore.table.params.customType = 1
|
||||
const flag = ref(true)
|
||||
onMounted(() => {
|
||||
initListByIds()
|
||||
nextTick(() => {
|
||||
const dom = document.getElementById('navigation-splitpanes')
|
||||
if (dom && dom.offsetHeight > 0) {
|
||||
size.value = (280 / (dom.offsetWidth - 7)) * 100
|
||||
} else {
|
||||
// 设置默认值
|
||||
size.value = 20
|
||||
}
|
||||
})
|
||||
})
|
||||
onUnmounted(() => {
|
||||
destroyLuckysheet()
|
||||
})
|
||||
|
||||
const idList = ref([])
|
||||
@@ -168,7 +123,6 @@ const initListByIds = () => {
|
||||
})
|
||||
}
|
||||
const stencil = (val: any) => {
|
||||
console.log('🚀 ~ stencil ~ val:', val)
|
||||
templatePolicy.value = val.filter((item: any) => item.excelType == '4')
|
||||
Template.value = templatePolicy.value[0]
|
||||
reportForm.value = templatePolicy.value[0]?.excelType
|
||||
@@ -179,7 +133,7 @@ const changetype = (val: any) => {
|
||||
}
|
||||
|
||||
const handleNodeClick = (data: any, node: any) => {
|
||||
if (data?.level == 3) {
|
||||
if (isLineTreeLeaf(data) || data?.level == 3) {
|
||||
dotList.value = data
|
||||
setTimeout(() => {
|
||||
tableStore.index()
|
||||
@@ -197,15 +151,40 @@ const exportEvent = () => {
|
||||
|
||||
// 格式化YYYY - MM - DD(补零)
|
||||
const formattedDate = `${year}${String(month).padStart(2, '0')}${String(day).padStart(2, '0')}`
|
||||
exportExcel(luckysheet.getAllSheets(), name.value + formattedDate)
|
||||
exportLuckysheetFile(name.value + formattedDate, tableStore.table.data.length > 0)
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.splitpanes.default-theme .splitpanes__pane {
|
||||
.report-zl-page {
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sidebar {
|
||||
width: 280px;
|
||||
flex-shrink: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.box {
|
||||
padding: 10px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 10px 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.report-zl-sheet {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" width="600px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-dialog class="cn-operate-dialog" width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-form :model="form" class="form-one" label-width="auto" ref="formRef" :rules="rules">
|
||||
<el-form-item label="所属厂站名称" prop="substationName">
|
||||
<el-input v-model.trim="form.substationName" placeholder="请输入所属厂站名称"></el-input>
|
||||
|
||||
@@ -76,8 +76,7 @@ const open = (text: string, data?: anyObj) => {
|
||||
form[key] = data ? data[key] : ''
|
||||
|
||||
if (key == 'sort') {
|
||||
form[key] = data?.sort ? data[key] : 100
|
||||
// console.log("🚀 ~ open ~ form[key]:", form[key])
|
||||
form[key] = data?.sort ?? 100
|
||||
}
|
||||
}
|
||||
dialogVisible.value = true
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
import { ref, inject } from 'vue'
|
||||
import { CascaderValue, ElMessage } from 'element-plus'
|
||||
import { addStatistical, queryStatistical } from '@/api/system-boot/csstatisticalset'
|
||||
import { getDictTreeById } from '@/api/system-boot/dictTree'
|
||||
import { getDictTreeById, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import PopupAdd from './add.vue'
|
||||
import { dicDelete } from '@/api/system-boot/dic'
|
||||
import List from '@/views/pms/comptroller/list.vue'
|
||||
@@ -122,7 +122,7 @@ const init = (val: any) => {
|
||||
id: item2.id,
|
||||
pid: item.dataType,
|
||||
value: item2.id,
|
||||
label: item2.phase === 'M' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
label: item2.phase === 'T' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
}
|
||||
if (item2.showName) {
|
||||
obj.children.push(obj2)
|
||||
@@ -143,7 +143,7 @@ const init = (val: any) => {
|
||||
id: item2.id,
|
||||
pid: item2.dataType,
|
||||
value: item2.id,
|
||||
label: item2.phase === 'M' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
label: item2.phase === 'T' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
}
|
||||
if (item2.showName) {
|
||||
obj.children.push(obj2)
|
||||
@@ -167,7 +167,7 @@ const init = (val: any) => {
|
||||
id: item2.id,
|
||||
pid: item.dataType,
|
||||
value: item2.id,
|
||||
label: item2.phase === 'M' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
label: item2.phase === 'T' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
}
|
||||
if (item2.showName) {
|
||||
obj.children.push(obj2)
|
||||
@@ -191,7 +191,7 @@ const init = (val: any) => {
|
||||
id: item2.id,
|
||||
pid: item2.dataType,
|
||||
value: item2.id,
|
||||
label: item2.phase === 'M' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
label: item2.phase === 'T' ? item2.showName : item2.phase + '相' + item2.showName
|
||||
}
|
||||
if (item2.showName) {
|
||||
obj.children.push(obj2)
|
||||
@@ -344,20 +344,25 @@ const dicDeleteGroup = (data: any) => {
|
||||
}
|
||||
|
||||
const newGroup = () => {
|
||||
|
||||
queryCsDictTree(pid.value).then(res => {
|
||||
const list = res.data || []
|
||||
const sort = list.length
|
||||
? Math.max(...list.map((item: any) => Number(item.sort) || 0)) + 1
|
||||
: 1
|
||||
addRef.value.open('新建分组', {
|
||||
sort: toData.value.length ? toData.value[toData.value.length - 1].sort + 1 : 1,
|
||||
sort,
|
||||
code: '',
|
||||
pid: pid.value,
|
||||
id: '',
|
||||
remark: '',
|
||||
name: ''
|
||||
})
|
||||
})
|
||||
}
|
||||
const editGroup = (data: any) => {
|
||||
getDictTreeById(data.id).then(res => {
|
||||
addRef.value.open('修改分组', {
|
||||
sort: res.data.sort || 100,
|
||||
sort: res.data.sort ?? 100,
|
||||
code: res.data.code || '',
|
||||
pid: res.data.pid || '',
|
||||
id: res.data.id || '',
|
||||
|
||||
@@ -60,7 +60,7 @@ const tableStore = new TableStore({
|
||||
{
|
||||
title: '类型',
|
||||
field: 'type',
|
||||
width: 200,
|
||||
width: 250,
|
||||
formatter: row => {
|
||||
return options.value.filter((item: any) => item.value == row.cellValue)[0]?.name
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<el-dialog width="600px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-dialog width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" :model="form" label-width="auto" class="form-one" :rules="rules" ref="formRef">
|
||||
<el-form-item label="名称:" class="top" prop="name">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-dialog class="cn-operate-dialog" width="500px" v-model.trim="dialogVisible" :title="title">
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" :model="form" ref="formRef" label-width="120px" :rules="rules">
|
||||
<el-form :inline="false" :model="form" ref="formRef" label-width="auto" :rules="rules">
|
||||
<el-form-item label="字典名称:" prop="name">
|
||||
<el-input
|
||||
maxlength="32"
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
></vxe-column>
|
||||
</template>
|
||||
</Table>
|
||||
<el-dialog width="600px" v-model.trim="dialogVisible" title="新增版本">
|
||||
<el-dialog width="500px" v-model.trim="dialogVisible" title="新增版本">
|
||||
<el-form :inline="false" :model="form" ref="formRef" label-width="auto" class="form-one" :rules="rules">
|
||||
<el-form-item label="版本号:" prop="appVersion">
|
||||
<el-input
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user