蒋珅 před 1 rokem
rodič
revize
94f8b9fa16
4 změnil soubory, kde provedl 266 přidání a 69 odebrání
  1. 6 1
      package-lock.json
  2. 2 1
      package.json
  3. 257 67
      src/components/temperatureMatrix.vue
  4. 1 0
      src/main.js

+ 6 - 1
package-lock.json

@@ -7566,6 +7566,11 @@
         }
       }
     },
+    "file-saver": {
+      "version": "2.0.5",
+      "resolved": "https://registry.npmmirror.com/file-saver/-/file-saver-2.0.5.tgz",
+      "integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
+    },
     "filelist": {
       "version": "1.0.4",
       "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
@@ -17314,7 +17319,7 @@
     },
     "xlsx": {
       "version": "0.17.5",
-      "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.17.5.tgz",
+      "resolved": "https://registry.npmmirror.com/xlsx/-/xlsx-0.17.5.tgz",
       "integrity": "sha512-lXNU0TuYsvElzvtI6O7WIVb9Zar1XYw7Xb3VAx2wn8N/n0whBYrCnHMxtFyIiUU1Wjf09WzmLALDfBO5PqTb1g==",
       "requires": {
         "adler-32": "~1.2.0",

+ 2 - 1
package.json

@@ -17,6 +17,7 @@
     "dayjs": "^1.10.6",
     "echarts": "^5.1.2",
     "element-plus": "^1.1.0-beta.4",
+    "file-saver": "^2.0.5",
     "html2canvas": "^1.4.1",
     "jquery": "^3.6.0",
     "json-bigint": "^1.0.0",
@@ -26,7 +27,7 @@
     "vue-grid-layout": "^3.0.0-beta1",
     "vue-router": "^4.0.0-0",
     "vuex": "^4.0.0-0",
-    "xlsx": "^0.17.1"
+    "xlsx": "^0.17.5"
   },
   "devDependencies": {
     "@vue/cli-plugin-babel": "~4.5.0",

+ 257 - 67
src/components/temperatureMatrix.vue

@@ -1,5 +1,12 @@
 <template>
-  <el-dialog width="70%" @open="opened" @closed="closed" :fullscreen="true" :show-close="true" class="dialogs">
+  <el-dialog
+    width="70%"
+    @open="opened"
+    @closed="closed"
+    :fullscreen="true"
+    :show-close="true"
+    class="dialogs"
+  >
     <template #title>
       <div class="showTitles currentShowTitles">
         <div class="titles" @click="cheshi()">温度矩阵</div>
@@ -7,38 +14,68 @@
     </template>
     <div class="body" @contextmenu="contextmenu">
       <div class="title">
-        <div :class="current === item.id ? 'title-onItem' : 'title-item'" v-for="(item, index) in stationList"
-          :key="index" @click="handleChange(item.id)">
+        <div
+          :class="current === item.id ? 'title-onItem' : 'title-item'"
+          v-for="(item, index) in stationList"
+          :key="index"
+          @click="handleChange(item.id,item.name)"
+        >
           {{ item.name }}
         </div>
         <div class="select">
-          <el-checkbox style="margin-right: 20px" :indeterminate="isIndeterminate" v-model="checkAll"
-            @change="handleCheckChange">全选</el-checkbox>
-          <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
+          <el-checkbox
+            style="margin-right: 20px"
+            :indeterminate="isIndeterminate"
+            v-model="checkAll"
+            @change="handleCheckChange"
+            >全选</el-checkbox
+          >
+          <el-checkbox-group
+            v-model="checkedCities"
+            @change="handleCheckedCitiesChange"
+          >
             <el-checkbox v-for="item in checkboxs" :label="item" :key="item">{{
-                item
+              item
             }}</el-checkbox>
           </el-checkbox-group>
+          <div class="bpickers">
+            <div>
+              <el-button type="info" size="small" @click="exportExcel()"
+                >导出</el-button
+              >
+            </div>
+          </div>
         </div>
       </div>
       <div class="tables">
-        <el-table id="tableId" ref="multipleTable" :data="tableData" class="table" style="width: 100%" height="83vh"
-          stripe :header-cell-style="{
+        <el-table
+          id="tableId"
+          ref="multipleTable"
+          :data="tableData"
+          class="table"
+          style="width: 100%"
+          height="83vh"
+          stripe
+          :header-cell-style="{
             background: 'rgb(30,30,30)',
             color: 'rgb(220,220,220)',
             padding: '4px',
             fontSize: '14px',
             border: 'solid 0.5px #000000',
-          }" :cell-style="{
-  height: '40px',
-  background: 'rgb(30,30,30)',
-  color: 'rgb(220,220,220)',
-  padding: '3px',
-  fontSize: '12px',
-  'border-top': '0px solid #000000',
-  'border-bottom': '1px solid #000000',
-  'border-right': '1px solid #000000',
-}" @cell-click="handleCellClick" @selection-change="handleSelectionChange">
+          }"
+          :cell-style="{
+            height: '40px',
+            background: 'rgb(30,30,30)',
+            color: 'rgb(220,220,220)',
+            padding: '3px',
+            fontSize: '12px',
+            'border-top': '0px solid #000000',
+            'border-bottom': '1px solid #000000',
+            'border-right': '1px solid #000000',
+          }"
+          @cell-click="handleCellClick"
+          @selection-change="handleSelectionChange"
+        >
           <el-table-column type="selection" width="50"> </el-table-column>
           <el-table-column prop="code" label="风机" width="90" align="center">
           </el-table-column>
