Ext.onReady(function() {
var itemsPerPage=30;//指定分頁大小
Ext.regModel('Node',
{
fields:[{name:'UI_id'},
{name:'UI_Time'},
{name:'UI_Level'},
{name:'UI_Sys'},
{name:'UI_FlowID'},
{name:'UI_UserName'},
{name:'UI_Message'},
{name:'UI_Result'}
]
}
);
function showColor(value){
if (value == '成功') {
return '' + value + '';
} else if (value == '失敗') {
return '' + value + '';
}
return value;
}
var store = Ext.create('Ext.data.JsonStore',{
//storeId:'gridStore',
autoload:true,
model:'Node',
pageSize:itemsPerPage,
remoteSort:true,
//data:[],
proxy:{
type:'memory',
reader:{
type:'json',
totalProperty:50
}
}
});
store.loadPage(1);
//store.loadPage(1);
var sysData =[['ALL','全部'],
['GATEWAY','接入網關'],
['NJGL','農機管理'],
['NQJC','農情監測'],
['GIS','GIS'],
['DSE','數據服務引擎'],
['YG','運管'],
['TERMINAL','仿真終端']];
var sysStore = new Ext.data.SimpleStore({
fields:['sysID','sysName'],
data:sysData
});
var logLevel = [['ALL','全部'],
['INFO','INFO'],
['WARN','WARN'],
['ERROR','ERROR'],
['FATAL','FATAL'],
['DEBUG','DEBUG']];
var levelStore = new Ext.data.SimpleStore({
fields:['levelID','levelName'],
data:logLevel
});
var accordion = Ext.create("Ext.form.FormPanel", {
title: "日志查詢",
layout: "form", //設置為手風琴布局
layoutConfig: {
animate: true
},
width: 250,
minWidth: 90,
height:50,
region: "west", //設置方位
split: true,
collapsible: true,
items: [
{xtype: 'datefield',fieldLabel: '開始時間',name: 'starttime',format:'Y-m-d',allowBlank: true,height:25},
{xtype: 'datefield',fieldLabel: '結束時間',name: 'endtime',format:'Y-m-d',allowBlank: true,width:30,height:25},
{xtype:'combo',fieldLabel: '子系統標示',name:'sysID',store:sysStore,displayField:'sysName',valueField:'sysID',queryMode:'local',forceSelection:true,typeAhead:true,value:'ALL',height:25},
{xtype:'combo',fieldLabel:'日志級別',name:'levelID',store:levelStore,displayField:'levelName',valueField:'levelID',queryMode:'local',forceSelection:true,typeAhead:true,value:'ALL',height:25 },
{xtype:'textfield',fieldLabel:'查找內容',name:'contentID',emptyText:'用戶名或者消息關鍵字',height:25}
],
// 重置 和 保存 按鈕.
buttons: [{
text: '重置',
width:'120',
heigth:'80',
style:'baseCls-18px',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: '查詢',
formBind: false, //only enabled once the form is valid
disabled: false,
width:'120',
handler: function(){
var form = this.up('form').getForm().getValues();
//alert("開始時間為:" + form.starttime + ",結束時間為:" + form.endtime);
var logParam = [];
logParam.push(form.starttime);
logParam.push(form.endtime);
logParam.push(form.sysID);
logParam.push(form.levelID);
logParam.push(form.contentID);
Ext.Ajax.request({
url:'selectLog.do',
//timeout:2000,
params:{'logParam':logParam.join(",")},
success:function(response,opts){
var strData= response.responseText;
var tableData = eval(strData);
store.loadData(tableData,false);
},
failure:function(response,opts)
{
alert('提示:保存數據失敗!!!');
}
})
}
}],
renderTo: Ext.getBody()
});
var pagingToolbar = new Ext.PagingToolbar({
pageSize:30,
store:store,
displayInfo:true,
displayMsg: '第{0}-共{1}條,一共{2}條',
emptyMsg:'沒有數據',
items: [
'-', {
pressed: true,
enableToggle: true,
text: '預覽',
cls: 'x-btn-text-icon details',
toggleHandler: function(btn, pressed) {
var view = grid.getView();
view.showPreview = pressed;
view.refresh();
}
}]
});
var accordion1 = Ext.create("Ext.Panel", {
renderTo:Ext.getBody(),
layout:'fit',
frame:true,
region: "center",
width:1000,
height:500,
items:[{
xtype:'grid',
title: '日志內容',
stripeRows:true,
loadMask:true,
height:200,
store: store,
columnLines: true,
columns: [
new Ext.grid.RowNumberer(),
// { header: '編號', dataIndex: 'UI_id' },
{ header: '日志時間', flex:1,dataIndex: 'UI_Time'},
{ header: '日志級別', flex:1,dataIndex: 'UI_Level' },
{ header: '子系統標示', flex:1,dataIndex: 'UI_Sys' },
{ header: '業務流水號', flex:1,dataIndex: 'UI_FlowID' },
{ header: '用戶名', flex:1,dataIndex: 'UI_UserName' },
{ header: '日志詳情', flex:2,dataIndex: 'UI_Message' },
{ header: '處理結果', flex:1,dataIndex: 'UI_Result',renderer:showColor}
],
bbar:pagingToolbar,
height: 800,
width: 2000
}
]
});
new Ext.Viewport({
title: "Viewport",
layout: "border", //這裡是(border)邊界布局
defaults: {
bodyStyle: "background-color: #FFFFFF;",
frame: true
},
items: [
accordion1,
accordion, //這裡是(accordion)手風琴布局
{ region: "north",
height: 150,
title: '日志管理系統',
html:'
參考:http://bbs.51cto.com/thread-1084215-1.html