inspectors.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. /**
  2. * inspectors.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 sm = Ext.create('Ext.selection.CheckboxModel');
  18. Ext.define('Inspectors',{
  19. extend: 'Ext.data.Model',
  20. fields: [
  21. {name:'id', type:'string'},
  22. {name:'name', type:'string'},
  23. {name:'phone', type:'string'},
  24. {name:'Job_duties', type:'string'},
  25. {name:'company_code', type:'string'},
  26. ]
  27. });
  28. Ext.onReady(function(){
  29. var baseUrl = document.getElementById('basePath').value;
  30. var theme = document.getElementById('theme').value;
  31. var chkIcon = '<img src="'+baseUrl+'res/img/common/check.gif"/>'
  32. var unchkIcon = '<img src="'+baseUrl+'res/img/common/uncheck.gif"/>'
  33. var countPerPage = 20;
  34. var maxHeight = 10000;
  35. var chkBoolean = function(flag) {
  36. if(flag)
  37. return chkIcon;
  38. return unchkIcon;
  39. }
  40. var clear_append_form = function (){
  41. Ext.getCmp('fa_name').setValue("");
  42. Ext.getCmp('fa_phone').setValue("");
  43. Ext.getCmp('fa_Job_duties').setValue("");
  44. Ext.getCmp('fa_company_code').setValue("");
  45. Ext.getCmp('InspectorsListPanel').getStore().reload();
  46. }
  47. var myStore = Ext.create('Ext.data.Store', {
  48. model: 'Inspectors',
  49. pageSize: countPerPage,
  50. proxy: {
  51. type: 'ajax',
  52. url: baseUrl+'iot/inspectors/getList',
  53. reader: {
  54. type: 'json',
  55. root: 'RESULT',
  56. totalProperty: 'totalCount'
  57. }
  58. },
  59. remoteSort: true
  60. });
  61. var AppendForm = Ext.create('Ext.form.Panel', {
  62. id: 'InspectorsAppendForm',
  63. labelWidth: 55,
  64. url: baseUrl+'iot/inspectors/append',
  65. defaultType: 'textfield',
  66. bodyPadding: 15,
  67. items: [{
  68. fieldLabel:'姓名',
  69. id: 'fa_name',
  70. name:'name',
  71. maxLength:20,
  72. maxLengthText:'长度不得超出{0}',
  73. anchor:'75%'
  74. },{
  75. fieldLabel:'手机号',
  76. id: 'fa_phone',
  77. name: 'phone',
  78. maxLength: 250,
  79. maxLengthText:'长度不得超出{0}',
  80. anchor:'95%'
  81. },{
  82. fieldLabel:'职务',
  83. id: 'fa_Job_duties',
  84. name:'Job_duties',
  85. maxLength: 30,
  86. maxLengthText:'长度不得超出{0}',
  87. anchor:'95%'
  88. },{
  89. fieldLabel:'单位编号',
  90. id: 'fa_company_code',
  91. name:'company_code',
  92. maxLength: 30,
  93. maxLengthText:'长度不得超出{0}',
  94. anchor:'95%'
  95. },{
  96. id:'fa_queryJson',
  97. name:'queryJson',
  98. hidden:true
  99. }],
  100. buttons: [{
  101. text: '提交',
  102. iconCls:'ok_btn',
  103. handler: function() {
  104. var form = this.up('form').getForm();
  105. if (form.isValid()) {
  106. var query = new Object();
  107. query.name = Ext.getCmp('fa_name').getValue();
  108. query.phone = Ext.getCmp('fa_phone').getValue();
  109. query.Job_duties = Ext.getCmp('fa_Job_duties').getValue();
  110. query.company_code = Ext.getCmp('fa_company_code').getValue();
  111. var jsonstr = Ext.JSON.encode(query);
  112. Ext.getCmp('fa_queryJson').setValue(jsonstr);
  113. form.submit({
  114. method:'post',
  115. success: function(form, action) {
  116. Ext.Msg.alert('操作成功', '已保存', function(btn,txt){
  117. clear_append_form();
  118. });
  119. },
  120. failure: function(form, action) {
  121. Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){
  122. clear_append_form();
  123. });
  124. }
  125. });
  126. }
  127. }
  128. },{
  129. text: '关闭',
  130. iconCls: 'cancel_btn',
  131. handler: function() {
  132. this.up('window').hide();
  133. }
  134. }]
  135. });
  136. var appendwin = function(){
  137. Ext.create('Ext.window.Window', {
  138. title: '新增',
  139. height: 350,
  140. width: 400,
  141. layout: 'fit',
  142. items: AppendForm,
  143. closeAction: 'hide'
  144. }).show();
  145. }
  146. //筛选
  147. var clear_filter_form = function(){
  148. Ext.getCmp('ff_name').setValue("");
  149. Ext.getCmp('ff_phone').setValue("");
  150. Ext.getCmp('ff_Job_duties').setValue("");
  151. Ext.getCmp('ff_company_code').setValue("");
  152. }
  153. var FilterWin = Ext.create('Ext.form.Panel', {
  154. id: 'InspectorsFilterForm',
  155. labelWidth: 55,
  156. defaultType: 'textfield',
  157. bodyPadding: 15,
  158. items: [{
  159. fieldLabel:'姓名',
  160. id: 'ff_name',
  161. name:'name',
  162. maxLength:20,
  163. maxLengthText:'长度不得超出{0}',
  164. value : document.getElementById('name').value,
  165. anchor:'75%'
  166. },{
  167. fieldLabel:'手机号',
  168. id:'ff_phone',
  169. name:'phone',
  170. maxLength: 250,
  171. maxLengthText:'长度不得超出{0}',
  172. value : document.getElementById('phone').value,
  173. editable : false
  174. },{
  175. fieldLabel:'职务',
  176. id: 'ff_Job_duties',
  177. name: 'Job_duties',
  178. maxLength: 250,
  179. maxLengthText:'长度不得超出{0}',
  180. value : document.getElementById('Job_duties').value,
  181. anchor:'95%'
  182. },{
  183. fieldLabel:'单位编号',
  184. id: 'ff_company_code',
  185. name: 'company_code',
  186. maxLength: 250,
  187. maxLengthText:'长度不得超出{0}',
  188. value : document.getElementById('company_code').value,
  189. anchor:'95%'
  190. },{
  191. id:'ff_queryJson',
  192. name:'queryJson',
  193. hidden:true
  194. }],
  195. buttons: [{
  196. text: '提交',
  197. iconCls:'ok_btn',
  198. handler: function() {
  199. var form = this.up('form').getForm();
  200. if (form.isValid()) {
  201. var query = new Object();
  202. if(Ext.getCmp('ff_name').getValue().length>0)
  203. query.name = Ext.getCmp('ff_name').getValue();
  204. if(Ext.getCmp('ff_phone').getValue().length>0)
  205. query.phone = Ext.getCmp('ff_phone').getValue();
  206. if(Ext.getCmp('ff_Job_duties').getValue().length>0)
  207. query.Job_duties = Ext.getCmp('ff_Job_duties').getValue();
  208. if(Ext.getCmp('ff_company_code').getValue().length>0)
  209. query.company_code = Ext.getCmp('ff_company_code').getValue();
  210. var jsonstr = Ext.JSON.encode(query);
  211. myStore.getProxy().extraParams = {
  212. queryJson : jsonstr
  213. };
  214. Ext.getCmp('InspectorsListPageToolbar').moveFirst();
  215. Ext.getCmp('name').setValue(query.name);
  216. Ext.getCmp('phone').setValue(query.phone);
  217. Ext.getCmp('Job_duties').setValue(query.Job_duties);
  218. Ext.getCmp('company_code').setValue(query.company_code);
  219. // myStore.reload();
  220. clear_filter_form();
  221. this.up('window').hide();
  222. }
  223. }
  224. },{
  225. text: '关闭',
  226. iconCls: 'cancel_btn',
  227. handler: function() {
  228. this.up('window').hide();
  229. }
  230. }]
  231. });
  232. var filterwin = function() {
  233. Ext.create('Ext.window.Window',{
  234. title: '筛选',
  235. height: 300,
  236. width: 350,
  237. layout: 'fit',
  238. items: FilterWin,
  239. closeAction: 'hide'
  240. }).show();
  241. }
  242. var clear_modify_form = function (){
  243. Ext.getCmp('fm_id').setValue("");
  244. Ext.getCmp('fm_name').setValue("");
  245. Ext.getCmp('fm_phone').setValue("");
  246. Ext.getCmp('fm_Job_duties').setValue("");
  247. Ext.getCmp('fm_company_code').setValue("");
  248. Ext.getCmp('InspectorsListPanel').getStore().reload();
  249. }
  250. var ModifyForm = Ext.create('Ext.form.Panel', {
  251. id: 'InspectorsEditForm',
  252. labelWidth: 55,
  253. url: baseUrl+'iot/inspectors/update',
  254. defaultType: 'textfield',
  255. bodyPadding: 15,
  256. items: [{
  257. fieldLabel:'姓名',
  258. id: 'fm_name',
  259. name:'name',
  260. maxLength:20,
  261. maxLengthText:'长度不得超出{0}',
  262. anchor:'75%'
  263. },{
  264. fieldLabel:'手机号',
  265. id: 'fm_phone',
  266. name: 'phone',
  267. maxLength: 250,
  268. maxLengthText:'长度不得超出{0}',
  269. anchor:'95%'
  270. },{
  271. fieldLabel:'职务',
  272. id: 'fm_Job_duties',
  273. name: 'Job_duties',
  274. maxLength: 250,
  275. maxLengthText:'长度不得超出{0}',
  276. anchor:'95%'
  277. },{
  278. fieldLabel:'单位编号',
  279. id: 'fm_company_code',
  280. name: 'company_code',
  281. maxLength: 250,
  282. maxLengthText:'长度不得超出{0}',
  283. anchor:'95%'
  284. },{
  285. id: 'fm_id',
  286. name:'id',
  287. hidden:true
  288. },{
  289. id:'fm_queryJson',
  290. name:'queryJson',
  291. hidden:true
  292. }],
  293. buttons: [{
  294. text: '修改',
  295. iconCls:'ok_btn',
  296. handler: function() {
  297. var form = this.up('form').getForm();
  298. if (form.isValid()) {
  299. var query = new Object();
  300. query.id = Ext.getCmp('fm_id').getValue();
  301. query.name = Ext.getCmp('fm_name').getValue();
  302. query.phone = Ext.getCmp('fm_phone').getValue();
  303. query.Job_duties = Ext.getCmp('fm_Job_duties').getValue();
  304. query.company_code = Ext.getCmp('fm_company_code').getValue();
  305. var jsonstr = Ext.JSON.encode(query);
  306. Ext.getCmp('fm_queryJson').setValue(jsonstr);
  307. form.submit({
  308. method:'post',
  309. success: function(form, action) {
  310. Ext.Msg.alert('操作成功', '已修改', function(btn,txt){
  311. clear_modify_form();
  312. });
  313. },
  314. failure: function(form, action) {
  315. Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){
  316. clear_modify_form();
  317. });
  318. }
  319. });
  320. this.up('window').hide();
  321. }
  322. }
  323. },{
  324. text: '关闭',
  325. iconCls: 'cancel_btn',
  326. handler: function() {
  327. this.up('window').hide();
  328. }
  329. }]
  330. });
  331. var modifywin = function(){
  332. Ext.create('Ext.window.Window', {
  333. title: '修改',
  334. height: 350,
  335. width: 400,
  336. layout: 'fit',
  337. items: ModifyForm,
  338. closeAction: 'hide'
  339. }).show();
  340. }
  341. var chk_sm = function() {
  342. if(sm.getCount()==1){
  343. modifywin();
  344. var selected = sm.getSelection( );
  345. Ext.getCmp('fm_id').setValue(selected[0].raw.id);
  346. Ext.getCmp('fm_name').setValue(selected[0].raw.name);
  347. Ext.getCmp('fm_phone').setValue(selected[0].raw.phone);
  348. Ext.getCmp('fm_Job_duties').setValue(selected[0].raw.Job_duties);
  349. Ext.getCmp('fm_company_code').setValue(selected[0].raw.company_code);
  350. }else{
  351. Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改');
  352. }
  353. }
  354. //
  355. // var deletewin = function() {
  356. // window.alert("无此功能");
  357. //
  358. // }
  359. Ext.create('Ext.grid.Panel', {
  360. title: '巡检人管理',
  361. id: 'InspectorsListPanel',
  362. store: myStore,
  363. selModel: sm,
  364. columns: [
  365. //{ header: 'ID', dataIndex: 'UQ_POINT_ID',hidden:true, menuDisabled:true },
  366. { header: 'ID', dataIndex: 'id', width:40, menuDisabled:true },
  367. { header: '姓名', dataIndex: 'name', width:120,align:'center', menuDisabled:true },
  368. { header: '手机号', dataIndex: 'phone', width:160,align:'center', menuDisabled:true },
  369. { header: '职务', dataIndex: 'Job_duties', width:120,align:'center', menuDisabled:true },
  370. { header: '单位编号', dataIndex: 'company_code', width:120,align:'center', menuDisabled:true },
  371. // { header: '记录版本', dataIndex: 'I_VERSION', width:120, align:'center', menuDisabled:true },
  372. // {
  373. // xtype : 'actioncolumn',
  374. // width:20,
  375. // sortable:false,
  376. //
  377. //
  378. // //这里
  379. // align:'center',
  380. // menuDisabled:true,
  381. // items:[{
  382. // icon: '../../res/img/common/forum.gif',
  383. // tooltip: '版本记录',
  384. // handler: function(grid, rowIndex, colIndex) {
  385. // var rec = grid.getStore().getAt(rowIndex);
  386. // window.location = 'version.jsp?theme='+theme+'&pointId='+rec.get('UQ_POINT_ID');
  387. // }
  388. // }]
  389. // }
  390. ],
  391. columnLines: true,
  392. tbar: [
  393. {
  394. xtype: 'button',
  395. iconCls:'filter_btn',
  396. text: '筛选',
  397. listeners: {
  398. click: filterwin
  399. }
  400. },'-',
  401. {xtype: 'tbfill'},'-',
  402. {
  403. xtype: 'button',
  404. iconCls:'append_btn',
  405. text: '新增',
  406. listeners: {
  407. click: appendwin
  408. }
  409. },
  410. {
  411. xtype: 'button',
  412. iconCls:'modify_btn',
  413. text: '修改',
  414. listeners: {
  415. click: chk_sm
  416. }
  417. },
  418. // {
  419. // xtype: 'button',
  420. // iconCls:'delete_btn',
  421. // text: '注销',
  422. // listeners: {
  423. // click: deletewin
  424. // }
  425. // }
  426. // ,{
  427. // xtype: 'button',
  428. // iconCls:'delete_btn',
  429. // text: '导出',
  430. // listeners: {
  431. // click: export_sj
  432. // }
  433. // }
  434. ],
  435. height: maxHeight,
  436. width: '100%',
  437. bbar: new Ext.PagingToolbar({
  438. store: myStore,
  439. id:'InspectorsListPageToolbar',
  440. displayInfo: true,
  441. pageSize: countPerPage,
  442. prependButtons: true,
  443. displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条',
  444. emptyMsg : "没有记录",
  445. firstText: '第一页',
  446. prevText: '前一页',
  447. nextText: '后一页',
  448. lastText: '最后一页',
  449. refreshText: '刷新',
  450. // doRefresh:function(start){
  451. // alert(start);
  452. // relushDataFunction(start); // 调用函数刷新数据
  453. // this.cursor = start; // 更新页签
  454. // }
  455. }),
  456. frame: true,
  457. border:false,
  458. iconCls: 'icon-grid',
  459. renderTo: Ext.getBody()
  460. });
  461. myStore.reload();
  462. maxHeight = document.documentElement.clientHeight;
  463. Ext.getCmp('InspectorsListPanel').setHeight(maxHeight);
  464. });