inspectionrecord.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. /**
  2. * inspectionrecord.js
  3. * 巡检点工作记录管理界面
  4. * emial: yaoqiang@chinausky.com
  5. * create: 2018-12-08
  6. */
  7. Ext.Loader.setConfig({
  8. enabled: true
  9. });
  10. Ext.Loader.setPath('Ext.ux', '../../res/extjs/examples/ux');
  11. Ext.require([
  12. 'Ext.grid.*',
  13. 'Ext.data.*',
  14. 'Ext.ux.RowExpander',
  15. 'Ext.selection.CheckboxModel'
  16. ]);
  17. var company_code;
  18. var myStore=null;
  19. var V_LOGINNAME='',V_PASSWORD='';
  20. var sm = Ext.create('Ext.selection.CheckboxModel');
  21. Ext.define('InspectionRecord',{
  22. extend: 'Ext.data.Model',
  23. fields: [
  24. {name:'id', type:'string'},
  25. // {name:'personnel', type:'string'},
  26. // {name:'route', type:'string'},
  27. {name:'inspection_time', type:'string'},
  28. // {name:'point_position', type:'string'},
  29. {name:'xjzt', type:'string'},
  30. {name:'qk', type:'string'},
  31. {name:'equipment_id', type:'string'},
  32. {name:'xj_name', type:'string'},
  33. {name:'analysis_content', type:'string'},
  34. {name:'name', type:'string'},
  35. {name:'route_name', type:'string'},
  36. {name:'company_code1', type:'string'},
  37. ]
  38. });
  39. function exportbtn_click(){
  40. baseUrl = document.getElementById('basePath').value;
  41. V_LOGINNAME = $("#V_LOGINNAME").val();
  42. V_PASSWORD = $("#V_PASSWORD").val();
  43. xj_name = document.getElementById('xj_name').value;
  44. equipment_id = document.getElementById('equipment_id').value;
  45. route_name = document.getElementById('route_name').value;
  46. analysis_content = document.getElementById('analysis_content').value;
  47. xjzt = document.getElementById('xjzt').value;
  48. qk = document.getElementById('qk').value;
  49. name = document.getElementById('name').value;
  50. inspection_time = document.getElementById('inspection_time').value;
  51. var fields = '';
  52. var array = ['id','xj_name','equipment_id','route_name','analysis_content','xjzt','qk','name','inspection_time'];
  53. var excelname = ['编号','巡检点名称','巡检点对应设备','巡检路线名称','巡检标签','巡检状态','巡检情况说明','巡检人','巡检时间'];
  54. for(var i=0;i<9;i++){
  55. if(i>0)
  56. fields += ',';
  57. fields += '{id:"'+array[i]+'",title:"'+excelname[i]+'",shown:"'+true+'"}';
  58. }
  59. var query = new Object();
  60. // query.V_LOGINNAME = V_LOGINNAME;
  61. // query.V_PASSWORD = V_PASSWORD;
  62. query.xj_name = xj_name;
  63. query.equipment_id = equipment_id;
  64. query.route_name = route_name;
  65. query.analysis_content = analysis_content;
  66. query.xjzt = xjzt;
  67. query.qk = qk;
  68. query.name = name;
  69. query.inspection_time = inspection_time;
  70. query.EXPORT_FILE = '巡检点操作记录列表';
  71. query.fields = '['+fields+']';
  72. $.ajax({
  73. type:'POST',
  74. url: baseUrl+"iot/excel/view/inspectionrecordExcel",
  75. data: {
  76. queryJson : Ext.JSON.encode(query)
  77. },
  78. success: function(result){
  79. var json = eval('(' + result + ')');
  80. if(json.action=='dormExport'){
  81. ConfirmStore = json.RESULT;
  82. var elemIF = document.createElement("iframe");
  83. elemIF.src = baseUrl+json.filename;
  84. elemIF.style.display = "none";
  85. document.body.appendChild(elemIF);
  86. }
  87. }
  88. });
  89. }
  90. Ext.onReady(function(){
  91. var baseUrl = document.getElementById('basePath').value;
  92. var theme = document.getElementById('theme').value;
  93. var chkIcon = '<img src="'+baseUrl+'res/img/common/check.gif"/>'
  94. var unchkIcon = '<img src="'+baseUrl+'res/img/common/uncheck.gif"/>'
  95. // company_code = document.getElementById('company_code').value;
  96. $("#V_LOGINNAME").val(sessionStorage.getItem('V_LOGINNAME'));
  97. $("#V_PASSWORD").val(sessionStorage.getItem('V_PASSWORD'));
  98. V_LOGINNAME = $("#V_LOGINNAME").val();
  99. V_PASSWORD = $("#V_PASSWORD").val();
  100. var countPerPage = 20;
  101. var maxHeight = 10000;
  102. var chkBoolean = function(flag) {
  103. if(flag)
  104. return chkIcon;
  105. return unchkIcon;
  106. }
  107. var queryJson = new Object();
  108. // queryJson.V_LOGINNAME = V_LOGINNAME;
  109. // queryJson.V_PASSWORD = V_PASSWORD;
  110. // queryJson.COMMSTATUS = 'NO';
  111. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  112. queryJson.company_code = company_code;
  113. myStore = Ext.create('Ext.data.Store', {
  114. model: 'InspectionRecord',
  115. pageSize: countPerPage,
  116. proxy: {
  117. type: 'ajax',
  118. actionMethods: {
  119. create : 'POST',
  120. read : 'POST', // by default GET
  121. update : 'POST',
  122. destroy: 'POST'
  123. },
  124. url: baseUrl+'iot/inspectionrecord/getList',
  125. reader: {
  126. type: 'json',
  127. root: 'RESULT',
  128. totalProperty: 'totalCount'
  129. },
  130. extraParams:{
  131. queryJson:Ext.JSON.encode(queryJson)
  132. }
  133. },
  134. // sorters:[{
  135. // property:'data_time',
  136. // direction:'DESC'
  137. // }],
  138. remoteSort: true
  139. });
  140. var states1 = Ext.create('Ext.data.Store', {
  141. fields: ['status', 'name'],
  142. data : [
  143. {"status":"全选", "name":"全选"},
  144. {"status":"正常", "name":"正常"},
  145. {"status":"异常", "name":"异常"},
  146. {"status":"故障", "name":"故障"},
  147. ]
  148. });
  149. //筛选
  150. var clear_filter_form = function(){
  151. Ext.getCmp('ff_name').setValue("");
  152. Ext.getCmp('ff_xj_name').setValue("");
  153. Ext.getCmp('ff_equipment_id').setValue("");
  154. Ext.getCmp('ff_analysis_content').setValue("");
  155. Ext.getCmp('ff_route_name').setValue("");
  156. // Ext.getCmp('ff_personnel').setValue("");
  157. // Ext.getCmp('ff_route').setValue("");
  158. // Ext.getCmp('ff_point_position').setValue("");
  159. Ext.getCmp('ff_xjzt').setValue("");
  160. // Ext.getCmp('ff_qk').setValue("");
  161. Ext.getCmp('ff_inspection_time').setValue("");
  162. Ext.getCmp('ff_company_code').setValue("");
  163. }
  164. var FilterWin = Ext.create('Ext.form.Panel', {
  165. id: 'InspectionRecordFilterForm',
  166. labelWidth: 55,
  167. defaultType: 'textfield',
  168. bodyPadding: 15,
  169. items: [{
  170. fieldLabel:'巡检人',
  171. id: 'ff_name',
  172. name:'name',
  173. maxLength:30,
  174. maxLengthText:'长度不得超出{0}',
  175. value : document.getElementById('name').value,
  176. anchor:'75%'
  177. },{
  178. fieldLabel:'巡检点名称',
  179. id:'ff_xj_name',
  180. name:'xj_name',
  181. maxLength: 50,
  182. maxLengthText:'长度不得超出{0}',
  183. value : document.getElementById('xj_name').value,
  184. anchor:'75%'
  185. },{
  186. fieldLabel:'巡检点对应的设备',
  187. id: 'ff_equipment_id',
  188. name: 'equipment_id',
  189. maxLength: 250,
  190. maxLengthText:'长度不得超出{0}',
  191. value : document.getElementById('equipment_id').value,
  192. anchor:'95%'
  193. },{
  194. fieldLabel:'巡检标签',
  195. id: 'ff_analysis_content',
  196. name: 'analysis_content',
  197. maxLength: 250,
  198. maxLengthText:'长度不得超出{0}',
  199. value : document.getElementById('analysis_content').value,
  200. anchor:'95%'
  201. },{
  202. fieldLabel:'巡检路线名称',
  203. id: 'ff_route_name',
  204. name: 'route_name',
  205. maxLength: 250,
  206. maxLengthText:'长度不得超出{0}',
  207. value : document.getElementById('route_name').value,
  208. anchor:'95%'
  209. },
  210. // {
  211. // fieldLabel:'巡检人',
  212. // id: 'ff_personnel',
  213. // name:'personnel',
  214. // maxLength:20,
  215. // maxLengthText:'长度不得超出{0}',
  216. // value : document.getElementById('personnel').value,
  217. // anchor:'75%'
  218. // },{
  219. // fieldLabel:'巡检路线',
  220. // id:'ff_route',
  221. // name:'route',
  222. // maxLength: 250,
  223. // maxLengthText:'长度不得超出{0}',
  224. // value : document.getElementById('route').value,
  225. // editable : false
  226. // },{
  227. // fieldLabel:'巡检标签',
  228. // id: 'ff_point_position',
  229. // name: 'point_position',
  230. // maxLength: 250,
  231. // maxLengthText:'长度不得超出{0}',
  232. // value : document.getElementById('point_position').value,
  233. // anchor:'95%'
  234. // },
  235. // {
  236. // fieldLabel:'巡检状态',
  237. // id:'ff_xjzt',
  238. // name:'xjzt',
  239. // maxLength: 250,
  240. // maxLengthText:'长度不得超出{0}',
  241. // value : document.getElementById('xjzt').value,
  242. // editable : false
  243. // }
  244. {
  245. fieldLabel:'巡检状态',
  246. id:'ff_xjzt',
  247. name:'xjzt',
  248. xtype:'combo',
  249. store:states1,
  250. displayField : 'name',
  251. valueField : 'status',
  252. value : "全选",
  253. editable : false
  254. },{
  255. fieldLabel:'巡检时间',
  256. id:'ff_inspection_time',
  257. name:'inspection_time',
  258. maxLength: 250,
  259. maxLengthText:'长度不得超出{0}',
  260. value : document.getElementById('inspection_time').value,
  261. editable : false
  262. },
  263. // {
  264. // fieldLabel:'巡检情况报说明',
  265. // id:'ff_qk',
  266. // name:'qk',
  267. // xtype: 'textareafield',
  268. // maxLength: 250,
  269. // maxLengthText:'长度不得超出{0}',
  270. // value : document.getElementById('qk').value,
  271. // anchor:'100%',
  272. // editable : false
  273. // },
  274. {
  275. id:'ff_queryJson',
  276. name:'queryJson',
  277. hidden:true
  278. }],
  279. buttons: [{
  280. text: '提交',
  281. iconCls:'ok_btn',
  282. handler: function() {
  283. var form = this.up('form').getForm();
  284. if (form.isValid()) {
  285. var query = new Object();
  286. query.V_LOGINNAME = V_LOGINNAME;
  287. query.V_PASSWORD = V_PASSWORD;
  288. if(Ext.getCmp('ff_name').getValue().length>0)
  289. query.name = Ext.getCmp('ff_name').getValue();
  290. $("#name").val(query.name);
  291. if(Ext.getCmp('ff_xj_name').getValue().length>0)
  292. query.xj_name = Ext.getCmp('ff_xj_name').getValue();
  293. $("#xj_name").val(query.xj_name);
  294. if(Ext.getCmp('ff_equipment_id').getValue().length>0)
  295. query.equipment_id = Ext.getCmp('ff_equipment_id').getValue();
  296. $("#equipment_id").val(query.equipment_id);
  297. if(Ext.getCmp('ff_analysis_content').getValue().length>0)
  298. query.analysis_content = Ext.getCmp('ff_analysis_content').getValue();
  299. $("#analysis_content").val(query.analysis_content);
  300. if(Ext.getCmp('ff_route_name').getValue().length>0)
  301. query.route_name = Ext.getCmp('ff_route_name').getValue();
  302. $("#route_name").val(query.route_name);
  303. // if(Ext.getCmp('ff_personnel').getValue().length>0)
  304. // query.personnel = Ext.getCmp('ff_personnel').getValue();
  305. // if(Ext.getCmp('ff_route').getValue().length>0)
  306. // query.route = Ext.getCmp('ff_route').getValue();
  307. // if(Ext.getCmp('ff_point_position').getValue().length>0)
  308. // query.point_position = Ext.getCmp('ff_point_position').getValue();
  309. if(Ext.getCmp('ff_xjzt').getValue().length>0){
  310. // query.xjzt = Ext.getCmp('ff_xjzt').getValue();
  311. if(Ext.getCmp('ff_xjzt').getValue()=="正常") {
  312. query.xjzt = "0";
  313. $("#xjzt").val(query.xjzt);
  314. }else if(Ext.getCmp('ff_xjzt').getValue()=="异常") {
  315. query.xjzt = "1";
  316. $("#xjzt").val(query.xjzt);
  317. }else if(Ext.getCmp('ff_xjzt').getValue()=="故障") {
  318. query.xjzt = "2";
  319. $("#xjzt").val(query.xjzt);
  320. }else if(Ext.getCmp('ff_xjzt').getValue()=="全选") {
  321. // query.xjzt = null;
  322. }
  323. }
  324. // if(Ext.getCmp('ff_qk').getValue().length>0)
  325. // query.qk = Ext.getCmp('ff_qk').getValue();
  326. if(Ext.getCmp('ff_inspection_time').getValue().length>0)
  327. query.inspection_time = Ext.getCmp('ff_inspection_time').getValue();
  328. $("#inspection_time").val(query.inspection_time);
  329. var jsonstr = Ext.JSON.encode(query);
  330. myStore.getProxy().extraParams = {
  331. queryJson : jsonstr
  332. };
  333. Ext.getCmp('InspectionRecordListPageToolbar').moveFirst();
  334. Ext.getCmp('name').setValue(query.name);
  335. Ext.getCmp('xj_name').setValue(query.xj_name);
  336. Ext.getCmp('equipment_id').setValue(query.equipment_id);
  337. Ext.getCmp('analysis_content').setValue(query.analysis_content);
  338. Ext.getCmp('route_name').setValue(query.route_name);
  339. // Ext.getCmp('personnel').setValue(query.personnel);
  340. // Ext.getCmp('route').setValue(query.route);
  341. // Ext.getCmp('point_position').setValue(query.point_position);
  342. Ext.getCmp('xjzt').setValue(query.xjzt);
  343. Ext.getCmp('qk').setValue(query.qk);
  344. Ext.getCmp('inspection_time').setValue(query.inspection_time);
  345. // myStore.reload();
  346. clear_filter_form();
  347. this.up('window').hide();
  348. }
  349. }
  350. },{
  351. text: '关闭',
  352. iconCls: 'cancel_btn',
  353. handler: function() {
  354. this.up('window').hide();
  355. }
  356. }]
  357. });
  358. var filterwin = function() {
  359. Ext.create('Ext.window.Window',{
  360. title: '筛选',
  361. height: 400,
  362. width: 400,
  363. layout: 'fit',
  364. items: FilterWin,
  365. closeAction: 'hide'
  366. }).show();
  367. }
  368. Ext.create('Ext.grid.Panel', {
  369. title: '巡检点工作记录',
  370. id: 'InspectionRecordListPanel',
  371. store: myStore,
  372. selModel: sm,
  373. columns: [
  374. //{ header: 'ID', dataIndex: 'UQ_POINT_ID',hidden:true, menuDisabled:true },
  375. { header: '序号', dataIndex: 'id', width:67, menuDisabled:true },
  376. { header: '巡检点名称', dataIndex: 'xj_name', width:130,align:'center', menuDisabled:true },
  377. { header: '巡检点对应设备', dataIndex: 'equipment_id', width:130,align:'center', menuDisabled:true },
  378. { header: '巡检路线名称', dataIndex: 'route_name', width:250,align:'center', menuDisabled:true },
  379. { header: '巡检标签', dataIndex: 'analysis_content', width:120,align:'center', menuDisabled:true },
  380. { header: '巡检状态', dataIndex: 'xjzt', width:120,align:'center', menuDisabled:true },
  381. { header: '巡检情况说明', dataIndex: 'qk', width:250, menuDisabled:true },
  382. // { header: '巡检人', dataIndex: 'personnel', width:120,align:'center', menuDisabled:true },
  383. { header: '巡检人', dataIndex: 'name', width:120,align:'center', menuDisabled:true },
  384. // { header: '巡检路线', dataIndex: 'route', width:160,align:'center', menuDisabled:true },
  385. // { header: '巡检标签', dataIndex: 'point_position', width:120,align:'center', menuDisabled:true },
  386. { header: '巡检时间', dataIndex: 'inspection_time', width:250,align:'center', menuDisabled:true },
  387. ],
  388. columnLines: true,
  389. tbar: [
  390. {
  391. xtype: 'button',
  392. iconCls:'filter_btn',
  393. text: '筛选',
  394. listeners: {
  395. click: filterwin
  396. }
  397. },'-',
  398. {xtype: 'tbfill'},'-',
  399. {
  400. xtype: 'button',
  401. iconCls:'export_btn',
  402. text: '导出',
  403. listeners: {
  404. click: exportbtn_click
  405. }
  406. }
  407. ],
  408. height: maxHeight,
  409. width: '100%',
  410. bbar: new Ext.PagingToolbar({
  411. store: myStore,
  412. id:'InspectionRecordListPageToolbar',
  413. displayInfo: true,
  414. pageSize: countPerPage,
  415. prependButtons: true,
  416. displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条',
  417. emptyMsg : "没有记录",
  418. firstText: '第一页',
  419. prevText: '前一页',
  420. nextText: '后一页',
  421. lastText: '最后一页',
  422. refreshText: '刷新',
  423. // doRefresh:function(start){
  424. // alert(start);
  425. // relushDataFunction(start); // 调用函数刷新数据
  426. // this.cursor = start; // 更新页签
  427. // }
  428. }),
  429. frame: true,
  430. border:false,
  431. iconCls: 'icon-grid',
  432. renderTo: Ext.getBody()
  433. });
  434. myStore.reload();
  435. maxHeight = document.documentElement.clientHeight;
  436. Ext.getCmp('InspectionRecordListPanel').setHeight(maxHeight);
  437. });