patrolpoint.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /**
  2. * patrolpoint.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('PatrolPoint',{
  19. extend: 'Ext.data.Model',
  20. fields: [
  21. {name:'id', type:'string'},
  22. {name:'label', type:'string'},
  23. {name:'label1', type:'string'},
  24. {name:'address', type:'string'},
  25. {name:'equipment_id', type:'string'},
  26. {name:'xj_name', type:'string'},
  27. ]
  28. });
  29. Ext.onReady(function(){
  30. var baseUrl = document.getElementById('basePath').value;
  31. var theme = document.getElementById('theme').value;
  32. var chkIcon = '<img src="'+baseUrl+'res/img/common/check.gif"/>'
  33. var unchkIcon = '<img src="'+baseUrl+'res/img/common/uncheck.gif"/>'
  34. var countPerPage = 20;
  35. var maxHeight = 10000;
  36. var chkBoolean = function(flag) {
  37. if(flag)
  38. return chkIcon;
  39. return unchkIcon;
  40. }
  41. var getManufacturerId = Ext.create("Ext.data.Store", {
  42. fields: ["id", "analysis_content"],
  43. autoLoad: true,
  44. proxy: {
  45. type: "ajax",
  46. actionMethods: { read: "POST" },
  47. url: baseUrl+'iot/qrcodeanalysis/getList1',
  48. reader: {
  49. type: "json",
  50. root: "RESULT"
  51. }
  52. }
  53. });
  54. var clear_append_form = function (){
  55. Ext.getCmp('fa_label').setValue("");
  56. Ext.getCmp('fa_address').setValue("");
  57. Ext.getCmp('fa_equipment_id').setValue("");
  58. Ext.getCmp('fa_xj_name').setValue("");
  59. Ext.getCmp('PatrolPointListPanel').getStore().reload();
  60. }
  61. var myStore = Ext.create('Ext.data.Store', {
  62. model: 'PatrolPoint',
  63. pageSize: countPerPage,
  64. proxy: {
  65. type: 'ajax',
  66. url: baseUrl+'iot/patrolpoint/getList1',
  67. reader: {
  68. type: 'json',
  69. root: 'RESULT',
  70. totalProperty: 'totalCount'
  71. }
  72. },
  73. remoteSort: true
  74. });
  75. var AppendForm = Ext.create('Ext.form.Panel', {
  76. id: 'PatrolPointAppendForm',
  77. labelWidth: 55,
  78. url: baseUrl+'iot/patrolpoint/append1',
  79. defaultType: 'textfield',
  80. bodyPadding: 15,
  81. items: [{
  82. fieldLabel:'巡检点名称',
  83. id: 'fa_xj_name',
  84. name:'xj_name',
  85. maxLength:20,
  86. maxLengthText:'长度不得超出{0}',
  87. anchor:'75%'
  88. }
  89. // ,{
  90. // fieldLabel:'巡检点标签',
  91. // id: 'fa_label',
  92. // name: 'label',
  93. // maxLength: 250,
  94. // maxLengthText:'长度不得超出{0}',
  95. // anchor:'95%'
  96. // }
  97. ,{
  98. fieldLabel:'请选择巡检点标签',
  99. id:'fa_label',
  100. name:'label',
  101. xtype:'combo',
  102. store:getManufacturerId,
  103. displayField : 'analysis_content',
  104. valueField : 'id',
  105. value : document.getElementById('id1').value,
  106. editable : false
  107. },{
  108. fieldLabel:'巡检点对应的设备',
  109. id: 'fa_equipment_id',
  110. name:'equipment_id',
  111. maxLength: 30,
  112. maxLengthText:'长度不得超出{0}',
  113. anchor:'95%'
  114. },{
  115. fieldLabel:'巡检点地址',
  116. id: 'fa_address',
  117. name: 'address',
  118. maxLength: 250,
  119. maxLengthText:'长度不得超出{0}',
  120. anchor:'95%'
  121. },{
  122. id:'fa_queryJson',
  123. name:'queryJson',
  124. hidden:true
  125. }],
  126. buttons: [{
  127. text: '提交',
  128. iconCls:'ok_btn',
  129. handler: function() {
  130. var form = this.up('form').getForm();
  131. if (form.isValid()) {
  132. var query = new Object();
  133. query.label = Ext.getCmp('fa_label').getValue();
  134. query.address = Ext.getCmp('fa_address').getValue();
  135. query.equipment_id = Ext.getCmp('fa_equipment_id').getValue();
  136. query.xj_name = Ext.getCmp('fa_xj_name').getValue();
  137. var jsonstr = Ext.JSON.encode(query);
  138. Ext.getCmp('fa_queryJson').setValue(jsonstr);
  139. form.submit({
  140. method:'post',
  141. success: function(form, action) {
  142. Ext.Msg.alert('操作成功', '新增点位地址已保存', function(btn,txt){
  143. clear_append_form();
  144. });
  145. },
  146. failure: function(form, action) {
  147. Ext.Msg.alert('操作失败', action.Msg , function(btn,txt){
  148. clear_append_form();
  149. });
  150. }
  151. });
  152. }
  153. }
  154. },{
  155. text: '关闭',
  156. iconCls: 'cancel_btn',
  157. handler: function() {
  158. this.up('window').hide();
  159. }
  160. }]
  161. });
  162. var appendwin = function(){
  163. Ext.create('Ext.window.Window', {
  164. title: '新增',
  165. height: 350,
  166. width: 400,
  167. layout: 'fit',
  168. items: AppendForm,
  169. closeAction: 'hide'
  170. }).show();
  171. }
  172. //筛选
  173. var clear_filter_form = function(){
  174. Ext.getCmp('ff_xj_name').setValue("");
  175. Ext.getCmp('ff_equipment_id').setValue("");
  176. Ext.getCmp('ff_label').setValue("");
  177. Ext.getCmp('ff_address').setValue("");
  178. }
  179. var FilterWin = Ext.create('Ext.form.Panel', {
  180. id: 'PatrolPointFilterForm',
  181. labelWidth: 55,
  182. defaultType: 'textfield',
  183. bodyPadding: 15,
  184. items: [{
  185. fieldLabel:'巡检点名称',
  186. id: 'ff_xj_name',
  187. name:'xj_name',
  188. maxLength:20,
  189. maxLengthText:'长度不得超出{0}',
  190. value : document.getElementById('xj_name').value,
  191. anchor:'75%'
  192. },{
  193. fieldLabel:'巡检点标签',
  194. id:'ff_label',
  195. name:'label',
  196. maxLength: 250,
  197. maxLengthText:'长度不得超出{0}',
  198. value : document.getElementById('label').value,
  199. editable : false
  200. },{
  201. fieldLabel:'巡检点对应的设备',
  202. id: 'ff_equipment_id',
  203. name: 'equipment_id',
  204. maxLength: 250,
  205. maxLengthText:'长度不得超出{0}',
  206. value : document.getElementById('equipment_id').value,
  207. anchor:'95%'
  208. },{
  209. fieldLabel:'巡检点地址',
  210. id: 'ff_address',
  211. name: 'address',
  212. maxLength: 250,
  213. maxLengthText:'长度不得超出{0}',
  214. value : document.getElementById('address').value,
  215. anchor:'95%'
  216. },{
  217. id:'ff_queryJson',
  218. name:'queryJson',
  219. hidden:true
  220. }],
  221. buttons: [{
  222. text: '提交',
  223. iconCls:'ok_btn',
  224. handler: function() {
  225. var form = this.up('form').getForm();
  226. if (form.isValid()) {
  227. var query = new Object();
  228. if(Ext.getCmp('ff_label').getValue().length>0)
  229. query.label = Ext.getCmp('ff_label').getValue();
  230. if(Ext.getCmp('ff_address').getValue().length>0)
  231. query.address = Ext.getCmp('ff_address').getValue();
  232. if(Ext.getCmp('ff_equipment_id').getValue().length>0)
  233. query.equipment_id = Ext.getCmp('ff_equipment_id').getValue();
  234. if(Ext.getCmp('ff_xj_name').getValue().length>0)
  235. query.xj_name = Ext.getCmp('ff_xj_name').getValue();
  236. var jsonstr = Ext.JSON.encode(query);
  237. myStore.getProxy().extraParams = {
  238. queryJson : jsonstr
  239. };
  240. Ext.getCmp('PatrolPointListPageToolbar').moveFirst();
  241. Ext.getCmp('label').setValue(query.label);
  242. Ext.getCmp('address').setValue(query.address);
  243. Ext.getCmp('equipment_id').setValue(query.equipment_id);
  244. Ext.getCmp('xj_name').setValue(query.xj_name);
  245. // myStore.reload();
  246. clear_filter_form();
  247. this.up('window').hide();
  248. }
  249. }
  250. },{
  251. text: '关闭',
  252. iconCls: 'cancel_btn',
  253. handler: function() {
  254. this.up('window').hide();
  255. }
  256. }]
  257. });
  258. var filterwin = function() {
  259. Ext.create('Ext.window.Window',{
  260. title: '筛选',
  261. height: 300,
  262. width: 350,
  263. layout: 'fit',
  264. items: FilterWin,
  265. closeAction: 'hide'
  266. }).show();
  267. }
  268. var getManufacturerId2 = Ext.create("Ext.data.Store", {
  269. fields: ["analysis_content", "analysis_content"],
  270. autoLoad: true,
  271. proxy: {
  272. type: "ajax",
  273. actionMethods: { read: "POST" },
  274. url: baseUrl+'iot/qrcodeanalysis/getList',
  275. reader: {
  276. type: "json",
  277. root: "RESULT"
  278. }
  279. }
  280. });
  281. var clear_modify_form = function (){
  282. Ext.getCmp('fm_id').setValue("");
  283. Ext.getCmp('fm_label').setValue("");
  284. Ext.getCmp('fm_address').setValue("");
  285. Ext.getCmp('fm_equipment_id').setValue("");
  286. Ext.getCmp('fm_xj_name').setValue("");
  287. Ext.getCmp('PatrolPointListPanel').getStore().reload();
  288. }
  289. var ModifyForm = Ext.create('Ext.form.Panel', {
  290. id: 'PatrolPointEditForm',
  291. labelWidth: 55,
  292. url: baseUrl+'iot/patrolpoint/update1',
  293. defaultType: 'textfield',
  294. bodyPadding: 15,
  295. items: [{
  296. fieldLabel:'巡检点名称',
  297. id: 'fm_xj_name',
  298. name:'xj_name',
  299. maxLength:20,
  300. maxLengthText:'长度不得超出{0}',
  301. anchor:'75%'
  302. }
  303. // ,{
  304. // fieldLabel:'巡检点标签',
  305. // id: 'fm_label',
  306. // name: 'label',
  307. // maxLength: 250,
  308. // maxLengthText:'长度不得超出{0}',
  309. // anchor:'95%'
  310. // }
  311. ,{
  312. fieldLabel:'请选择巡检点标签',
  313. id:'fm_label',
  314. name:'label',
  315. xtype:'combo',
  316. store:getManufacturerId2,
  317. displayField : 'analysis_content',
  318. valueField : 'analysis_content',
  319. editable : false,
  320. },{
  321. fieldLabel:'巡检点对应名称',
  322. id: 'fm_equipment_id',
  323. name: 'equipment_id',
  324. maxLength: 250,
  325. maxLengthText:'长度不得超出{0}',
  326. anchor:'95%'
  327. },{
  328. fieldLabel:'巡检点地址',
  329. id: 'fm_address',
  330. name:'address',
  331. maxLength: 30,
  332. // value:"0000-0000-0000",
  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.label = Ext.getCmp('fm_label').getValue();
  353. query.address = Ext.getCmp('fm_address').getValue();
  354. query.equipment_id = Ext.getCmp('fm_equipment_id').getValue();
  355. query.xj_name = Ext.getCmp('fm_xj_name').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_label').setValue(selected[0].raw.label);
  398. Ext.getCmp('fm_address').setValue(selected[0].raw.address);
  399. Ext.getCmp('fm_equipment_id').setValue(selected[0].raw.equipment_id);
  400. Ext.getCmp('fm_xj_name').setValue(selected[0].raw.xj_name);
  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: 'PatrolPointListPanel',
  413. store: myStore,
  414. selModel: sm,
  415. columns: [
  416. { header: '默认标签id', dataIndex: 'label1',hidden:true, menuDisabled:true },
  417. { header: 'ID', dataIndex: 'id', width:40, menuDisabled:true },
  418. { header: '巡检点名称', dataIndex: 'xj_name', width:120,align:'center', menuDisabled:true },
  419. { header: '巡检点标签', dataIndex: 'label', width:160,align:'center', menuDisabled:true },
  420. { header: '巡检点对应设备', dataIndex: 'equipment_id', width:120,align:'center', menuDisabled:true },
  421. { header: '巡检点地址', dataIndex: 'address',width:160, 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:'PatrolPointListPageToolbar',
  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('PatrolPointListPanel').setHeight(maxHeight);
  515. });