@@ -49,26 +86,49 @@
               </span>
             </template>
           </el-table-column>
-          <el-table-column prop="windSpeed"  width="50" label="风速" align="center">
+          <el-table-column
+            prop="windSpeed"
+            width="50"
+            label="风速"
+            align="center"
+          >
           </el-table-column>
           <el-table-column prop="power" width="60" label="功率" align="center">
           </el-table-column>
-          <el-table-column prop="rollSpeed"  width="70" label="发电机转速" align="center">
+          <el-table-column
+            prop="rollSpeed"
+            width="70"
+            label="发电机转速"
+            align="center"
+          >
           </el-table-column>
-          <el-table-column v-for="(item, index) in contentList" :key="index" :label="item.name" align="center">
-            <el-table-column v-for="(res, index) in item.children" :key="index" :label="res.name" width="61"
-              align="center">
+          <el-table-column
+            v-for="(item, index) in contentList"
+            :key="index"
+            :label="item.name"
+            align="center"
+          >
+            <el-table-column
+              v-for="(res, index) in item.children"
+              :key="index"
+              :label="res.name"
+              width="61"
+              align="center"
+            >
               <template #default="scope">
-                <span :id="scope.row.id === tableData.length - 3 ? 'lastTable' : ''" :class="
-                  scope.row[`${res.keyname}Status`] === 'OverLimit'
-                    ? 'overModle'
-                    : scope.row[`${res.keyname}Status`] === 'CrossingLimit'
+                <span
+                  :id="scope.row.id === tableData.length - 3 ? 'lastTable' : ''"
+                  :class="
+                    scope.row[`${res.keyname}Status`] === 'OverLimit'
+                      ? 'overModle'
+                      : scope.row[`${res.keyname}Status`] === 'CrossingLimit'
                       ? 'crossModle'
                       : scope.row[`${res.keyname}Status`] === 'BadPoint'
-                        ? 'badModle'
-                        : ''
-                ">
-                  {{ scope.row[res.keyname] ? scope.row[res.keyname] : '' }}
+                      ? 'badModle'
+                      : ''
+                  "
+                >
+                  {{ scope.row[res.keyname] ? scope.row[res.keyname] : "" }}
                 </span>
               </template>
             </el-table-column>
@@ -82,6 +142,8 @@
 <script>
 import api from "api/index";
 import BackgroundData from "utils/BackgroundData";
+import XLSX from "xlsx";
+import { saveAs } from 'file-saver'
 const cityOptions = ["越限", "超限", "坏点"];
 export default {
   data() {
@@ -121,6 +183,8 @@ export default {
         },
       ],
       contentList: [],
+      resultArray: [],
+      hanb:"",
       tableData: [],
       stationList: [],
       current: "",
@@ -171,19 +235,19 @@ export default {
       pagenum: 1,
     };
   },
