whychdw
2020-08-29 02d848bf39005e83882a87f8bc322d8499b92fbc
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<template>
  <flex-layout direction="row" class="page-real-time">
    <home-list slot="header" @toggleChange="toggleChange" @leaf-click="leafClick"></home-list>
    <content-box style="margin-left: 4px; margin-right: 4px;" :title="battFullName">
      <flex-layout>
        <div class="content-header" slot="header" :model="inputs">
          <div class="table-layout">
            <div class="table-row">
              <div class="table-cell text-right w80">电池状态:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_state" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">端电压:</div>
              <div class="table-cell">
                <el-input :value="backInputs.group_online_vol" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">电池电流:</div>
              <div class="table-cell">
                <el-input :value="backInputs.group_curr" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">更新日期:</div>
              <div class="table-cell">
                <el-input :value="backInputs.rec_datetime" size="small" :disabled="true"></el-input>
              </div>
            </div>
            <div class="table-row">
              <div class="table-cell text-right w80">测试时长:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_test_tlong" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">测试容量:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_test_cap" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">剩余容量:</div>
              <div class="table-cell">
                <el-input :value="backInputs.batt_syrl_cap" size="small" :disabled="true"></el-input>
              </div>
              <div class="table-cell text-right w80">续航时长:</div>
              <div class="table-cell">
                <el-input :value="backInputs.sysc" size="small" :disabled="true"></el-input>
              </div>
            </div>
          </div>
        </div>
        <div class="page-content">
          <el-tabs v-model="acTabs" type="border-card" class="flex-layout" @tab-click="tabClick">
            <!-- <el-tab-pane label="电路拓扑图" name="eleLine">
                            电路拓扑图
            </el-tab-pane>-->
            <el-tab-pane label="电压" name="vol">
              <bar-chart ref="vol" id="vol" unit="V"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="内阻" name="res">
              <bar-chart ref="res" id="res" unit="mΩ"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="温度" name="temp">
              <bar-chart ref="temp" id="temp" unit="℃"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="电导" name="conduct">
              <bar-chart ref="conduct" id="conduct"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="均衡电流" name="curr">
              <bar-chart ref="curr" id="curr"></bar-chart>
            </el-tab-pane>
            <el-tab-pane label="数据表格" name="tblData">
              <el-table border size="small" :data="table.datas" height="100%">
                <el-table-column
                  v-for="header in table.headers"
                  :key="header.prop"
                  :prop="header.prop"
                  :label="header.label"
                  :width="header.width"
                  align="center"
                ></el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </div>
      </flex-layout>
    </content-box>
  </flex-layout>
</template>
 
<script>
import ContentBox from "../../components/ContentBox";
import HomeList from "./HomeList";
import BarChart from "../../components/chart/BarChart";
 
