he wei
2024-09-21 70edda3b00f2528a473c28ec5a50b739ed160f0f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<template>
  <div
    class="tbl-container dialog-table"
    v-loading="loading"
    element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.2)"
  >
    <flex-layout no-bg>
      <el-table :data="tblData" height="100%">
        <el-table-column
          v-for="item in tblHeader"
          :key="item.prop"
          :label="item.label"
          :prop="item.prop"
          align="center"
          :min-width="item.minWidth"
        ></el-table-column>
      </el-table>
      <div class="flex-page-footer" slot="footer">
        <div class="el-pagination-btns">
          <el-button
            type="primary"
            round
            size="mini"
            icon="el-icon-search"
            @click="searchData"
            >查询</el-button
          >
          <el-button
            type="primary"
            round
            size="mini"
            icon="el-icon-wallet"
            @click="ExportFile"
            >导出</el-button
          >
        </div>
      </div>
    </flex-layout>
  </div>
</template>
 
<script>
import { ExportFile } from "@/assets/js/tools/exportFile";
import ResLineContrast from "./resLineContrast";
import {
  historyResData
} from '../js/history';
// TODO
 
export default {
  components: { ResLineContrast },
  props: {
    batt: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      loading: false,
      acTabs: "tblData",
      tblHeader: [
        {
          label: "测试日期",
          prop: "time",
          minWidth: 180,
        },
      ],
      tblData: [],
    };
  },
  methods: {
    historyResData(id) {
      this.loading = true;
      historyResData(id)
        .then((res) => {
          res = res.data;
          this.loading = false;
          let list = [];
          if (res.data) {
            let data = res.data.list;
            let time = "";
            for (let i = 0; i < data.length; i++) {
              let item = data[i];
              if (time == item.testStartTime) {
                let tmp = list[list.length - 1];
                tmp.time = time;
                tmp["mon" + item.monNum] = item.monRes;
              } else {
                time = item.testStartTime;
                let tmp = {};
                tmp.time = time;
                tmp["mon" + item.monNum] = item.monRes;
                list.push(tmp);
              }
            }
          } else {
            this.$layer.msg(res.msg);
          }
          this.tblData = list;
        })
        .catch((error) => {
          this.loading = false;
          console.log(error);
        });
    },
    searchData() {
      let batt = this.batt;
      this.historyResData(batt.battGroupId);
    },
    ExportFile() {
      let batt = this.batt;
      let text = batt.stationName + "-" + batt.battGroupName + "-内阻信息";
      ExportFile(this.tblHeader, this.tblData, text);
    },
  },
  computed: {},
  mounted() {
    let batt = this.batt;
    let monCount = batt.monCount ? batt.monCount : 0;
    for (let i = 0; i < monCount; i++) {
      let temp = {
        label: "#" + (i + 1),
        prop: "mon" + (i + 1) + "1",
        minWidth: 80,
      };
      this.tblHeader.push(temp);
    }
 
    // 查询历史数据
    //this.historyResData(batt.battGroupId);
    this.searchData();
  },
};
</script>
 
<style scoped>
.tbl-container {
  height: 560px;
}
</style>