|
|
@ -532,70 +532,81 @@ 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 || {}; |
|
|
|
var valueMap = {}; |
|
|
|
function getResult(parentValues, checkState) { |
|
|
|
// if (judgeState(parentValues, selectedValues, checkState)) {
|
|
|
|
var valueMap = {}; |
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
|
// if (judgeState(parentValues, selectedValues, checkState)) {
|
|
|
|
// }
|
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
|
var nodes = this._getChildren(parentValues); |
|
|
|
// }
|
|
|
|
for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { |
|
|
|
var nodes = self._getChildren(parentValues); |
|
|
|
var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); |
|
|
|
for (var i = (times - 1) * self._const.perPage; nodes[i] && i < times * self._const.perPage; i++) { |
|
|
|
result.push({ |
|
|
|
var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); |
|
|
|
id: nodes[i].id, |
|
|
|
var openState = o.open || nodes[i].open; |
|
|
|
pId: nodes[i].pId, |
|
|
|
|
|
|
|
value: nodes[i].value, |
|
|
|
|
|
|
|
text: nodes[i].text, |
|
|
|
|
|
|
|
times: 1, |
|
|
|
|
|
|
|
isParent: nodes[i].getChildrenLength() > 0, |
|
|
|
|
|
|
|
checked: state[0], |
|
|
|
|
|
|
|
halfCheck: state[1], |
|
|
|
|
|
|
|
open: o.open || nodes[i].open, |
|
|
|
|
|
|
|
disabled: nodes[i].disabled, |
|
|
|
|
|
|
|
title: nodes[i].title || nodes[i].text, |
|
|
|
|
|
|
|
warningTitle: nodes[i].warningTitle, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 如果指定节点全部打开
|
|
|
|
|
|
|
|
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({ |
|
|
|
result.push({ |
|
|
|
id: node.id, |
|
|
|
id: nodes[i].id, |
|
|
|
pId: node.pId, |
|
|
|
pId: nodes[i].pId, |
|
|
|
value: node.value, |
|
|
|
value: nodes[i].value, |
|
|
|
text: node.text, |
|
|
|
text: nodes[i].text, |
|
|
|
times: 1, |
|
|
|
times: 1, |
|
|
|
isParent: node.getChildrenLength() > 0, |
|
|
|
isParent: nodes[i].getChildrenLength() > 0, |
|
|
|
checked: state[0], |
|
|
|
checked: state[0], |
|
|
|
halfCheck: state[1], |
|
|
|
half: state[1], |
|
|
|
open: true, |
|
|
|
halfCheck: openState ? false : state[1], |
|
|
|
disabled: node.disabled, |
|
|
|
open: openState, |
|
|
|
title: node.title || node.text, |
|
|
|
disabled: nodes[i].disabled, |
|
|
|
warningTitle: node.warningTitle, |
|
|
|
title: nodes[i].title || nodes[i].text, |
|
|
|
|
|
|
|
warningTitle: nodes[i].warningTitle, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
if (openState) { |
|
|
|
|
|
|
|
getResult(parentValues.concat([nodes[i].value]), {checked: state[0], half: state[1]}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getResult(parentValues, checkState); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 如果指定节点全部打开
|
|
|
|
|
|
|
|
// 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); |
|
|
|