| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.mps.MpsDesk', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'core.form.Panel','pm.mps.MpsDesk','core.grid.Panel2','core.toolbar.Toolbar','core.button.ExecuteOperation','pm.mps.DeskForm',
- 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close','core.button.Print',
- 'core.button.Upload','core.button.Update','core.button.Delete','core.button.ResAudit',
- 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger'
- ],
- init:function(){
- var me=this;
-
- this.control({
- 'erpGridPanel2': {
- itemclick: function(selModel, record){
- if(!Ext.getCmp('grid').readOnly){
- this.onGridItemClick(selModel, record);
- }
- }
- },
- 'dbfindtrigger[name=mm_code]':{
- afterrender:function(f){
- var kind=me.BaseUtil.getUrlParam('kind');
- if (kind)
- {
- f.dbBaseCondition="mm_kind IS '"+kind+"'";
- }
-
- var code= me.BaseUtil.getUrlParam('code');
- if (code)
- {
- f.setValue(code);
- f.autoDbfind('form', caller, f.name, f.name + ' like\'%' + f.value + '%\'');
- }
- }
-
- },
- 'erpExecuteOperationButton':{
- click:function(btn){
- me.ExecuteOperation();
- }
- },
- 'button[id=tomake]':{
- click:function(btn){
- var code=Ext.getCmp('mm_code').getValue();
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'pm/mps/turnmake.action',
- params: {
- code:code
- },
- method : 'post',
- timeout: 6000,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }else if(res.success){
- showError(res.message);
- }
- }
- });
- }
- },
- 'button[id=topurchase]':{
- click:function(btn){
- var code=Ext.getCmp('mm_code').getValue();
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'pm/mps/turnpurchase.action',
- params: {
- code:code
- },
- method : 'post',
- timeout: 6000,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }else if(res.success){
- showError(res.message);
- }
- }
- });
- }
- },
- 'button[id=topurchaseforecast]':{
- click:function(btn){
- var code=Ext.getCmp('mm_code').getValue();
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'pm/mps/turnpurchaseforecast.action',
- params: {
- code:code
- },
- method : 'post',
- timeout: 6000,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }else if(res.success){
- showError(res.message);
- }
- }
- });
- }
- },
- 'button[id=product]':{
- click:function(btn){
- var id=Ext.getCmp('mm_id').getValue();
- var condition="md_mpsid='"+id+"'";
- me.FormUtil.onAdd('MPSProduct','物料','/jsps/pm/mps/DeskProduct.jsp?whoami=MPSSupply&_noc=1&urlcondition='+condition);
- }
- },
- 'button[id=supply]':{
- click:function(btn){
- var id=Ext.getCmp('mm_id').getValue();
- var code=Ext.getCmp('mm_code').getValue();
- var condition="md_mpsid='"+id+"' AND md_kind='SUPPLY' AND nvl(pr_supplytype,' ') <>'VIRTUAL'";
- me.FormUtil.onAdd('MPSSupply','供应','/jsps/pm/mps/MRPThrow.jsp?whoami=MPSSupply&_noc=1&urlcondition='+condition+"&mpscode="+code);
- }
- },
- 'button[id=need]':{
- click:function(btn){
- var id=Ext.getCmp('mm_id').getValue();
- var code=Ext.getCmp('mm_code').getValue();
- var condition="md_mpsid='"+id+"'AND md_kind='NEED' AND nvl(pr_supplytype,' ') <>'VIRTUAL' ";
- me.FormUtil.onAdd('MPSNeed','需求','/jsps/pm/mps/MRPThrow.jsp?whoami=MPSNeed&_noc=1&urlcondition='+condition+"&mpscode="+code);
- }
- },
- 'button[id=error]':{
- click:function(btn){
- var id=Ext.getCmp('mm_id').getValue();
- var win = new Ext.window.Window({
- id : 'win',
- title: "异常信息",
- height: "70%",
- width: "80%",
- maximizable : false,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [{
- xtype: 'erpGridPanel2',
- anchor: '100% 100%',
- id:'errorgrid',
- condition: 'mm_mpsid='+id,
- caller:'MRPmessage',
- bbar:{},
- listeners:{
- itemclick: function(selModel, record){
- me.GridUtil.onGridItemClick(selModel, record);
- }
- },
- plugins: [Ext.create('Ext.grid.plugin.CellEditing', {
- clicksToEdit: 1
- })],
- }],
- bbar: ['->',{
- text:'导出',
- iconCls: 'x-button-icon-excel',
- cls: 'x-btn-gray',
- handler: function(btn){
- me.BaseUtil.createExcel('MRPmessage', 'detailgrid', 'mm_mpsid='+id,'错误信息');
-
- }
- },{
- text:'关闭',
- cls: 'x-btn-gray',
- iconCls: 'x-button-icon-close',
- listeners: {
- click: function(){
- win.close();
- }
- }
- },'->']
- });
- win.show();
- }
- },
- 'button[id=close]':{
- click:function(btn){
- var main = parent.Ext.getCmp("content-panel");
- main.getActiveTab().close();
- }
- },
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- save: function(btn){
- var me = this;
- if(Ext.getCmp('team_code').value == null || Ext.getCmp('team_code').value == ''){
- me.BaseUtil.getRandomNumber();
- }
- me.FormUtil.beforeSave(me);
- },
- changeGrid: function(trigger){
- var grid = Ext.getCmp('grid');
- Ext.Array.each(grid.store.data.items, function(item){
- item.set('tm_prjid',trigger.value);
- });
- },
- ExecuteOperation:function(){
- var code=Ext.getCmp('mm_code').getValue();
- /* var main = parent.Ext.getCmp('content-panel');*/
- var mb = new Ext.window.MessageBox();
- mb.wait('正在运算中','请稍后...',{
- interval: 10000, //bar will move fast!
- duration: 1000000,
- increment: 20,
- /* text: 'Runing...',*/
- scope: this,
- });
- Ext.Ajax.request({//拿到grid的columns
- url : basePath + 'pm/mps/RunMrp.action',
- params: {
- code:code
- },
- method : 'post',
- timeout: 600000,
- callback : function(options,success,response){
- mb.close();
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);
- return;
- }else if(res.success){
- Ext.Msg.alert('提示',res.message,function(){
- if(res.message=='运算成功') window.location.href=basePath+"jsps/pm/mps/MpsDesk.jsp?kind=MRP&&code="+code;
- });
- }
- }
- });
- }
- }
- );
|