修改数据中心问题

This commit is contained in:
GGJ
2024-11-08 16:30:12 +08:00
parent a4b6bb111b
commit 7640b53b20
12 changed files with 874 additions and 456 deletions

View File

@@ -0,0 +1,266 @@
<template>
<div id="chart-container" v-loading="tableStore.table.loading"
:style="`height: calc(${tableStore.table.height} - 125px)`"></div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import * as echarts from 'echarts';
import { useDictData } from '@/stores/dictData'
import { useConfig } from '@/stores/config'
const config = useConfig()
const dictData = useDictData()
const options = ref({})
const TableHeaderRef = ref()
const tableStoreParams: any = ref({})
const loading = ref(false)
const getTableStoreParams = async (val: any) => {
tableStoreParams.value = val
loading.value = true
setTimeout(() => {
tableStore.index()
}, 1500)
}
const tableStore = new TableStore({
url: '/harmonic-boot/steadyExceedRate/getSteadyExceedRateCensus',
showPage: false,
method: 'POST',
column: [],
beforeSearchFun: () => {
tableStore.table.params = tableStoreParams.value
},
loadCallback: () => {
let code = tableStore.table.params.statisticalType.code
let title = '',
titleX = ''
if (code == 'Power_Network') {
title = '区域'
titleX = '区域'
} else if (code == 'Manufacturer') {
title = '终端厂家'
titleX = '终端\n厂家'
} else if (code == 'Voltage_Level') {
title = '电压等级'
titleX = '电压\n等级'
} else if (code == 'Load_Type') {
title = '干扰源类型'
titleX = '干扰\n源类型'
}
const chart = echarts.init(document.getElementById('chart-container'));
let data = tableStore.table.data.steadyExceedRate
let ydata = tableStore.table.data.type
for (var i = 0; i < tableStore.table.data.time.length; i++) {
if (i != 0) {
i
tableStore.table.data.time[i] = tableStore.table.data.time[i].slice(5)
} else if (i == 0) {
let date = tableStore.table.data.time[i].slice(5)
let t = tableStore.table.data.time[i].slice(0, 4)
tableStore.table.data.time[i] = date + '\n' + '(' + t + ')'
}
}
let xdata = tableStore.table.data.time
let arr = []
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[i].length; j++) {
if (data[i][j] == 3.14159 || data[i][j] == 0) {
arr.push([i, j, 0])
} else if (data[i][j] == 3.1415) {
arr.push([i, j, '/'])
} else {
arr.push([i, j, data[i][j]])
}
}
}
// 配置项
const option = {
title: {
text: '稳态指标符合性占比' + '(统计类型' + title + ')',
left: 'center',
// textStyle: {
color: '#000',
fontSize: 18,
},
toolbox: {
right: 20,
top: 20,
feature: {
saveAsImage: {
title: '保存图片',
},
},
emphasis: {
iconStyle: {
borderColor: config.layout.elementUiPrimary[0], // 鼠标悬停时的边框颜色
color: config.layout.elementUiPrimary[0] // 鼠标悬停时的图标颜色
}
},
},
grid: {
top: '60px',
left: '30px',
right: '70px',
bottom: '40px',
containLabel: true,
},
dataZoom: [
{
type: 'inside',
height: 13,
start: 0,
bottom: '20px',
end: 100
},
{
start: 0,
height: 13,
bottom: '20px',
end: 100
}
],
visualMap: {
min: 0,
max: 100,
text: ['', '稳态指标符合性占比(%)'],
//calculable: true,
orient: 'horizontal',
top: '0px',
right: '50px',
inRange: {
color: ['#ccc', '#CC0000', "#339966"]
}
},
tooltip: {
trigger: 'item',
axisPointer: {
type: 'shadow',
label: {
color: '#fff',
fontSize: 16
}
},
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
fontSize: 14
},
backgroundColor: 'rgba(0,0,0,0.35)',
borderWidth: 0,
confine: true,
formatter: function (param) {
let msg = ''
if (param.value[2] === 0) {
msg += ydata[param.value[1]] + '<br/>'
if (xdata[param.value[0]].length == 1) {
msg += '时间:' + xdata[param.value[0]] + '月<br/>'
msg += param.seriesName + ':暂无数据'
} else if (xdata[param.value[0]].length == 8) {
let p = xdata[param.value[0]].slice(0, 2)
msg += '时间:' + p + '月<br/>'
msg += param.seriesName + ':暂无数据'
} else if (xdata[param.value[0]].length == 12) {
let r = xdata[param.value[0]].slice(0, 5)
msg += '时间:' + r + '<br/>'
msg += param.seriesName + ':暂无数据'
}
else {
msg += '时间:' + xdata[param.value[0]] + '<br/>'
msg += param.seriesName + ':暂无数据'
}
return msg
} else {
msg += ydata[param.value[1]] + '<br/>'
if (xdata[param.value[0]].length == 1) {
msg += '时间:' + xdata[param.value[0]] + '月<br/>'
msg += param.seriesName + ':' + param.value[2]
} else if (xdata[param.value[0]].length == 8) {
let p = xdata[param.value[0]].slice(0, 2)
msg += '时间:' + p + '月<br/>'
msg += param.seriesName + ':' + param.value[2]
} else if (xdata[param.value[0]].length == 12) {
let r = xdata[param.value[0]].slice(0, 5)
msg += '时间:' + r + '<br/>'
msg += param.seriesName + ':' + param.value[2]
}
else {
msg += '时间:' + xdata[param.value[0]] + '<br/>'
msg += param.seriesName + ':' + param.value[2]
}
return msg
}
},
},
xAxis: {
name: titleX,
type: 'category',
data: xdata,
},
yAxis: {
type: 'category',
data: ydata
},
series: [
{
name: '稳态指标符合性占比',
type: 'heatmap',
data: arr,
itemStyle: {
normal: {
// 随机显示
//color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}
// 定制显示(按顺序)
color: function (params) {
if (params.value == 3.14159 || params.value == 0) {
return new echarts.graphic.LinearGradient(0, 1, 0, 0, [{ offset: 1, color: "#ccc" }], false);
}
}
},
},
label: {
normal: {
show: true,
fontSize: '12px',
color: '#fff'
}
},
}
]
};
// 使用配置项设置图表
chart.setOption(option);
}
})
provide('tableStore', tableStore)
onMounted(() => { })
defineExpose({ getTableStoreParams })
</script>
<style scoped lang="scss"></style>

