Browse Source

DESIGN-4160 feat: 复选树节点,某一个节点支持灰化,复选框也灰化,并且前边的展开收起是正常的

即disabled属性不再限制展开收起
es6
zsmj 3 years ago
parent
commit
a6e85eb8d3
  1. 34
      src/case/ztree/0.treeview.js
  2. 25
      src/case/ztree/1.asynctree.js

34
src/case/ztree/0.treeview.js

@ -110,7 +110,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
};
var className = "dark", perTime = 100;
function onClick (event, treeId, treeNode) {
function onClick(event, treeId, treeNode) {
// 当前点击节点的状态是半选,且为true_part, 则将其改为false_part,使得点击半选后切换到的是全选
var checked = treeNode.checked;
var status = treeNode.getCheckStatus();
@ -121,7 +121,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
self.nodes.checkNode(treeNode, !checked, true, true);
}
function getUrl (treeId, treeNode) {
function getUrl(treeId, treeNode) {
var parentNode = self._getParentValues(treeNode);
treeNode.times = treeNode.times || 1;
var param = "id=" + treeNode.id
@ -132,7 +132,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
return "&" + param;
}
function beforeExpand (treeId, treeNode) {
function beforeExpand(treeId, treeNode) {
if (!treeNode.isAjaxing) {
if (!treeNode.children) {
treeNode.times = 1;
@ -147,7 +147,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
}
function onAsyncSuccess (event, treeId, treeNode, msg) {
function onAsyncSuccess(event, treeId, treeNode, msg) {
treeNode.halfCheck = false;
if (!msg || msg.length === 0 || /^<html>[\s,\S]*<\/html>$/gi.test(msg) || self._stop) {
return;
@ -170,14 +170,14 @@ BI.TreeView = BI.inherit(BI.Pane, {
}
}
function onAsyncError (event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
function onAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {
var zTree = self.nodes;
BI.Msg.toast("Error!", "warning");
// treeNode.icon = "";
// zTree.updateNode(treeNode);
}
function ajaxGetNodes (treeNode, reloadType) {
function ajaxGetNodes(treeNode, reloadType) {
var zTree = self.nodes;
if (reloadType == "refresh") {
zTree.updateNode(treeNode); // 刷新一下当前节点,如果treeNode.xxx被改了的话
@ -185,7 +185,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
zTree.reAsyncChildNodes(treeNode, reloadType, true); // 强制加载子节点,reloadType === refresh为先清空再加载,否则为追加到现有子节点之后
}
function beforeCheck (treeId, treeNode) {
function beforeCheck(treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
@ -195,7 +195,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
if (treeNode.checked === true) {
// 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy
// 所有的半选状态都需要取消halfCheck=true的情况
function track (children) {
function track(children) {
BI.each(children, function (i, ch) {
if (ch.halfCheck === true) {
ch.halfCheck = false;
@ -217,24 +217,18 @@ BI.TreeView = BI.inherit(BI.Pane, {
}
}
function onCheck (event, treeId, treeNode) {
function onCheck(event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
self._selectTreeNode(treeId, treeNode);
}
function onExpand (event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
function onExpand(event, treeId, treeNode) {
treeNode.halfCheck = false;
}
function onCollapse (event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
function onCollapse(event, treeId, treeNode) {
}
return setting;
@ -325,7 +319,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var hashMap = {};
var rootNoots = this.nodes.getNodes();
track(rootNoots); // 可以看到这个方法没有递归调用,所以在_getHalfSelectedValues中需要关心全选的节点
function track (nodes) {
function track(nodes) {
BI.each(nodes, function (i, node) {
var checkState = node.getCheckStatus();
if (checkState.checked === true || checkState.half === true) {
@ -503,7 +497,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
checkAll: function (checked) {
function setNode (children) {
function setNode(children) {
BI.each(children, function (i, child) {
child.halfCheck = false;
setNode(child.children);
@ -545,7 +539,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
BI.each(values, function (v, op) {
var nodes = treeObj.getNodesByParam(param, v, null);
BI.each(nodes, function (j, node) {
BI.extend(node, {checked: true}, op);
BI.extend(node, { checked: true }, op);
treeObj.updateNode(node);
});
});

25
src/case/ztree/1.asynctree.js

@ -58,7 +58,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
};
function onClick (event, treeId, treeNode) {
function onClick(event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
@ -72,7 +72,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
zTree.checkNode(treeNode, !checked, true, true);
}
function beforeCheck (treeId, treeNode) {
function beforeCheck(treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
@ -82,7 +82,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
if (treeNode.checked === true) {
// 将展开的节点halfCheck设为false,解决展开节点存在halfCheck=true的情况 guy
// 所有的半选状态都需要取消halfCheck=true的情况
function track (children) {
function track(children) {
BI.each(children, function (i, ch) {
ch.halfCheck = false;
track(ch.children);
@ -103,31 +103,22 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
}
function beforeExpand (treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
function beforeExpand(treeId, treeNode) {
self._beforeExpandNode(treeId, treeNode);
}
function onCheck (event, treeId, treeNode) {
function onCheck(event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
self._selectTreeNode(treeId, treeNode);
}
function onExpand (event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
function onExpand(event, treeId, treeNode) {
treeNode.halfCheck = false;
}
function onCollapse (event, treeId, treeNode) {
if (treeNode.disabled) {
return false;
}
function onCollapse(event, treeId, treeNode) {
treeNode.halfCheck = false;
}
@ -216,7 +207,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
track([], valueA, valueB);
track([], valueB, valueA);
function track (parent, node, compare) {
function track(parent, node, compare) {
BI.each(node, function (n, item) {
if (BI.isNull(compare[n])) {
self._addTreeNode(map, parent, n, item);

Loading…
Cancel
Save