From b4816f6294646157b50bb49f1d19eaf306e0ac8c Mon Sep 17 00:00:00 2001
From: he wei <858544502@qq.com>
Date: 星期日, 13 十一月 2022 22:06:22 +0800
Subject: [PATCH] UA 0.1.4发布

---
 src/pages/xmlResult.vue |  237 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 207 insertions(+), 30 deletions(-)

diff --git a/src/pages/xmlResult.vue b/src/pages/xmlResult.vue
index 2e1baa7..09737dd 100644
--- a/src/pages/xmlResult.vue
+++ b/src/pages/xmlResult.vue
@@ -41,6 +41,7 @@
             <el-table
               :data="tableData"
               style="width: 100%"
+              ref="table"
               :default-sort="{ prop: 'date', order: 'descending' }"
               stripe
               size="small"
@@ -76,15 +77,39 @@
       @toggleLabel="toggleLabel"
       @updateChart="updateChart"
     ></chart-context-menu>
+    <!-- 鏂囦欢灞炴�� -->
+    <el-dialog
+      title="灞炴��"
+      class="file-info"
+      :visible.sync="fileInfoVisible"
+      append-to-body
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      :show-close="false"
+      width="800px"
+    >
+      <file-info v-if="fileInfoVisible" :info="fileData" @ok="editOk" @quit="quit"></file-info>
+    </el-dialog>
   </div>
 </template>
 
 <script>
+import FileInfo from "@/components/fileInfo";
 import NormalBar from "@/components/myCharts/NormalBar";
 import ChartContextMenu from "@/components/chartContextMenu";
 import offset from "@/assets/js/offset";
 import { mapGetters } from "vuex";
