Bladeren bron

fix: 数据分析曲线图&本地导出模版

yijianjun 1 maand geleden
bovenliggende
commit
30a0afd7d9

+ 9 - 1
src/views/modules/load-data/index.vue

@@ -154,7 +154,7 @@
             ></span>
             导入
           </el-button>
-          <el-button class="add" type="danger" @click="download('upload/voltageLoad_template.xlsx')">
+          <el-button class="add" type="danger" @click="downloadTemplate()">
             <span
               class="icon iconfont icon-xihuan"
               :style="{
@@ -356,6 +356,14 @@ export default {
     importHandler() {
       this.$refs.uploadModal.openDialog();
     },
+    downloadTemplate() {
+      const link = document.createElement('a');
+      link.href = './voltageLoad_template.xlsx';
+      link.download = 'voltageLoad_template.xlsx';
+      document.body.appendChild(link);
+      link.click();
+      document.body.removeChild(link);
+    },
     exportTemplate() {
       axios
         .get(this.$base.url + 'file/download?fileName=' + 'voltageLoad_template.xlsx', {

BIN
src/views/modules/load-data/voltageLoad_template.xlsx


+ 33 - 34
src/views/modules/load-forecasting/index.vue

@@ -571,6 +571,25 @@ export default {
           },
         ],
       },
+      lineOption: {
+        grid: { top: 10, left: 15, right: 15, bottom: 20 },
+        color: ['#0977fd'],
+        tooltip: { trigger: 'item', formatter: '{b} : {c}', backgroundColor: 'transparent' },
+        xAxis: {
+          type: 'category',
+          data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
+        },
+        yAxis: {
+          type: 'value',
+        },
+        series: [
+          {
+            data: [],
+            type: 'line',
+            smooth: true,
+          },
+        ],
+      },
     };
   },
   created() {
@@ -642,41 +661,21 @@ export default {
           const chart = echarts.init(document.getElementById(`chart${i + 1}`), 'carp');
           const res = initType === 'init' ? data?.data?.result || [] : data?.data || [];
           // 使用刚指定的配置项和数据显示图表。
-          if ([0, 1, 2].includes(i)) {
-            chart.setOption({
-              ...this.barOption,
-              xAxis: {
-                type: 'category',
-                data: res?.map(item => item.subName),
+          // if ([0, 1, 2].includes(i)) {
+          chart.setOption({
+            ...this.lineOption,
+            xAxis: {
+              type: 'category',
+              data: res?.map(item => item.subName),
+            },
+            series: [
+              {
+                data: res?.map(item => item.total),
+                type: 'line',
               },
-              series: [
-                {
-                  data: res?.map(item => item.total),
-                  type: 'bar',
-                },
-              ],
-            });
-          }
-          if ([3, 4, 5].includes(i)) {
-            chart.setOption({
-              ...this.pieOption,
-              series: [
-                {
-                  data: res?.map(item => ({ name: item.subName, value: item.total })),
-                  type: 'pie',
-                  radius: ['25%', '55%'],
-                  center: ['50%', '60%'],
-                  emphasis: {
-                    itemStyle: {
-                      shadowBlur: 10,
-                      shadowOffsetX: 0,
-                      shadowColor: 'rgba(0, 0, 0, 0.5)',
-                    },
-                  },
-                },
-              ],
-            });
-          }
+            ],
+          });
+          // }
           //根据窗口的大小变动图表
           window.onresize = function () {
             chart.resize();