longyvfengyun
2023-12-25 d8d792a6842832e8f6af6604274c438b25053afe
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<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-tabs type="border-card" name="resTabs" v-model="acTabs" class="flex-layout noborder">
        <el-tab-pane name="line" label="曲线图">
          <res-line-contrast :active="acTabs" :update-time="timeStamp" :list="tblData"></res-line-contrast>
        </el-tab-pane>
        <el-tab-pane name="tblData" label="数据表格">
          <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-column
                fixed="right"
                label="操作"
                width="120"
                align="center">
              <template slot-scope="scope">
                <el-button @click="confirmUpdate(scope.row)" :type="scope.row.btnType" size="mini">{{ scope.row.isStandardText }}</el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-tab-pane>
      </el-tabs>
      <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 "@/pages/dataTest/components/resLineContrast";
 
export default {
  components: {ResLineContrast},
  props: {
    batt: {
      type: Object,
      default() {
        return {}
      }
    },
  },
  data() {
    return {
      loading: false,
      acTabs: "tblData",
      timeStamp: 0,
      tblHeader: [
        {
          label: '测试日期',
          prop: 'time',
          minWidth: 180
        }
      ],
      tblData: []
    }
  },
  methods: {
    historyResData(id) {
      this.loading = true;
      this.$apis.dataTest.history.historyResData(id).then(res=>{
        let rs = JSON.parse(res.data.result);
        this.loading = false;
        let list = [];
        if(rs.code == 1) {
          let data = rs.data;
          let time = "";
          for(let i=0; i<data.length; i++) {
            let item = data[i];
            if(time == item.test_starttime) {
              let tmp = list[list.length-1];
              tmp.time = time;
              tmp['mon'+item.mon_num] = item.mon_res;
              tmp.data.push(item.mon_res);
            }else {
              time = item.test_starttime;
              let tmp = {
                data: []
              };
              tmp.time = time;
              tmp['mon'+item.mon_num] = item.mon_res;
              tmp.isStandard = item.isStandard;
              tmp.isStandardText = tmp.isStandard?"标准内组值":"设置为标准";
              tmp.btnType = tmp.isStandard?"primary":"success";
              tmp.data.push(item.mon_res);
              list.push(tmp);
            }
          }
        }else {
          this.$layer.msg(rs.msg);
        }
        this.tblData = list;
        this.timeStamp = new Date().getTime();
      }).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);
    },
    confirmUpdate(data) {
      this.$confirm('此操作将修改基础内阻值, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(res=>{
        this.updateStandardRes(data);
      }).catch(error=>{});
    },
    // 更新标准内阻
    updateStandardRes(data) {
      let batt = this.batt;
      let params = {
        BattGroupId: batt.BattGroupId,
        test_starttime: data.time
      };
      this.loading = true;
      this.$apis.dataTest.history.updateStandardRes(params).then(res=>{
        this.loading = false;
        let rs = JSON.parse(res.data.result);
        if(rs.code == 1) {
          this.$layer.msg("设置成功!");
        }else {
          this.$layer.msg("设置失败!");
        }
        this.searchData();
      }).catch(error=>{
        this.$layer.msg("设置成功,请检测网络!");
        this.loading = false;
      });
    }
  },
  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.searchData();
  }
}
</script>
 
<style scoped>
.tbl-container {
  height: 560px;
}
</style>