qrcodeanalysis2.js 12 KB

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