fix:禅道341

This commit is contained in:
shijing 2026-03-05 14:11:13 +08:00
parent fdacb84301
commit 281ff811c8
1 changed files with 103 additions and 9 deletions

View File

@ -7,7 +7,32 @@
destroy-on-close destroy-on-close
@closed="$emit('closed')" @closed="$emit('closed')"
> >
<div id="tableWap" style="height: 100%;"> <div id="tableWap" style="height: 100%;" v-if="route_code=='zlybcl'">
<el-tabs v-model="activeName" @tab-change="handleClick1">
<el-tab-pane v-for="item in mpointList" :label="item.nickname" :name="item.nickname" :key="item.id" lazy>
<scTable
v-if="item.name !== '折线图'"
ref="table"
:apiObj="apiObj"
row-key="id"
stripe
:height="tableHeight1"
:params="{'mpoint':item.id, 'timex__gte':startTime, 'timex__lte':endTime}"
hideDo
>
<el-table-column label="时间" prop="timex">
</el-table-column>
<el-table-column label="数值" prop="val_float">
<template #default="scope">
{{ scope.row.val_float.toFixed(3) }}
</template>
</el-table-column>
</scTable>
<scEcharts v-if="item.name == '折线图'" :height="chartHeight" :option="option"></scEcharts>
</el-tab-pane>
</el-tabs>
</div>
<div id="tableWap" style="height: 100%;" v-else>
<el-tabs v-model="activeName" @tab-change="handleClick"> <el-tabs v-model="activeName" @tab-change="handleClick">
<el-tab-pane v-for="item in mpointList" :label="item.nickname" :name="item.nickname" :key="item.id" lazy> <el-tab-pane v-for="item in mpointList" :label="item.nickname" :name="item.nickname" :key="item.id" lazy>
<scTable <scTable
@ -61,6 +86,8 @@ export default {
mpointList:[], mpointList:[],
activeName: "", activeName: "",
tableHeight:300, tableHeight:300,
tableHeight1:300,
chartHeight:'280px',
option: { option: {
title: { title: {
text: "", text: "",
@ -84,14 +111,19 @@ export default {
min: 0, min: 0,
max: 100 max: 100
}, },
series:{ series:[
{
name: "数据检测", name: "数据检测",
type: "line", type: "line",
data: [], data: [],
} }
]
} }
}; };
}, },
mounted() {
this.route_code = this.$route.path.split("/")[2];
},
methods: { methods: {
open() { open() {
let that = this; let that = this;
@ -100,6 +132,8 @@ export default {
that.$nextTick(() => { that.$nextTick(() => {
let height = document.getElementById("tableWap").clientHeight; let height = document.getElementById("tableWap").clientHeight;
that.tableHeight = height - 345; that.tableHeight = height - 345;
that.tableHeight1 = height - 40;
that.chartHeight =(height - 40)+'px';
}) })
that.params.timex__gte = that.startTime; that.params.timex__gte = that.startTime;
that.params.timex__lte = that.endTime; that.params.timex__lte = that.endTime;
@ -109,7 +143,14 @@ export default {
that.activeName = res[0].nickname; that.activeName = res[0].nickname;
that.params.mpoint = res[0].id; that.params.mpoint = res[0].id;
that.apiObj = that.$API.enm.mplogx; that.apiObj = that.$API.enm.mplogx;
if(this.route_code =='zlybcl'){
let obj = {name:'折线图',nickname:'折线图',id:'666'};
that.mpointList.push(obj);
that.chartData();
that.handleClick1();
}else{
that.handleClick(); that.handleClick();
}
}else{ }else{
that.$message.error("该设备没有监测点"); that.$message.error("该设备没有监测点");
} }
@ -118,7 +159,7 @@ export default {
handleClick(val){ handleClick(val){
let that = this; let that = this;
that.option.xAxis.data = []; that.option.xAxis.data = [];
that.option.series.data = []; that.option.series[0].data = [];
that.mpointList.forEach(item=>{ that.mpointList.forEach(item=>{
if(item.nickname == that.activeName){ if(item.nickname == that.activeName){
that.query.mpoint = item.id; that.query.mpoint = item.id;
@ -141,11 +182,64 @@ export default {
that.option.yAxis.min = minNum; that.option.yAxis.min = minNum;
that.option.yAxis.max = maxNum; that.option.yAxis.max = maxNum;
that.option.xAxis.data = xAxisData; that.option.xAxis.data = xAxisData;
that.option.series.data = seriesData; that.option.series[0].data = seriesData;
}) })
} }
}) })
}, },
handleClick1(val){
let that = this;
that.mpointList.forEach(item=>{
if(item.nickname == that.activeName){
that.query.mpoint = item.id;
that.query.page = 1;
}
})
},
chartData(){
let that = this;
const promises = that.mpointList.map(item => {
if (item.name !== '折线图') {
let params = {
mpoint: item.id,
timex__gte: that.startTime,
timex__lte: that.endTime,
page: 0
};
return that.$API.enm.mplogx.req(params);
}
});
Promise.all(promises).then(responses => {
that.option.xAxis.data = [];
that.option.series.data = [];
let minNum = null,maxNum = 0,series = [];
responses.forEach((res,index) => {
if(res!==undefined){
let minNum0=0,maxNum0=0,seriesData = [],xAxisData = [];
res.forEach(item=>{
xAxisData.unshift(item.timex);
let value = Number(item.val_float);
seriesData.unshift(value);
})
that.option.xAxis.data = xAxisData;
minNum0 = seriesData.reduce((a, b) => a < b ? a : b);
minNum = minNum === null ? minNum0 : Math.min(minNum,minNum0);
maxNum0 = Math.max(...seriesData);
maxNum = Math.max(maxNum,maxNum0);
series.push({
name: that.mpointList[index].nickname,
type: "line",
data: seriesData,
})
}
});
that.option.yAxis.min = minNum;
that.option.yAxis.max = maxNum;
that.option.series = series;
}).catch(error => {
console.error('Error:', error);
});
},
}, },
}; };
</script> </script>