guy 7 years ago
parent
commit
1d51646697
  1. 42
      src/base/tree/asynctree.js

42
src/base/tree/asynctree.js

@ -6,13 +6,13 @@
*/ */
BI.AsyncTree = BI.inherit(BI.TreeView, { BI.AsyncTree = BI.inherit(BI.TreeView, {
_defaultConfig: function () { _defaultConfig: function () {
return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {}) return BI.extend(BI.AsyncTree.superclass._defaultConfig.apply(this, arguments), {});
}, },
_init: function () { _init: function () {
BI.AsyncTree.superclass._init.apply(this, arguments); BI.AsyncTree.superclass._init.apply(this, arguments);
}, },
//配置属性 // 配置属性
_configSetting: function () { _configSetting: function () {
var paras = this.options.paras; var paras = this.options.paras;
var self = this; var self = this;
@ -49,23 +49,23 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} }
}; };
function onClick(event, treeId, treeNode) { function onClick (event, treeId, treeNode) {
var zTree = $.fn.zTree.getZTreeObj(treeId); var zTree = $.fn.zTree.getZTreeObj(treeId);
zTree.checkNode(treeNode, !treeNode.checked, true, true); zTree.checkNode(treeNode, !treeNode.checked, true, true);
} }
function beforeCheck(treeId, treeNode) { function beforeCheck (treeId, treeNode) {
treeNode.halfCheck = false; treeNode.halfCheck = false;
if (treeNode.checked === true) { if (treeNode.checked === true) {
//将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy // 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy
//所有的半选状态都需要取消halfCheck=true的情况 // 所有的半选状态都需要取消halfCheck=true的情况
function track(children) { function track (children) {
BI.each(children, function (i, ch) { BI.each(children, function (i, ch) {
if (ch.halfCheck === true) { if (ch.halfCheck === true) {
ch.halfCheck = false; ch.halfCheck = false;
track(ch.children); track(ch.children);
} }
}) });
} }
track(treeNode.children); track(treeNode.children);
@ -74,23 +74,23 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var nodes = treeObj.getSelectedNodes(); var nodes = treeObj.getSelectedNodes();
BI.each(nodes, function (index, node) { BI.each(nodes, function (index, node) {
node.halfCheck = false; node.halfCheck = false;
}) });
} }
} }
function beforeExpand(treeId, treeNode) { function beforeExpand (treeId, treeNode) {
self._beforeExpandNode(treeId, treeNode); self._beforeExpandNode(treeId, treeNode);
} }
function onCheck(event, treeId, treeNode) { function onCheck (event, treeId, treeNode) {
self._selectTreeNode(treeId, treeNode); self._selectTreeNode(treeId, treeNode);
} }
function onExpand(event, treeId, treeNode) { function onExpand (event, treeId, treeNode) {
treeNode.halfCheck = false; treeNode.halfCheck = false;
} }
function onCollapse(event, treeId, treeNode) { function onCollapse (event, treeId, treeNode) {
treeNode.halfCheck = false; treeNode.halfCheck = false;
} }
@ -101,7 +101,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode)); var parentValues = BI.deepClone(treeNode.parentValues || self._getParentValues(treeNode));
var name = this._getNodeValue(treeNode); var name = this._getNodeValue(treeNode);
// var values = parentValues.concat([name]); // var values = parentValues.concat([name]);
if (treeNode.checked === true) { if (treeNode.checked === true) {
} else { } else {
var tNode = treeNode; var tNode = treeNode;
@ -122,7 +122,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments); BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
}, },
//展开节点 // 展开节点
_beforeExpandNode: function (treeId, treeNode) { _beforeExpandNode: function (treeId, treeNode) {
var self = this, o = this.options; var self = this, o = this.options;
var parentValues = treeNode.parentValues || self._getParentValues(treeNode); var parentValues = treeNode.parentValues || self._getParentValues(treeNode);
@ -140,7 +140,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}; };
var times = 1; var times = 1;
function callback(nodes, hasNext) { function callback (nodes, hasNext) {
self.nodes.addNodes(treeNode, nodes); self.nodes.addNodes(treeNode, nodes);
if (hasNext === true) { if (hasNext === true) {
@ -153,7 +153,9 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} }
if (!treeNode.children) { if (!treeNode.children) {
o.itemsCreator(op, complete) setTimeout(function () {
o.itemsCreator(op, complete);
}, 17);
} }
}, },
@ -162,7 +164,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
var map = {}; var map = {};
track([], valueA, valueB); track([], valueA, valueB);
track([], valueB, valueA); track([], valueB, valueA);
function track(parent, node, compare) { function track (parent, node, compare) {
BI.each(node, function (n, item) { BI.each(node, function (n, item) {
if (BI.isNull(compare[n])) { if (BI.isNull(compare[n])) {
self._addTreeNode(map, parent, n, item); self._addTreeNode(map, parent, n, item);
@ -171,7 +173,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
} else { } else {
track(parent.concat([n]), node[n], compare[n]); track(parent.concat([n]), node[n], compare[n]);
} }
}) });
} }
return map; return map;
@ -195,7 +197,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
return this._join(checkedValues, this.options.paras.selectedValues); return this._join(checkedValues, this.options.paras.selectedValues);
}, },
//生成树方法 // 生成树方法
stroke: function (config) { stroke: function (config) {
delete this.options.keyword; delete this.options.keyword;
BI.extend(this.options.paras, config); BI.extend(this.options.paras, config);

Loading…
Cancel
Save