CenterGrid = Ext.extend(UxGrid,{
constructor: function(height,width){
this.store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({url:CENTER_GRID_STORE_URL,method:'POST'}),
reader: new Ext.data.JsonReader({totalProperty:'total',root:'rows'},[
{name:'taskId'},{name:'scriptId'},{name:'state'},{name:'taskName'},{name:'taskDate'},
{name:'scriptName'},{name:'updateTime'},{name:'remark'}
])
});
this.selectItem=this.createMemoryCombo('查看所有','id','name','95%',TASK_SERACH_DATA, 'week');
this.selectItem.store.load();
this.dataStart = this.createSDateField("开始时间", "beginTime","Y-m-d",'请选择开始时间' );//"请选择开始时间"
var today = new Date();
today.setDate(today.getDate()-1);
this.dataStart.setValue(today);
this.dataEnd = this.createEDateField("结束时间", "endTime","Y-m-d",'请选择结束时间');//,"请选择结束时间"
this.dataEnd.setValue(new Date());
this.vtbar = new Ext.Toolbar({
items: [
'-','请选择查看类型:',this.selectItem,
'->','-',this.dataStart,this.dataEnd,
'-',{xtype:'button',text:'查询',iconCls:'query',handler:function(){
if(centerGrid.dataStart.getValue() && centerGrid.dataEnd.getValue()){
var beginTime = centerGrid.dataStart.getValue().format("Y-m-d");
var endTime = centerGrid.dataEnd.getValue().format("Y-m-d");
centerGrid.store.baseParams= {beginTime:beginTime,endTime:endTime};
centerGrid.store.load({params:{start:0,limit:PAGESIZE}});
}
}
}
]
});
this.vbbar = this.createPagingToolbar(PAGESIZE);
this.vsm = new Ext.grid.CheckboxSelectionModel();
this.vcm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),
this.vsm,
{header:'脚本名称',dataIndex:'scriptName',sortable:true,width:140,hidden:false},
{header:'任务名称',dataIndex:'taskName',width:140,sortable:true,hidden:false},
{header:'状态',dataIndex:'state',sortable:true,width:190,
renderer: function(value){
if(value == '0'){
return "<span style='background:#FFA500;width:80px;float:left'> </span> <font size='2' color='#FFA500'> 未执行</font>";
}else if(value == '1'){
return "<span style='background:#00BB00;width:80px;float:left'> </span> <font size='2' color='#00BB00'> 执行中</font>";
}else if(value == '2'){
return "<span style='background:#00FF00;width:80px;float:left'> </span> <font size='2' color='#00FF00'> 完成</font>";
}else if(value == '3'){
return "<span style='background:#FF0000;width:80px;float:left'> </span> <font size='2' color='#FF0000'> 异常</font>";
}else if(value == '4'){
return "<span style='background:#FFA500;width:80px;float:left'> </span> <font size='2' color='#FFA500'> 文件未下发</font>";
}else if(value == '5'){
return "<span style='background:#FFA500;width:80px;float:left'> </span> <font size='2' color='#FFA500'> 前置任务未执行</font>";
}
}
},
{header:'数据时间',dataIndex:'taskDate',sortable:true,hidden:false},
{header:'历史任务',dataIndex:'',sortable:true,
renderer: function(){
return "<a href='javascript:void(0)' οnclick='centerGrid.detailClick()'>查看历史状态</a>";
}
},
{header:'更新时间',dataIndex:'updateTime',width:130,sortable:true},
{header:'备注',dataIndex:'remark',width:130,sortable:true,id:'remarkId'}
]);
CenterGrid.superclass.constructor.call(this,{
region: 'center',
title: '任务状态列表显示',
frame: true,
height: height,
autoWidth : true,
autoExpandColumn: 'remarkId',
viewConfig: {
forceFit: false
},
loadMask: {
msg: '正在载入数据,请稍后...'
},
sm: this.vsm,
cm: this.vcm,
tbar: this.vtbar,
bbar: this.vbbar,
ds: this.store
});
},
detailClick: function(){
var record = this.selectedRecord();
var taskId = record.data.taskId;
var win = new DetailWindow();
win.windowInfoGrid.store.baseParams = {taskId:taskId};
win.windowInfoGrid.store.load({params:{start:0,limit:PAGESIZE}});
win.show();
win.maximize();
},
createSDateField: function(fieldLabel, name, format, emptyText) {
var date = new Ext.form.DateField({
id:'sdate',
fieldLabel: fieldLabel,
name: name,
format: format,
maxValue: new Date(),
// anchor: anchor,
width:115,
allowBlank: false,
editable:false,//不能手动输入
blankText: '请选择时间',
emptyText: emptyText,
listeners:{
'select': function(){
var startDate = Ext.getCmp('sdate').getValue();
Ext.getCmp('edate').setMinValue(startDate);
}
}
});
return date;
},
createEDateField: function(fieldLabel, name, format, emptyText) {
var date = new Ext.form.DateField({
id:'edate',
fieldLabel: fieldLabel,
name: name,
format: format,
maxValue: new Date(),
// anchor: anchor,
width:115,
allowBlank: false,
editable:false,//不能手动输入
blankText: '请选择时间',
emptyText: emptyText,
listeners: {
'select': function(){
var endDate = Ext.getCmp('edate').getValue();
Ext.getCmp('sdate').setMaxValue(endDate);
}
}
});
return date;
},
createMemoryCombo: function(fieldLabel,id,name,anchor,jsonData,formName) {
var combo = new Ext.form.ComboBox({
fieldLabel: fieldLabel,
emptyText: '请选择...',
isFormField: true,
anchor: anchor,
mode: 'local',
name: formName,
hiddenName :formName,
allowBlank: false,
blankText:'请选择...',
forceSelection: true,
triggerAction: 'all',
displayField:name,
valueField:id,
store: new Ext.data.Store({
proxy: new Ext.data.MemoryProxy(jsonData),
reader: new Ext.data.JsonReader({},new Ext.data.Record.create([{name:id},{name:name}]))
}),
editable : false,
listeners:{
'select':{fn:this.selectFn,scope:this}
}
});
return combo;
},
selectFn: function(node,e){
var state = node.value;
centerGrid.store.baseParams = {state:state};
centerGrid.store.load({params:{start:0,limit:PAGESIZE}});
}
});
Extjs Grid当中Toolbar上面按时间段查询2
最新推荐文章于 2018-10-09 08:34:33 发布