MachineNoScan.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.sale.MachineNoScan', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
  5. views:[
  6. 'scm.sale.MachineNoScan','core.button.VastDeal','core.button.Delete','core.button.Close',
  7. 'core.form.Panel','core.button.Query', 'core.grid.ButtonColumn'
  8. ],
  9. init:function(){
  10. var me = this;
  11. me.FormUtil = Ext.create('erp.util.FormUtil');
  12. this.control({
  13. 'erpQueryButton' : {
  14. click: function(btn) {
  15. me.query();
  16. }
  17. },
  18. '#machineno': {
  19. specialkey: function(f, e){//按ENTER自动把摘要复制到下一行
  20. var piid = Ext.getCmp('pi_id').value, iswcj = Ext.getCmp("iswcj").value;
  21. if ([e.ENTER, e.RETURN, e.SPACE].indexOf(e.getKey()) > -1) {
  22. Ext.defer(function(){
  23. var val = e.target.value;
  24. if(val){
  25. me.onConfirm(piid, iswcj, val);
  26. }
  27. }, 50);
  28. }
  29. }
  30. },
  31. '#confirm' : {
  32. click: function(btn) {
  33. var piid = Ext.getCmp('pi_id').value, iswcj = Ext.getCmp("iswcj").value;
  34. me.onConfirm(piid, iswcj);
  35. }
  36. }
  37. });
  38. },
  39. query : function(){
  40. var me = this;
  41. var pi_inoutno = Ext.getCmp("pi_inoutno").value, piid = Ext.getCmp('pi_id').value,
  42. iswcj = Ext.getCmp("iswcj").value;
  43. if(Ext.isEmpty(pi_inoutno)){
  44. showError("请录入出货单号再进行筛选!");
  45. return ;
  46. }
  47. if(!Ext.isEmpty(piid)) {
  48. Ext.getCmp('grid').getStore().load({
  49. params: {
  50. piid: piid,
  51. iswcj:iswcj
  52. }
  53. });
  54. }
  55. },
  56. onConfirm : function(piid, iswcj, machineno){
  57. var me = this, operator = Ext.getCmp('operator').getValue(),
  58. machineno = machineno || Ext.getCmp('machineno').value;
  59. if(Ext.isEmpty(machineno)){
  60. showError('请先采集机器号!');
  61. return;
  62. }
  63. if(Ext.isEmpty(prcode)){
  64. showError('请先指定产品编号!');
  65. return;
  66. }
  67. if(operator.operator == 'get'){
  68. me.FormUtil.getActiveTab().setLoading(true);//loading...
  69. Ext.Ajax.request({
  70. url : basePath + 'scm/sale/insertProdioMac.action',
  71. params: {
  72. piid : Ext.getCmp('piid').value,
  73. inoutno : Ext.getCmp('inoutno').value,
  74. machineno: machineno,
  75. prcode : Ext.getCmp('prcode').value,
  76. qty : Ext.getCmp('qty').value
  77. },
  78. method : 'post',
  79. callback : function(options,success,response){
  80. me.FormUtil.getActiveTab().setLoading(false);
  81. var r = new Ext.decode(response.responseText);
  82. if(r.exceptionInfo){
  83. showError(r.exceptionInfo);
  84. }
  85. if(r.success){
  86. if(!Ext.isEmpty(piid)) {
  87. Ext.getCmp('grid').getStore().load({
  88. params: {
  89. piid: piid,
  90. iswcj:iswcj
  91. }
  92. });
  93. }
  94. showMessage('提示', '采集成功!', 1000);
  95. Ext.getCmp('gather').down('#machineno').setValue('');
  96. var yqty = Ext.getCmp('gather').down('#yqty').value;
  97. Ext.getCmp('gather').down('#yqty').setValue(Number(yqty)+Number(1));
  98. Ext.getCmp('gather').down('#machineno').focus(false, 200);
  99. if(Number(Ext.getCmp('gather').down('#yqty').value) >= Number(Ext.getCmp('gather').down('#qty').value)){
  100. Ext.getCmp('gather').close();
  101. }
  102. }
  103. }
  104. });
  105. } else if(operator.operator == 'back'){
  106. me.FormUtil.getActiveTab().setLoading(true);//loading...
  107. Ext.Ajax.request({
  108. url : basePath + 'scm/sale/deleteProdioMac.action',
  109. params: {
  110. piid : Ext.getCmp('piid').value,
  111. inoutno : Ext.getCmp('inoutno').value,
  112. machineno: machineno,
  113. prcode : Ext.getCmp('prcode').value,
  114. qty : Ext.getCmp('qty').value
  115. },
  116. method : 'post',
  117. callback : function(options,success,response){
  118. me.FormUtil.getActiveTab().setLoading(false);
  119. var r = new Ext.decode(response.responseText);
  120. if(r.exceptionInfo){
  121. showError(r.exceptionInfo);
  122. }
  123. if(r.success){
  124. showMessage('提示', '取消成功!', 1000);
  125. if(!Ext.isEmpty(piid)) {
  126. Ext.getCmp('grid').getStore().load({
  127. params: {
  128. piid: piid,
  129. iswcj:iswcj
  130. }
  131. });
  132. Ext.getCmp('gather').down('#machineno').setValue('');
  133. var yqty = Ext.getCmp('gather').down('#yqty').value;
  134. Ext.getCmp('gather').down('#yqty').setValue(Number(yqty)-Number(1));
  135. Ext.getCmp('gather').down('#machineno').focus(false, 200);
  136. if(Number(Ext.getCmp('gather').down('#yqty').value) == 0){
  137. Ext.getCmp('gather').close();
  138. }
  139. }
  140. }
  141. }
  142. });
  143. }
  144. }
  145. });