Ext.QuickTips.init(); Ext.define('erp.controller.scm.product.PreProduct', { extend: 'Ext.app.Controller', FormUtil: Ext.create('erp.util.FormUtil'), BaseUtil: Ext.create('erp.util.BaseUtil'), views:[ 'scm.product.PreProduct','core.form.Panel','core.form.MultiField','core.form.FileField', 'core.button.Add','core.button.Submit','core.button.Audit','core.button.Save','core.button.Close', 'core.button.ResSubmit','core.button.Update','core.button.Delete','core.button.TurnCustomer', 'core.button.ResAudit','core.button.Temporary','core.button.Flow','core.button.TurnBorrow','core.trigger.MultiDbfindTrigger','core.trigger.AddDbfindTrigger', 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField','core.trigger.AutoCodeTrigger' ], init:function(){ var me = this; this.control({ 'erpSaveButton': { click: function(btn){ //申请编号 if(Ext.getCmp('pre_thisid').value == null || Ext.getCmp('pre_thisid').value == ''){ me.BaseUtil.getRandomNumber(null, null, 'pre_thisid'); } this.FormUtil.beforeSave(me); } }, 'mfilefield':{ beforerender:function(f){ f.readOnly=false; } }, 'erpCloseButton': { click: function(btn){ this.FormUtil.beforeClose(this); } }, 'erpAddButton': { click: function(){ me.FormUtil.onAdd('addPreProduct', '新增物料申请', 'jsps/scm/product/preProduct.jsp'); } }, 'erpUpdateButton': { click: function(btn){ this.FormUtil.onUpdate(this); } }, 'erpTurnBorrowButton':{ beforerender:function(btn){ btn.setText('转询价'); }, afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'TURNFM'){ btn.hide(); } }, click:function(btn){ warnMsg("确定要转询价吗?", function(b){ if(b == 'yes'){ me.turn(btn.ownerCt.ownerCt,'scm/product/turninquiry.action', 'jsps/scm/purchase/inquiry.jsp?formCondition=in_idIS@@&gridCondition=id_inidIS@@','inquiry','采购询价单维护'); } }); } }, 'erpTurnCustomerButton':{ beforerender:function(btn){ btn.setText('转打样'); }, afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'TURNFM'){ btn.hide(); } }, click:function(btn){ warnMsg("确定要转打样吗?", function(b){//url,jsp,pageid,title if(b == 'yes'){ me.turn(btn.ownerCt.ownerCt,'scm/product/turnsample.action', 'jsps/scm/product/ProductSample.jsp?formCondition=ps_idIS@@&gridCondition=pd_psidIS@@','ProductSample','打样申请单'); } }); } }, 'combobox[name=pre_manutype]': { change: function(btn){ /*var value = Ext.getCmp('pre_manutype').value; if(value =="MAKE" || value =="PURCHASE"){ Ext.getCmp('pre_leadtime').allowBlank = false; }else{ Ext.getCmp('pre_gdtqq').allowBlank = false; }*/ } }, 'autocodetrigger': { aftertrigger: function(trigger, val, path, item) { if(path) { if(path[0]) { Ext.getCmp('pre_kind').setValue(path[0]); } if(path[1]) { Ext.getCmp('pre_kind2').setValue(path[1]); } if(path[2]) { Ext.getCmp('pre_kind3').setValue(path[2]); } if(path[3]) { if(Ext.getCmp('pre_xikind')){ Ext.getCmp('pre_xikind').setValue(path[3]); } Ext.getCmp('pre_detail').setValue(('无' == path[3] ? '' : path[3]) + ('无' == path[2] ? '' : path[2]) + ('无' == path[1] ? '' : path[1])); } var data = item.get('data') || item.raw.data, f; if(typeof (f = Ext.getCmp('pre_namerule')) !== 'undefined') f.setValue(data.pk_namerule); if(typeof (f = Ext.getCmp('pre_nameeg')) !== 'undefined') f.setValue(data.pk_nameeg); if(typeof (f = Ext.getCmp('pre_specrule')) !== 'undefined') f.setValue(data.pk_specrule); if(typeof (f = Ext.getCmp('pre_speceg')) !== 'undefined') f.setValue(data.pk_speceg); if(typeof (f = Ext.getCmp('pre_parameterrule')) !== 'undefined') f.setValue(data.pk_parameterrule); if(typeof (f = Ext.getCmp('pre_parametereg')) !== 'undefined') f.setValue(data.pk_parametereg); if(typeof (f = Ext.getCmp('pre_dhzc')) !== 'undefined') f.setValue(data.pk_dhzc); if(typeof (f = Ext.getCmp('pre_supplytype')) !== 'undefined') f.setValue(data.pk_supplytype); if(typeof (f = Ext.getCmp('pre_manutype')) !== 'undefined'){ var d = data.pk_manutype, v = d; switch(d){ case '制造': v = 'MAKE';break; case '委外': v = 'OSMAKE';break; case '外购': v = 'PURCHASE';break; case '客供': v = 'CUSTOFFER';break; } f.setValue(v); } if(typeof (f = Ext.getCmp('pre_acceptmethod')) !== 'undefined') f.setValue(['检验','0'].indexOf(data.pk_acceptmethod) > -1 ? '0' : '1'); if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){ f.setValue(data.pk_stockcatecode); Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate); } if(typeof (f = Ext.getCmp('pre_stockcatecode')) !== 'undefined'){ f.setValue(data.pk_stockcatecode); Ext.getCmp('pre_stockcate').setValue(data.pk_stockcate); } if(typeof (f = Ext.getCmp('pre_incomecatecode')) !== 'undefined'){ f.setValue(data.pk_incomecatecode); Ext.getCmp('pre_incomecate').setValue(data.pk_incomecate); } if(typeof (f = Ext.getCmp('pre_costcatecode')) !== 'undefined'){ f.setValue(data.pk_costcatecode); Ext.getCmp('pre_costcate').setValue(data.pk_costcate); } if(typeof (f = Ext.getCmp('pre_whcode')) !== 'undefined'){ f.setValue(data.pk_whcode); Ext.getCmp('pre_whname').setValue(data.pk_whname); } if(typeof (f = Ext.getCmp('pre_isstandardpr')) !== 'undefined'){ f.setValue(data.pk_isstandardpr);// 是否标准化物料 } if(typeof (f = Ext.getCmp('pre_wccode')) !== 'undefined'){ f.setValue(data.pk_wccode); Ext.getCmp('pre_wcname').setValue(data.pk_wcname); } if(typeof (f = Ext.getCmp('pre_material')) !== 'undefined'){ f.setValue(data.pk_material);// 认可状态 } if(typeof (f = Ext.getCmp('pre_level')) !== 'undefined'){ f.setValue(data.pk_priority);// 优先等级 } if(typeof (f = Ext.getCmp('pre_testlossrate')) !== 'undefined'){ f.setValue(data.pk_testlossrate);// 试产损耗 } if(typeof (f = Ext.getCmp('pre_lossrate')) !== 'undefined'){ f.setValue(data.pk_lossrate);// 量产 } if(typeof (f = Ext.getCmp('pre_exportlossrate')) !== 'undefined'){ f.setValue(data.pk_exportlossrate);// 委外 } } } }, 'erpDeleteButton': { click: function(btn){ this.FormUtil.onDelete(Ext.getCmp('pre_id').value); } }, 'erpSubmitButton': { afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'ENTERING'){ btn.hide(); } }, click: function(btn){ me.FormUtil.onSubmit(Ext.getCmp('pre_id').value); } }, 'erpResSubmitButton': { afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'COMMITED'){ btn.hide(); } }, click: function(btn){ me.FormUtil.onResSubmit(Ext.getCmp('pre_id').value); } }, 'erpAuditButton': { afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'COMMITED'){ btn.hide(); } }, click: function(btn){ me.FormUtil.onAudit(Ext.getCmp('pre_id').value); } }, 'erpResAuditButton': { afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'AUDITED'){ btn.hide(); } }, click: function(btn){ me.FormUtil.onResAudit(Ext.getCmp('pre_id').value); } }, 'erpTemporaryButton': { afterrender: function(btn){ var status = Ext.getCmp('pre_statuscode'); if(status && status.value != 'AUDITED'){ btn.hide(); } }, click: function(b){ warnMsg("确定要转入正式物料吗?", function(btn){ if(btn == 'yes'){ me.turnFormal(b.ownerCt.ownerCt); } }); } } }); }, getForm: function(btn){ return btn.ownerCt.ownerCt; }, turnFormal: function(form) { var me = this; form.setLoading(true);//loading... Ext.Ajax.request({ url : basePath + 'scm/product/turnFormal.action', params: { id: form.down('#pre_id').value }, method : 'post', callback : function(options,success,response){ form.setLoading(false); var localJson = new Ext.decode(response.responseText); if(localJson.exceptionInfo){ showError(localJson.exceptionInfo); } if(localJson.success){ turnSuccess(function(){ var id = localJson.id; var url = "jsps/scm/product/product.jsp?formCondition=pr_id=" + id; me.FormUtil.onAdd('Product' + id, '物料资料' + id, url); }); } } }); }, turn: function(form,url,jsp,pageid,title) { var me = this; form.setLoading(true);//loading... Ext.Ajax.request({ url : basePath + url, params: { id: form.down('#pre_id').value }, method : 'post', callback : function(options,success,response){ form.setLoading(false); var localJson = new Ext.decode(response.responseText); if(localJson.exceptionInfo){ showError(localJson.exceptionInfo); } if(localJson.success){ turnSuccess(function(){ var id = localJson.id; var url2 = jsp.replace(/@@/g,id); me.FormUtil.onAdd(pageid + id, title + id, url2); }); } } }); } });