MakeSerial.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.mes.MakeSerial', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views:[
  8. 'pm.mes.MakeSerial','core.form.Panel','core.grid.Panel2','core.button.PrintRepair',
  9. 'core.button.Add','core.button.Save','core.button.Close','core.button.Update','core.button.Delete',
  10. 'core.form.YnField','core.grid.YnColumn', 'core.grid.TfColumn', 'core.button.VastOccur',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.button.PrintAll','core.button.PrintCombine'
  12. ],
  13. init:function(){
  14. var me = this;
  15. this.control({
  16. 'erpGridPanel2': {
  17. itemclick: this.onGridItemClick
  18. },
  19. 'dbfindtrigger[name=mc_code]' : {
  20. afterrender: function(v) {
  21. var mcid = Ext.getCmp('mc_id').value;
  22. if (mcid != null & mcid != '') {
  23. var params = {
  24. caller: 'MakeSerial',
  25. condition : ('ms_mcid=' + mcid || '1=1')
  26. };
  27. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  28. }
  29. },
  30. aftertrigger : function(v) {
  31. var mcid = Ext.getCmp('mc_id').value;
  32. var dbtn = Ext.getCmp('deletebutton'), ubtn = Ext.getCmp('updatebutton'),
  33. vbtn = Ext.getCmp('erpVastOccurButton'),pabtn1 = Ext.getCmp('printCombine'),
  34. pabtn2 = Ext.getCmp('printAll'),prbtn = Ext.getCmp('printRepair');
  35. dbtn.setDisabled(false);
  36. ubtn.setDisabled(false);
  37. vbtn.setDisabled(false);
  38. pabtn1.setDisabled(false);
  39. pabtn2.setDisabled(false);
  40. prbtn.setDisabled(false);
  41. if (mcid != null & mcid != '') {
  42. var params = {
  43. caller: 'MakeSerial',
  44. condition : ('ms_mcid=' + mcid || '1=1')
  45. };
  46. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  47. }
  48. }
  49. },
  50. 'erpSaveButton': {
  51. click: function(btn){
  52. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  53. var mc_id = Ext.getCmp('mc_id').value,
  54. mc_code = Ext.getCmp('mc_code').value,
  55. mc_prodcode = Ext.getCmp('mc_prodcode').value;
  56. Ext.Array.each(items, function(item) {
  57. if(!Ext.isEmpty(item.data['ms_code'])){
  58. item.set('ms_mcid', mc_id);
  59. item.set('ms_mccode', mc_code);
  60. item.set('ms_prodcode', mc_prodcode);
  61. item.set('ms_indate', new Date());
  62. }
  63. });
  64. this.FormUtil.onUpdate(this);
  65. var params = {
  66. caller: 'MakeSerial',
  67. condition : ('ms_mcid=' + mc_id || '1=1')
  68. };
  69. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  70. }
  71. },
  72. 'erpDeleteButton': {
  73. click: function(btn){
  74. warnMsg("确认清空?", function(btn){
  75. var mcid = Ext.getCmp('mc_id').value;
  76. if(btn == 'yes'){
  77. me.FormUtil.getActiveTab().setLoading(true);//loading...
  78. Ext.Ajax.request({
  79. url : basePath + 'pm/mes/deleteMakeSerial.action',
  80. params: {
  81. id: mcid
  82. },
  83. method : 'post',
  84. callback : function(opt, s, res) {
  85. me.FormUtil.getActiveTab().setLoading(false);//loading...
  86. var r = Ext.decode(res.responseText);
  87. if (r.success) {
  88. if (mcid != null & mcid != '') {
  89. var params = {
  90. caller: 'MakeSerial',
  91. condition : ('ms_mcid=' + mcid || '1=1')
  92. };
  93. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  94. }
  95. }
  96. }
  97. });
  98. }
  99. });
  100. },
  101. afterrender:function(btn){
  102. btn.setWidth(100);
  103. btn.setText('清空序列号');
  104. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  105. btn.setDisabled(true);
  106. }
  107. }
  108. },
  109. 'erpCloseButton': {
  110. click: function(btn){
  111. this.FormUtil.beforeClose(this);
  112. }
  113. },
  114. 'erpUpdateButton': {
  115. click: function(btn){
  116. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  117. var mc_id = Ext.getCmp('mc_id').value,
  118. mc_code = Ext.getCmp('mc_code').value,
  119. mc_prodcode = Ext.getCmp('mc_prodcode').value;
  120. Ext.Array.each(items, function(item) {
  121. if(!Ext.isEmpty(item.data['ms_code'])){
  122. item.set('ms_mcid', mc_id);
  123. item.set('ms_mccode', mc_code);
  124. item.set('ms_prodcode', mc_prodcode);
  125. item.set('ms_indate', new Date());
  126. }
  127. });
  128. var params = {
  129. caller: 'MakeSerial',
  130. condition : ('ms_mcid=' + mc_id || '1=1')
  131. };
  132. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  133. },
  134. afterrender:function(btn){
  135. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  136. btn.setDisabled(true);
  137. }
  138. }
  139. },
  140. 'erpVastOccurButton': {
  141. click: function(btn){
  142. var me = this, win = Ext.getCmp('Complaint-win');
  143. var pscode = Ext.getCmp('mc_pscode').value,ps_combineqty ;
  144. if(Ext.isEmpty(pscode)){
  145. showError('请先维护作业单排位表编号!');return;
  146. }
  147. win = Ext.create('Ext.Window', {
  148. id: 'Complaint-win',
  149. title: '批量生成序列号',
  150. height: 200,
  151. width: 590,
  152. items: [{
  153. xtype: 'form',
  154. height: '100%',
  155. width: '100%',
  156. bodyStyle: 'background:#f1f2f5;',
  157. items: [{
  158. xtype: 'fieldcontainer',
  159. defaults: {
  160. width:190
  161. },
  162. layout: {
  163. type: 'table',
  164. columns: 3
  165. },
  166. items: [{
  167. margin: '10 0 0 0',
  168. xtype: 'textfield',
  169. fieldLabel: '序列前缀',
  170. id:'prefixcode',
  171. allowBlank: false,
  172. colspan: 1,
  173. labelWidth:70
  174. },{
  175. margin: '10 0 0 0',
  176. xtype: 'textfield',
  177. fieldLabel: '起始编码',
  178. id:'startno',
  179. allowBlank: false,
  180. colspan: 1,
  181. labelWidth:70
  182. },{
  183. margin: '10 0 0 0',
  184. xtype: 'textfield',
  185. fieldLabel: '序列后缀',
  186. id:'suffixcode',
  187. allowBlank: true,
  188. colspan: 1,
  189. labelWidth:70
  190. },{
  191. margin: '3 0 0 0',
  192. xtype: 'numberfield',
  193. fieldLabel: '产生序列号数量',
  194. id:'number',
  195. allowBlank: false,
  196. emptyText: 'n' ,
  197. style:{'padding-top': '15px'}
  198. },{
  199. margin: '3 0 0 0',
  200. xtype: 'textfield',
  201. fieldLabel: '拼板数',
  202. id:'combineqty',
  203. name:'combineqty',
  204. allowBlank: true ,
  205. labelWidth:70,
  206. value:Ext.getCmp('ps_combineqty').value || 0
  207. }]
  208. }],
  209. closeAction: 'hide',
  210. buttonAlign: 'center',
  211. layout: {
  212. type: 'vbox',
  213. align: 'center'
  214. },
  215. buttons: [{
  216. text: $I18N.common.button.erpConfirmButton,
  217. formBind:true,
  218. handler: function(btn) {
  219. var form = btn.ownerCt.ownerCt,
  220. a = form.down('#prefixcode'),
  221. b = form.down('#suffixcode'),
  222. c = form.down('#startno'),
  223. d = form.down('#number');
  224. e = form.down('#combineqty');
  225. if(form.getForm().isDirty()) {
  226. if(!Ext.isNumeric(c.value) || c.value <'0' ){
  227. showError("起始编码必须为数值或者大于等于0!");
  228. return ;
  229. }
  230. if(e.value != '' && e.value != null){
  231. if(e.value != 0 && (!Ext.isNumeric(e.value) || e.value <'2') ){
  232. showError("拼板数必须为数值或者大于1!");
  233. return ;
  234. }
  235. }else{
  236. form.down('#combineqty').setValue(0);
  237. }
  238. me.OccurCode(Ext.getCmp('mc_id').value, a.value, b.value, c.value, d.value,e.value);
  239. }
  240. }
  241. }, {
  242. text: $I18N.common.button.erpCloseButton,
  243. cls: 'x-btn-gray',
  244. handler: function(btn) {
  245. btn.up('window').close();
  246. }
  247. }]
  248. }]
  249. });
  250. win.show();
  251. },
  252. afterrender:function(btn){
  253. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  254. btn.setDisabled(true);
  255. }
  256. }
  257. } ,
  258. 'erpPrintCombineButton':{
  259. click:function(btn){//打印拼板号
  260. var lp_barcaller = 'MakeSerialCombinePrintAll';
  261. var items = Ext.getCmp('grid').store.data.items;
  262. var bool = true;
  263. Ext.each(items, function(item, index){
  264. if(item.data.ms_id != '' && item.data.ms_id != 0 && item.data.ms_id != null){
  265. }else{
  266. bool = false;
  267. }
  268. });
  269. if(bool){
  270. var win = new Ext.window.Window({
  271. id : 'win',
  272. maximizable : true,
  273. buttonAlign : 'center',
  274. layout : 'anchor',
  275. title: '打印模板选择',
  276. modal : true,
  277. items: [{
  278. tag : 'iframe',
  279. frame : true,
  280. anchor : '100% 100%',
  281. layout : 'fit',
  282. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lp_barcaller+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  283. }]
  284. });
  285. win.show();
  286. }else{
  287. showError('没有需要打印的明细!');
  288. }
  289. },
  290. afterrender:function(btn){
  291. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  292. btn.setDisabled(true);
  293. }
  294. }
  295. },
  296. 'erpPrintAllButton':{
  297. afterrender:function(btn){
  298. btn.setText('打印序列号');
  299. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  300. btn.setDisabled(true);
  301. }
  302. },
  303. click :function(btn){//打印序列号
  304. var lp_barcaller = 'MakeSerialCodePrintAll';
  305. var items = Ext.getCmp('grid').store.data.items;
  306. var bool = true;
  307. Ext.each(items, function(item, index){
  308. if(item.data.ms_id != '' && item.data.ms_id != 0 && item.data.ms_id != null){
  309. }else{
  310. bool = false;
  311. }
  312. });
  313. if(bool){
  314. var win = new Ext.window.Window({
  315. id : 'win',
  316. maximizable : true,
  317. buttonAlign : 'center',
  318. layout : 'anchor',
  319. title: '打印模板选择',
  320. modal : true,
  321. items: [{
  322. tag : 'iframe',
  323. frame : true,
  324. anchor : '100% 100%',
  325. layout : 'fit',
  326. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lp_barcaller +'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  327. }]
  328. });
  329. win.show();
  330. }else{
  331. showError('没有需要打印的明细!');
  332. }
  333. }
  334. },
  335. erpPrintRepairButton:{//补打条码
  336. afterrender:function(btn){
  337. if(Ext.isEmpty(Ext.getCmp('mc_id').value)){
  338. btn.setDisabled(true);
  339. }
  340. },
  341. click :function(btn){//打印序列号
  342. var me = this;
  343. me.createWin();
  344. }
  345. }
  346. });
  347. },
  348. getForm: function(btn){
  349. return btn.ownerCt.ownerCt;
  350. },
  351. onGridItemClick: function(selModel, record){//grid行选择
  352. this.GridUtil.onGridItemClick(selModel, record);
  353. },
  354. OccurCode: function(id, a, b, c, d,e) {
  355. var me = this;
  356. Ext.getCmp('Complaint-win').setLoading(true);
  357. Ext.Ajax.request({
  358. url: basePath + 'pm/mes/makeSerial/occurCode.action',
  359. params: {
  360. id: id,
  361. prefixcode: a,
  362. suffixcode: b,
  363. startno : c,
  364. number : d,
  365. combineqty: e
  366. },
  367. callback: function(opt, s, r) {
  368. Ext.getCmp('Complaint-win').setLoading(false);
  369. var rs = Ext.decode(r.responseText);
  370. if(rs.exceptionInfo) {
  371. showError(rs.exceptionInfo);
  372. } else {
  373. Ext.Msg.alert("提示","生成成功!");
  374. var params = {
  375. caller: 'MakeSerial',
  376. condition : ('ms_mcid=' + id || '1=1')
  377. };
  378. Ext.getCmp('Complaint-win').close();
  379. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  380. }
  381. }
  382. });
  383. },
  384. createWin: function(){
  385. var me = this;
  386. var win = new Ext.window.Window({
  387. modal : true,
  388. id : 'win',
  389. height : '35%',
  390. width : '30%',
  391. layout : 'anchor',
  392. bodyStyle: 'background: #f1f1f1;',
  393. bodyPadding:5,
  394. items : [{
  395. anchor: '100% 100%',
  396. xtype: 'form',
  397. bodyStyle: 'background: #f1f1f1;',
  398. items:[{
  399. xtype:'textfield',
  400. name:'serialCode',
  401. fieldLabel:'序列号',
  402. id:'serialCode',
  403. allowBlank:false,
  404. fieldStyle : "background:rgb(224, 224, 255);",
  405. labelStyle:"color:red;"
  406. },{
  407. xtype: 'checkbox',
  408. boxLabel : '产生新序列号',
  409. name : 'newSerial',
  410. checked : false,
  411. id : 'newSerial',
  412. fieldStyle:''
  413. }],
  414. buttonAlign : 'center',
  415. buttons: [{
  416. text: '确定' ,
  417. cls: 'x-btn-gray',
  418. iconCls: 'x-button-icon-save',
  419. id:'confirmBtn',
  420. formBind: true, //only enabled once the form is valid
  421. handler: function(btn) {
  422. me.checkOrNewBarcode();
  423. }
  424. },{
  425. text: '取消' ,
  426. cls: 'x-btn-gray',
  427. iconCls: 'x-button-icon-delete',
  428. handler: function(btn) {
  429. win.close();
  430. }
  431. }]
  432. }]
  433. });
  434. win.show();
  435. },
  436. checkOrNewBarcode:function(){//判断是新增条码还是补打原有的条码
  437. var me= this , newSerial = Ext.getCmp('newSerial').value,
  438. mc_id = Ext.getCmp('mc_id').value,serialCode = Ext.getCmp('serialCode').value;
  439. Ext.Ajax.request({
  440. url: basePath + 'pm/mes/makeSerial/checkOrNewSerialCode.action',
  441. params: {
  442. newSerial: newSerial,//是否新生成条码
  443. serialCode:serialCode, //需要打印的条码
  444. mc_id:mc_id //作业单Id,
  445. },
  446. callback: function(opt, s, r) {
  447. var rs = Ext.decode(r.responseText);
  448. if(rs.exceptionInfo) {
  449. showError(rs.exceptionInfo);return;
  450. } else {
  451. Ext.getCmp('win').close();
  452. var params = {
  453. caller: 'MakeSerial',
  454. condition : ('ms_mcid=' + mc_id || '1=1')
  455. };
  456. me.GridUtil.loadNewStore(Ext.getCmp('grid'), params);
  457. var ms_id = rs.message;
  458. var lp_barcaller = 'MakeSerialCodePrint';
  459. var win = new Ext.window.Window({
  460. id : 'win2',
  461. maximizable : true,
  462. buttonAlign : 'center',
  463. layout : 'anchor',
  464. title: '打印模板选择',
  465. modal : true,
  466. items: [{
  467. tag : 'iframe',
  468. frame : true,
  469. anchor : '100% 100%',
  470. layout : 'fit',
  471. html : '<iframe id="iframe_' + caller + '" src="' + basePath + 'jsps/scm/reserve/selPrintTemplate.jsp?whoami='+lp_barcaller +'&formCondition='+ms_id+'height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
  472. }]
  473. });
  474. win.show();
  475. }
  476. }
  477. });
  478. }
  479. });