-import { getXmlValue, testReport, getInfoByFileId } from "@/apis";
+import { Loading } from 'element-ui';
+import {
+  getXmlValue,
+  testReport,
+  getInfoByFileId,
+  getParamByFileId,
+  updateFileParam,
+} from "@/apis";
+import { toFixed } from "@/assets/js/util";
+// 淇濈暀涓変綅灏忔暟
+const BIT = 3;
 
 export default {
   name: "",
@@ -137,12 +162,15 @@
       ],
     };
     return {
+      fileInfoVisible: false,
+      fileData: {},
+      tmpParams: null,
       stdDevBr: "",
       stdDevBs: "",
       stdDevBv: "",
       stdDevCr: "",
-      resPic: '',
-      volPic: '',
+      resPic: "",
+      volPic: "",
       fileParam: undefined,
       stationInfo: undefined,
       marks,
@@ -170,7 +198,7 @@
         },
         {
           prop: "cr",
-          label: "杩炴帴鏉�(m惟)",
+          label: "杩炴帴鏉�(渭惟)",
           minWidth: 120,
         },
         {
@@ -191,6 +219,7 @@
   components: {
     NormalBar,
     ChartContextMenu,
+    FileInfo,
   },
   computed: {
     ...mapGetters("setting", [
@@ -216,7 +245,7 @@
         xLabel.push("#" + v.monNum);
         resData.push(v.br);
         volData.push(v.bv);
-        condData.push(v.cr);
+        condData.push(v.bs);
         // capData.push() TODO
         chainData.push(v.cr);
         tableData.push({ ...v, monNum: "#" + v.monNum });
@@ -286,17 +315,46 @@
             chainResCoeK5,
             resBadCoeK4,
             resGoodCoeK3,
-            volHighCoeK2,
-            volLowCoeK1,
+            vol2HighCoeK2,
+            vol2LowCoeK1,
+            vol12HighCoeK2,
+            vol12LowCoeK1,
           } = this.params;
 
-          this.marks.resVisiable[0].y = resGoodCoeK3 * fileParam.battRes;
-          this.marks.resVisiable[1].y = resBadCoeK4 * fileParam.battRes;
+          this.marks.resVisiable[0].y = toFixed(
+            resGoodCoeK3 * fileParam.battRes / 100,
+            BIT
+          );
+          this.marks.resVisiable[1].y = toFixed(
+            resBadCoeK4 * fileParam.battRes / 100,
+            BIT
+          );
+          if (2 == fileParam.battVol) {
+            this.marks.volVisiable[0].y = toFixed(
+              vol2HighCoeK2,
+              BIT
+            );
+            this.marks.volVisiable[1].y = toFixed(
+              vol2LowCoeK1,
+              BIT
+            );
+          } else if (12 == fileParam.battVol) {
+            this.marks.volVisiable[0].y = toFixed(
+              vol12HighCoeK2,
+              BIT
+            );
+            this.marks.volVisiable[1].y = toFixed(
+              vol12LowCoeK1,
+              BIT
+            );
+          } else {
+            this.marks.volVisiable = [];
+          }
 
-          this.marks.volVisiable[0].y = volHighCoeK2 * fileParam.battVol;
-          this.marks.volVisiable[1].y = volLowCoeK1 * fileParam.battVol;
-
-          this.marks.chainVisiable[0].y = chainResCoeK5 * fileParam.chainRes;
+          this.marks.chainVisiable[0].y = toFixed(
+            chainResCoeK5 * fileParam.chainRes / 100,
+            BIT
+          );
 
           this.list = data.dataList;
 
@@ -306,8 +364,9 @@
           this.stdDevCr = data2.stdDevCr;
           this.fileParam = fileParam;
           this.stationInfo = data.stationInfo;
-
-          this.initChart();
+          this.$nextTick(() => {
+            this.initChart();
+          });
         } else {
           this.$message.error("鏌ヨ鏁版嵁澶辫触");
         }
@@ -321,36 +380,70 @@
         const { code, data, data2 } = res.data;
         if (code && data) {
           // console.log(data2, "====d");
-          let fileParam = data2.fileParam;
+          this.fileData = this.tmpParams || data2.fileParam;
+          let fileParam = this.fileData;
 
           const {
             chainResCoeK5,
             resBadCoeK4,
             resGoodCoeK3,
-            volHighCoeK2,
-            volLowCoeK1,
+            vol2HighCoeK2,
+            vol2LowCoeK1,
+            vol12HighCoeK2,
+            vol12LowCoeK1,
           } = this.params;
 
-          this.marks.resVisiable[0].y = resGoodCoeK3 * fileParam.battRes;
-          this.marks.resVisiable[1].y = resBadCoeK4 * fileParam.battRes;
+          this.marks.resVisiable[0].y = toFixed(
+            resGoodCoeK3 * fileParam.battRes / 100,
+            BIT
+          );
+          this.marks.resVisiable[1].y = toFixed(
+            resBadCoeK4 * fileParam.battRes / 100,
+            BIT
+          );
+          if (2 == fileParam.battVol) {
+            this.marks.volVisiable[0].y = toFixed(
+              vol2HighCoeK2,
+              BIT
+            );
+            this.marks.volVisiable[1].y = toFixed(
+              vol2LowCoeK1,
+              BIT
+            );
+          } else if (12 == fileParam.battVol) {
+            this.marks.volVisiable[0].y = toFixed(
+              vol12HighCoeK2,
+              BIT
+            );
+            this.marks.volVisiable[1].y = toFixed(
+              vol12LowCoeK1,
+              BIT
+            );
+          } else {
+            this.marks.volVisiable = [];
+          }
 
-          this.marks.volVisiable[0].y = volHighCoeK2 * fileParam.battVol;
-          this.marks.volVisiable[1].y = volLowCoeK1 * fileParam.battVol;
-
-          this.marks.chainVisiable[0].y = chainResCoeK5 * fileParam.chainRes;
+          this.marks.chainVisiable[0].y = toFixed(
+            chainResCoeK5 * fileParam.chainRes / 100,
+            BIT
+          );
 
           this.list = data2.battInfoList[0].battDataList;
           let columns = ["", "bv", "br", "cr", "bs"].map((v) => ({
             property: v,
           }));
-          let [a, stdDevBv, stdDevBr, stdDevCr, stdDevBs] =
-            this.summaryMethod({ columns, data: this.list });
+          let [a, stdDevBv, stdDevBr, stdDevCr, stdDevBs] = this.summaryMethod({
+            columns,
+            data: this.list,
+          });
           this.stdDevBr = stdDevBr;
           this.stdDevBs = stdDevBs;
           this.stdDevBv = stdDevBv;
           this.stdDevCr = stdDevCr;
           this.fileParam = fileParam;
-          this.initChart();
+          this.$nextTick(() => {
+            this.initChart();
+          });
         } else {
           this.$message.error("鏂囦欢瑙f瀽澶辫触");
         }
@@ -393,6 +486,11 @@
           this.volPic = chart[0].getDataURL();
         }
       });
