From 67ddfbd2db13529c8923838d4dc7ed4cf105b0fe Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: Fri, 20 Oct 2023 15:41:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
src/views/monitorData/fluxData/index.vue | 56 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 42 insertions(+), 14 deletions(-)
diff --git a/src/views/monitorData/fluxData/index.vue b/src/views/monitorData/fluxData/index.vue
index d50c5d2..107a490 100644
--- a/src/views/monitorData/fluxData/index.vue
+++ b/src/views/monitorData/fluxData/index.vue
@@ -49,7 +49,7 @@
</el-form>
</div>
<div id="gasChart" style="height: 500px;width: auto"></div>
- <el-table :data="state.tableData.data" style="width: 100%">
+ <el-table :data="state.tableData.data" style="width: 100%" v-loading="loading">
<el-table-column type="index" label="序号" width="80" />
<el-table-column align="center" prop="time" label="采集时间"/>
<el-table-column align="center" prop="regionName" label="区域名称"/>
@@ -78,7 +78,7 @@
</template>
<script setup lang="ts">
-import {reactive, ref,onMounted} from "vue";
+import {reactive, ref, onMounted, shallowRef} from "vue";
import * as echarts from "echarts";
import { ElMessage, ElMessageBox } from 'element-plus'
import {TableFluxState} from "/@/types/monitorData";
@@ -103,8 +103,11 @@
},
gasList: [],
areaList: [],
- }
+ },
});
+
+const loading = ref(false);
+const myChart = shallowRef(null)
const chooseTime = (val:any) => {
console.log("val",val)
@@ -154,7 +157,7 @@
const yData = ref([]);
const areaChart = ref([]as any);
const initInfoData = async () => {
- //折线图
+ //柱状图
const chartParam = {
startTime: moment(state.tableData.listQuery.searchParams.time[0]).format('YYYY-MM-DD HH:mm:ss'),
endTime: moment(state.tableData.listQuery.searchParams.time[1]).format('YYYY-MM-DD HH:mm:ss'),
@@ -163,11 +166,18 @@
}
let resChart = await fluxDataApi().getFluxLineChart(chartParam);
if(resChart.data.code == 100) {
- yData.value = mapArray(resChart.data.data);
- areaChart.value = yData.value.map((item: any) => {
- return item.name
- });
- dataZoomEnd.value = xData.value.length > 25 ? 2 : 100;
+ if(resChart.data.data) {
+ yData.value = mapArray(resChart.data.data);
+ areaChart.value = yData.value.map((item: any) => {
+ return item.name
+ });
+ dataZoomEnd.value = xData.value.length > 25 ? 5 : 100;
+ }else {
+ yData.value = [];
+ xData.value = [];
+ dataZoomEnd.value = 100;
+ }
+
initCharts();
}else {
ElMessage({
@@ -176,6 +186,7 @@
});
}
+ loading.value = true;
//表格
const pageParam = {
pageIndex: state.tableData.listQuery.pageIndex,
@@ -193,6 +204,7 @@
state.tableData.total = res.data.total;
state.tableData.listQuery.pageIndex = res.data.pageIndex;
state.tableData.listQuery.pageSize = res.data.pageSize;
+ loading.value = false;
}else {
ElMessage({
type: 'warning',
@@ -214,7 +226,6 @@
let finalResult = []as any;
target.map((item: any) => {
let key = item.regionName;
- //如果有这个key,就push一个对象
if (obj[key]) {
obj[key].push(item);
} else {
@@ -306,7 +317,10 @@
const initCharts = () => {
- const myChart = echarts.init(document.getElementById('gasChart'));
+ if (myChart.value != null && myChart.value != "" && myChart.value != undefined) {
+ myChart.value.dispose();
+ }
+ myChart.value = echarts.init(document.getElementById('gasChart'));
// 指定图表的配置项和数据
const option = {
tooltip: {
@@ -329,6 +343,20 @@
magicType: { show: true, type: ['line', 'bar', 'stack'] },
restore: { show: true },
saveAsImage: { show: true }
+ }
+ },
+ graphic: {
+ type: 'text', // 类型:文本
+ left: 'center',
+ top: 'middle',
+ silent: true, // 不响应事件
+ invisible: yData.value.length > 0, // 有数据就隐藏
+ style: {
+ fill: '#9d9d9d',
+ fontWeight: 'bold',
+ text: '暂无数据',
+ fontFamily: 'Microsoft YaHei',
+ fontSize: '22px'
}
},
xAxis: [
@@ -362,10 +390,10 @@
]
};
// 使用刚指定的配置项和数据显示图表。
- myChart.setOption(option,true);
+ myChart.value.setOption(option,true);
//自适应宽度
window.addEventListener('resize', function () {
- myChart.resize();
+ myChart.value.resize();
})
}
</script>
@@ -388,4 +416,4 @@
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2);
padding: 3px
}
-</style>
\ No newline at end of file
+</style>
--
Gitblit v1.9.2