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
| ;(function($, window, document, gl, undefined) {
| // 首页饼状图
| gl.namespace('Index.Pie');
|
| var pieType = [
| {
| name: '电池状态',
| action: 'Batt_rtstateAction!serchBattStateRate',
| formatData: eleStatus
| },
| {
| name: '电池告警率',
| action: 'Battalarm_dataAction!serchAlm',
| formatData: eleWarn
| },
| {
| name: '机房停电',
| action: 'BattPower_offAction!serchPowerOff',
| formatData: homeCut
| },
| {
| name: '单体容量健康率',
| action: 'Battalarm_dataAction!serchGood',
| formatData: monCapGood
| }
| ];
|
| // 将pieType绑定到Index.Pie命名空间下
| gl.Index.Pie.pieType = pieType;
|
| // 根据数组调用查询内容
| function search(arr) {
| for(var i=0; i<arr.length; i++) {
| if(arr[i]) {
| ajax(pieType[i]);
| }
| }
| }
|
| // 将search绑定到Index.Pie命名空间下
| gl.Index.Pie.search = search;
|
| // 请求后台
| function ajax(obj) {
| // ajax请求后台
| $.ajax({
| type: 'post',
| url: obj.action,
| data: null,
| async: true,
| dataType: 'json',
| success:function(result) {
| var rs = JSON.parse(result.result);
| var pieData = obj.formatData(rs);
|
| }
| });
| }
|
| // 电池状态
| function eleStatus(data) {
| console.log(data);
| }
|
| // 电池告警
| function eleWarn(data) {
| console.log(data);
| }
|
| // 机房停电
| function homeCut(data) {
| console.log(data);
| }
| // 单体容量健康率
| function monCapGood(data) {
| console.log(data);
| }
| })(jQuery, window, document, GLOBAL);
|
|