whychdw
2019-12-09 064c6d5b84fd6ddbbe4c20c41d139f7371460985
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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
<template>
    <div class="view-root">
        <div class="view-root-inner">
            <div class="view-layout">
                <div class="view-layout-left">
                    <science-card width="100%" height="100%">
                        <home-tree @on-select-change="handlerSelectChange"></home-tree>
                    </science-card>
                </div>
                <div class="view-layout-right">
                    <science-card width="100%" height="100%">
                        <Spin size="large" fix v-if="spinShow">
                            <Icon type="ios-loading" size=18 class="demo-spin-icon-load"></Icon>
                            <div>加载中...</div>
                        </Spin>
                        <content-title :title="contentTitle"></content-title>
                        <square-box style="margin: 8px" title="实时数据图谱" icon="ios-podium">
                            <Tabs value="monVol" class="ivu-tabs-yellow" name="controlTabs" @on-click="handlerTabClick">
                                <TabPane label="电压" name="monVol" tab="controlTabs">
                                    <bar-chart height="400px" ref="monVolBar" :show-value=true :range="{'min': 0,'max': 1}"></bar-chart>
                                </TabPane>
                                <TabPane label="内阻" name="monRes" tab="controlTabs">
                                    <bar-chart height="400px" ref="monResBar" :show-value=true :range="{'min': 0,'max': 1}"></bar-chart>
                                </TabPane>
                                <TabPane label="温度" name="monTmp" tab="controlTabs">
                                    <bar-chart height="400px" ref="monTmpBar" :colors="{normal: '#5cadff',max: '#ed4014',min: '#19be6b',}" :show-value=true :range="{'min': 0,'max': 1}"></bar-chart>
                                </TabPane>
                                <TabPane label="电导" name="monSer" tab="controlTabs">
                                    <bar-chart height="400px" ref="monSerBar" :show-value=true :range="{'min': 0,'max': 1}"></bar-chart>
                                </TabPane>
                            </Tabs>
                        </square-box>
                        <table style="width: 99%; vertical-align: top">
                            <tr>
                                <td valign="top">
                                    <div style="width: 300px"></div>
                                    <square-box style="margin: 8px;" minHeight="220px" title="机房基础信息">
                                        <table style="color: #468FB6;">
                                            <tr>
                                                <td>电池状态:</td>
                                                <td>{{rtState.ele_state}}</td>
                                            </tr>
                                            <tr>
                                                <td>组端电压:</td>
                                                <td>{{rtState.ele_tension}}</td>
                                            </tr>
                                            <tr>
                                                <td>电池电流:</td>
                                                <td>{{rtState.ele_current}}</td>
                                            </tr>
                                            <tr>
                                                <td>更新日期:</td>
                                                <td>{{rtState.test_date}}</td>
                                            </tr>
                                            <tr>
                                                <td>测试时长:</td>
                                                <td>{{rtState.test_time}}</td>
                                            </tr>
                                            <tr>
                                                <td>测试容量:</td>
                                                <td>{{rtState.test_content}}</td>
                                            </tr>
                                            <tr>
                                                <td>剩余容量:</td>
                                                <td>{{rtState.over_content}}</td>
                                            </tr>
                                            <tr>
                                                <td>续航时长:</td>
                                                <td>{{rtState.reserve_time}}</td>
                                            </tr>
                                        </table>
                                    </square-box>
                                </td>
                                <td valign="top">
                                    <square-box style="margin: 8px" minHeight="220px" title="图谱数据信息" icon="md-grid">
                                        <Table border :columns="tbl.columns" :data="tbl.data" height="215"></Table>
                                    </square-box>
                                </td>
                            </tr>
                        </table>
                    </science-card>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import ScienceCard from '../../components/ScienceCard'
import HomeTree from "../../components/HomeTree"
import ContentTitle from "../../components/ContentTitle"
import BarChart from "../../components/BarChart"
import {ajax, formatSeconds, sethoubeiTime, 
        Timeout, getMaxFromArr, getMinFromArr, 
        Title, getSumFromArr, getAvgFromArr} from "../../libs/common"