View File

@@ -0,0 +1,212 @@
<template>
<div class="default-main online">
<div class="online_header">
<TableHeader date-picker area ref="tableHeaderRef">
<template #select>
<el-form-item label="统计类型:">
<el-select v-model="tableStore.table.params.statisticalType" placeholder="请选择统计类型"
value-key="id" style="width: 100%">
<el-option v-for="item in classificationData" :key="item.id" :label="item.name"
:value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="电压等级:">
<el-select v-model="tableStore.table.params.scale" multiple collapse-tags clearable
placeholder="请选择电压等级" style="width: 100%" value-key="id">
<el-option v-for="item in voltageleveloption" :key="item.id" :label="item.name"
:value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="终端厂家:">
<el-select v-model="tableStore.table.params.manufacturer" multiple collapse-tags clearable
placeholder="请选择终端厂家" style="width: 100%" value-key="id">
<el-option v-for="(item, index) in terminaloption" :key="index" :label="item.name"
:value="item"></el-option>
</el-select>
</el-form-item>
<el-form-item label="干扰源类型:">
<el-select v-model="tableStore.table.params.loadType" multiple collapse-tags clearable
placeholder="请选择干扰源类型" style="width: 100%" value-key="id">
<el-option v-for="(item, index) in interfereoption" :key="index" :label="item.name"
:value="item"></el-option>
</el-select>
</el-form-item>
</template>
</TableHeader>
</div>
<div class="online_main">
<el-tabs v-model="activeName" type="border-card" @tab-click="handleClick">
<el-tab-pane :name="0" :lazy="true" label="稳态指标符合性占比表格">
<Table ref="tableRef" :tree-config="{ transform: true, parentField: 'pid' }"
:scroll-y="{ enabled: true }" v-if="activeName == 0" />
</el-tab-pane>
<el-tab-pane :name="1" :lazy="true" label="稳态指标符合性占比图">
<charts v-if="activeName == 1" ref="chartsRef" />
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted, watch } from 'vue'
import { useDictData } from '@/stores/dictData'
import DatePicker from '@/components/form/datePicker/index.vue'
import { getAreaDept } from '@/api/harmonic-boot/area'
import TableHeader from '@/components/table/header/index.vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import charts from './components/charts.vue'
defineOptions({
name: 'harmonic-boot/area/SteadyState'
})
const tableRef = ref()
const onlineChartsRef = ref()
const dictData = useDictData()
//字典获取电压等级
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
//字典获取终端厂家
const terminaloption = dictData.getBasicData('Dev_Manufacturers')
//字典获取干扰源类型
const interfereoption = dictData.getBasicData('Interference_Source')
//字典获取统计类型
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
//调用区域接口获取区域
const treeData = ref([])
const idArr = ref([])
const activeName = ref(0)
const getTreeData = async () => {
await getAreaDept().then(res => {
var data = res.data
data.forEach(element => {
idArr.value.push(element.id)
})
treeData.value = JSON.parse(JSON.stringify(res.data))
})
}
getTreeData()
const chartsRef = ref()
const handleClick = (tab: any, e: any) => {
// console.log(tab,e,"??????????");
// if(activeName.value===1){
tableStore.index()
// }
}
// const datePickerRef = ref()
const tableHeaderRef = ref()
const tableStore = new TableStore({
publicHeight: 60,
showPage: false,
url: '/harmonic-boot/steadyExceedRate/getSteadyExceedRateData',
method: 'POST',
column: [
{
title: '',
field: 'name',
align: 'left',
treeNode: true
},
{
title: '电压等级',
field: 'voltageLevel',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '厂家',
field: 'factoryName',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '网络参数',
field: 'networkParam',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '监测点名称',
field: 'lineName',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '符合性占比(%)',
field: 'steadyExceedRate',
formatter: function (row) {
return row.cellValue == 3.14159 ? '暂无数据' : row.cellValue
}
}
],
loadCallback: () => {
let treeData = []
treeData = tree2List(tableStore.table.data)
tableStore.table.column[0].title = tableStore.table.params.statisticalType.name
tableStore.table.data = JSON.parse(JSON.stringify(treeData))
chartsRef.value && chartsRef.value.getTableStoreParams(tableStore.table.params)
setTimeout(() => {
activeName.value == 0 && tableRef.value && tableRef.value.getRef().setAllTreeExpand(true)
}, 0)
}
})
tableStore.table.params.statisticalType = classificationData[0]
tableStore.table.params.scale = []
tableStore.table.params.manufacturer = []
tableStore.table.params.loadType = []
tableStore.table.params.serverName = 'harmonicBoot'
provide('tableStore', tableStore)
const tree2List = (list: any, pid?: string) => {
//存储结果的数组
let arr: any = []
// 遍历 tree 数组
list.forEach((item: any) => {
// item.comFlag = item.comFlag == null ? 3 : item.comFlag
item.valueOver == 3.14159 ? 0 : item.valueOver >= 90 ? 1 : item.valueOver && item.valueOver < 90 ? 2 : 3
item.pid = pid
// 判断item是否存在children
if (!item.children) return arr.push(item)
// 函数递归对children数组进行tree2List的转换
const children = tree2List(item.children, item.id)
// 删除item的children属性
delete item.children
// 把item和children数组添加至结果数组
//..children: 意思是把children数组展开
arr.push(item, ...children)
})
// 返回结果数组
return arr
}
onMounted(() => { tableStore.index() })
</script>
<style lang="scss" scoped>
// .online {
// width: 100%;
// height: 100%;
// .online_header {
// width: 100%;
// max-height: 140px;
// padding: 10px;
// box-sizing: border-box;
// }
// .online_main {
// padding: 0 10px;
// }
// }</style>