关闭时,尽量使用hide事件,把new Ext.Window()设置为全局对象,在要调用 的界面进行创建一次后,把创建对象变量保存起来,以便下次使用,只对数据做操作。
CPC.WFBILL = Ext.extend(CPC.BaseForm,{
selm:null,
procs:null,
ClassName: null,
formclass:null,
init: function(){
CPC.WFBILL.superclass.init.call(this);
try {
var objconf={};
if(this.procs)
objconf = {operright:this.procs.operright};
this.billObj=null;
if(this.formclass != null){
this.billObj= this.formclass;
}else{
this.billObj= eval('new '+this.ClassName+'(objconf)');
}
}catch(e){alert("脚本加载失败,请检查网络连接或刷新浏览器!"+e.message)}
var panel=this.billObj.getPanel();
var bh=document.body.clientHeight*0.9;
if(bh<500)bh=500;
this.win=new Ext.Window({
//width:920,
modify by daiwei. 2011-05-23.修改点击单据号弹出框宽度.
width:'90%',//mainForm.tabPanel.getSize().width-120,
maximizable:true,
animateTarget:true,
draggable:false,
expandOnShow:false,
monitorResize:false,
resizable:false,
//maximized:true,
height: 570,
title: this.selm.get('objname'),
layout:'fit',
modal:true,
buttons:[{text:'取 消',scope:this,handler:function(){this.win.hide()}}],
items:panel,
closeAction:'hide',
listeners : {
scope : this,
'beforeshow' : function(a,b) {
if(this.formclass == null){
this.billObj.is_billwf=true;
this.billObj.selectFirstRow =true;
this.billObj.setSqlWhere(this.billObj.pkFieldName+"= "+ this.selm.get('objid'));
this.billObj.search();
}
},/*'show':function(){
billObj.panel.setActiveTab(billObj.wfPanel);
},*/'maximize':function(win){
win.doLayout();
},'hide':function(){
if (this.callback)
this.callback.call(this);
}
}
});
if(panel.topToolbar)
this.disableBar(panel.topToolbar)
},
search_data:function(ClassName,selm,formclass){
var wftempid_new=selm.data['wftempid'];
var wftempid_old=this.selm.data['wftempid'];
this.ClassName = ClassName;
this.selm =selm;
this.formclass=formclass;
this.win.setTitle(this.selm.get('objname'));
if(wftempid_new != wftempid_old || this.formclass != null){
try {
var objconf={};
if(this.procs)
objconf = {operright:this.procs.operright};
this.billObj=null;
if(this.formclass != null){
this.billObj= this.formclass;
}else{
this.billObj= eval('new '+this.ClassName+'(objconf)');
}
}catch(e){alert("脚本加载失败,请检查网络连接或刷新浏览器!"+e.message)}
var panel=this.billObj.getPanel();
this.win.remove(this.win.items.items[0]);
this.win.add(panel);
this.win.doLayout();
}
},
//禁用工具栏按钮
disableBar: function(bbar){
if(bbar.items){
bbar.items.each(function(button) {
if(button.setDisabled)
button.setDisabled(true);
}, this);
}else{
for (var i = 0; i < bbar.length; i++) {
if(bbar[i].setDisabled)bbar[i].setDisabled(true);
}
}
},
getPanel: function(){
return this.win;
});
调用对象方法:
var self = this;
if(typeof this.wfbill == 'undefined'){
this.wfbill = new CPC.WFBILL({
ClassName : confobj.formclass,
selm : selm,
formclass:formclass,
callback:function(){
self.refresh2();
}
});
}else{
this.wfbill.search_data(confobj.formclass,selm,formclass);
}
this.wfbill.getPanel().show();