route2.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. /**
  2. * route2.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('Route2',{
  22. extend: 'Ext.data.Model',
  23. fields: [
  24. {name:'id', type:'string'},
  25. {name:'route', type:'string'},
  26. {name:'route_name', type:'string'},
  27. // {name:'xjzq', type:'string'},
  28. {name:'company_code1', type:'string'},
  29. ]
  30. });
  31. function exportbtn_click(){
  32. baseUrl = document.getElementById('basePath').value;
  33. V_LOGINNAME = $("#V_LOGINNAME").val();
  34. V_PASSWORD = $("#V_PASSWORD").val();
  35. route_name = document.getElementById('route_name').value;
  36. route = document.getElementById('route').value;
  37. var fields = '';
  38. var array = ['id','route','route_name'];
  39. var name = ['编号','路线','路线名称'];
  40. for(var i=0;i<3;i++){
  41. if(i>0)
  42. fields += ',';
  43. fields += '{id:"'+array[i]+'",title:"'+name[i]+'",shown:"'+true+'"}';
  44. }
  45. var query = new Object();
  46. // query.V_LOGINNAME = V_LOGINNAME;
  47. // query.V_PASSWORD = V_PASSWORD;
  48. query.route_name = route_name;
  49. query.route = route;
  50. query.EXPORT_FILE = '巡检路线列表';
  51. query.fields = '['+fields+']';
  52. $.ajax({
  53. type:'POST',
  54. url: baseUrl+"iot/excel/view/route2Excel",
  55. data: {
  56. queryJson : Ext.JSON.encode(query)
  57. },
  58. success: function(result){
  59. var json = eval('(' + result + ')');
  60. if(json.action=='dormExport'){
  61. ConfirmStore = json.RESULT;
  62. var elemIF = document.createElement("iframe");
  63. elemIF.src = baseUrl+json.filename;
  64. elemIF.style.display = "none";
  65. document.body.appendChild(elemIF);
  66. }
  67. }
  68. });
  69. }
  70. Ext.onReady(function(){
  71. var baseUrl = document.getElementById('basePath').value;
  72. var theme = document.getElementById('theme').value;
  73. var chkIcon = '<img src="'+baseUrl+'res/img/common/check.gif"/>'
  74. var unchkIcon = '<img src="'+baseUrl+'res/img/common/uncheck.gif"/>'
  75. // company_code = document.getElementById('company_code').value;
  76. $("#V_LOGINNAME").val(sessionStorage.getItem('V_LOGINNAME'));
  77. $("#V_PASSWORD").val(sessionStorage.getItem('V_PASSWORD'));
  78. V_LOGINNAME = $("#V_LOGINNAME").val();
  79. V_PASSWORD = $("#V_PASSWORD").val();
  80. var countPerPage = 20;
  81. var maxHeight = 10000;
  82. var chkBoolean = function(flag) {
  83. if(flag)
  84. return chkIcon;
  85. return unchkIcon;
  86. }
  87. var queryJson = new Object();
  88. // queryJson.V_LOGINNAME = V_LOGINNAME;
  89. // queryJson.V_PASSWORD = V_PASSWORD;
  90. // queryJson.COMMSTATUS = 'NO';
  91. if((company_code!=null)&&(company_code!='null')&&(company_code.length>0))
  92. queryJson.company_code = company_code;
  93. var clear_append_form = function (){
  94. Ext.getCmp('fa_route').setValue("");
  95. Ext.getCmp('fa_route_name').setValue("");
  96. // Ext.getCmp('fa_xjzq').setValue("");
  97. // Ext.getCmp('fa_company_code').setValue("");
  98. Ext.getCmp('Route2ListPanel').getStore().reload();
  99. }
  100. myStore = Ext.create('Ext.data.Store', {
  101. model: 'Route2',
  102. pageSize: countPerPage,
  103. proxy: {
  104. type: 'ajax',
  105. actionMethods: {
  106. create : 'POST',
  107. read : 'POST', // by default GET
  108. update : 'POST',
  109. destroy: 'POST'
  110. },
  111. url: baseUrl+'iot/route2/getList',
  112. reader: {
  113. type: 'json',
  114. root: 'RESULT',
  115. totalProperty: 'totalCount'
  116. },
  117. extraParams:{
  118. queryJson:Ext.JSON.encode(queryJson)
  119. }
  120. },
  121. // sorters:[{
  122. // property:'data_time',
  123. // direction:'DESC'
  124. // }],
  125. remoteSort: true
  126. });
  127. Ext.define('Maintenance',{
  128. extend: 'Ext.data.Model',
  129. fields: [
  130. {name:'id', type:'string'},
  131. {name:'xj_name', type:'string'},
  132. ]
  133. });
  134. myStore1 = Ext.create('Ext.data.Store', {
  135. model: 'Maintenance',
  136. pageSize: countPerPage,
  137. proxy: {
  138. type: 'ajax',
  139. actionMethods: {
  140. create : 'POST',
  141. read : 'POST', // by default GET
  142. update : 'POST',
  143. destroy: 'POST'
  144. },
  145. url: baseUrl+'iot/maintenance/getList',
  146. reader: {
  147. type: 'json',
  148. root: 'RESULT',
  149. totalProperty: 'totalCount'
  150. },
  151. extraParams:{
  152. queryJson:Ext.JSON.encode(queryJson)
  153. }
  154. },
  155. // sorters:[{
  156. // property:'data_time',
  157. // direction:'DESC'
  158. // }],
  159. remoteSort: true
  160. });
  161. // var myStore = Ext.create('Ext.data.Store', {
  162. // model: 'Route',
  163. // pageSize: countPerPage,
  164. // proxy: {
  165. // type: 'ajax',
  166. // url: baseUrl+'iot/route/getList',
  167. // reader: {
  168. // type: 'json',
  169. // root: 'RESULT',
  170. // totalProperty: 'totalCount'
  171. // }
  172. // },
  173. // remoteSort: true
  174. // });
  175. var AppendForm = Ext.create('Ext.form.Panel', {
  176. id: 'Route2AppendForm',
  177. labelWidth: 55,
  178. url: baseUrl+'iot/route2/append',
  179. defaultType: 'textfield',
  180. bodyPadding: 15,
  181. items: [{
  182. fieldLabel:'路线名称',
  183. id: 'fa_route_name',
  184. name:'route_name',
  185. maxLength:20,
  186. maxLengthText:'长度不得超出{0}',
  187. anchor:'75%'
  188. }
  189. // ,{
  190. // fieldLabel:'路线',
  191. // id: 'fa_route',
  192. // name: 'route',
  193. // maxLength: 250,
  194. // maxLengthText:'长度不得超出{0}',
  195. // anchor:'95%'
  196. // }
  197. ,{
  198. fieldLabel:'路线',
  199. id:'fa_route',
  200. name:'route',
  201. xtype:'combo',
  202. multiSelect: true,
  203. store:myStore1,
  204. displayField : 'xj_name',
  205. valueField : 'id',
  206. // value : document.getElementById('id1').value,
  207. editable : false
  208. }
  209. // ,{
  210. // id: 'fm_company_code',
  211. // name:'company_code',
  212. // hidden:true
  213. // }
  214. ,{
  215. id:'fa_queryJson',
  216. name:'queryJson',
  217. hidden:true
  218. }],
  219. buttons: [{
  220. text: '提交',
  221. iconCls:'ok_btn',
  222. handler: function() {
  223. var form = this.up('form').getForm();
  224. if (form.isValid()) {
  225. var query = new Object();
  226. // query.V_LOGINNAME = V_LOGINNAME;
  227. query.route_name = Ext.getCmp('fa_route_name').getValue();
  228. // var a,b,c;
  229. a = Ext.getCmp('fa_route').getValue();
  230. c = a.join(',');
  231. // query.route = Ext.getCmp('fa_route').getValue();
  232. query.route = c;
  233. // query.xjzq = Ext.getCmp('fa_xjzq').getValue();
  234. // query.company_code = Ext.getCmp('fa_company_code').getValue();
  235. var jsonstr = Ext.JSON.encode(query);
  236. Ext.getCmp('fa_queryJson').setValue(jsonstr);
  237. form.submit({
  238. method:'post',
  239. success: function(form, action) {
  240. Ext.Msg.alert('操作成功', '已保存', function(btn,txt){
  241. clear_append_form();
  242. });
  243. },
  244. failure: function(form, action) {
  245. Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){
  246. clear_append_form();
  247. });
  248. }
  249. });
  250. }
  251. }
  252. },{
  253. text: '关闭',
  254. iconCls: 'cancel_btn',
  255. handler: function() {
  256. this.up('window').hide();
  257. }
  258. }]
  259. });
  260. var appendwin = function(){
  261. Ext.create('Ext.window.Window', {
  262. title: '新增',
  263. height: 350,
  264. width: 400,
  265. layout: 'fit',
  266. items: AppendForm,
  267. closeAction: 'hide'
  268. }).show();
  269. }
  270. //筛选
  271. var clear_filter_form = function(){
  272. Ext.getCmp('ff_route_name').setValue("");
  273. Ext.getCmp('ff_route').setValue("");
  274. // Ext.getCmp('ff_xjzq').setValue("");
  275. Ext.getCmp('ff_company_code').setValue("");
  276. }
  277. var FilterWin = Ext.create('Ext.form.Panel', {
  278. id: 'Route2FilterForm',
  279. labelWidth: 55,
  280. defaultType: 'textfield',
  281. bodyPadding: 15,
  282. items: [{
  283. fieldLabel:'路线名称',
  284. id: 'ff_route_name',
  285. name:'route_name',
  286. maxLength:20,
  287. maxLengthText:'长度不得超出{0}',
  288. value : document.getElementById('route_name').value,
  289. anchor:'75%'
  290. },{
  291. fieldLabel:'路线',
  292. id:'ff_route',
  293. name:'route',
  294. maxLength: 250,
  295. maxLengthText:'长度不得超出{0}',
  296. value : document.getElementById('route_name').value,
  297. editable : false
  298. },{
  299. id:'ff_queryJson',
  300. name:'queryJson',
  301. hidden:true
  302. }],
  303. buttons: [{
  304. text: '提交',
  305. iconCls:'ok_btn',
  306. handler: function() {
  307. var form = this.up('form').getForm();
  308. if (form.isValid()) {
  309. var query = new Object();
  310. // if(Ext.getCmp('company_code').getValue().length>0){
  311. // query.company_code = company_code;
  312. // company_code = query.company_code;
  313. // }else{
  314. // company_code = null;
  315. // }
  316. // query.V_LOGINNAME = V_LOGINNAME;
  317. // query.V_PASSWORD = V_PASSWORD;
  318. if(Ext.getCmp('ff_route_name').getValue().length>0)
  319. query.route_name = Ext.getCmp('ff_route_name').getValue();
  320. $("#route_name").val(query.route_name);
  321. if(Ext.getCmp('ff_route').getValue().length>0)
  322. query.route = Ext.getCmp('ff_route').getValue();
  323. $("#route").val(query.route);
  324. // if(Ext.getCmp('ff_xjzq').getValue().length>0)
  325. // query.xjzq = Ext.getCmp('ff_xjzq').getValue();
  326. var jsonstr = Ext.JSON.encode(query);
  327. myStore.getProxy().extraParams = {
  328. queryJson : jsonstr
  329. };
  330. Ext.getCmp('Route2ListPageToolbar').moveFirst();
  331. Ext.getCmp('route_name').setValue(query.route_name);
  332. Ext.getCmp('route').setValue(query.route);
  333. // Ext.getCmp('xjzq').setValue(query.xjzq);
  334. // Ext.getCmp('company_code').setValue(query.company_code);
  335. // myStore.reload();
  336. clear_filter_form();
  337. this.up('window').hide();
  338. }
  339. }
  340. },{
  341. text: '关闭',
  342. iconCls: 'cancel_btn',
  343. handler: function() {
  344. this.up('window').hide();
  345. }
  346. }]
  347. });
  348. var filterwin = function() {
  349. Ext.create('Ext.window.Window',{
  350. title: '筛选',
  351. height: 300,
  352. width: 350,
  353. layout: 'fit',
  354. items: FilterWin,
  355. closeAction: 'hide'
  356. }).show();
  357. }
  358. var clear_modify_form = function (){
  359. Ext.getCmp('fm_id').setValue("");
  360. Ext.getCmp('fm_route_name').setValue("");
  361. Ext.getCmp('fm_route').setValue("");
  362. Ext.getCmp('fm_company_code').setValue("");
  363. // Ext.getCmp('fm_xjzq').setValue("");
  364. Ext.getCmp('Route2ListPanel').getStore().reload();
  365. }
  366. var ModifyForm = Ext.create('Ext.form.Panel', {
  367. id: 'Route2EditForm',
  368. labelWidth: 55,
  369. url: baseUrl+'iot/route2/update',
  370. defaultType: 'textfield',
  371. bodyPadding: 15,
  372. items: [{
  373. fieldLabel:'路线名称',
  374. id: 'fm_route_name',
  375. name:'route_name',
  376. maxLength:20,
  377. maxLengthText:'长度不得超出{0}',
  378. anchor:'75%'
  379. },{
  380. fieldLabel:'路线',
  381. id: 'fm_route',
  382. name: 'route',
  383. maxLength: 250,
  384. maxLengthText:'长度不得超出{0}',
  385. anchor:'95%'
  386. },
  387. {
  388. id: 'fm_id',
  389. name:'id',
  390. hidden:true
  391. },
  392. {
  393. id: 'fm_company_code',
  394. name:'company_code1',
  395. hidden:true
  396. },
  397. {
  398. id:'fm_queryJson',
  399. name:'queryJson',
  400. hidden:true
  401. }],
  402. buttons: [{
  403. text: '修改',
  404. iconCls:'ok_btn',
  405. handler: function() {
  406. var form = this.up('form').getForm();
  407. if (form.isValid()) {
  408. var query = new Object();
  409. query.id = Ext.getCmp('fm_id').getValue();
  410. query.route_name = Ext.getCmp('fm_route_name').getValue();
  411. query.route = Ext.getCmp('fm_route').getValue();
  412. query.company_code = Ext.getCmp('fm_company_code').getValue();
  413. var jsonstr = Ext.JSON.encode(query);
  414. Ext.getCmp('fm_queryJson').setValue(jsonstr);
  415. form.submit({
  416. method:'post',
  417. success: function(form, action) {
  418. Ext.Msg.alert('操作成功', '已修改', function(btn,txt){
  419. clear_modify_form();
  420. });
  421. },
  422. failure: function(form, action) {
  423. Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){
  424. clear_modify_form();
  425. });
  426. }
  427. });
  428. this.up('window').hide();
  429. }
  430. }
  431. },{
  432. text: '关闭',
  433. iconCls: 'cancel_btn',
  434. handler: function() {
  435. this.up('window').hide();
  436. }
  437. }]
  438. });
  439. var modifywin = function(){
  440. Ext.create('Ext.window.Window', {
  441. title: '修改',
  442. height: 350,
  443. width: 400,
  444. layout: 'fit',
  445. items: ModifyForm,
  446. closeAction: 'hide'
  447. }).show();
  448. }
  449. var chk_sm = function() {
  450. if(sm.getCount()==1){
  451. modifywin();
  452. var selected = sm.getSelection( );
  453. Ext.getCmp('fm_id').setValue(selected[0].raw.id);
  454. Ext.getCmp('fm_route_name').setValue(selected[0].raw.route_name);
  455. Ext.getCmp('fm_route').setValue(selected[0].raw.route);
  456. Ext.getCmp('fm_company_code').setValue(selected[0].raw.company_code1);
  457. // Ext.getCmp('fm_xjzq').setValue(selected[0].raw.xjzq);
  458. }else{
  459. Ext.Msg.alert('请先选择','请先选择一条记录,再点击修改');
  460. }
  461. }
  462. //
  463. // var deletewin = function() {
  464. // window.alert("无此功能");
  465. //
  466. // }
  467. Ext.create('Ext.grid.Panel', {
  468. title: '路线管理',
  469. id: 'Route2ListPanel',
  470. store: myStore,
  471. selModel: sm,
  472. columns: [
  473. //{ header: 'ID', dataIndex: 'UQ_POINT_ID',hidden:true, menuDisabled:true },
  474. { header: 'ID', dataIndex: 'id', width:37, menuDisabled:true },
  475. { header: '路线名称', dataIndex: 'route_name', width:700,align:'center', menuDisabled:true },
  476. { header: '路线', dataIndex: 'route', width:700,align:'center', menuDisabled:true },
  477. // { header: '巡检周期', dataIndex: 'xjzq', width:120,align:'center', menuDisabled:true },
  478. // { header: '记录版本', dataIndex: 'I_VERSION', width:120, align:'center', menuDisabled:true },
  479. // {
  480. // xtype : 'actioncolumn',
  481. // width:20,
  482. // sortable:false,
  483. //
  484. //
  485. // //这里
  486. // align:'center',
  487. // menuDisabled:true,
  488. // items:[{
  489. // icon: '../../res/img/common/forum.gif',
  490. // tooltip: '版本记录',
  491. // handler: function(grid, rowIndex, colIndex) {
  492. // var rec = grid.getStore().getAt(rowIndex);
  493. // window.location = 'version.jsp?theme='+theme+'&pointId='+rec.get('UQ_POINT_ID');
  494. // }
  495. // }]
  496. // }
  497. ],
  498. columnLines: true,
  499. tbar: [
  500. {
  501. xtype: 'button',
  502. iconCls:'filter_btn',
  503. text: '筛选',
  504. listeners: {
  505. click: filterwin
  506. }
  507. },'-',
  508. {xtype: 'tbfill'},'-',
  509. {
  510. xtype: 'button',
  511. iconCls:'append_btn',
  512. text: '新增',
  513. listeners: {
  514. click: appendwin
  515. }
  516. },
  517. {
  518. xtype: 'button',
  519. iconCls:'modify_btn',
  520. text: '修改',
  521. listeners: {
  522. click: chk_sm
  523. }
  524. },
  525. // {
  526. // xtype: 'button',
  527. // iconCls:'delete_btn',
  528. // text: '注销',
  529. // listeners: {
  530. // click: deletewin
  531. // }
  532. // }
  533. {
  534. xtype: 'button',
  535. iconCls:'export_btn',
  536. text: '导出',
  537. listeners: {
  538. click: exportbtn_click
  539. }
  540. }
  541. ],
  542. height: maxHeight,
  543. width: '100%',
  544. bbar: new Ext.PagingToolbar({
  545. store: myStore,
  546. id:'Route2ListPageToolbar',
  547. displayInfo: true,
  548. pageSize: countPerPage,
  549. prependButtons: true,
  550. displayMsg : '显示第 {0}条到 {1}条记录,总共 {2}条',
  551. emptyMsg : "没有记录",
  552. firstText: '第一页',
  553. prevText: '前一页',
  554. nextText: '后一页',
  555. lastText: '最后一页',
  556. refreshText: '刷新',
  557. // doRefresh:function(start){
  558. // alert(start);
  559. // relushDataFunction(start); // 调用函数刷新数据
  560. // this.cursor = start; // 更新页签
  561. // }
  562. }),
  563. frame: true,
  564. border:false,
  565. iconCls: 'icon-grid',
  566. renderTo: Ext.getBody()
  567. });
  568. myStore.reload();
  569. maxHeight = document.documentElement.clientHeight;
  570. Ext.getCmp('Route2ListPanel').setHeight(maxHeight);
  571. });