MpsDesk.js 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.mps.MpsDesk', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','pm.mps.MpsDesk','core.grid.Panel2','core.toolbar.Toolbar','core.button.ExecuteOperation','pm.mps.DeskForm',
  9. 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
  10. 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit',
  11. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
  12. ],
  13. init:function(){
  14. var me=this;
  15. this.control({
  16. 'erpGridPanel2': {
  17. itemclick: function(selModel, record){
  18. if(!Ext.getCmp('grid').readOnly){
  19. this.onGridItemClick(selModel, record);
  20. }
  21. }
  22. },
  23. 'dbfindtrigger[name=mm_code]':{
  24. afterrender:function(f){
  25. var kind=me.BaseUtil.getUrlParam('kind');
  26. if (kind)
  27. {
  28. f.dbBaseCondition="mm_kind ='"+kind+"'";
  29. }
  30. var code= me.BaseUtil.getUrlParam('code');
  31. if (code)
  32. {
  33. f.setValue(code);
  34. f.autoDbfind('form', caller, f.name, f.name + ' like\'%' + f.value + '%\'');
  35. }
  36. }
  37. },
  38. 'erpExecuteOperationButton':{
  39. click:function(btn){
  40. me.ExecuteOperation();
  41. }
  42. },
  43. 'button[id=tomake]':{
  44. click:function(btn){
  45. if (!confirm('确定要转制造?')){
  46. return;
  47. };
  48. var code=Ext.getCmp('mm_code').getValue();
  49. Ext.Ajax.request({//拿到grid的columns
  50. url : basePath + 'pm/mps/turnmake.action',
  51. params: {
  52. code:code,
  53. caller:caller
  54. },
  55. method : 'post',
  56. timeout: 6000,
  57. callback : function(options,success,response){
  58. var res = new Ext.decode(response.responseText);
  59. if(res.exceptionInfo){
  60. showError(res.exceptionInfo);
  61. return;
  62. }else if(res.success){
  63. showError(res.message);
  64. window.location.href=basePath+"jsps/pm/mps/MpsDesk.jsp?kind=MRP&&code="+code;
  65. }
  66. }
  67. });
  68. }
  69. },
  70. 'button[id=topurchase]':{
  71. click:function(btn){
  72. if (!confirm('所有未审核的请购单将作废,确定要转采购?')){
  73. return;
  74. };
  75. var code=Ext.getCmp('mm_code').getValue();
  76. Ext.Ajax.request({//拿到grid的columns
  77. url : basePath + 'pm/mps/turnpurchase.action',
  78. params: {
  79. code:code,
  80. caller:caller
  81. },
  82. method : 'post',
  83. timeout: 6000,
  84. callback : function(options,success,response){
  85. var res = new Ext.decode(response.responseText);
  86. if(res.exceptionInfo){
  87. showError(res.exceptionInfo);
  88. return;
  89. }else if(res.success){
  90. showError(res.message);
  91. window.location.href=basePath+"jsps/pm/mps/MpsDesk.jsp?kind=MRP&&code="+code;
  92. }
  93. }
  94. });
  95. }
  96. },
  97. 'button[id=topurchaseforecast]':{
  98. click:function(btn){
  99. var code=Ext.getCmp('mm_code').getValue();
  100. Ext.Ajax.request({//拿到grid的columns
  101. url : basePath + 'pm/mps/turnpurchaseforecast.action',
  102. params: {
  103. code:code,
  104. caller:caller
  105. },
  106. method : 'post',
  107. timeout: 6000,
  108. callback : function(options,success,response){
  109. var res = new Ext.decode(response.responseText);
  110. if(res.exceptionInfo){
  111. showError(res.exceptionInfo);
  112. return;
  113. }else if(res.success){
  114. showError(res.message);
  115. window.location.href=basePath+"jsps/pm/mps/MpsDesk.jsp?kind=MRP&&code="+code;
  116. }
  117. }
  118. });
  119. }
  120. },
  121. 'button[id=product]':{
  122. click:function(btn){
  123. var id=Ext.getCmp('mm_id').getValue();
  124. var condition="md_mpsid='"+id+"'";
  125. me.FormUtil.onAdd('MPSProduct','物料','/jsps/pm/mps/DeskProduct.jsp?whoami=MPSSupply&_noc=1&urlcondition='+condition);
  126. }
  127. },
  128. 'button[id=supply]':{
  129. click:function(btn){
  130. var id=Ext.getCmp('mm_id').getValue();
  131. var code=Ext.getCmp('mm_code').getValue();
  132. var condition="md_mpsid='"+id+"' AND md_kind='SUPPLY' AND nvl(pr_supplytype,' ') <>'VIRTUAL'";
  133. me.FormUtil.onAdd('MPSSupply','供应','/jsps/pm/mps/MRPThrow.jsp?whoami=MPSSupply&_noc=1&urlcondition='+condition+"&mpscode="+code);
  134. }
  135. },
  136. 'button[id=need]':{
  137. click:function(btn){
  138. var id=Ext.getCmp('mm_id').getValue();
  139. var code=Ext.getCmp('mm_code').getValue();
  140. var condition="md_mpsid='"+id+"'AND md_kind='NEED' AND nvl(pr_supplytype,' ') <>'VIRTUAL' ";
  141. me.FormUtil.onAdd('MPSNeed','需求','/jsps/pm/mps/MRPThrow.jsp?whoami=MPSNeed&_noc=1&urlcondition='+condition+"&mpscode="+code);
  142. }
  143. },
  144. 'button[id=error]':{
  145. click:function(btn){
  146. var id=Ext.getCmp('mm_id').getValue();
  147. if(Ext.isEmpty(id)){
  148. return;
  149. }
  150. var win = new Ext.window.Window({
  151. id : 'win',
  152. title: "异常信息",
  153. height: "70%",
  154. width: "80%",
  155. maximizable : false,
  156. buttonAlign : 'center',
  157. layout : 'anchor',
  158. items: [{
  159. xtype: 'erpGridPanel2',
  160. anchor: '100% 100%',
  161. id:'errorgrid',
  162. condition: 'mm_mpsid='+id,
  163. caller:'MRPmessage',
  164. bbar:{},
  165. listeners:{
  166. itemclick: function(selModel, record){
  167. me.GridUtil.onGridItemClick(selModel, record);
  168. }
  169. },
  170. plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
  171. clicksToEdit: 1
  172. })]
  173. }],
  174. bbar: ['->',{
  175. text:'导出',
  176. iconCls: 'x-button-icon-excel',
  177. cls: 'x-btn-gray',
  178. handler: function(btn){
  179. me.BaseUtil.createExcel('MRPmessage', 'detailgrid', 'mm_mpsid='+id,'错误信息');
  180. }
  181. },{
  182. text:'关闭',
  183. cls: 'x-btn-gray',
  184. iconCls: 'x-button-icon-close',
  185. listeners: {
  186. click: function(){
  187. win.close();
  188. }
  189. }
  190. },'->']
  191. });
  192. win.show();
  193. }
  194. },
  195. 'button[id=ecnAnalysis]':{//剩余供应ECN分析
  196. click:function(btn){
  197. var id=Ext.getCmp('mm_id').getValue();
  198. var code=Ext.getCmp('mm_code').getValue();
  199. var condition="md_mpsid='"+id+"' AND md_kind='SUPPLY' AND nvl(pr_supplytype,' ') <>'VIRTUAL' AND md_model='取消'";
  200. me.FormUtil.onAdd('EcnAnalysis!Query','剩余供应ECN分析','/jsps/pm/mps/MRPThrow.jsp?whoami=EcnAnalysis!Query&_noc=1&urlcondition='+condition+"&mpscode="+code);
  201. }
  202. },
  203. 'button[id=close]':{
  204. click:function(btn){
  205. var main = parent.Ext.getCmp("content-panel");
  206. main.getActiveTab().close();
  207. }
  208. },
  209. 'button[id=dullstockdeal]':{//呆滞库存处理
  210. click:function(btn){
  211. var id=Ext.getCmp('mm_id').getValue();
  212. var code=Ext.getCmp('mm_code').getValue();
  213. var condition="md_mpsid='"+id+"' AND md_kind='SUPPLY' AND nvl(pr_supplytype,' ') <>'VIRTUAL' and md_worktype='剩余库存'";
  214. me.FormUtil.onAdd('MRPOnhandThrow','MRP呆滞库存处理','/jsps/pm/mps/MRPThrow.jsp?whoami=MRPOnhandThrow&_noc=1&urlcondition='+condition+"&mpscode="+code);
  215. }
  216. }
  217. });
  218. },
  219. onGridItemClick: function(selModel, record){//grid行选择
  220. this.GridUtil.onGridItemClick(selModel, record);
  221. },
  222. getForm: function(btn){
  223. return btn.ownerCt.ownerCt;
  224. },
  225. save: function(btn){
  226. var me = this;
  227. if(Ext.getCmp('team_code').value == null || Ext.getCmp('team_code').value == ''){
  228. me.BaseUtil.getRandomNumber();
  229. }
  230. me.FormUtil.beforeSave(me);
  231. },
  232. changeGrid: function(trigger){
  233. var grid = Ext.getCmp('grid');
  234. Ext.Array.each(grid.store.data.items, function(item){
  235. item.set('tm_prjid',trigger.value);
  236. });
  237. },
  238. ExecuteOperation:function(){
  239. var code=Ext.getCmp('mm_code').getValue();
  240. /* var main = parent.Ext.getCmp('content-panel');*/
  241. var mb = new Ext.window.MessageBox();
  242. mb.wait('正在运算中','请稍后...',{
  243. interval: 10000, //bar will move fast!
  244. duration: 1000000,
  245. increment: 20,
  246. /* text: 'Runing...',*/
  247. scope: this
  248. });
  249. Ext.Ajax.request({//拿到grid的columns
  250. url : basePath + 'pm/mps/RunMrp.action',
  251. params: {
  252. code:code,
  253. caller:caller
  254. },
  255. method : 'post',
  256. timeout: 600000,
  257. callback : function(options,success,response){
  258. mb.close();
  259. var res = new Ext.decode(response.responseText);
  260. if(res.exceptionInfo){
  261. showError(res.exceptionInfo);
  262. return;
  263. }else if(res.success){
  264. Ext.Msg.alert('提示',res.message,function(){
  265. if(res.message=='运算成功') window.location.href=basePath+"jsps/pm/mps/MpsDesk.jsp?kind=MRP&&code="+code;
  266. });
  267. }
  268. }
  269. });
  270. }
  271. }
  272. );