From 328febf368f1494b4b5b647f3eab5f4ad38eb072 Mon Sep 17 00:00:00 2001 From: zhouwenxuan <1175765986@qq.com> Date: 星期四, 12 十月 2023 16:54:27 +0800 Subject: [PATCH] 日报接口、图表优化 --- src/views/monitorData/gasData/index.vue | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/views/monitorData/gasData/index.vue b/src/views/monitorData/gasData/index.vue index 552db39..043df7a 100644 --- a/src/views/monitorData/gasData/index.vue +++ b/src/views/monitorData/gasData/index.vue @@ -39,7 +39,7 @@ </el-form> </div> <div id="gasChart" style="height: 500px;width: auto"></div> - <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px"> + <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px" 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="windSpeed" label="风速"/> @@ -112,6 +112,7 @@ } } } +const loading = ref(false); const dataZoomEnd = ref(); const xData = ref([]); const yData = ref([]); @@ -140,14 +141,22 @@ } let resChart = await gasDataApi().getGasLineChart(chartParam); if(resChart.data.code == 100) { - xData.value = resChart.data.data.map((item: any) => { - return item.time; - }) - yData.value = resChart.data.data.map((item: any) => { - return item.gasValue; - }) - dataZoomEnd.value = xData.value.length > 25 ? 30 : 100; - markLines.value = 110; + if (resChart.data.data) { + xData.value = resChart.data.data.map((item: any) => { + return item.time; + }) + yData.value = resChart.data.data.map((item: any) => { + return item.gasValue; + }) + dataZoomEnd.value = xData.value.length > 25 ? 30 : 100; + markLines.value = 110; + + }else { + xData.value = []; + yData.value = []; + markLines.value = 0; + dataZoomEnd.value = 100; + } initCharts(); }else { ElMessage({ @@ -156,6 +165,7 @@ }); } + loading.value = true; //表格 const pageParam = { pageIndex: state.tableData.listQuery.pageIndex, @@ -172,6 +182,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', @@ -204,6 +215,7 @@ initInfoData(); }; const search = () => { + state.tableData.listQuery.pageIndex = 1; initInfoData(); console.log("vla",state.tableData.listQuery.searchParams) } @@ -238,6 +250,20 @@ max: Math.max(markLines.value,...yData.value), min: Math.min(markLines.value,...yData.value) }, + graphic: { + type: 'text', // 类型:文本 + left: 'center', + top: 'middle', + silent: true, // 不响应事件 + invisible: yData.value.length > 0, // 有数据就隐藏 + style: { + fill: '#9d9d9d', + fontWeight: 'bold', + text: '暂无数据', + fontFamily: 'Microsoft YaHei', + fontSize: '25px' + } + }, series: [ { data: yData.value, @@ -249,10 +275,10 @@ position: 'end', // 表现内容展示的位置 color: 'red' // 展示内容颜色 }, - yAxis: markLines.value, + yAxis: markLines.value == 0 ? '':markLines.value , lineStyle: { color: "red", - width: 1, // 0 的时候可以隐藏线 + width: markLines.value == 0 ? 0: 1, // 0 的时候可以隐藏线 type: "solid" // 实线,不写默认虚线 } },],//type: 'average', 平均值, min最小值, max 最大值, median中位数 @@ -278,7 +304,7 @@ // 使用刚指定的配置项和数据显示图表。 myChart.value.setOption(option,true); //自适应宽度 - window.addEventListener('resize', function () { + window.addEventListener('resize',function () { myChart.value.resize(); }) } -- Gitblit v1.9.2