Browse Source

环路分析和换热站失水分析数据导出功能使用后端接口

yanglzh 2 years ago
parent
commit
4bbe45be8c

+ 3 - 2
src/api/energyAnalysis/index.ts

@@ -1,4 +1,4 @@
-import { get, post, del, put } from '/@/utils/request';
+import { get, post, del, put, file } from '/@/utils/request';
 
 export default {
   getStationInfoList: (params?: object) => get('/energy/station/info/list', params), // 换热站基础数据(分析报表数据)
@@ -6,11 +6,12 @@ export default {
   getEnergyHuanluWaterLossLineChart: (params?: object) => get('/energy/huanlu/water/loss/line/chart', params), // 换热站失水分析折现图列表
   getEnergyWaterWarnList: (params?: object) => get('/energy/early/warn/list', params), // 换热站温度压力报警
 
-
   getEnergyLoopdata: (params?: object) => get('/energy/loopdata', params), // 环路分析
   getEnergyLoopdataPage: (params?: object) => get('/energy/loopdata/page_list', params), // 环路分析
   getEnergyWaterLossLineChart: (params?: object) => get('/energy/water/loss/line/chart', params), // 换热站失水分析
   getEnergyHuanluWaterLossLineChartPage: (params?: object) => get('/energy/water/loss/page_list', params), // 换热站失水分析折现图列表
   getEnergyPerformance: (params?: object) => get('/energy/performance', params), // 绩效考核
   getEnergyTop: (params?: object) => get('/energy/top', params), // 能耗排行榜
+  loopdataExport: (params: object) => file('/energy/loopdata/export', params), // 导出:环路分析
+  lossWaterExport: (params: object) => file('/energy/water/loss/export', params), // 导出:环路分析
 }

+ 42 - 30
src/views/heating/energyAnalysis/analysisReport/index.vue

@@ -80,7 +80,8 @@ import heatApi from '/@/api/heatStation';
 import energyApi from '/@/api/energyAnalysis';
 import { formatDate } from '/@/utils/formatTime'
 import { useSearch } from '/@/hooks/useCommon';
-import { export_json_to_excel } from '/@/utils/xlsx';
+import downloadFile from '/@/utils/download';
+// import { export_json_to_excel } from '/@/utils/xlsx';
 
 const { params, tableData, getList, loading } = useSearch<any[]>(energyApi.getEnergyLoopdataPage, 'list', {
   loopCode: '',
@@ -148,39 +149,50 @@ const filterNode = (value: string, data: any) => {
   return data.name.includes(value)
 }
 
+// 后端导出
 const exportExcel = () => {
+  energyApi.loopdataExport({
+    loopCode: curNode.value,
+    dateRange: state.tableData.param.dateRange
+  }).then((res: any) => {
+    downloadFile(res, nodeName + '-环路分析数据导出.xlsx')
+  })
+}
 
-  const header = {
-    huanLuNo: '环路编号',
-    inTemperature1: '一网供水温度',
-    outTemperature1: '一网回水温度',
-    inTemperature2: '二网供水温度',
-    outTemperature2: '二网回水温度',
-    inPressure1: '一网供水压力',
-    outPressure1: '一网回水压力',
-    inPressure2: '二网供水压力',
-    outPressure2: '二网回水压力',
-    supplyWaterFlow: '供水流量',
-    returnWaterFlow: '回水流量',
-    supplyWaterFlow2: '二网供水流量',
-    supplyValve: '阀门开度',
-  };
+// 前端导出
+// const exportExcel = () => {
 
-  // 主体数据
-  const list = state.tableData.data.map((item: any) => {
-    const newItem: any = {}
-    Object.keys(header).forEach((key: string) => {
-      newItem[key] = item[key]
-    })
-    return newItem
-  });
+//   const header = {
+//     huanLuNo: '环路编号',
+//     inTemperature1: '一网供水温度',
+//     outTemperature1: '一网回水温度',
+//     inTemperature2: '二网供水温度',
+//     outTemperature2: '二网回水温度',
+//     inPressure1: '一网供水压力',
+//     outPressure1: '一网回水压力',
+//     inPressure2: '二网供水压力',
+//     outPressure2: '二网回水压力',
+//     supplyWaterFlow: '供水流量',
+//     returnWaterFlow: '回水流量',
+//     supplyWaterFlow2: '二网供水流量',
+//     supplyValve: '阀门开度',
+//   };
 
-  export_json_to_excel({
-    header,
-    list,
-    fileName: nodeName + '-环路分析数据导出',
-  });
-}
+//   // 主体数据
+//   const list = state.tableData.data.map((item: any) => {
+//     const newItem: any = {}
+//     Object.keys(header).forEach((key: string) => {
+//       newItem[key] = item[key]
+//     })
+//     return newItem
+//   });
+
+//   export_json_to_excel({
+//     header,
+//     list,
+//     fileName: nodeName + '-环路分析数据导出',
+//   });
+// }
 
 const queryTree = () => {
   heatApi.heatStation.getAllStaAndLoop({})

+ 26 - 17
src/views/heating/energyAnalysis/heatStationWaterAnalysis/index.vue

@@ -48,7 +48,8 @@ import api from '/@/api/energyAnalysis';
 import heatApi from '/@/api/heatStation';
 import { formatDate } from '/@/utils/formatTime';
 import { useSearch } from '/@/hooks/useCommon';
-import { export_json_to_excel } from '/@/utils/xlsx';
+// import { export_json_to_excel } from '/@/utils/xlsx';
+import downloadFile from '/@/utils/download';
 
 const { params, tableData, getList, loading } = useSearch<any[]>(api.getEnergyHuanluWaterLossLineChartPage, 'list', { loopCode: '' });
 
@@ -107,26 +108,34 @@ const onNodeClick = (data: any) => {
   queryLineChart()
 }
 
-
+// 后端导出
 const exportExcel = () => {
+  api.lossWaterExport({
+    loopCode: curNode.value
+  }).then((res: any) => {
+    downloadFile(res, nodeName + '-换热站失水分析数据导出.xlsx')
+  })
+}
 
-  const header = {
-    datetime: '日期',
-    huanLuNo: '环路编码',
-    huanLuName: '环路名称',
-    supplyWater: '供水流量',
-    returnWater: '回水流量',
-    waterLoss: '失水量',
-  };
+// 前端导出
+// const exportExcel = () => {
+//   const header = {
+//     datetime: '日期',
+//     huanLuNo: '环路编码',
+//     huanLuName: '环路名称',
+//     supplyWater: '供水流量',
+//     returnWater: '回水流量',
+//     waterLoss: '失水量',
+//   };
 
-  const list = state.tableData.data
+//   const list = state.tableData.data
 
-  export_json_to_excel({
-    header,
-    list,
-    fileName: nodeName + '-换热站失水分析数据导出',
-  });
-}
+//   export_json_to_excel({
+//     header,
+//     list,
+//     fileName: nodeName + '-换热站失水分析数据导出',
+//   });
+// }
 
 const queryTree = () => {
   heatApi.heatStation.getAllStaAndLoop({})