谐波畸变率统计页面

This commit is contained in:
zhujiyan
2024-08-07 15:11:01 +08:00
parent e8f4305fa9
commit a9dfdb58cf
2 changed files with 599 additions and 0 deletions

View File

@@ -0,0 +1,280 @@
<template>
<!-- <TableHeader area datePicker ref="TableHeaderRef">
<template #select>
<el-form-item label="统计类型:">
<el-select
v-model="tableStore.table.params.statisticalType"
value-key="id"
placeholder="请选择统计类型"
>
<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
value-key="id"
placeholder="请选择电压等级"
>
<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
value-key="id"
placeholder="请选择终端厂家"
>
<el-option
v-for="item in terminaloption"
: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.loadType"
multiple
collapse-tags
clearable
value-key="id"
placeholder="请选择干扰源类型"
>
<el-option
v-for="item in interfereoption"
:key="item.id"
:label="item.name"
:value="item"
></el-option>
</el-select>
</el-form-item>
</template>
</TableHeader> -->
<my-echart
v-loading="loading"
class="mt10"
:style="`height: calc(${tableStore.table.height} - 75px)`"
:options="options"
/>
</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 MyEchart from '@/components/echarts/MyEchart.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import * as echarts from 'echarts/core'
const dictData = useDictData()
const options = ref({})
const classificationData = dictData.getBasicData('Statistical_Type', ['Report_Type'])
const voltageleveloption = dictData.getBasicData('Dev_Voltage_Stand')
const terminaloption = dictData.getBasicData('Dev_Manufacturers')
const interfereoption = dictData.getBasicData('Interference_Source')
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()
}, 2000)
}
const tableStore = new TableStore({
url: '/device-boot/terminalOnlineRateData/getOnlineRateDataCensus',
showPage: false,
method: 'POST',
column: [],
beforeSearchFun: () => {
tableStore.table.params = tableStoreParams.value
},
loadCallback: () => {
// tableStore.table.data.type
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源类型'
} else if (code == 'Report_Type') {
title = '上报类型'
titleX = '上报\n类型'
}
options.value = {
title: {
text: title
},
toolbox: {
show: true,
feature: {
saveAsImage: {
// bottom: '10px',
show: true,
title: '保存'
// yAxisIndex: 'none'
}
},
right: 10,
top: 0
},
tooltip: {
formatter: function (params: any) {
var tips = ''
for (var i = 0; i < params.length; i++) {
if (params[i].value == 1) {
tips += params[i].name + '</br>'
tips += '总畸变率:暂无数据'
} else {
tips += params[i].name + '</br>'
tips += '总畸变率:' + params[i].value.toFixed(2)
}
}
return tips
}
},
grid: {
top: '50px', // 等价于 y: '16%'
left: '10px',
right: '10px',
bottom: '80px',
containLabel: true
},
xAxis: {
name: titleX,
data: tableStore.table.data.type
},
yAxis: {
name: '%',
max: 100
},
series: [
{
name: '',
type: 'bar',
barMinWidth: 40,
data: tableStore.table.data.single,
itemStyle: {
// barWidth: '50',
normal: {
// 随机显示
//color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}
// 定制显示(按顺序)
// color: function (params: any) {
// if (params.value >= 90) {
// return new echarts.graphic.LinearGradient(
// 0,
// 1,
// 0,
// 0,
// [
// {
// offset: 1,
// color: '#339966'
// }
// ],
// false
// )
// } else if (params.value >= 60 && params.value <= 90) {
// return new echarts.graphic.LinearGradient(
// 0,
// 1,
// 0,
// 0,
// [
// {
// offset: 1,
// color: '#FFCC33'
// }
// ],
// false
// )
// } else if (params.value <= 60 && params.value > 1) {
// return new echarts.graphic.LinearGradient(
// 0,
// 1,
// 0,
// 0,
// [
// {
// offset: 1,
// color: '#CC0000'
// }
// ],
// false
// )
// } else if (params.value > 0 && params.value <= 1) {
// return new echarts.graphic.LinearGradient(
// 0,
// 1,
// 0,
// 0,
// [
// {
// offset: 1,
// color: '#ccc'
// }
// ],
// false
// )
// }
// }
color: '#30DFE2'
}
},
markLine: {
silent: false,
symbol: 'circle',
show: false,
data: []
}
}
]
}
loading.value = false
}
})
// tableStore.table.params.statisticalType = classificationData.filter(item => item.name == '电网拓扑')[0]
// tableStore.table.params.monitorFlag = 2
// tableStore.table.params.powerFlag = 2
// tableStore.table.params.serverName = 'harmonicBoot'
// tableStore.table.params.deptIndex = '5699e5916a18a6381e1ac92da5bd2628'
provide('tableStore', tableStore)
onMounted(() => {})
defineExpose({ getTableStoreParams })
</script>
<style scoped lang="scss"></style>