import {getBattstate, BTSCircle} from '../../assets/js/battInfo'
import $ from 'jquery'
import echarts from "echarts"
import SquareBox from "../../components/SquareBox"
import { setTimeout } from 'timers';
export default {
    components: {
        ScienceCard,
        HomeTree,
        SquareBox,
        ContentTitle,
        BarChart,
    },
    data() {
        return {
            batt: {},       // 电池组信息
            alarmlist: [],   // 电池告警参数
            contentTitle: '机房信息', // 主题内容的标题 
            rtDataTime: new Timeout(),        // 实时数据计时器
            rtStateTime: new Timeout(),       // 实时状态计时器
            spinShow: false,
            activeTab: 'monVol',
            mygraph: {
                battstate:0,
                graphtype:0,            //拓扑图类型    0->浮充       1->放电       2->稳流(限流)充电     3->直流(直连)充电        4->未知(未连接)
                group_vol:"0V",            //组端电压值
                online_vol:"0V",            //在线电压值
                ischange:1,                //是否重新绘制,        0:不需要重新绘制              1:需要重新绘制
            },
            rtState: {
                ele_state: '未知',
                ele_tension: '在线:??V;组端:??V',
                ele_current: '??A',
                test_date: 'yyyy-MM-dd HH:mm:ss',
                test_time: 'HH:mm:ss',
                test_content: '??AH',
                over_content: '??AH',
                reserve_time: '------'
            },
            options: {
                monVol:{    // 单体电压
                    title: new Title(),
                    option: {
                        title: {
                            subtext: '',
                            x: 'center',
                        },
                        xAxis: {
                            type: 'category',
                            data: []
                        },
                        yAxis: {
                            type: 'value',
                            name: '单位(V)',
                            min: 0,
                            max: 10
                        },
                        series: [{
                            name: '电压',
                            type: 'bar',
                            data: []
                        }]
                    }
                },
                monRes: {   // 单体内阻
                    title: new Title(),
                    option: {
                        title: {
                            subtext: '',
                            x: 'center',
                        },
                        xAxis: {
                            type: 'category',
                            data: []
                        },
                        yAxis: {
                            type: 'value',
                            name: '单位(mΩ)',
                            min: 0,
                            max: 10
                        },
                        series: [{
                            name: '内阻',
                            type: 'bar',
                            data: []
                        }]
                    }
                },
                monTmp: {   // 单体内阻
                    title: new Title(),
                    option: {
                        title: {
                            subtext: '',
                            x: 'center',
                        },
                        xAxis: {
                            type: 'category',
                            data: []
                        },
                        yAxis: {
                            type: 'value',
                            name: '单位(℃)',
                            min: 0,
                            max: 10
                        },
                        series: [{
                            name: '温度',
                            type: 'bar',
                            data: []
                        }]
                    }
                },
                monSer: {   // 单体内阻
                    title: new Title(),
                    option: {
                        title: {
                            subtext: '',
                            x: 'center',
                        },
                        xAxis: {
                            type: 'category',
                            data: []
                        },
                        yAxis: {
                            type: 'value',
                            min: 0,
                            max: 10
                        },
                        series: [{
                            name: '电导',
                            type: 'bar',
                            data: []
                        }]
                    }
                }
            },
            tbl:{
                columns:[],
                data: []
            },
            tblDatas:{
                monVol: [],
                monRes: [],
                monSer: [],
                monTmp: [],
            }
        }
    },
    methods: {
        getBatt: function() {
            return this.batt;
        },
        handlerTabClick: function(name) {
            this.activeTab = name;
            var batt = this.getBatt();
            this.setTbl();
        },
        setTbl: function() {        // 设置显示表格的数据
            var name = this.activeTab;
            var tblDatas = this.tblDatas;
            var columns = {
                monVol: [       // 单体电压
                    {
                        title: '编号',
                        key: 'num1'
                    },
                    {
                        title: '电压(V)',
                        key: 'num2'
                    },
                    {
                        title: '编号',
                        key: 'num3'
                    },
                    {
                        title: '电压(V)',
                        key: 'num4'
                    },
                    {
                        title: '编号',
                        key: 'num5'
                    },
                    {
                        title: '电压(V)',
                        key: 'num6'
                    },
                    {
                        title: '编号',
                        key: 'num7'
                    },
                    {
                        title: '电压(V)',
                        key: 'num8'
                    },
                ],
                monRes: [       // 单体电压
                    {
                        title: '编号',
                        key: 'num1'
                    },
                    {
                        title: '内阻(mΩ)',
                        key: 'num2'
                    },
                    {
                        title: '编号',
                        key: 'num3'
                    },
                    {
                        title: '内阻(mΩ)',
                        key: 'num4'
                    },
                    {
                        title: '编号',
                        key: 'num5'
                    },
                    {
                        title: '内阻(mΩ)',
                        key: 'num6'
                    },
                    {
                        title: '编号',
                        key: 'num7'
                    },
                    {
                        title: '内阻(mΩ)',
                        key: 'num8'
                    },
                ],
                monTmp: [       // 单体温度
                    {
                        title: '编号',
                        key: 'num1'
                    },
                    {
                        title: '温度(℃)',
                        key: 'num2'
                    },
                    {
                        title: '编号',
                        key: 'num3'
                    },
                    {
                        title: '温度(℃)',
                        key: 'num4'
                    },
                    {
                        title: '编号',
                        key: 'num5'
                    },
                    {
                        title: '温度(℃)',
                        key: 'num6'
                    },
                    {
                        title: '编号',
                        key: 'num7'
                    },
                    {
                        title: '温度(℃)',
                        key: 'num8'
                    },
                ],
                monSer: [       // 单体温度
                    {
                        title: '编号',
                        key: 'num1'
                    },
                    {
                        title: '电导',
                        key: 'num2'
                    },
                    {
                        title: '编号',
                        key: 'num3'
                    },
                    {
                        title: '电导',
                        key: 'num4'
                    },
                    {
                        title: '编号',
                        key: 'num5'
                    },
                    {
                        title: '电导',
                        key: 'num6'
                    },
                    {
                        title: '编号',
                        key: 'num7'
                    },
                    {
                        title: '电导',
                        key: 'num8'
                    },
                ],
            };
            var column = [];
            var data = [];
            switch(name){
                case 'monVol':      // 单体电压
                  column = columns.monVol;
                  data = $.extend(true, [], tblDatas.monVol);
                break;
                case 'monRes':      // 单体内阻
                    column = columns.monRes;
                    data = $.extend(true, [], tblDatas.monRes); 
                break;
                case 'monTmp':   // 单体温度
                    column = columns.monTmp;   
                    data =  $.extend(true, [], tblDatas.monTmp);
                break; 
                case 'monSer':  // 单体电导
                    column = columns.monSer;   
                    data =  $.extend(true, [], tblDatas.monSer);
                break; 
            }
            // console.log(column);
            this.tbl.columns = column;
            this.tbl.data = data;
        },
        handlerSelectChange: function(item) {   // 处理左侧机房列表点击事件
            var self = this;
            if(item.type == 'group') {
                this.batt = item;
                this.searchBattAlarmParam();        //查询并存储电池告警参数
                this.setContentTitle();             // 设置内容的标题
                this.spinShow = true;               // 切换显示加载等待框
                this.rtDataTime.start(function() {
                    self.searchRtData();
                }, 4000);                // 查询实时的信息
 
                this.rtStateTime.start(function() {
                    self.searchRtState();
                }, 4000);               // 查询实时状态
            }
        },
        setContentTitle: function() {   // 设置内容的标题
            var batt = this.batt;
            this.contentTitle = batt.StationName+'-'+batt.BattGroupName+'-标称容量'+batt.MonCapStd+'AH';
        },
        searchBattAlarmParam: function() {      //查询并存储电池告警参数
            var batt = this.batt;
            if(!batt.BattGroupId) {
                this.$Message.error('请先选择电池组');
                return;
            }
            var temp = {
                dev_id: batt.FBSDeviceId,
            };
            // 请求后台 获取电池告警参数
            ajax({     
                type:"post",                 
                url: "Dev_paramAction!serchParamById",            
                async:true,            
                dataType:'json',
                data:"json="+JSON.stringify(temp),    
                success: function(res){
                    var rs = JSON.parse(res.result);
                    if(rs.code == 1) {
                        this.alarmlist = rs.data;
                    }
                }
            });
        },
        getAlarmParamByType: function(type) {       // 根据告警类型获取告警参数
            var alarmlist = this.alarmlist;
            // 遍历alarmlist,根据type返回参数
            for(var i=0;i<alarmlist.length;i++){
                if(alarmlist[i].alm_name == type){
                    return alarmlist[i];
                }
            }
            return new Object();
        },
        searchRtData: function() {    // 查询电池组实时信息
            var self = this;
            var batt = this.getBatt();
            if(!batt.BattGroupId) {
                return;
            }
            var temp = {
                BattGroupId: batt.BattGroupId,
            };
            // 请求后台 获取电池组实时信息
            ajax({
                type:"post",                 
                url: "Batt_rtdataAction_serchByCondition",            
                async: true,            
                dataType: 'json',
                data: "json="+JSON.stringify(temp),
                success: function(res) {
                    self.spinShow = false;      // 关闭容器加载等待框
                    var rs = JSON.parse(res.result);
                    if(rs.code == 1) {
                        var data = rs.data;
                        // console.log(data);
                        self.formatData(data);
                        // 开启计时器
                        self.rtDataTime.open();
                    }
                }
            });
        },
        formatData: function(Rtdatalist) {
            var mon_vol_table_list = new Array();            //电压
            var mon_tmp_table_list = new Array();            //温度
            var mon_res_table_list = new Array();            //内阻
            var mon_ser_table_list = new Array();            //电导
            var mon_jh_table_list = new Array();            //均衡电流
        
            var mon_res_list=new Array();
            var mon_vol_list=new Array();
            var mon_ser_list=new Array();
            var mon_tmp_list=new Array();
            var mon_num_list=new Array();
            var mon_conn_list=new Array();
            var mon_serpcent_list=new Array();
            var mon_jh_list = new Array();
            var batt = this.getBatt();
            // console.info(Rtdatalist);
            for(var i=0;i<Rtdatalist.length;i++){
                mon_vol_table_list.push("#"+Rtdatalist[i].mon_num);
                mon_vol_table_list.push(Rtdatalist[i].mon_vol.toFixed(3));
                mon_tmp_table_list.push("#"+Rtdatalist[i].mon_num);
                mon_tmp_table_list.push(Rtdatalist[i].mon_tmp.toFixed(1));
                mon_res_table_list.push("#"+Rtdatalist[i].mon_num);
                mon_res_table_list.push(Rtdatalist[i].mon_res.toFixed(3));
                mon_jh_table_list.push("#"+Rtdatalist[i].mon_num);
                mon_jh_table_list.push(Rtdatalist[i].mon_JH_curr.toFixed(3));
                if(Rtdatalist[i].mon_res > 0){
                    var ser_value = ((1/Rtdatalist[i].mon_res)*1000).toFixed(0);
                    mon_ser_table_list.push("#"+Rtdatalist[i].mon_num);
                    mon_ser_table_list.push(ser_value);
                    mon_ser_list[i]=ser_value;
                }else{                
                    mon_ser_table_list.push("#"+Rtdatalist[i].mon_num);
                    mon_ser_table_list.push(Rtdatalist[i].mon_ser.toFixed(0));
                    mon_ser_list[i]=Rtdatalist[i].mon_ser.toFixed(0);
                }
            
                mon_res_list[i]=Rtdatalist[i].mon_res.toFixed(3);
                mon_vol_list[i]=Rtdatalist[i].mon_vol.toFixed(3);
                mon_tmp_list[i]=Rtdatalist[i].mon_tmp.toFixed(1);
                //console.info(Rtdatalist);
                mon_serpcent_list[i]=(batt.MonSerStd==0?0:Rtdatalist[i].mon_ser/batt.MonSerStd).toFixed(3);
                //console.info(batt.MonSerStd);
                mon_conn_list[i]=Rtdatalist[i].mon_conn_res.toFixed(3);
                mon_num_list[i]="#"+Rtdatalist[i].mon_num;
                mon_jh_list[i] = Rtdatalist[i].mon_JH_curr.toFixed(3);
            }
 
            // 设置表格的所有数据
            this.setTblDatas(mon_vol_table_list, mon_res_table_list, mon_tmp_table_list, mon_ser_table_list)
            // 设置显示表格的数据
            this.setTbl();
            // 设置单体电压图谱的配置项
            this.setOptions(mon_num_list, mon_vol_list, mon_res_list, mon_tmp_list, mon_ser_list);
        },
        // 单体电压,单体内阻, 单体温度, 电导
        setTblDatas: function(mon_vol, mon_res, mon_tmp, mon_ser) {
            // console.log(mon_vol);
            var tblDatas = this.tblDatas;
            tblDatas.monVol = this.formateTblData(mon_vol);
            tblDatas.monRes = this.formateTblData(mon_res);
            tblDatas.monTmp = this.formateTblData(mon_tmp, {
                max: 'table-tmp-high-cell',
                min: 'table-tmp-low-cell',
            });
            tblDatas.monSer = this.formateTblData(mon_ser);
        },
        formateTblData: function(data, classes) {
            var result = [];
            var values = [];
            var default_colors = {
                max: 'table-success-cell',
                min: 'table-error-cell',
            };
            classes = $.extend({}, default_colors, classes||{});
            for(var i=0; i<data.length; i+=8) {
                var tmp = {};
                tmp.cellClassName = {
                    num1: 'table-number-cell',
                    num3: 'table-number-cell',
                    num5: 'table-number-cell',
                    num7: 'table-number-cell',
                };
                for(var k=1;k<9; k++) {
                    var num = k+i;
                    // 超出界限
                    if(num-1>=data.length) {
                        break;
                    }
                    var key;
                    var key2 = num%2;
                    var key8 = num%8;
                    if(key8 == 0) {
                        key8 = 8;
                    }
                    key = 'num'+key8;
                    if(key2 == 0) {
                       values.push(data[num-1]);
                    }
                    tmp[key] = data[num-1];
                }
                result.push(tmp);
            }
 
            // 设置最大值和最小值
            var min = getMinFromArr(values);
            var max = getMaxFromArr(values);
            var keys = [2, 4, 6, 8];
            for(var i=0; i<result.length; i++) {
                var _result = result[i];
                for(var k=0; k<keys.length; k++) {
                    var key = 'num'+keys[k];
                    if(_result[key] >= max) {
                        _result.cellClassName[key] = classes.max;
                    }else if(_result[key] <= min) {
                        _result.cellClassName[key] = classes.min;
                    }
                }
            }
            // console.log(result);
            return result;
        },
        // 单体编号,单体电压,单体内阻, 单体温度, 电导
        setOptions: function(mon_num_list, mon_vol_list, mon_res_list, mon_tmp_list, mon_ser_list) {
            var options = this.options;
            // 单体电压设置
            options.monVol.option.xAxis.data = mon_num_list;
            options.monVol.option.series[0].data = mon_vol_list;
            var title = options.monVol.title;
            var min = getMinFromArr(mon_vol_list);
            var max = getMaxFromArr(mon_vol_list);
            var sum = getSumFromArr(mon_vol_list);
            var avg = getAvgFromArr(mon_vol_list);
            title.setMax(max);
            title.setMin(min);
            title.setAvg(avg);
            title.setSum(sum);
            var allTitle = title.getAllTile('Voltage');
            options.monVol.option.title.subtext = allTitle;
 
            // 单体内阻设置
            options.monRes.option.xAxis.data = mon_num_list;
            options.monRes.option.series[0].data = mon_res_list;
            var title = options.monRes.title;
            var min = getMinFromArr(mon_res_list);
            var max = getMaxFromArr(mon_res_list);
            var sum = getSumFromArr(mon_res_list);
            var avg = getAvgFromArr(mon_res_list);
            title.setMax(max);
            title.setMin(min);
            title.setAvg(avg);
            title.setSum(sum);
            var allTitle = title.getAllTile('Resistance');
            options.monRes.option.title.subtext = allTitle;
 
            // 单体温度
            options.monTmp.option.xAxis.data = mon_num_list;
            options.monTmp.option.series[0].data = mon_tmp_list;
            var title = options.monTmp.title;
            var min = getMinFromArr(mon_tmp_list);
            var max = getMaxFromArr(mon_tmp_list);
            var sum = getSumFromArr(mon_tmp_list);
            var avg = getAvgFromArr(mon_tmp_list);
            title.setMax(max);
            title.setMin(min);
            title.setAvg(avg);
            title.setSum(sum);
            var allTitle = title.getAllTile('Temperature');
            options.monTmp.option.title.subtext = allTitle;
 
            // 单体电导
            options.monSer.option.xAxis.data = mon_num_list;
            options.monSer.option.series[0].data = mon_ser_list;
            var title = options.monSer.title;
            var min = getMinFromArr(mon_ser_list);
            var max = getMaxFromArr(mon_ser_list);
            var sum = getSumFromArr(mon_ser_list);
            var avg = getAvgFromArr(mon_ser_list);
            title.setMax(max);
            title.setMin(min);
            title.setAvg(avg);
            title.setSum(sum);
            var allTitle = title.getAllTile('Conductance');
            options.monSer.option.title.subtext = allTitle;
 
            this.updateGraph();
        },
        // 更新图谱
        updateGraph: function() {
            // 更新单体电压
            this.$refs['monVolBar'].setOption(this.options.monVol.option);
 
            // 更新单体内阻
            this.$refs['monResBar'].setOption(this.options.monRes.option);
 
            // 更新单体温度
            this.$refs['monTmpBar'].setOption(this.options.monTmp.option);
 
            // 更新单体电导
            this.$refs['monSerBar'].setOption(this.options.monSer.option);
        },
        // 图谱更改大小
        resizeGraph: function() {
            // 更新单体电压
            this.$refs['monVolBar'].resize();
 
            // 更新单体内阻
            this.$refs['monResBar'].resize();
 
            // 更新单体温度
            this.$refs['monTmpBar'].resize();
 
            // 更新单体电导
            this.$refs['monSerBar'].resize();
        },
        searchRtState: function() {
            var self = this;
            var batt = this.getBatt();
            if(!batt.BattGroupId) {
                return;
            }
            var temp = {
                BattGroupId: batt.BattGroupId,
            };
            // 请求后台 获取电池组实时信息
            ajax({
                type:"post",                 
                url: "Batt_rtstateAction_serchByCondition",            
                async: true,            
                dataType: 'json',
                data: "rtstate.battGroupId="+batt.BattGroupId,
                success: function(res) {
                    // console.log(res);
                    var rs  = JSON.parse(res.result);
                    if(rs.code == 1) {
                        var rtstate = rs.data[0];
                        var online_vol = rtstate.online_vol.toFixed(2);
                        var group_vol = rtstate.group_vol.toFixed(2);
                        var opts = {};
                        opts.ele_state = getBattstate(rtstate.batt_state);
                        opts.ele_tension = "在线:"+online_vol+"V;组端:"+group_vol+"V";  // 组端电压
                        opts.ele_current = rtstate.group_curr.toFixed(2)+"A";       // 电池电流
                        opts.test_date = rtstate.rec_datetime;          // 更新日期
                        opts.test_time = formatSeconds(rtstate.batt_test_tlong);
                        opts.test_content = rtstate.batt_test_cap.toFixed(1)+"AH";
                        // 剩余容量
                        if(rtstate.batt_state==2){
                            opts.over_content = "---";
                        }else{
                            opts.over_content = rtstate.batt_rest_cap.toFixed(1)+"AH";
                        }
                        // 续航时间
                        if(rtstate.batt_state == 3){
                            opts.reserve_time = sethoubeiTime(parseFloat(rtstate.batt_rest_cap)/parseFloat(rtstate.group_curr));
                            
                        }else{
                            opts.reserve_time = "------";
                        }
                        // 设置rtState
                        self.setRtState(opts);
                        // console.log(opts);
                        // 开启计时器
                        self.rtStateTime.open()
                    }
                }
            });
        },
        initRtState: function() {
            this.rtState = {
                ele_state: '未知',
                ele_tension: '在线:??V;组端:??V',
                ele_current: '??A',
                test_date: 'yyyy-MM-dd HH:mm:ss',
                test_time: 'HH:mm:ss',
                test_content: '??AH',
                over_content: '??AH',
                reserve_time: '------'
            };
            return this.rtState;
        },
        setRtState: function(rtState) {
            var defaults =this.initRtState();
            this.rtState = $.extend({}, defaults, rtState); 
        }
    },
    mounted: function() {
        // 默认选中单体电压
        this.handlerTabClick('monVol');
    },
    destroyed: function() {
        this.rtDataTime.stop();
        this.rtStateTime.stop();
    }
}
</script>
<style scoped>
    .view-layout {
        height: 100%;
    }
    .view-layout-left {
        float: left;
        width: 360px;
        height: 100%;
        overflow-y: auto;
    }
    .view-layout-right {
        margin-left: 370px;
        height: 100%;
        overflow-y: auto;
    }
</style>