SetBarcodeRuleForm.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. /**
  2. * setBarcodeRule的Form
  3. */
  4. Ext.define('erp.view.scm.reserve.SetBarcodeRuleForm',{
  5. extend: 'Ext.form.Panel',
  6. alias: 'widget.erpSetBarcodeRuleForm',
  7. id: 'form',
  8. title : caller=='BarCodeSet!BATCH'?'条码产生规则维护':'包装箱号产生规则维护',
  9. frame : true,
  10. layout: 'column',
  11. autoScroll : true,
  12. defaultType : 'textfield',
  13. labelSeparator : ':',
  14. buttonAlign : 'center',
  15. cls: 'u-form-default',
  16. enableTools: true,
  17. fieldDefaults : {
  18. fieldStyle : "background:#FFFAFA;color:#515151;",
  19. focusCls: 'x-form-field-cir-focus',
  20. labelAlign : "right",
  21. msgTarget: 'side',
  22. blankText : $I18N.common.form.blankText
  23. },
  24. //requires: ['erp.view.common.JProcess.SetNodeGridPanel','erp.view.oa.task.TaskPanel'],
  25. FormUtil: Ext.create('erp.util.FormUtil'),
  26. BaseUtil: Ext.create('erp.util.BaseUtil'),
  27. items : [{ xtype : "container",
  28. html : '<div class="x-form-group-label" id="group1" style="background-color: #bfbfbe;height:22px!important;" title="收拢"><h6>'+(caller=='BarCodeSet!BATCH'?"P+V+D+N":"P+N")+'</h6></div>',
  29. columnWidth:1,
  30. style:"padding-bottom: 4px;"
  31. },{
  32. allowBlank:false,
  33. allowDecimals:false,
  34. cls:"form-field-allowBlank-hidden",
  35. columnWidth:0.25,
  36. dataIndex:"bs_id",
  37. editable:true,
  38. fieldLabel:"ID",
  39. fieldStyle:"background:#E0E0FF;color:#515151;",
  40. id:"bs_id",
  41. labelAlign:"left",
  42. name:"bs_id",
  43. readOnly:true,
  44. table:"BarcodeSet",
  45. xtype:"hidden"
  46. },{
  47. allowBlank:false,
  48. allowDecimals:false,
  49. cls:"form-field-allowBlank-hidden",
  50. columnWidth:0.25,
  51. dataIndex:"bs_type",
  52. editable:true,
  53. fieldLabel:"类型",
  54. fieldStyle:"background:#E0E0FF;color:#515151;",
  55. id:"bs_type",
  56. labelAlign:"left",
  57. name:"bs_type",
  58. readOnly:true,
  59. value : formCondition.split("=")[1].replace(/'/g,""),
  60. table:"BarcodeSet",
  61. xtype:"hidden"
  62. },{
  63. allowBlank:false,
  64. allowDecimals:false,
  65. cls:"form-field-allowBlank",
  66. columnWidth:0.25,
  67. dataIndex:"bs_lenprid",
  68. editable:true,
  69. fieldLabel:"物料长度(P)",
  70. fieldStyle:"background:#FFFAFA;color:#515151;",
  71. id:"bs_lenprid",
  72. labelAlign:"left",
  73. name:"bs_lenprid",
  74. table:"BarcodeSet",
  75. xtype:"numberfield"
  76. },{
  77. allowBlank:false,
  78. allowDecimals:false,
  79. cls:"form-field-allowBlank",
  80. columnWidth:0.25,
  81. dataIndex:"bs_lenveid",
  82. editable:true,
  83. fieldLabel:"供应商长度(V)",
  84. fieldStyle:"background:#FFFAFA;color:#515151;",
  85. id:"bs_lenveid",
  86. labelAlign:"left",
  87. name:"bs_lenveid",
  88. table:"BarcodeSet",
  89. xtype:caller=='BarCodeSet!BATCH'?"numberfield":"hidden"
  90. },{
  91. allowBlank:true,
  92. allowDecimals:false,
  93. cls:"form-field-allowBlank",
  94. columnWidth:0.25,
  95. dataIndex:"bs_datestr",
  96. displayField: 'display',
  97. valueField: 'value',
  98. editable:true,
  99. fieldLabel:"日期信息(D)",
  100. fieldStyle:"background:#FFFAFA;color:#515151;",
  101. id:"bs_datestr",
  102. labelAlign:"left",
  103. name:"bs_datestr",
  104. table:"BarcodeSet",
  105. xtype:caller=='BarCodeSet!BATCH'?"combo":"hidden",
  106. store:Ext.create("Ext.data.Store",{
  107. fields:["display","value"],
  108. data : [{display: "YYMMDD", value: "YYMMDD"},
  109. {display: "YYMM", value: "YYMM"},
  110. {display: "MMDD", value: "MMDD"},
  111. {display: "无", value: "0"}]
  112. })
  113. },{
  114. allowBlank:true,
  115. allowDecimals:false,
  116. cls:"form-field-allowBlank",
  117. columnWidth:0.25,
  118. dataIndex:"bs_lennum",
  119. editable:true,
  120. fieldLabel:"流水长度(N)",
  121. fieldStyle:"background:#FFFAFA;color:#515151;",
  122. id:"bs_lennum",
  123. labelAlign:"left",
  124. name:"bs_lennum",
  125. table:"BarcodeSet",
  126. xtype:"numberfield"
  127. },{
  128. xtype : "container",
  129. html : '<div class="x-form-group-label" id="group2" style="background-color: #bfbfbe;height:22px!important;" title="收拢2"><h6>其他信息</h6></div>',
  130. columnWidth:1,
  131. style:"padding-bottom: 4px;"
  132. },{
  133. cls:"form-field-allowBlank",
  134. columnWidth:0.25,
  135. dataIndex:"bs_maxnum",
  136. editable:true,
  137. fieldLabel:"当前流水",
  138. fieldStyle:"background:#E0E0FF;color:#515151;",
  139. id:"bs_maxnum",
  140. labelAlign:"left",
  141. name:"bs_maxnum",
  142. readOnly:true,
  143. table:"BarcodeSet",
  144. value:"0",
  145. xtype:"textfield"
  146. },{
  147. cls:"form-field-allowBlank",
  148. columnWidth:0.25,
  149. dataIndex:"bs_totallen",
  150. editable:true,
  151. fieldLabel:"总长度",
  152. fieldStyle:"background:#E0E0FF;color:#515151;",
  153. id:"bs_totallen",
  154. labelAlign:"left",
  155. name:"bs_totallen",
  156. readOnly:true,
  157. table:"BarcodeSet",
  158. value:"",
  159. xtype:"numberfield"
  160. },{
  161. cls:"form-field-allowBlank",
  162. columnWidth:0.25,
  163. dataIndex:"bs_recorder",
  164. editable:true,
  165. fieldLabel:"录入人",
  166. fieldStyle:"background:#E0E0FF;color:#515151;",
  167. id:"bs_recorder",
  168. labelAlign:"left",
  169. name:"bs_recorder",
  170. readOnly:true,
  171. table:"BarcodeSet",
  172. value:"",
  173. xtype:"textfield"
  174. },{
  175. cls:"form-field-allowBlank",
  176. columnWidth:0.25,
  177. dataIndex:"bs_date",
  178. editable:true,
  179. fieldLabel:"录入日期",
  180. fieldStyle:"background:#E0E0FF;color:#515151;",
  181. id:"bs_date",
  182. labelAlign:"left",
  183. name:"bs_date",
  184. readOnly:true,
  185. table:"BarcodeSet",
  186. value:"",
  187. xtype:"datefield"
  188. },{
  189. cls:"form-field-allowBlank",
  190. columnWidth:0.25,
  191. dataIndex:"bs_maxdate",
  192. editable:true,
  193. fieldLabel:"上次日期",
  194. fieldStyle:"background:#E0E0FF;color:#515151;",
  195. id:"bs_maxdate",
  196. labelAlign:"left",
  197. name:"bs_maxdate",
  198. readOnly:true,
  199. table:"BarcodeSet",
  200. value:"",
  201. xtype:caller=='BarCodeSet!BATCH'?"textfield":"hidden"
  202. }],
  203. buttonAlign:'center',
  204. buttons:[{
  205. xtype: 'erpSaveButton',
  206. id:"saveButton"
  207. },{
  208. xtype: 'erpUpdateButton',
  209. id:"updateButton"
  210. },{
  211. xtype: 'erpCloseButton',
  212. id:'close'
  213. }],
  214. initComponent : function(){
  215. var me = this;
  216. me.FormUtil=Ext.create('erp.util.FormUtil');
  217. me.GridUtil=Ext.create('erp.util.GridUtil');
  218. me.BaseUtil=Ext.create('erp.util.BaseUtil');
  219. formCondition = getUrlParam('formCondition');
  220. this.getData();
  221. this.callParent(arguments);
  222. if(this.enableTools) {
  223. me.setTools();
  224. }
  225. },
  226. /**
  227. * FormHeader Tools
  228. * 包括:查看日志、查看流程、查看列表、最大化、最小化、刷新、关闭、上一条、下一条
  229. */
  230. setTools: function(){
  231. var datalistId = getUrlParam('datalistId');
  232. this.tools = [{
  233. type: 'search',
  234. tooltip: '查看单据日志',
  235. listeners:{
  236. click: function(btn){
  237. var form = Ext.getCmp('form');
  238. var id = Ext.getCmp(form.keyField).value;
  239. if(id != null && id != 0){
  240. form.getLogs(id);
  241. }
  242. }
  243. }
  244. },{
  245. type: 'save',
  246. tooltip: '导出Excel',
  247. listeners:{
  248. click: function(btn){
  249. var form = Ext.getCmp('form');
  250. var id = Ext.getCmp(form.keyField).value;
  251. form.saveAsExcel(id,caller);
  252. }
  253. }
  254. },{
  255. type: 'maximize',
  256. tooltip: '最大化',
  257. listeners:{
  258. click: function(btn){
  259. var height = window.screen.height*0.87;
  260. var width = window.screen.width;
  261. //弹出框显示,可以锁定住地址栏和工具栏,防止用户不合理操作
  262. window.open(window.location.href, '', 'width=' + width + ',height=' + height + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
  263. }
  264. }
  265. },{
  266. type: 'minus',
  267. tooltip: '最小化',
  268. listeners:{
  269. click: function(btn){
  270. var p = parent.Ext.getCmp('content-panel');
  271. if(p){
  272. var t = p.getActiveTab();
  273. var b = parent.Ext.getCmp('bottom');
  274. if(b){
  275. b.insert(4, {
  276. text: t.title,
  277. tooltip: t.tabConfig.tooltip,
  278. tab: t,
  279. handler: function(btn){
  280. var a = p.add(btn.tab);
  281. p.setActiveTab(a);
  282. btn.destroy();
  283. }
  284. });
  285. p.remove(t, false);//并不销毁
  286. }
  287. }
  288. }
  289. }
  290. },{
  291. type: 'refresh',
  292. tooltip: '刷新',
  293. listeners:{
  294. click: function(btn){
  295. var form = btn.up('form');
  296. if(typeof form.refresh === 'function')
  297. form.refresh.call(null, form);
  298. else
  299. window.location.reload();
  300. }
  301. }
  302. }];
  303. },
  304. /**
  305. * 拿到操作日志
  306. */
  307. getLogs: function(id){
  308. if(Ext.getCmp('win' + id)){
  309. Ext.getCmp('win' + id).show();
  310. } else {
  311. Ext.Ajax.request({//拿到grid的columns
  312. url : basePath + 'common/getMessageLogs.action',
  313. async: false,
  314. params: {
  315. caller: caller,
  316. id: id
  317. },
  318. method : 'post',
  319. callback : function(options,success,response){
  320. var res = new Ext.decode(response.responseText);
  321. if(res.exception || res.exceptionInfo){
  322. showError(res.exceptionInfo);
  323. return;
  324. }
  325. var logs = res.logs;
  326. logs = logs.length == 0 ? [{ml_date: $I18N.common.grid.emptyText, ml_man: $I18N.common.grid.emptyText,
  327. ml_content: $I18N.common.grid.emptyText, ml_result: $I18N.common.grid.emptyText}] : logs;
  328. Ext.create('Ext.window.Window', {
  329. id : 'win' + id,
  330. title: '<span style="color:#CD6839;">操作日志</span>',
  331. iconCls: 'x-button-icon-set',
  332. closeAction: 'hide',
  333. height: "100%",
  334. width: "80%",
  335. maximizable : true,
  336. buttonAlign : 'center',
  337. layout : 'anchor',
  338. items: [{
  339. anchor: '100% 100%',
  340. xtype: 'gridpanel',
  341. ignore: true,
  342. bodyStyle: 'background:#f1f1f1;',
  343. autoScroll: true,
  344. store: Ext.create('Ext.data.Store', {
  345. fields: ['ml_date', 'ml_man', 'ml_content', 'ml_result'],
  346. data: logs
  347. }),
  348. columnLines: true,
  349. columns: [
  350. { header: '时间', dataIndex: 'ml_date', flex: 1.5 , renderer: function(val){
  351. if(val != '无数据'){
  352. return Ext.Date.format(new Date(val), 'Y-m-d H:i:s');
  353. }
  354. }},
  355. { header: '操作人员', dataIndex: 'ml_man', flex: 1 ,renderer: function(val){
  356. if(val == em_name){
  357. return '<font color=red>' + val + '</font>';
  358. } else {
  359. return val;
  360. }
  361. }},
  362. { header: '操作', dataIndex: 'ml_content', flex: 1.5},
  363. { header: '结果', dataIndex: 'ml_result', flex: 3}
  364. ]
  365. }],
  366. buttons : [{
  367. text : '关 闭',
  368. iconCls: 'x-button-icon-close',
  369. cls: 'x-btn-gray',
  370. handler : function(){
  371. Ext.getCmp('win' + id).close();
  372. }
  373. }]
  374. }).show();
  375. }
  376. });
  377. }
  378. },
  379. saveAsExcel:function(id,caller){
  380. if(id==null || id =='') showMessage('提示','无法导出空数据单据',1000);
  381. else window.location.href=basePath+'excel/savePanelAsExcel.action?id='+id+"&caller="+caller+"&_noc=1";
  382. },
  383. getData:function(){
  384. var me = this;
  385. //从url解析参数
  386. if(formCondition != null && formCondition != ''){
  387. Ext.Ajax.request({
  388. url : basePath + 'scm/reserve/getBarcodeRuleData.action',
  389. params: {
  390. caller: caller,
  391. condition: formCondition.split("&")[0],
  392. _noc: (getUrlParam('_noc') || me._noc)
  393. },
  394. method : 'post',
  395. callback : function(options,success,response){
  396. var res = new Ext.decode(response.responseText);
  397. if(res.exceptionInfo != null){
  398. showError(res.exceptionInfo);return;
  399. }else{
  400. Ext.getCmp("saveButton").hide();
  401. me.setFormValues(res.data);
  402. }
  403. }
  404. });
  405. }else{
  406. Ext.Ajax.request({
  407. url : basePath + "scm/reserve/getCurrent.action",
  408. params: {},
  409. method : 'post',
  410. callback : function(options,success,response){
  411. var res = new Ext.decode(response.responseText);
  412. if(res.exceptionInfo != null){
  413. showError(res.exceptionInfo);return;
  414. }
  415. if(res.man&&res.date){
  416. Ext.getCmp("bs_recorder").setValue(res.man);
  417. Ext.getCmp("bs_date").setValue(res.date);
  418. }
  419. }
  420. });
  421. Ext.getCmp("updateButton").hide();
  422. }
  423. },
  424. setFormValues : function(data){
  425. var form = Ext.getCmp('form');
  426. form.getForm().setValues(data);
  427. }
  428. });