var tree,grid;
function btn(bo){
	try{
	getcmp('edit_'+rand+'').setDisabled(bo);
	getcmp('del_'+rand+'').setDisabled(bo);
	}catch(e){}	
}
function savecalblc(){
	tree.storereload();
}
var panel= [{
	xtype:'rocktree',tablename:'option',region:'west',width:200,split:true,bbarbool:false,title:'信息类型',collapsible: true,url:publictreestore({order:'xu',expandall:'true',pidfields:'mnum',idfields:'num',fistid:'infortype'}),
	columns:[{
		xtype: 'treecolumn',
		text:'名称',align:'left',dataIndex:'name',width:'99%'
	}],
	bbar:[{
		text:'刷新',handler:function(){tree.storereload()},icon:gicons('arrow_refresh')
	},'-',{
		text:'类型管理',handler:function(){rockoption.setlist('信息类型','infortype',{savecall:function(){savecalblc();},delcall:function(){savecalblc();}});}
	}],
	dblclick:function(o,v){
		grid.searchgoto("and typename='"+v.data.name+"'");
	}
},{
	xtype:'rockgrid',
	tablename:'infor',searchtools:true,celleditbool:true,defaultorder:'xu,optdt desc',
	tbar:['-','双击可预览','->',{
		text:'新增',icon:gicons('add'),handler:function(){grid._clickeadd()}
	},'-',{
		text:'修改',icon:gicons('page_edit'),disabled:true,id:'edit_'+rand+'',handler:function(){grid._clickedit()}
	},'-',{
		text:'删除',icon:gicons('delete'),disabled:true,id:'del_'+rand+'',handler:function(a){grid.del(a)}
	}],
	_clickedit:function(){
		var sid = this.changedata.id;
		addtabs('编辑信息','system,infor,add,id='+sid+',index='+index+'','inforadd_'+sid+'',{icon:gicons('edit')});
	},
	_clickeadd:function(){
		addtabs('新增信息','system,infor,add,index='+index+'','inforadd',{icon:gicons('add')});
	},
	columns:[{
		xtype: 'rownumberer',
		width: 40
	},{
		text:'类型',dataIndex:'typename',width:100,search:true,editor:'textfield',autowidth:true
	},{
		text:'标题',dataIndex:'title',align:'left',flex:1,search:true
	},{
		text:'序号',dataIndex:'xu',width:60,search:true,editor:{xtype:'numberfield',minValue:0}
	},{
		text:'显示首页',dataIndex:'isshow',width:80,renderer:renderbox,editor:{xtype:'combo',store:[['1','显示'],['0','不显示']]},search:true,atype:'select'
	},{
		text:'操作人',dataIndex:'optname',width:70,search:true
	},{
		text:'发布者/部门',dataIndex:'zuozhe',search:true,autowidth:true
	},{
		text:'时间',dataIndex:'indate',search:true,autowidth:true
	},{
		text:'操作时间',dataIndex:'optdt',width:150,search:true
	}],
	beforeload:function(){
		btn(true);
	},
	click:function(o,r){
		btn(false);
	},
	dblclick:function(o, r){
		js.open(js.getajaxurl('@view', mode, dir,{id:r.data.id}), 820);
	}
}];



return {
	panel:panel,
	init:function(){
		tree = rock[index][0];
		grid = rock[index][1];
	},
	tabson:{
		show:function(){
			if(rock[index][1].isreadload){
				grid.storereload();
				rock[index][1].isreadload=false;
			}	
		}
	}	
};