Browse Source

Merge pull request #1303 in VISUAL/fineui from ~WINDY/fineui:master to master

* commit '131e0af0297d015b9e1d4599121f7f2392b30fbe':
  changelog
  update
  BI-61057 refactor: 提供加载更多的分页方式
es6
windy 5 years ago
parent
commit
2612ac9760
  1. 1
      changelog.md
  2. 7
      src/base/tree/ztree/asynctree.js
  3. 3
      src/base/tree/ztree/treerender.scroll.service.js
  4. 76
      src/base/tree/ztree/treetrender.page.service.js

1
changelog.md

@ -1,5 +1,6 @@
# 更新日志
2.0(2020-04)
- 复选下拉树展开节点提供分页加载和滚动加载两种方式
- 修复了复选下拉列表初始化的时候发送执行两次itemsCreator的问题
- 修复了virtual_list重新populate无效的问题
- 复选下拉框新增值的时候外抛事件

7
src/base/tree/ztree/asynctree.js

@ -11,9 +11,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
_init: function () {
BI.AsyncTree.superclass._init.apply(this, arguments);
var self = this;
this.service = new BI.TreeRenderService({
id: this.id,
container: this.element,
this.service = new BI.TreeRenderPageService({
subNodeListGetter: function (tId) {
// 获取待检测的子节点列表, ztree并没有获取节点列表dom的API, 此处使用BI.$获取
return BI.$("#" + self.id + " #" + tId + "_ul");
@ -156,13 +154,12 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
};
function callback(nodes, hasNext) {
self.nodes.addNodes(treeNode, nodes);
if (hasNext) {
self.service.pushNodeList(treeNode.tId, getNodes);
} else {
self.service.removeNodeList(treeNode.tId);
}
// console.log("add nodes");
self.nodes.addNodes(treeNode, nodes);
}

3
src/base/tree/ztree/treerender.service.js → src/base/tree/ztree/treerender.scroll.service.js

@ -2,10 +2,11 @@
* @author windy
* @version 2.0
* Created by windy on 2020/1/8
* 提供节点滚动加载方式
*/
!(function () {
BI.TreeRenderService = BI.inherit(BI.OB, {
BI.TreeRenderScrollService = BI.inherit(BI.OB, {
_init: function () {
this.nodeLists = {};

76
src/base/tree/ztree/treetrender.page.service.js

@ -0,0 +1,76 @@
/**
* @author windy
* @version 2.0
* Created by windy on 2020/1/8
* 提供节点分页加载方式
*/
!(function () {
BI.TreeRenderPageService = BI.inherit(BI.OB, {
_init: function () {
this.nodeLists = {};
},
_getLoadingBar: function(tId) {
var self = this;
var tip = BI.createWidget({
type: "bi.loading_bar",
height: 25,
handler: function () {
self.refreshNodes(tId);
}
});
tip.setLoaded();
return tip;
},
pushNodeList: function (tId, populate) {
var self = this, o = this.options;
var tip = this._getLoadingBar(tId);
if (!BI.has(this.nodeLists, tId)) {
this.nodeLists[tId] = {
populate: BI.debounce(populate, 0),
options: {
times: 1
},
loadWidget: tip
};
} else {
this.nodeLists[tId].loadWidget.destroy();
this.nodeLists[tId].loadWidget = tip;
}
BI.createWidget({
type: "bi.vertical",
element: o.subNodeListGetter(tId),
items: [tip]
});
},
refreshNodes: function (tId) {
var nodeList = this.nodeLists[tId];
nodeList.options.times++;
nodeList.loadWidget.setLoading();
nodeList.populate({
times: nodeList.options.times
});
},
removeNodeList: function (tId) {
this.nodeLists[tId].loadWidget.destroy();
this.nodeLists[tId].loadWidget = null;
delete this.nodeLists[tId];
if (BI.size(this.nodeLists) === 0) {
this.clear();
}
},
clear: function () {
var self = this;
BI.each(this.nodeLists, function (tId) {
self.removeNodeList(tId);
});
this.nodeLists = {};
}
});
})();
Loading…
Cancel
Save