mirror of https://github.com/layui/layui
添加树表模块的一些默认样式;调整table.getOptions的返回,不做克隆直接返回当前表格实例的属性;优化table.reloadData细节,将以前只允许部分参数改成排除自带参数中会影响整体不适合作为重载数据的参数,这样更加方便后续对于一些自定义属性的更新,因为这类属性一样不会影响到实例的本质,可以根据需要进行修改;修复treeTable的一些问题。
parent
5d77e15fa3
commit
5b20931196
|
@ -1099,6 +1099,10 @@ body .layui-table-tips .layui-layer-content{background: none; padding: 0; box-sh
|
||||||
.layui-table-tips-c:hover{background-color: #777;}
|
.layui-table-tips-c:hover{background-color: #777;}
|
||||||
.layui-table-tips-c:before{position: relative; right: -2px;}
|
.layui-table-tips-c:before{position: relative; right: -2px;}
|
||||||
|
|
||||||
|
/** 树表 **/
|
||||||
|
.layui-table-tree-nodeIcon {padding-right: 2px;width: 20px;}
|
||||||
|
.layui-table-tree-nodeIcon > * {width: 100%;}
|
||||||
|
|
||||||
/** 文件上传 **/
|
/** 文件上传 **/
|
||||||
.layui-upload-file{display: none!important; opacity: .01; filter: Alpha(opacity=1);}
|
.layui-upload-file{display: none!important; opacity: .01; filter: Alpha(opacity=1);}
|
||||||
.layui-upload-list{margin: 10px 0;}
|
.layui-upload-list{margin: 10px 0;}
|
||||||
|
|
|
@ -2722,7 +2722,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
|
|
||||||
// 获取表格配置信息
|
// 获取表格配置信息
|
||||||
table.getOptions = function (id) {
|
table.getOptions = function (id) {
|
||||||
return $.extend(true, {}, getThisTableConfig(id));
|
return getThisTableConfig(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示或隐藏列
|
// 显示或隐藏列
|
||||||
|
@ -2789,22 +2789,20 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
|
||||||
var args = $.extend([], arguments);
|
var args = $.extend([], arguments);
|
||||||
args[3] = 'reloadData';
|
args[3] = 'reloadData';
|
||||||
|
|
||||||
// 重载时,与数据相关的参数
|
// 重载时,影响整个结构的参数,不适合更新的参数
|
||||||
var dataParams = new RegExp('^('+ [
|
var dataParams = new RegExp('^('+ [
|
||||||
'data', 'url', 'method', 'contentType',
|
'elem', 'id', 'cols', 'width', 'height', 'maxHeight',
|
||||||
'dataType','jsonpCallback',
|
'toolbar', 'defaultToolbar',
|
||||||
'headers', 'where', 'page', 'limit',
|
'className', 'css', 'totalRow', 'page', 'pagebar'
|
||||||
'request', 'response', 'parseData',
|
|
||||||
'scrollPos'
|
|
||||||
].join('|') + ')$');
|
].join('|') + ')$');
|
||||||
|
|
||||||
// 过滤与数据无关的参数
|
// 过滤与数据无关的参数
|
||||||
layui.each(args[1], function (key, value) {
|
layui.each(args[1], function (key, value) {
|
||||||
if(!dataParams.test(key)){
|
if(dataParams.test(key)){
|
||||||
delete args[1][key];
|
delete args[1][key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return table.reload.apply(null, args);
|
return table.reload.apply(null, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,6 @@ layui.define(['table'], function (exports) {
|
||||||
var tableIns = table.render($.extend({}, options, {
|
var tableIns = table.render($.extend({}, options, {
|
||||||
data: [],
|
data: [],
|
||||||
url: '',
|
url: '',
|
||||||
text: {
|
|
||||||
none: ' '
|
|
||||||
},
|
|
||||||
done: null
|
done: null
|
||||||
}))
|
}))
|
||||||
var id = tableIns.config.id;
|
var id = tableIns.config.id;
|
||||||
|
@ -208,13 +205,14 @@ layui.define(['table'], function (exports) {
|
||||||
beforeExpand: null, // 展开前的回调 return false 可以阻止展开的动作
|
beforeExpand: null, // 展开前的回调 return false 可以阻止展开的动作
|
||||||
onExpand: null, // 展开之后的回调
|
onExpand: null, // 展开之后的回调
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
autoSort: false
|
||||||
};
|
};
|
||||||
|
|
||||||
Class.prototype.getOptions = function () {
|
Class.prototype.getOptions = function () {
|
||||||
var that = this;
|
var that = this;
|
||||||
if (that.tableIns) {
|
if (that.tableIns) {
|
||||||
return that.tableIns.config
|
return table.getOptions(that.tableIns.config.id); // 获取表格的实时配置信息
|
||||||
} else {
|
} else {
|
||||||
return that.config;
|
return that.config;
|
||||||
}
|
}
|
||||||
|
@ -392,9 +390,7 @@ layui.define(['table'], function (exports) {
|
||||||
if (LAY_EXPAND) {
|
if (LAY_EXPAND) {
|
||||||
// 展开
|
// 展开
|
||||||
if (LAY_HAS_EXPANDED) { // 已经展开过
|
if (LAY_HAS_EXPANDED) { // 已经展开过
|
||||||
if (LAY_EXPAND == trData['LAY_EXPAND']) {
|
if (LAY_EXPAND == trData['LAY_EXPAND']) { // 已经和当前的状态一样,是否有优化的空间,要注意直接方法调用级联展开和触发和不是级联的情况下的区别
|
||||||
// 需要更新的状态已经跟节点上的状态一致,则为无效的操作,直接返回避免做一些无意义的操作
|
|
||||||
return retValue;
|
|
||||||
}
|
}
|
||||||
trData['LAY_EXPAND'] = LAY_EXPAND;
|
trData['LAY_EXPAND'] = LAY_EXPAND;
|
||||||
|
|
||||||
|
@ -521,19 +517,23 @@ layui.define(['table'], function (exports) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (LAY_EXPAND == trData['LAY_EXPAND']) {
|
if (LAY_EXPAND == trData['LAY_EXPAND']) {}
|
||||||
// 需要更新的状态已经跟节点上的状态一致,则为无效的操作,直接返回避免做一些无意义的操作
|
|
||||||
return retValue;
|
|
||||||
}
|
|
||||||
trData['LAY_EXPAND'] = LAY_EXPAND;
|
trData['LAY_EXPAND'] = LAY_EXPAND;
|
||||||
// 折叠
|
// 折叠
|
||||||
var childNodesFlat = treeTableThat.treeToFlat(childNodes, trData[treeOptions.data.simpleData.idKey], trIndex);
|
if (sonSign && !isToggle) { // 非状态切换的情况下
|
||||||
tableViewElem.find(childNodesFlat.map(function (value, index, array) {
|
layui.each(childNodes, function (i1, item1) {
|
||||||
if (sonSign && !isToggle) { // 非状态切换的情况下
|
expandNode({trElem: tableViewElem.find('tr[data-index="' + item1.LAY_DATA_INDEX + '"]').first()}, expandFlag, sonSign, focus, callbackFlag);
|
||||||
treeTableThat.getNodeDataByIndex(value['LAY_DATA_INDEX'])['LAY_EXPAND'] = false;
|
});
|
||||||
}
|
tableViewElem.find(childNodes.map(function (value, index, array) { // 只隐藏直接子节点,其他由递归的处理
|
||||||
return 'tr[data-index="' + value[LAY_DATA_INDEX] + '"]'
|
return 'tr[data-index="' + value[LAY_DATA_INDEX] + '"]'
|
||||||
}).join(',')).addClass('layui-hide');
|
}).join(',')).addClass('layui-hide');
|
||||||
|
} else {
|
||||||
|
var childNodesFlat = treeTableThat.treeToFlat(childNodes, trData[treeOptions.data.simpleData.idKey], trIndex);
|
||||||
|
tableViewElem.find(childNodesFlat.map(function (value, index, array) {
|
||||||
|
return 'tr[data-index="' + value[LAY_DATA_INDEX] + '"]'
|
||||||
|
}).join(',')).addClass('layui-hide');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
table.resize(tableId);
|
table.resize(tableId);
|
||||||
|
|
||||||
|
@ -756,6 +756,7 @@ layui.define(['table'], function (exports) {
|
||||||
} else {
|
} else {
|
||||||
options.data = layui.sort(options.data, table.config.indexName);
|
options.data = layui.sort(options.data, table.config.indexName);
|
||||||
}
|
}
|
||||||
|
that.initData(options.data);
|
||||||
treeTable.reloadData(id);
|
treeTable.reloadData(id);
|
||||||
} else {
|
} else {
|
||||||
// url异步取数的表格一般需要自己添加监听之后进行reloadData并且把排序参数加入到where中
|
// url异步取数的表格一般需要自己添加监听之后进行reloadData并且把排序参数加入到where中
|
||||||
|
@ -1016,6 +1017,7 @@ layui.define(['table'], function (exports) {
|
||||||
|
|
||||||
// 重载
|
// 重载
|
||||||
treeTable.reload = function (id, options, deep, type) {
|
treeTable.reload = function (id, options, deep, type) {
|
||||||
|
deep = deep !== false; // 默认采用深拷贝
|
||||||
var config = getThisTableConfig(id); //获取当前实例配置项
|
var config = getThisTableConfig(id); //获取当前实例配置项
|
||||||
if (!config) return;
|
if (!config) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue