var gridConfig = {};
var gridId = "statisticsGrid";
var xwidth = 290;
var fwidth = 160;
var treeNoid = "";
var _json= 1;
Ext.onReady(function(){
gridConfig.pagesize = pagesize;
gridConfig.gridId = gridId;
gridConfig.gridCmReaderConfig = [
{show:'uid',tag:'ROWNUM_',hidden:true},
{show:'板块Id',tag:'COLUMN_ID',hidden:true},
{show:'文章名称',tag:'CONTENT_TITEL'},
{show:'所属板块',tag:'COLUMN_NAME'},
{show:'发布时间',tag:'PUBLISH_DATE',renderer:dateFormat},
{show:'浏览量',tag:'VIEWS'}
];
gridConfig.sm = false;
gridConfig.storeURL = basepath+"/admin/statistics/statistic";
gridConfig.baseParams = {_json:_json};
var startTime = {xtype:'datefield',emptyText:'==起始日期==',format :'Y-m-d',id:'startTime' };
var endTime = {xtype:'datefield',emptyText:'==起始日期==',format :'Y-m-d',id:'endTime' };
var contentTitle = {xtype:'textfield',emptyText:'==文章名称==',id:'contentTitle'};
/**********************************************************************************/
//内容栏目树//
var loader = new Ext.tree.TreeLoader({
dataUrl:basepath+"/admin/statistics/columntree",
listeners :{
'beforeload':{
fn : function(loader) {
loader.baseParams._json = _json;
},
scope : this
}
}
});
loader.processResponse = function(response, node, callback){
var json = response.responseText;
try {
var json = eval("("+json+")");
var amenu = json["data"];
node.beginUpdate();
var o = makeTreeNode (amenu);
for(var i = 0, len = o.length; i < len; i++){
var n = this.createNode(o[i]);
if(n){
node.appendChild(n);
}
}
node.endUpdate();
if(typeof callback == "function"){
callback(this, node);
}
}catch(e){
this.handleFailure(response);
}
};
var root = new Ext.tree.AsyncTreeNode({expanded:true,id:'0',text:'全部'});
var tree = new Ext.tree.TreePanel({
loader: loader,
id:'tree',
border :false,
editable:true,
rootVisible:true,
root:root,
listeners :{
'click':function(node,e)
{
var title = node.attributes.text;
treeNoid = node.attributes.id;
}
}
});
var treeCombo = new ComboBoxTree({
id:'treeCombo',
allowBlank : true,
width:200,
allowUnLeafClick:true,//只允许选择叶子
treeHeight:200,
emptyText:'请选择栏目',
fieldLabel:'栏目',
tree:tree
});
/********************************************************************************/
gridConfig.tbar=['-',"起始日期:",startTime,'截止日期:',endTime,'文章名称',contentTitle,'-',treeCombo,'-',
{text:'查询',handler:searchFn,iconCls:'searchBtn'},'-',
{text:'重置',handler:reSetFn,iconCls:'reSetBtn'},'-','->'
];
gridConfig.viewConfig = {
forceFit: true,
enableRowBody:true,
showPreview:false
};
var agrid = new basePagingGrid(gridConfig);
var viewport = new Ext.Viewport({
layout:'fit',
listeners:{'afterrender':function(){
}},
items:[agrid]
});
})
/********************************************************************************************/
function makeTreeNode (menus)
{
var mapdata = {};
//第一次组织树节点内容
for(var i=0;i<menus.length;i++)
{
var node = menus[i];
var menuname = node['name'];
var parentNo = node['parentId'];
var aid = node['id'];
mapdata["id_"+aid]= {id:aid,text:menuname,parentNo:parentNo};
}
var ret = [];
for(var key in mapdata)
{
var node = mapdata[key];
var pid = mapdata[key]['parentNo'];
if(mapdata["id_"+pid])
{
if(typeof mapdata["id_"+pid]['children'] == 'undefined')
{
mapdata["id_"+pid]['children'] = [];
}
mapdata["id_"+pid]['children'].push(mapdata[key]);
}else
{
ret.push(mapdata[key]);
}
}
//设置叶子节点,两部分
for(var key in mapdata)
{
var node = mapdata[key];
if (typeof mapdata[key]['children'] == 'undefined')
{
mapdata[key]['leaf'] = true;
}
}
return ret;
}
function searchFn()
{
var startTime = Ext.getCmp("startTime");
var endTime = Ext.getCmp('endTime');
var contentTitle = Ext.getCmp('contentTitle');
var startvalue = "";
var endvalue = "";
if(startTime.getValue().length!=0 &&startTime.validate() )
{
startvalue = startTime.getValue().format('Y-m-d');
}
if(endTime.getValue().length!=0 && endTime.validate())
{
endvalue = endTime.getValue().format('Y-m-d');
}
var grid = Ext.getCmp(gridId);
var obj = grid.store.baseParams?grid.store.baseParams:{};
obj.startTime=startvalue;
obj.endTime = endvalue;
obj.contentTitle =contentTitle.getValue();
obj.columnId = treeNoid;
grid.store.baseParams = obj;
grid.store.load({params : {start : 0,limit : pagesize }});
}
function dateFormat(v, cellmeta, record, rowIndex, columnIndex, store)
{
if(!v)return "";
else
{
return new Date(v).format("Y-m-d")
}
}
function reSetFn()
{
Ext.getCmp('startTime').reset();
Ext.getCmp('endTime').reset();
Ext.getCmp('contentTitle').reset();
Ext.getCmp('treeCombo').reset();
treeNoid='0';
}
var gridId = "statisticsGrid";
var xwidth = 290;
var fwidth = 160;
var treeNoid = "";
var _json= 1;
Ext.onReady(function(){
gridConfig.pagesize = pagesize;
gridConfig.gridId = gridId;
gridConfig.gridCmReaderConfig = [
{show:'uid',tag:'ROWNUM_',hidden:true},
{show:'板块Id',tag:'COLUMN_ID',hidden:true},
{show:'文章名称',tag:'CONTENT_TITEL'},
{show:'所属板块',tag:'COLUMN_NAME'},
{show:'发布时间',tag:'PUBLISH_DATE',renderer:dateFormat},
{show:'浏览量',tag:'VIEWS'}
];
gridConfig.sm = false;
gridConfig.storeURL = basepath+"/admin/statistics/statistic";
gridConfig.baseParams = {_json:_json};
var startTime = {xtype:'datefield',emptyText:'==起始日期==',format :'Y-m-d',id:'startTime' };
var endTime = {xtype:'datefield',emptyText:'==起始日期==',format :'Y-m-d',id:'endTime' };
var contentTitle = {xtype:'textfield',emptyText:'==文章名称==',id:'contentTitle'};
/**********************************************************************************/
//内容栏目树//
var loader = new Ext.tree.TreeLoader({
dataUrl:basepath+"/admin/statistics/columntree",
listeners :{
'beforeload':{
fn : function(loader) {
loader.baseParams._json = _json;
},
scope : this
}
}
});
loader.processResponse = function(response, node, callback){
var json = response.responseText;
try {
var json = eval("("+json+")");
var amenu = json["data"];
node.beginUpdate();
var o = makeTreeNode (amenu);
for(var i = 0, len = o.length; i < len; i++){
var n = this.createNode(o[i]);
if(n){
node.appendChild(n);
}
}
node.endUpdate();
if(typeof callback == "function"){
callback(this, node);
}
}catch(e){
this.handleFailure(response);
}
};
var root = new Ext.tree.AsyncTreeNode({expanded:true,id:'0',text:'全部'});
var tree = new Ext.tree.TreePanel({
loader: loader,
id:'tree',
border :false,
editable:true,
rootVisible:true,
root:root,
listeners :{
'click':function(node,e)
{
var title = node.attributes.text;
treeNoid = node.attributes.id;
}
}
});
var treeCombo = new ComboBoxTree({
id:'treeCombo',
allowBlank : true,
width:200,
allowUnLeafClick:true,//只允许选择叶子
treeHeight:200,
emptyText:'请选择栏目',
fieldLabel:'栏目',
tree:tree
});
/********************************************************************************/
gridConfig.tbar=['-',"起始日期:",startTime,'截止日期:',endTime,'文章名称',contentTitle,'-',treeCombo,'-',
{text:'查询',handler:searchFn,iconCls:'searchBtn'},'-',
{text:'重置',handler:reSetFn,iconCls:'reSetBtn'},'-','->'
];
gridConfig.viewConfig = {
forceFit: true,
enableRowBody:true,
showPreview:false
};
var agrid = new basePagingGrid(gridConfig);
var viewport = new Ext.Viewport({
layout:'fit',
listeners:{'afterrender':function(){
}},
items:[agrid]
});
})
/********************************************************************************************/
function makeTreeNode (menus)
{
var mapdata = {};
//第一次组织树节点内容
for(var i=0;i<menus.length;i++)
{
var node = menus[i];
var menuname = node['name'];
var parentNo = node['parentId'];
var aid = node['id'];
mapdata["id_"+aid]= {id:aid,text:menuname,parentNo:parentNo};
}
var ret = [];
for(var key in mapdata)
{
var node = mapdata[key];
var pid = mapdata[key]['parentNo'];
if(mapdata["id_"+pid])
{
if(typeof mapdata["id_"+pid]['children'] == 'undefined')
{
mapdata["id_"+pid]['children'] = [];
}
mapdata["id_"+pid]['children'].push(mapdata[key]);
}else
{
ret.push(mapdata[key]);
}
}
//设置叶子节点,两部分
for(var key in mapdata)
{
var node = mapdata[key];
if (typeof mapdata[key]['children'] == 'undefined')
{
mapdata[key]['leaf'] = true;
}
}
return ret;
}
function searchFn()
{
var startTime = Ext.getCmp("startTime");
var endTime = Ext.getCmp('endTime');
var contentTitle = Ext.getCmp('contentTitle');
var startvalue = "";
var endvalue = "";
if(startTime.getValue().length!=0 &&startTime.validate() )
{
startvalue = startTime.getValue().format('Y-m-d');
}
if(endTime.getValue().length!=0 && endTime.validate())
{
endvalue = endTime.getValue().format('Y-m-d');
}
var grid = Ext.getCmp(gridId);
var obj = grid.store.baseParams?grid.store.baseParams:{};
obj.startTime=startvalue;
obj.endTime = endvalue;
obj.contentTitle =contentTitle.getValue();
obj.columnId = treeNoid;
grid.store.baseParams = obj;
grid.store.load({params : {start : 0,limit : pagesize }});
}
function dateFormat(v, cellmeta, record, rowIndex, columnIndex, store)
{
if(!v)return "";
else
{
return new Date(v).format("Y-m-d")
}
}
function reSetFn()
{
Ext.getCmp('startTime').reset();
Ext.getCmp('endTime').reset();
Ext.getCmp('contentTitle').reset();
Ext.getCmp('treeCombo').reset();
treeNoid='0';
}