rtuAlarm.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /**
  2. *
  3. */
  4. Ext.Loader.setConfig({
  5. enabled: true
  6. });
  7. Ext.Loader.setPath('Ext.ux', '../../res/extjs/examples/ux');
  8. Ext.require([
  9. 'Ext.grid.*',
  10. 'Ext.data.*',
  11. 'Ext.ux.RowExpander',
  12. 'Ext.selection.CheckboxModel'
  13. ]);
  14. var sm = Ext.create('Ext.selection.CheckboxModel');
  15. var company_code = null;
  16. var myStore;
  17. Ext.define('VRtuAlarm',{
  18. extend: 'Ext.data.Model',
  19. fields: [
  20. { name:'id', type:'int'},
  21. { name:'device_code', type:'string' },
  22. { name:'company_code', type:'string' },
  23. { name:'company_name', type:'string' },
  24. { name:'fullname', type:'string' },
  25. { name:'time', type:'string' },
  26. { name:'data', type:'string' },
  27. { name:'clzt', type:'string' },
  28. { name:'clr_name', type:'string' },
  29. { name:'clsj', type:'string' }
  30. ]
  31. });
  32. var change_company = function(id){
  33. var maxHeight = 10000;
  34. maxHeight = document.documentElement.clientHeight;
  35. if(id.length>0){
  36. company_code = id;
  37. var query = new Object();
  38. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  39. query.company_code = company_code;
  40. myStore.getProxy().extraParams = {queryJson:Ext.JSON.encode(query)};
  41. myStore.reload();
  42. $("#company_code").val(company_code);
  43. }else{
  44. company_code = null;
  45. var query = new Object();
  46. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  47. query.company_code = company_code;
  48. myStore.getProxy().extraParams = {queryJson:Ext.JSON.encode(query)};
  49. myStore.reload();
  50. $("#company_code").val('');
  51. }
  52. Ext.getCmp('VWaterAlarmListPanel').setHeight(maxHeight);
  53. }
  54. Ext.onReady(function(){
  55. var baseUrl = document.getElementById('basePath').value;
  56. var theme = document.getElementById('theme').value;
  57. var chkIcon = '<img src="'+baseUrl+'res/img/common/check.gif"/>'
  58. var unchkIcon = '<img src="'+baseUrl+'res/img/common/uncheck.gif"/>'
  59. var countPerPage = 20;
  60. var maxHeight = 10000;
  61. company_code = document.getElementById('company_code').value;
  62. maxHeight = document.documentElement.clientHeight;
  63. var chkBoolean = function(flag) {
  64. if(flag)
  65. return chkIcon;
  66. return unchkIcon;
  67. }
  68. var query = new Object();
  69. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  70. query.company_code = company_code;
  71. myStore = Ext.create('Ext.data.Store', {
  72. model: 'VRtuAlarm',
  73. pageSize: countPerPage,
  74. proxy: {
  75. type: 'ajax',
  76. url: baseUrl+'iot/alarm/view/getRTUList',
  77. extraParams:{
  78. queryJson:Ext.JSON.encode(query)
  79. },
  80. reader: {
  81. type: 'json',
  82. root: 'RESULT',
  83. totalProperty: 'totalCount'
  84. }
  85. },
  86. sorters:[{
  87. property:'time',
  88. direction:'DESC'
  89. }],
  90. remoteSort: true
  91. });
  92. var storeReload=function(){
  93. var query = new Object();
  94. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  95. query.company_code = company_code;
  96. myStore.getProxy().extraParams = {queryJson:Ext.JSON.encode(query)};
  97. myStore.reload();
  98. setTimeout(storeReload,30000);
  99. }
  100. var FilterForm = Ext.create('Ext.form.Panel', {
  101. id: 'VRtuAlarmFilterForm',
  102. labelWidth: 55,
  103. defaultType: 'textfield',
  104. bodyPadding: 15
  105. });
  106. var filterwin = function() {
  107. Ext.create('Ext.window.Window',{
  108. id: 'VRtuAlarmFilterWin',
  109. title: '火警报告筛选',
  110. height: 300,
  111. width: 400,
  112. layout: 'fit',
  113. items: FilterForm,
  114. closeAction: 'hide'
  115. }).show();
  116. }
  117. Ext.create('Ext.grid.Panel', {
  118. title: 'RTU报告列表',
  119. id: 'VRtuAlarmListPanel',
  120. cellTip:true,
  121. store: myStore,
  122. selModel: sm,
  123. columns: [
  124. { header: 'id', dataIndex:'id',hidden:true, menuDisabled:true},
  125. { header: '单位名称', dataIndex: 'company_name',width:240, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  126. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  127. return value;
  128. }},
  129. { header: '报告时间', dataIndex: 'time', width:160, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  130. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  131. return value;
  132. }},
  133. { header: '报告数据', dataIndex: 'data', width:140, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  134. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  135. return value;
  136. }},
  137. { header: '报告内容', dataIndex: 'fullname', width:480, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  138. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  139. return value;
  140. }},
  141. { header: '处理状态', dataIndex: 'clzt', width:100, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  142. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  143. return value;
  144. }},
  145. { header: '处理人', dataIndex: 'clr_name',width:150, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  146. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  147. return value;
  148. }},
  149. { header: '处理时间', dataIndex: 'clsj', width:160, menuDisabled:true,renderer:function (value, metaData, record, rowIdx, colIdx, store){
  150. metaData.tdAttr = 'data-qtip="' + Ext.String.htmlEncode(value) + '"';
  151. return value;
  152. }}
  153. ],
  154. columnLines: true,
  155. height: maxHeight,
  156. width: '100%',
  157. bbar: new Ext.PagingToolbar({
  158. store: myStore,
  159. id:'VRtuAlarmListPageToolbar',
  160. displayInfo: true,
  161. pageSize: countPerPage,
  162. prependButtons: true,
  163. displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条',
  164. emptyMsg : "没有记录",
  165. firstText: '第一页',
  166. prevText: '前一页',
  167. nextText: '后一页',
  168. lastText: '最后一页'
  169. }),
  170. frame: true,
  171. border:false,
  172. iconCls: 'icon-grid',
  173. renderTo: Ext.getBody()
  174. });
  175. storeReload();
  176. Ext.getCmp('VRtuAlarmListPanel').setHeight(maxHeight);
  177. });