inspectors.js 14 KB

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