+      this.$nextTick(() => {
+        if (this.$refs.table[0]) {
+          this.$refs.table[0].doLayout();
+        }
+      });
     },
     resize() {
       this.$nextTick(() => {
@@ -403,6 +501,9 @@
           }
           chart[0].resize();
         });
+        if (this.$refs.table[0]) {
+          this.$refs.table[0].doLayout();
+        }
       });
     },
     chartContextClick($e, item) {
@@ -522,11 +623,75 @@
         this.resize();
       });
     },
-    exportReport() {
-      // console.log(this, 'export')
-      if (this._directInactive) {
+    editOk(data) {
+      // 涓存椂鏂囦欢涓嶄慨鏀�
+      if (!this.fileId) {
+        this.tmpParams = data;
+        this.refreshPage();
+        this.fileInfoVisible = false;
         return false;
       }
+      updateFileParam(this.fileId, data).then((res) => {
+        const { code, data } = res.data;
+        if (code && data) {
+          this.$message.success("淇敼鎴愬姛");
+          this.refreshPage();
+          this.fileInfoVisible = false;
+        } else {
+          this.$message.error("淇敼澶辫触");
+        }
+      });
+    },
+    quit() {
+      this.fileInfoVisible = false;
+    },
+    viewProp() {
+      if (this._isDestroyed || this._directInactive) {
+        return false;
+      }
+      if (!this.fileId) {
+        const params = {
+          filePath: this.fileUrl,
+        };
+        getXmlValue(params).then((res) => {
+          const { code, data, data2 } = res.data;
+          if (code && data) {
+            // console.log(data2, "====d");
+            this.fileData = data2.fileParam;
+            this.fileInfoVisible = true;
+          } else {
+            this.$message.error("璇诲彇鏂囦欢澶辫触");
+          }
+        });
+        return false;
+      }
+      getParamByFileId(this.fileId).then((res) => {
+        const { code, data, data2 } = res.data;
+        if (code && data) {
+          this.fileData = data2;
+          this.fileInfoVisible = true;
+        } else {
+          this.$message.error("鑾峰彇鍙傛暟澶辫触");
+        }
+      });
+    },
+    refreshPage(force) {
+      if (!force && (this._isDestroyed || this._directInactive)) {
+        return false;
+      }
+      this.getWindowList();
+      if (this.fileId) {
+        this.getInfoByFileId();
+      } else {
+        this.getFileInfo();
+      }
+    },
+    exportReport() {
+      if (this._isDestroyed || this._directInactive) {
+        return false;
+      }
+      let loading = Loading.service({ fullscreen: true });
+      // console.log(111,this._isDestroyed, this._directInactive, 'export')
       const {
         resPic,
         volPic,
@@ -551,12 +716,14 @@
       };
       testReport(params).then((res) => {
         let { headers, data, status } = res;
+        loading.close();
         if (200 == status && data) {
           let url = window.URL.createObjectURL(data);
           const matchRes = /filename=(.*)/.exec(headers["content-disposition"]);
           const fileName = matchRes
             ? decodeURI(matchRes[1].trim())
             : "鏈煡鏂囦欢鍚�.xls";
+          
           let link = document.createElement("a");
           link.style.display = "none";
           link.href = url;
@@ -580,10 +747,20 @@
     } else {
       this.getFileInfo();
     }
+    if (this.$route.query.params) {
+      this.tmpParams = this.$route.query.params;
+    }
     this.addListener();
     this.$bus.$on("checkScroll", this.resize);
     this.$bus.$on("chartResize", this.resize);
     this.$bus.$on("export", this.exportReport);
+    this.$bus.$on("viewProp", this.viewProp);
+    this.$bus.$on("paramsUpdated", () => {
+      this.refreshPage(true);
+    });
+    this.$bus.$on("windowConfigChanged", () => {
+      this.refreshPage(true);
+    });
   },
 };
 </script>

--
Gitblit v1.9.1