he wei
2022-11-13 b4816f6294646157b50bb49f1d19eaf306e0ac8c
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("文件解析失败");
        }
@@ -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>