var date = js.now(),grid,win;
var panel = {
	xtype:'rockgrid',url:publicstore(mode,dir),
	storeafteraction:'getwcslistwock',
	tablename:'work',searchtools:true,defaultorder:'startdt desc',
	keywhere:"and mid>1 and instr(concat(',', distid, ','), ',"+adminid+",') and ifnull(state,'')<>'已完成'",
	columns:[{
		xtype: 'rownumberer',
		width: 40
	},{
		text:'标题',dataIndex:'title',search:true,autowidth:true,align:'left'
	},{
		text:'创建者',dataIndex:'optname',search:true,width:80
	},{
		text:'任务类型',dataIndex:'type',search:true,width:80
	},{
		text:'等级',dataIndex:'grade',search:true,width:60
	},{
		text:'分配给',dataIndex:'dist',search:true,autowidth:true
	},{
		text:'状态',dataIndex:'state',width:60,search:true
	},{
		text:'延迟了',dataIndex:'sjla',width:60,autowidth:true
	},{
		text:'开始时间',dataIndex:'startdt',width:160
	},{
		text:'截止时间',dataIndex:'enddt',width:160
	},{
		text:'任务报告',dataIndex:'baoname',search:true,autowidth:true,renderer:function(v, m, b){
			var s = '';
			if(!isempt(v)&&!isempt(b.raw.bgtime)){
				s = '每天'+b.raw.bgtime+'的报告给'+v+'';
			}
			return s;
		}
	},{
		text:'说明',align:'left',dataIndex:'explain',search:true,autowidth:true,renderer:rendercont
	}],
	tbar:['->',{
		text:'任务报告',disabled:true,itemId:'baog',icon:gicons('pencil'),handler:function(){grid._showwin();}
	},'-',{
		text:'详情',icon:gicons('page_white_text'),disabled:true,itemId:'xiang',handler:function(){
			grid._xiang();
		}
	}],
	click:function(){
		if(!this.changedata.id)return;
		this.down('#baog').setDisabled(false);
		this.down('#xiang').setDisabled(false);
	},
	beforeload:function(){
		this.down('#baog').setDisabled(true);
		this.down('#xiang').setDisabled(true);
	},
	dblclick:function(){
		this._xiang();
	},
	_showwin:function(){
		if(!win){
			var cans = winopt({title:'任务报告',width:350,items:{
				border:false,aftersaveaction:'workbgaftersave',
				tablename:'workbg',url:publicsave(mode,dir),
				xtype:'rockform',
				submitfields:'mid,state,explain',
				params:{int_filestype:'mid',otherfields:'optdt={now},optname={admin},optid={adminid}'},
				cancelbool:true,
				items:[{
					value:'0',name:'idPost',hidden:true
				},{
					value:'0',name:'midPost',hidden:true
				},{
					fieldLabel:''+bitian+'状态',name:'statePost',allowBlank: false,xtype:'optioncombo',optionmnum:'workstate'
				},{
					fieldLabel:'说明',name:'explainPost',xtype:'textareafield',height:60
				},uploadwindows.fields()],
				success:function(){
					grid.storereload();
					win.hide();
				}
			}});
			win = Ext.create('Ext.Window',cans);
			this.destroypanel.push(win);
		}
		win.show();
		var form = win.child('rockform');
		form.reset();
		form.setVal('mid', this.changedata.id);
	},
	_xiang:function(){
		var url = js.getajaxurl('@xiang', 'view', dir, {id:this.changedata.id});
		js.open(url, 800);
	}
};

return {
	panel:panel,
	init:function(){
		grid = rock[index];
	}
};