View File

@@ -0,0 +1,319 @@
<template>
<div class="default-main online">
<div class="online_header">
<TableHeader date-picker ref="tableHeaderRef">
<template #select>
<el-form-item label="统计类型:">
<el-select
v-model="formData.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 ref="select1" v-model="deptName" placeholder="请选择所属部门区域" style="width: 100%">
<el-option :value="formData.deptIndex" style="height: auto"> -->
<!-- {{ formData.deptIndex }} -->
<el-cascader
v-model="formData.deptIndex"
:props="defaultProps"
:options="treeData"
clearable
filterable
collapse-tags
placeholder="请选择区域"
/>
<!-- <el-tree
ref="tree"
v-model="formData.deptName"
:data="treeData"
node-key="id"
accordion
:default-expanded-keys="idArr"
:props="defaultProps"
@node-click="handleNodeClick"
>
<template #default="{ node, data }">
<span :title="data.name">{{ data?.name }}</span>
</template>
</el-tree> -->
<!-- </el-option>
</el-select> -->
</el-form-item>
<el-form-item label="电压等级:">
<el-select
v-model="formData.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="formData.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="formData.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" 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" label="谐波畸变率统计图">
<charts 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'
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')
//调用区域接口获取区域
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 formData = ref({
statisticalType: classificationData[0], //统计类型
deptIndex: treeData.value[0]?.id, //区域选择
scale: voltageleveloption, //电压等级
manufacturer: terminaloption, //终端厂家
loadType: interfereoption //干扰源类型
// searchBeginTime: '',
// searchEndTime: ''
})
formData.value.deptIndex = treeData.value[0]?.id
const defaultProps = ref({
label: 'name',
value: 'id',
checkStrictly: true,
emitPath: false,
expandTrigger: 'click' as const
})
const chartsRef=ref()
const handleClick = (tab: any, e: any) => {
// console.log(tab,e,"??????????");
// if(activeName.value===1){
tableStore.index()
chartsRef.value.getTableStoreParams(tableStore.table.params)
// }
}
// const datePickerRef = ref()
const tableHeaderRef = ref()
const tableStore = new TableStore({
// publicHeight: 60,
showPage: false,
url: '/harmonic-boot/tHDistortion/getTHDistortionData',
method: 'POST',
column: [
{
title: formData.value.statisticalType.name,
field: 'name',
align: 'left',
treeNode: true
},
{
title: '电压等级',
field: 'voltageLevel',
align: 'center',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '网络参数',
field: 'networkParam',
align: 'center',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '监测点名称',
field: 'lineName',
align: 'center',
formatter: function (row) {
return row.cellValue ? row.cellValue : '/'
}
},
{
title: '总谐波畸变率(%)',
field: 'distortion',
align: 'center',
formatter: function (row) {
return row.cellValue == 3.14159 ? '暂无数据' : row.cellValue
}
},
],
beforeSearchFun: () => {
tableStore.table.params.deptIndex = formData.value.deptIndex
tableStore.table.params.statisticalType = formData.value.statisticalType
tableStore.table.params.scale = formData.value.scale
tableStore.table.params.manufacturer = formData.value.manufacturer
tableStore.table.params.loadType = formData.value.loadType
tableStore.table.params.serverName = 'harmonicBoot'
delete tableStore.table.params.timeFlag
delete tableStore.table.params.startTime
delete tableStore.table.params.endTime
delete tableStore.table.params.pageNum
delete tableStore.table.params.pageSize
// tableStore.table.params.searchBeginTime = tableHeaderRef.value.datePickerRef.timeValue[0]
// tableStore.table.params.searchEndTime = tableHeaderRef.value.datePickerRef.timeValue[1]
},
loadCallback: () => {
let treeData = []
treeData = tree2List(tableStore.table.data)
tableStore.table.column[0].title = formData.value.statisticalType.name
tableStore.table.data = JSON.parse(JSON.stringify(treeData))
setTimeout(() => {
activeName.value == 0 && tableRef.value && tableRef.value.getRef().setAllTreeExpand(true)
}, 0)
}
})
const handleSearch = () => {
formData.value.searchBeginTime = datePickerRef.value.timeValue[0]
formData.value.searchEndTime = datePickerRef.value.timeValue[1]
}
tableStore.table.params.deptIndex = ''
tableStore.table.params.statisticalType = []
tableStore.table.params.scale = []
tableStore.table.params.manufacturer = []
tableStore.table.params.loadType = []
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(() => {})
watch(
() => treeData.value,
(val, oldVal) => {
if (val && val.length != 0) {
formData.value.deptIndex = val[0].id
tableStore.index()
}
},
{
immediate: true,
deep: true
}
)
</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>