yijianjun hace 1 mes
padre
commit
ee4d4b6b38
Se han modificado 1 ficheros con 50 adiciones y 1 borrados
  1. 50 1
      src/views/modules/load-forecasting/index.vue

+ 50 - 1
src/views/modules/load-forecasting/index.vue

@@ -174,6 +174,19 @@
             ></span>
             数据分析
           </el-button>
+          <el-button class="add" type="danger" @click="exportHandler()">
+            <span
+              class="icon iconfont icon-xihuan"
+              :style="{
+                margin: '0 2px',
+                fontSize: '14px',
+                color: '#fff',
+                display: 'none',
+                height: '34px',
+              }"
+            ></span>
+            导出
+          </el-button>
         </el-row>
       </el-form>
       <div
@@ -598,6 +611,42 @@ export default {
     this.getDataList();
   },
   methods: {
+    exportHandler() {
+      let params = {
+        page: this.pageIndex,
+        limit: this.pageSize,
+        sort: 'id',
+        order: 'desc',
+      };
+      if (this.searchForm.subId != '' && this.searchForm.subId != undefined) {
+        params['subId'] = Number(this.searchForm.subId);
+      }
+      if (this.searchForm.compId != '' && this.searchForm.compId != undefined) {
+        params['compId'] = Number(this.searchForm.compId);
+      }
+      if (this.searchForm.temperature != '' && this.searchForm.temperature != undefined) {
+        params['temperature'] = Number(this.searchForm.temperature);
+      }
+      if (this.searchForm.dateRange != '' && this.searchForm.dateRange != undefined) {
+        params['record_date_start'] = this.searchForm.dateRange[0];
+        params['record_date_end'] = this.searchForm.dateRange[1];
+      }
+      this.$http({
+        url: '/electric-heating/export',
+        method: 'get',
+        params: params,
+        responseType: 'blob',
+      }).then(({ data }) => {
+        const blob = new Blob([data], { type: 'application/vnd.ms-excel' });
+        const fileName = '负荷预测.xlsx';
+        const a = document.createElement('a');
+        a.href = URL.createObjectURL(blob);
+        a.download = fileName;
+        a.click();
+        URL.revokeObjectURL(a.href);
+        this.$message.success('导出成功');
+      });
+    },
     // 获取变电站列表
     async getSubList() {
       this.subList = [];
@@ -654,7 +703,7 @@ export default {
       };
       columns.forEach((item, i) => {
         this.$http({
-          url: `/electric-heating/${initType}/${item.filed}/${this.searchForm.timeStatType}`,
+          url: `/electric-heating/${initType}/${item}/${this.searchForm.timeStatType}`,
           method: 'get',
           params: params,
         }).then(({ data }) => {