当先锋百科网

首页 1 2 3 4 5 6 7
             
paging: function(options){
var controot = options.controot;
var handle = options.handle;
var pagfun = options.pagfun;
var pageroot = options.pageroot;
var id = options.id;
if(!pagfun)
pagfun = options.pagfun = arguments.callee.caller;

var cond = options.cond;
var url = options.url;
$wqd.pagingQuery({
url: url,
data: cond,
success: function(datas, query){
options.data = datas;
options.query = query;
handle(options);
},
paging: function(pageInfo){
$wqd.page({selector:pageroot, schFun: pagfun}, pageInfo);
}
});
},


pagingQuery : function(req){
var defaults = {
url: "", 
async: true, 
dataType: 'json', 
type: 'POST',
data: null, 
extData: null,
pager: "pager", 
schForm: null, 
queryName: "query",
success: function(){},
fail: function(){},
error: function(){}
};
req = $.extend(true, defaults, req);

var pager = null;
if(req.pager){
if(typeof req.pager === "object")
pager = req.pager;
else if(typeof req.pager === "string")
pager =  $wqd.getPager(req.pager);
}else{
pager = $wqd.getPager();
}

// if(req.schForm){
// var $schForm = $(req.schForm);
if(data == null){
data = $(req.schForm)
}
// if(pager == null)
// pager = $schForm.data("pager");
// }

var currpage = 1;
if(pager)
currpage = pager.getCurrentPage();
var pageInfo = this.jsonToArr({'currentPage':currpage,'pageSize':req.pageSize}, req.queryName);
$.merge(req.data, pageInfo);

$.ajax({
'url' : req.url,
'async' : req.async,
'dataType' : req.dataType,
'type' : req.type,
'data' : req.data,
'success' : function(result){
if(req.dataType == "html"){
if(req.success)
req.success(result); 
if(req.paging)
req.paging();
return;
}
if(result.errorMsg || result.errorCode){
if(req.fail)
req.fail(result);
return;
}
var data = result.list;
var query = result.query;
if(req.success)
req.success(data, query);

if(req.paging){
var pageInfo = {"totalPage": query.totalPage, "page": query.currentPage, "totalItem": query.totalItem};
req.paging(pageInfo);
}
},
'error' : function(rep){
if(req.error)
req.error(rep);
// else
// alert('请求出错!');
}
});
},