|
|
@ -532,13 +532,15 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { |
|
|
|
var checkState = op.checkState || {}; |
|
|
|
var checkState = op.checkState || {}; |
|
|
|
var parentValues = op.parentValues || []; |
|
|
|
var parentValues = op.parentValues || []; |
|
|
|
var selectedValues = op.selectedValues || {}; |
|
|
|
var selectedValues = op.selectedValues || {}; |
|
|
|
|
|
|
|
function getResult(parentValues) { |
|
|
|
var valueMap = {}; |
|
|
|
var valueMap = {}; |
|
|
|
// if (judgeState(parentValues, selectedValues, checkState)) {
|
|
|
|
// if (judgeState(parentValues, selectedValues, checkState)) {
|
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
var nodes = this._getChildren(parentValues); |
|
|
|
var nodes = self._getChildren(parentValues); |
|
|
|
for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { |
|
|
|
for (var i = (times - 1) * self._const.perPage; nodes[i] && i < times * self._const.perPage; i++) { |
|
|
|
var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); |
|
|
|
var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); |
|
|
|
|
|
|
|
var openState = o.open || nodes[i].open; |
|
|
|
result.push({ |
|
|
|
result.push({ |
|
|
|
id: nodes[i].id, |
|
|
|
id: nodes[i].id, |
|
|
|
pId: nodes[i].pId, |
|
|
|
pId: nodes[i].pId, |
|
|
@ -547,55 +549,64 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { |
|
|
|
times: 1, |
|
|
|
times: 1, |
|
|
|
isParent: nodes[i].getChildrenLength() > 0, |
|
|
|
isParent: nodes[i].getChildrenLength() > 0, |
|
|
|
checked: state[0], |
|
|
|
checked: state[0], |
|
|
|
halfCheck: state[1], |
|
|
|
half: state[1], |
|
|
|
open: o.open || nodes[i].open, |
|
|
|
halfCheck: openState ? false : state[1], |
|
|
|
|
|
|
|
open: openState, |
|
|
|
disabled: nodes[i].disabled, |
|
|
|
disabled: nodes[i].disabled, |
|
|
|
title: nodes[i].title || nodes[i].text, |
|
|
|
title: nodes[i].title || nodes[i].text, |
|
|
|
warningTitle: nodes[i].warningTitle, |
|
|
|
warningTitle: nodes[i].warningTitle, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if (openState) { |
|
|
|
|
|
|
|
getResult(parentValues.concat([nodes[i].value])); |
|
|
|
} |
|
|
|
} |
|
|
|
// 如果指定节点全部打开
|
|
|
|
|
|
|
|
if (o.open) { |
|
|
|
|
|
|
|
var allNodes = []; |
|
|
|
|
|
|
|
// 获取所有节点
|
|
|
|
|
|
|
|
BI.each(nodes, function (idx, node) { |
|
|
|
|
|
|
|
allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value]))); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
var lastFind; |
|
|
|
|
|
|
|
BI.each(allNodes, function (idx, node) { |
|
|
|
|
|
|
|
var valueMap = dealWithSelectedValue(node.parentValues, selectedValues); |
|
|
|
|
|
|
|
// REPORT-24409 fix: 设置节点全部展开,添加的节点没有给状态
|
|
|
|
|
|
|
|
var parentCheckState = {}; |
|
|
|
|
|
|
|
var find = BI.find(result, function (idx, pNode) { |
|
|
|
|
|
|
|
return pNode.id === node.pId; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (find) { |
|
|
|
|
|
|
|
parentCheckState.checked = find.halfCheck ? false : find.checked; |
|
|
|
|
|
|
|
parentCheckState.half = find.halfCheck; |
|
|
|
|
|
|
|
// 默认展开也需要重置父节点的halfCheck
|
|
|
|
|
|
|
|
if (BI.isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) { |
|
|
|
|
|
|
|
lastFind.half = lastFind.halfCheck; |
|
|
|
|
|
|
|
lastFind.halfCheck = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lastFind = find; |
|
|
|
|
|
|
|
var state = getCheckState(node.value, node.parentValues, valueMap, parentCheckState); |
|
|
|
|
|
|
|
result.push({ |
|
|
|
|
|
|
|
id: node.id, |
|
|
|
|
|
|
|
pId: node.pId, |
|
|
|
|
|
|
|
value: node.value, |
|
|
|
|
|
|
|
text: node.text, |
|
|
|
|
|
|
|
times: 1, |
|
|
|
|
|
|
|
isParent: node.getChildrenLength() > 0, |
|
|
|
|
|
|
|
checked: state[0], |
|
|
|
|
|
|
|
halfCheck: state[1], |
|
|
|
|
|
|
|
open: true, |
|
|
|
|
|
|
|
disabled: node.disabled, |
|
|
|
|
|
|
|
title: node.title || node.text, |
|
|
|
|
|
|
|
warningTitle: node.warningTitle, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getResult(parentValues); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果指定节点全部打开
|
|
|
|
|
|
|
|
// if (o.open) {
|
|
|
|
|
|
|
|
// var allNodes = [];
|
|
|
|
|
|
|
|
// // 获取所有节点
|
|
|
|
|
|
|
|
// BI.each(nodes, function (idx, node) {
|
|
|
|
|
|
|
|
// allNodes = BI.concat(allNodes, self._getAllChildren(parentValues.concat([node.value])));
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// var lastFind;
|
|
|
|
|
|
|
|
// BI.each(allNodes, function (idx, node) {
|
|
|
|
|
|
|
|
// var valueMap = dealWithSelectedValue(node.parentValues, selectedValues);
|
|
|
|
|
|
|
|
// // REPORT-24409 fix: 设置节点全部展开,添加的节点没有给状态
|
|
|
|
|
|
|
|
// var parentCheckState = {};
|
|
|
|
|
|
|
|
// var find = BI.find(result, function (idx, pNode) {
|
|
|
|
|
|
|
|
// return pNode.id === node.pId;
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// if (find) {
|
|
|
|
|
|
|
|
// parentCheckState.checked = find.halfCheck ? false : find.checked;
|
|
|
|
|
|
|
|
// parentCheckState.half = find.halfCheck;
|
|
|
|
|
|
|
|
// // 默认展开也需要重置父节点的halfCheck
|
|
|
|
|
|
|
|
// if (BI.isNotNull(lastFind) && (lastFind !== find || allNodes.length - 1 === idx)) {
|
|
|
|
|
|
|
|
// lastFind.half = lastFind.halfCheck;
|
|
|
|
|
|
|
|
// lastFind.halfCheck = false;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// lastFind = find;
|
|
|
|
|
|
|
|
// var state = getCheckState(node.value, node.parentValues, valueMap, parentCheckState);
|
|
|
|
|
|
|
|
// result.push({
|
|
|
|
|
|
|
|
// id: node.id,
|
|
|
|
|
|
|
|
// pId: node.pId,
|
|
|
|
|
|
|
|
// value: node.value,
|
|
|
|
|
|
|
|
// text: node.text,
|
|
|
|
|
|
|
|
// times: 1,
|
|
|
|
|
|
|
|
// isParent: node.getChildrenLength() > 0,
|
|
|
|
|
|
|
|
// checked: state[0],
|
|
|
|
|
|
|
|
// halfCheck: state[1],
|
|
|
|
|
|
|
|
// open: true,
|
|
|
|
|
|
|
|
// disabled: node.disabled,
|
|
|
|
|
|
|
|
// title: node.title || node.text,
|
|
|
|
|
|
|
|
// warningTitle: node.warningTitle,
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
|
|
|
|
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
|
|
|
|
if (parentValues.length === 0 && times === 1) { |
|
|
|
if (parentValues.length === 0 && times === 1) { |
|
|
|
result = BI.concat(self._getAddedValueNode(parentValues, selectedValues), result); |
|
|
|
result = BI.concat(self._getAddedValueNode(parentValues, selectedValues), result); |
|
|
@ -603,17 +614,17 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { |
|
|
|
BI.nextTick(function () { |
|
|
|
BI.nextTick(function () { |
|
|
|
callback({ |
|
|
|
callback({ |
|
|
|
items: result, |
|
|
|
items: result, |
|
|
|
hasNext: nodes.length > times * self._const.perPage |
|
|
|
hasNext: self._getChildren(parentValues).length > times * self._const.perPage |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
function judgeState(parentValues, selected_value, checkState) { |
|
|
|
// function judgeState(parentValues, selected_value, checkState) {
|
|
|
|
var checked = checkState.checked, half = checkState.half; |
|
|
|
// var checked = checkState.checked, half = checkState.half;
|
|
|
|
if (parentValues.length > 0 && !checked) { |
|
|
|
// if (parentValues.length > 0 && !checked) {
|
|
|
|
return false; |
|
|
|
// return false;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value)); |
|
|
|
// return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value));
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
function dealWithSelectedValue(parentValues, selectedValues) { |
|
|
|
function dealWithSelectedValue(parentValues, selectedValues) { |
|
|
|
var valueMap = {}, parents = (parentValues || []).slice(0); |
|
|
|
var valueMap = {}, parents = (parentValues || []).slice(0); |
|
|
|