-  mounted() { },
+  mounted() {},
   methods: {
     cheshi() {
-      const lastTable = document.getElementById('lastTable').getClientRects()
-      const tableId = document.getElementById('tableId').getClientRects()
+      const lastTable = document.getElementById("lastTable").getClientRects();
+      const tableId = document.getElementById("tableId").getClientRects();
       if (lastTable[0].top < tableId[0].bottom) {
-        this.pagenum = this.pagenum + 1
+        this.pagenum = this.pagenum + 1;
         this.getData();
       }
     },
     handleCheckChange(val) {
-      this.tableData = []
-      this.pagenum = 1
+      this.tableData = [];
+      this.pagenum = 1;
       this.checkedCities = val ? cityOptions : [];
       this.isIndeterminate = false;
       this.multipleSelection = [];
@@ -195,28 +259,25 @@ export default {
       this.isIndeterminate =
         checkedCount > 0 && checkedCount < this.checkboxs.length;
       this.multipleSelection = [];
-      this.tableData = []
-      this.pagenum = 1
+      this.tableData = [];
+      this.pagenum = 1;
       this.getData();
     },
     opened() {
       this.$nextTick(() => {
-        let tableDom = this.$refs.multipleTable?.$refs?.bodyWrapper
-        let time = null
-        tableDom.addEventListener('scroll', () => {
-          
+        let tableDom = this.$refs.multipleTable?.$refs?.bodyWrapper;
+        let time = null;
+        tableDom.addEventListener("scroll", () => {
           if (time !== null) {
             clearTimeout(time);
           }
           time = setTimeout(() => {
-            this.cheshi()
-          }, 100)
-
-        })
+            this.cheshi();
+          }, 100);
+        });
       });
-      let stationList = [
-        
-      ];
+      let stationList = [];
+      console.log('61',stationList);
       let stations = this.$store.state.stationList;
       stations.forEach((item) => {
         if (item.id.indexOf("FDC") != -1) {
@@ -233,10 +294,11 @@ export default {
       clearInterval(this.intervals);
       this.intervals = null;
     },
-    handleChange(val) {
+    handleChange(val,nb) {
       this.current = val;
-      this.tableData = []
-      this.pagenum = 1
+      this.hanb=nb
+      this.tableData = [];
+      this.pagenum = 1;
       this.getData();
     },
     handleCellClick(val) {
@@ -246,9 +308,9 @@ export default {
       this.multipleSelection = val;
     },
     handleData() {
-      this.tableData = []
-      this.pagenum = 1
-      this.getData()
+      this.tableData = [];
+      this.pagenum = 1;
+      this.getData();
     },
     getData() {
       let selectStatus = "";
@@ -264,10 +326,14 @@ export default {
       selectStatus = statusArr.join(",");
       api
         .temperatureInfo({
-          id: this.current === 'all' ? '' : this.stationList.filter(item => item.id === this.current)[0].id,
+          id:
+            this.current === "all"
+              ? ""
+              : this.stationList.filter((item) => item.id === this.current)[0]
+                  .id,
           status: selectStatus,
           pagenum: this.pagenum,
-          pagesize: 30,
+          pagesize: 200,
         })
         .then((res) => {
           if (res.data.length) {
@@ -276,8 +342,9 @@ export default {
             res.data.forEach((item, index) => {
               let tableData = {};
               tableData.code = item.code;
+
               tableData.windSpeed = item.windSpeed.toFixed(1);
-              tableData.status = Number(item.status)
+              tableData.status = Number(item.status);
               tableData.stationId = item.stationId;
               tableData.rollSpeed = item.rollSpeed.toFixed(1);
               tableData.power = item.power.toFixed(1);
@@ -294,18 +361,22 @@ export default {
                       str.keyname = `${val.name}${temp.name}`;
                       obj.children.push(str);
                     }
-                    tableData[`${val.name}${temp.name}`] = temp.value.toFixed(1);
+                    tableData[`${val.name}${temp.name}`] =
+                      temp.value.toFixed(1);
                     tableData[`${val.name}${temp.name}Status`] = temp.status;
                   });
                   contentList.push(obj);
                 } else {
                   val.temperatureItemInfos.forEach((temp) => {
-                    tableData[`${val.name}${temp.name}`] = temp.value.toFixed(1);
+                    tableData[`${val.name}${temp.name}`] =
+                      temp.value.toFixed(1);
                     tableData[`${val.name}${temp.name}Status`] = temp.status;
                   });
                 }
               });
               tableDatas.push(tableData);
+              // console.log('ha',tableDatas);
+              this.resultArray = tableDatas;
             });
             this.contentList = contentList;
             let arr = [];
@@ -318,8 +389,8 @@ export default {
               this.tableData = [...this.tableData, ...tableDatas];
 
               this.tableData.forEach((item, index) => {
-                item.id = index
-              })
+                item.id = index;
+              });
             }
 
             this.multipleSelection.forEach((item) => {
@@ -333,10 +404,120 @@ export default {
               }
             });
           }
-
         });
     },
 
+    exportExcel() {
+      const headers = [
+        "机组编号",
+        "状态",
+        "风速",
+        "功率",
+        "发电机转速",
+        "主轴叶轮侧温度",
+        "主轴齿轮箱侧温度",
+        "塔底柜温度",
+        "机舱柜温度",
+        "机舱温度",
+        "滑环温度",
+        "环境温度",
+        "发电机U1绕组温度",
+        "发电机U2绕组温度",
+        "发电机V1绕组温度",
+        "发电机V2绕组温度",
+        "发电机W1绕组温度",
+        "发电机W2绕组温度",
+        "轴a温度",
+        "轴b温度",
+        "变桨电池柜1温度",
+        "变桨电池柜2温度",
+        "变桨电池柜3温度",
+        "液压压力",
+        "液压油温",
+        "齿轮箱入口温度",
+        "齿轮箱油温",
+        "齿轮箱轴1温度",
+        "齿轮箱轴2温度",
+      ];
+      let data = this.resultArray.map((item) => [
+        item.code,
+        item.status,
+        item.windSpeed,
+        item.power,
+        item.rollSpeed,
+        item.主轴叶轮侧温度,
+        item.主轴齿轮箱侧温度,
+        item.其他塔底柜温度,
+        item.其他机舱柜温度,
+        item.其他机舱温度,
+        item.其他滑环温度,
+        item.其他环境温度,
+        item.发电机U1绕组温度,
+        item.发电机U2绕组温度,
+        item.发电机V1绕组温度,
+        item.发电机V2绕组温度,
+        item.发电机W1绕组温度,
+        item.发电机W2绕组温度,
+        item.发电机W2绕组温度,
+        item.发电机轴a温度,
+        item.发电机轴b温度,
+        item.变桨电池柜1温度,
+        item.变桨电池柜2温度,
+        item.变桨电池柜3温度,
+        item.液压压力,
+        item.液压油温,
+        item.齿轮箱入口油温,
+        item.齿轮箱油温,
+        item.齿轮箱轴1温度,
+        item.齿轮箱轴2温度,
+      ]);
+
+      data.forEach((ele) => {
+        if (ele[1] == 0) {
+          ele[1] = '停机';
+        } else if (ele[1] == 1) {
+          ele[1] = '上电';
+        } else if (ele[1] == 2) {
+          ele[1] = '待机';
+        } else if (ele[1] == 3) {
+          ele[1] = '启动';
+        } else if (ele[1] == 4) {
+          ele[1] = '并网';
+        } else if (ele[1] == 5) {
+          ele[1] = '故障';
+        } else if (ele[1] == 6) {
+          ele[1]= '维护';
+        } else if (ele[1] == 7) {
+          ele[1] = '离线';
+        }
+      });
+      console.log("66 ", data);
+
+      const worksheet = XLSX.utils.aoa_to_sheet([headers, ...data]);
+      const workbook = XLSX.utils.book_new();
+      XLSX.utils.book_append_sheet(workbook, worksheet, "Sheet1");
+      // XLSX.writeFile(workbook, `${this.hanb}温度矩阵.xlsx`);
+       const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' })
+       this.saveAsExcelFile(excelBuffer, `${this.hanb}温度矩阵`)
+      // this.saveAsExcelFile()
+    },
+
+   saveAsExcelFile(buffer, fileName) {
+  const data = new Blob([buffer], { type: 'application/octet-stream' })
+   if (typeof window.navigator.msSaveBlob !== 'undefined') {
+    // IE10+
+    window.navigator.msSaveBlob(data, fileName + '.xlsx')
+  } else {
+    // Others
+    const url = window.URL.createObjectURL(data)
+    const link = document.createElement('a')
+    link.href = url
+    link.setAttribute('download', fileName + '.xlsx')
+    document.body.appendChild(link)
+    link.click()
+    document.body.removeChild(link)
+  }
+},
     /* 右键菜单 */
     contextmenu() {
       const remote = require("electron").remote;
@@ -526,8 +707,9 @@ export default {
         let val = msg.data[v];
         if (val.errorCode > 0) {
           iserror = true;
-          mss += `${val.windturbineId}  ${this.controlErorCodes[val.errorCode]
-            }\n`;
+          mss += `${val.windturbineId}  ${
+            this.controlErorCodes[val.errorCode]
+          }\n`;
         }
       }
       let tp = iserror ? "warning" : "success";
@@ -557,6 +739,7 @@ export default {
       });
     },
   },
+  
 };
 </script>
 <style lang="less" scoped>
@@ -657,4 +840,11 @@ export default {
   align-items: center;
   justify-content: center;
 }
+.bpickers {
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  justify-content: space-between;
+  margin-left: 20px;
+}
 </style>

+ 1 - 0
src/main.js

@@ -14,3 +14,4 @@ app.use(store)
 app.use(router)
 app.use(ElementPlus, { locale })
 app.mount('#app')
+