route.js 11 KB

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