1
81041
2019-06-20 ab3c4acf83f54f8449ca8664c4a2bb79bd30f297
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
<template>
    <div data-name="history-vol" class="page">
        <!-- Top Navbar -->
        <div class="navbar">
            <div class="navbar-inner">
                <div class="left">
                    <a href="#" class="link back">
                        <i class="icon f7-icons">chevron_left</i>
                    </a>
                </div>
                <div class="title center">单体电压({{params.groupname}})</div>
                <div class="right">
                    <a href="#" class="link ac"><i class="icon f7-icons">more_vertical</i></a>
                </div>
            </div>
        </div>
        <!-- Scrollable page content -->
        <div class="page-content">
            
        </div>
    </div>
</template>
<style>
    
</style>
<script>
    return {
        data: function() {
            var params = this.$route.params;
            var str = getUrlStr({
                groupid: params.groupid,
                groupname: params.groupname,
                count: params.count
            });
            var path = "/monitor/history/data/"+str;
            var cView = app.views.current;
            return {
                params: params,
                path: path,
                cView: cView
            }
        },
        methods: {
            searchData: function() {
                // 定义参数
                var _this = this;
                var params = this.params;
                // 请求后台
                $.ajax({
                    type: 'post',
                    async: true,
                    url: 'BatttestdataAction!findByInfo',
                    data: "btd.BattGroupId="+params.groupid+"&btd.test_record_count="+params.count,
                    dataType: 'json',
                    success: function(res) {
                        var rs = JSON.parse(res.result);
                        if(rs.code == 1) {
                            var data = rs.data;
                            var list = _this.formatData(data);
                            console.log(list);
                        }
                    }
                });
            },
            formatData: function(list) {
                var _this = this;
                var rs = [];
                var record = -1;
                var index = -1;
                var flag = false;
                var start_record_num = list[0].record_num;
                // 遍历结果集
                for(var i=0;i<list.length;i++){
                    if(list[i].record_num != record){
                        rs[++index] = new Array();
                        
                        if(list[i].record_num > start_record_num){    
                            flag = true;
                            rs[index] = rs[index-1].slice(0);
                        }
                        record = list[i].record_num;
                    }
                    rs[index][list[i].mon_num-1] = list[i];
                    // 判断是否上一笔
                    if(flag){
                        _this.setArrayVal(list[i],rs[index]);
                        flag = false;
                    }
                }
                // 返回被格式化后的数组
                return rs;
            },
            setArrayVal: function(obj, list) {
                if(obj != undefined && list != undefined){
                    for(var i = 0; i<list.length;i++){
                        list[i].group_vol = obj.group_vol;
                        list[i].record_num = obj.record_num;
                        list[i].record_time = obj.record_time;
                        list[i].test_cap = obj.test_cap;
                        list[i].test_curr = obj.test_curr;
                        list[i].test_timelong = obj.test_timelong;
                    }
                }
            }
        },
        on: {
            pageInit: function() {
                var cView  = this.cView;
                var path = this.path;
                // 查询数据
                this.searchData();
                
                // 菜单选择
                var ac = app.actions.create({
                    convertToPopover: false,
                    buttons:[
                        {
                            text: "单体电压",
                            onClick: function() {
                                cView.router.navigate(path+"vol/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "单体实际容量",
                            onClick: function() {
                                cView.router.navigate(path+"real-cap/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "单体剩余容量",
                            onClick: function() {
                                cView.router.navigate(path+"res-cap/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "单体容量百分比",
                            onClick: function() {
                                cView.router.navigate(path+"cap-per/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "端电压折线图",
                            onClick: function() {
                                cView.router.navigate(path+"group-vol-line/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "电池电流折线图",
                            onClick: function() {
                                cView.router.navigate(path+"group-vol-line/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                        {
                            text: "单体电压曲线图",
                            onClick: function() {
                                cView.router.navigate(path+"mon-vol-line/", {
                                    reloadCurrent: true
                                });
                            }
                        },
                    ]
                });
                
                // 点击ac显示选择内容
                $$('.ac').click(function() {
                    ac.open();
                });
            }
        }
    }
</script>