Skip to content

Commit

Permalink
Merge bd35929 into ce3a0e7
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongzhenhai-zh committed Feb 9, 2018
2 parents ce3a0e7 + bd35929 commit 9b496cb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/lay/modules/table.js
Expand Up @@ -411,18 +411,20 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
var params = {};
params[request.pageName] = curr;
params[request.limitName] = options.limit;

var dataObj = $.extend(params, options.where);
options.contentType = options.contentType || 'application/x-www-form-urlencoded '
$.ajax({
type: options.method || 'get'
,url: options.url
,data: $.extend(params, options.where)
,contentType: options.contentType
,data: options.contentType ==='application/json'?JSON.stringify(dataObj):dataObj
,dataType: 'json'
,success: function(res){
if(res[response.statusName] != response.statusCode){
that.renderForm();
that.layMain.html('<div class="'+ NONE +'">'+ (res[response.msgName] || '返回的数据状态异常') +'</div>');
} else {
that.renderData(res, curr, res[response.countName]), sort();
that.renderData(res, curr, that.treeToList(res,response.countName)), sort();
options.time = (new Date().getTime() - that.startTime) + ' ms'; //耗时(接口请求+视图渲染)
}
loadIndex && layer.close(loadIndex);
Expand Down Expand Up @@ -478,15 +480,24 @@ layui.define(['laytpl', 'laypage', 'layer', 'form'], function(exports){
callback(i, item);
});
};

eachArrs();
};


// 循环获取路径下对象
Class.prototype.treeToList = function (data, path) {
var propList = path.split('.');
for (var i = 0; i < propList.length; i++) {
data = data[propList[i]];
}
return data;
}

//数据渲染
Class.prototype.renderData = function(res, curr, count, sort){
var that = this
,options = that.config
,data = res[options.response.dataName] || []
,data = that.treeToList(res, options.response.dataName) || []
,trs = []
,trs_fixed = []
,trs_fixed_r = []
Expand Down

0 comments on commit 9b496cb

Please sign in to comment.