qrcodeanalysis.js 10 KB

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