1 // 构建设备总览列表
2 $('#dg_machine_list').datagrid({
3 title : '设备列表模式',
4 iconCls : 'icon-a_detail',
5 fit : true,
6 fitColumns : true,
7 rownumbers : true,
8 pagination : true,
9 singleSelect : true,
10 border : false,
11 striped : true,
12 toolbar : [ {
13 text : '查看详情',
14 iconCls : 'icon-script_link',
15 handler : function() {
16 viewDetail();
17 }
18 }, '-', {
19 iconCls : 'icon-help',
20 handler : function() {
21 alert('帮助按钮');
22 }
23 } ],
24 columns : [ [ {
25 field : 'unid',
26 title : 'UNID',
27 width : 100,
28 align : 'center',
29 hidden : true
30 }, {
31 field : 'machine_name',
32 title : '设备名称',
33 width : 100,
34 align : 'center'
35 }, {
36 field : 'machine_type',
37 title : '设备类型',
38 width : 100,
39 align : 'center'
40 }, {
41 field : 'num_recoder',
42 title : '备案编号',
43 width : 100,
44 align : 'center'
45 }, {
46 field : 'work_state',
47 title : '当前状态',
48 width : 100,
49 align : 'center'
50 }, {
51 field : 'update_time',
52 title : '更新时间',
53 width : 100,
54 align : 'center'
55 }, {
56 field : 'moment',
57 title : '力矩(KN.m)',
58 width : 70,
59 align : 'center'
60 }, {
61 field : 'load',
62 title : '载重(t)',
63 width : 50,
64 align : 'center'
65 }, {
66 field : 'height',
67 title : '高度(m)',
68 width : 50,
69 align : 'center'
70 }, {
71 field : 'range',
72 title : '幅度(m)',
73 width : 50,
74 align : 'center'
75 }, {
76 field : 'angle',
77 title : '角度(度)',
78 width : 50,
79 align : 'center'
80 }, {
81 field : 'wind_speed',
82 title : '风速(m/s)',
83 width : 50,
84 align : 'center'
85 }, {
86 field : 'dip_angle',
87 title : '倾角(度)',
88 width : 50,
89 align : 'center'
90 }, {
91 field : 'alarm_info',
92 title : '报警信息',
93 width : 100,
94 align : 'center'
95 } ] ]
96 });
97 // 先通过ajax获取数据,然后再传给datagrid
98 // https://bas.gimiscloud.com/api/crane/machinelist
99 // json/data_machine_list.json
100
101 $.ajax({
102 method : 'GET',
103 url : 'https://bas.gimiscloud.com/api/crane/machinelist',
104 async : false,
105 dataType : 'json',
106 beforeSend : function(jqXHR) {
107 jqXHR.setRequestHeader('Authorization', 'Bearer '
108 + '3feee5b76d8e698f4e5e29c626eb9dc2');
109 },
110 success : function(data) {
111 for ( var machine in data) {
112 alert(data[machine].name);
113 var a = [ {
114 'unid' : data[machine].unid,
115 'machine_name' : data[machine].name,
116 'machine_type' : data[machine].type,
117 'num_recoder' : data[machine].unid,
118 'work_state' : data[machine].online,
119 'update_time' : data[machine].date,
120 'moment' : data[machine].torque,
121 'load' : data[machine].capa,
122 'height' : data[machine].hook_height,
123 'range' : data[machine].radius,
124 'angle' : data[machine].angle,
125 'wind_speed' : data[machine].wind_velocity,
126 'dip_angle' : data[machine].obliquity,
127 'alarm_info' : data[machine].content
128 } ];
129 $('#dg_machine_list').datagrid('loadData', a);
130 }
131 },
132 error : function() {
133 alert('error');
134 }
135 });