import { realTimeSearch, realTimeGroup } from "../../assets/js/realTime";
let vol, res, temp, conduct, curr;
export default {
  components: {
    ContentBox,
    HomeList,
    BarChart
  },
  data() {
    return {
      /* 电池状态 模块 组端展示 */
      inputs: {
        group_vol: 0 /* 端电压-组端电压 */,
        online_vol: 0 /* 端电压-在线电压 */,
        group_curr: 0 /* 电池电流 */,
        batt_test_tlong: "0:00:00" /* 测试时长 */,
        rec_datetime: 0 /* 更新日期 */,
        batt_test_cap: 0 /* 测试容量 */,
        batt_state: 0 /* 电池状态 */
      },
      battFullName: "电池组全称",
      acTabs: "vol",
      table: {
        headers: [
          {
            prop: "num1",
            label: "单体编号",
            width: ""
          },
          {
            prop: "vol1",
            label: "电压(V)",
            width: ""
          },
          {
            prop: "res1",
            label: "内阻(mΩ)",
            width: ""
          },
          {
            prop: "temp1",
            label: "温度(℃)",
            width: ""
          },
          {
            prop: "conduct1",
            label: "电导",
            width: ""
          },
          {
            prop: "curr1",
            label: "均衡电流",
            width: ""
          }
        ],
        datas: [
          {
            num1: 0,
            vol1: 0,
            res1: 0,
            temp1: 0,
            conduct1: 0,
            curr1: 0
          }
        ]
      },
      batt: {}
    };
  },
  methods: {
    tabClick(tab) {
      this.$nextTick(() => {
        this.$G.chartManage.resize(tab.name);
      });
    },
    toggleChange() {
      this.resize();
    },
    resize() {
      this.$G.chartManage.resize(this.acTabs);
    },
    initChart() {
      // 电压
      vol = {
        title: {
          show: true,
          text: "最大值=0V;最小值=0V;平均值=0V;累加和=0V",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "电压",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 内阻
      res = {
        title: {
          show: true,
          text: "最大值=0mΩ;最小值=mΩ;平均值=0mΩ",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "内阻",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 温度
      temp = {
        title: {
          show: true,
          text: "最大值=0℃;最小值=0℃;平均值=0℃",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "温度",
            type: "bar",
            data: []
          }
        ]
      };
 
      // 电导
      conduct = {
        title: {
          show: true,
          text: "最大值=0;最小值=0;平均值=0",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "电导",
            type: "bar",
            data: []
          }
        ]
      };
      // 均衡电流
      curr = {
        title: {
          show: true,
          text: "最大值=0mA;最小值=0mA;平均值=0mA",
          x: "center",
          textStyle: {
            fontSize: "14"
          }
        },
        series: [
          {
            name: "均衡电流",
            type: "bar",
            data: []
          }
        ]
      };
      // 设置配置项
      this.setChart();
    },
    setChart() {
      this.$refs.vol.setOption(vol);
      this.$refs.res.setOption(res);
      this.$refs.temp.setOption(temp);
      this.$refs.conduct.setOption(conduct);
      this.$refs.curr.setOption(curr);
    },
    leafClick(data) {
      this.batt = data;
      /*   console.log('this.batt',this.batt); */
 
      this.realTimeGroupss();
      this.realTimeSearch();
    },
    /* 实时组端信息 */
    realTimeGroupss() {
      var batt = this.batt;
      realTimeGroup(batt.BattGroupId).then(res => {
        let rsa = JSON.parse(res.data.result);
        /*   console.log("rsa", rsa); */
        this.inputs = rsa.data[0];
        console.log("this.inputs", this.inputs);
      });
    },
 
    /* echars图表 */
    realTimeSearch() {
      var batt = this.batt;
      realTimeSearch({
        BattGroupId: batt.BattGroupId
      }).then(res => {
        let rs = JSON.parse(res.data.result);
        /*   console.log("rs", rs); */
 
        /* 数据表格 */
        if (rs.code == 1) {
          this.vovo = rs.data.map(item => {
            return {
              num1: "#" + item.mon_num,
              vol1: item.mon_vol,
              res1: item.mon_res,
              temp1: item.mon_tmp
            };
          });
        }
        this.table.datas = this.vovo;
 
        // 电压值
        let volTempVol = [];
        if (rs.code == 1) {
          volTempVol = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_vol];
          });
        }
        vol.series[0].data = volTempVol;
 
        // 内阻
        /*     let volTempres = [];
        if (rs.code == 1) {
          volTempres = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_res];
          });
        }
        res.series[0].data = volTempres; */
 
        // 温度
        let volTempte = [];
        if (rs.code == 1) {
          volTempte = rs.data.map(item => {
            return ["#" + item.mon_num, item.mon_tmp];
          });
        }
 
        temp.series[0].data = volTempte;
 
        // 更新电压图表
        this.$refs.vol.setOption(vol);
        this.$refs.res.setOption(res);
        this.$refs.temp.setOption(temp);
      });
    },
    // 计算续航时长方法  顶部组端
    sethoubeiTime(value) {
      value = Math.abs(value);
      var str = "";
      if (value > 0) {
        var hour = parseInt(value);
        var min = parseInt((parseFloat(value) - hour) * 60);
        if (hour < 10) {
          str = "0";
        }
        str += hour + "H";
        if (min < 10) {
          str += "0";
        }
        str += min + "M";
      } else {
        str = "00H00M";
      }
      return str;
    }
  },
  computed: {
    backInputs() {
      const obj = {
          0: "未知",
          1: "浮充",
          2: "充电",
          3: "放电",
          4: "均充"
        },
        list = {};
      list.batt_state = obj[this.inputs.batt_state];
      list.group_online_vol = `在线:${this.inputs.online_vol.toFixed(
        2
      )}V;组端:${this.inputs.group_vol.toFixed(2)}V`;
      list.group_curr = this.inputs.group_curr.toFixed(2) + "A";
      list.rec_datetime = this.inputs.rec_datetime;
      list.batt_test_tlong = this.inputs.batt_test_tlong;
 
      list.batt_test_cap = this.inputs.batt_test_cap.toFixed(1) + "Ah";
      if (this.inputs.batt_state === 2) {
        list.batt_syrl_cap = "---";
      } else {
        list.batt_syrl_cap = this.inputs.batt_test_cap.toFixed(1) + "Ah";
      }
      if (this.inputs.batt_state === 3) {
        list.sysc = this.sethoubeiTime(
          parseFloat(this.inputs.batt_rest_cap) /
            parseFloat(this.inputs.group_curr)
        );
      } else {
        list.sysc = "------";
      }
      return list;
    }
  },
  mounted() {
    // 初始化图表
    this.initChart();
 
    this.$nextTick(() => {
      this.$G.chartManage.resize(this.acTabs);
    });
    // 向父组件通信
    window.parent.postMessage({kk:1}, "*")
 
    // 屏幕缩放时触发
    window.addEventListener("resize", () => {
      this.resize();
    });
  }
};
</script>
 
<style scoped>
.page-real-time {
  color: #ffffff;
}
.table-cell.text-right {
  font-size: 14px;
}
.table-row .table-cell {
  padding-top: 12px;
}
.page-content {
  padding-top: 8px;
  padding-bottom: 2px;
  box-sizing: border-box;
  height: 100%;
}
</style>