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
| 'use strict';
|
| /**
| * 首页模块
| * 默认模块名: main
| * @return {[object]} [ 返回一个对象 ]
| */
| loader.define({
| data: {
| vm: ''
| },
| loaded: function loaded(require, exports, module) {
| // 引入vue
| this.vm = new Vue({
| el: getPageRoot(module),
| data: {
| tabs: {
| active: 'menu',
| menu: 4,
| warning: 0,
| charge: 0,
| discharge: 0
| },
| tbls: {
| warning: {
| name: '告警信息',
| height: 300,
| noData: '暂无告警数据',
| data: []
| },
| charge: {
| timer: new Timeout(),
| name: '充电电池组信息',
| height: 300,
| noData: '暂无充电电池组',
| data: []
| },
| discharge: {
| timer: new Timeout(),
| name: '放电电池组信息',
| height: 300,
| noData: '暂无放电电池组',
| data: []
| }
| },
| routes: [{
| path: '/monitor-data',
| url: '../monitor-data/monitor-data.html'
| }, {
| path: '/batt-info-set',
| url: '../batt-info-set/batt-info-set.html'
| }, {
| path: '/history-data',
| url: '../history-data/history-data.html'
| }]
| },
| methods: {
| setTabsActive: function setTabsActive(str) {
| this.tabs.active = str;
| },
| startReadBattDiscInfo: function startReadBattDiscInfo() {
| var self = this;
| this.tbls.discharge.timer.start(function () {
| self.readBattDiscInfo();
| }, 4000);
| },
| readBattDiscInfo: function readBattDiscInfo() {
| // 读取放电信息
| if (typeof DeviceService != 'undefined') {
| DeviceService.readBattDiscInfo();
| } else {
| this.setBattDiscInfo({
| code: 1,
| data: [{
| num: 1,
| BattGroupName: '电池组1',
| BattGroupName1: '电池组',
| testStartTime: '2019-11-23 14:48:00',
| testTimelong: 20,
| groupvol: 10,
| groupcurr: 5
| }]
| });
| // 开启计时器
| this.tbls.discharge.timer.open();
| }
| },
| setBattDiscInfo: function setBattDiscInfo(res) {
| console.log(res);
| // 对数据进行处理
| this.tbls.discharge.data = res.data;
| // 统计个数
| this.tabs.discharge = res.data.length;
| },
| startReadBattCharInfo: function startReadBattCharInfo() {
| var self = this;
| this.tbls.charge.timer.start(function () {
| self.readBattCharInfo();
| }, 4000);
| },
| readBattCharInfo: function readBattCharInfo() {
| // 读取充电信息
| if (typeof DeviceService != 'undefined') {
| DeviceService.readBattCharInfo();
| } else {
| this.setBattCharInfo({
| code: 1,
| data: [{
| num: 2,
| BattGroupName: '电池组2',
| BattGroupName1: '电池组',
| testStartTime: '2019-11-23 14:48:00',
| testTimelong: 30,
| groupvol: 11,
| groupcurr: 4
| }, {
| num: 5,
| BattGroupName: '电池组5',
| BattGroupName1: '电池组',
| testStartTime: '2019-11-23 14:50:40',
| testTimelong: 30,
| groupvol: 11,
| groupcurr: 4
| }]
| });
| // 开启计时器
| this.tbls.charge.timer.open();
| }
| },
| setBattCharInfo: function setBattCharInfo(res) {
| console.log(res);
| // 对数据进行处理
| this.tbls.charge.data = res.data;
| // 统计个数
| this.tabs.charge = res.data.length;
| },
| routerTo: function routerTo(path) {
| var routes = this.routes;
| var url = "";
| // 遍历
| for (var i = 0; i < routes.length; i++) {
| var route = routes[i];
| if (route.path == path) {
| url = route.url;
| }
| }
| // 跳转
| router.load({
| url: url,
| param: {
| random: Math.random().toFixed(2)
| },
| reload: true
| });
| }
| },
| mounted: function mounted() {
| var self = this;
|
| // 查询放电信息
| this.startReadBattDiscInfo();
|
| // 查询充电测试信息
| this.startReadBattCharInfo();
|
| // 后台触发事件查询所有的电池组放电信息
| window['DeviceServicereadBattDiscInfocalljs'] = function (res) {
| // 设置电池信息
| self.setBattDiscInfo(res);
| // 开启计时器
| self.tbls.discharge.timer.open();
| };
|
| // 后台触发事件查询所有的电池组充电信息
| window['DeviceServicereadBattCharInfocalljs'] = function (res) {
| // 设置电池信息
| self.setBattCharInfo(res);
| // 开启计时器
| self.tbls.charge.timer.open();
| };
| },
| destroyed: function destroyed() {}
| });
| },
| destroyed: function destroyed() {
| this.vm.$destroy();
| }
| });
|
|