inspectors.js 14 KB

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