guy 7 years ago
parent
commit
659d675e3f
  1. 35
      bi/widget.js
  2. 35
      docs/widget.js
  3. 35
      src/component/treevaluechooser/abstract.treevaluechooser.js

35
bi/widget.js

@ -17189,16 +17189,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree(); this.tree = new BI.Tree();
this.tree.initTree(nodes); this.tree.initTree(nodes);
this._initFloors();
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
}, },
_itemsCreator: function (options, callback) { _itemsCreator: function (options, callback) {
@ -17242,23 +17232,20 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return; return;
} }
doCheck(0, [], this.tree.getRoot(), selectedValues); doCheck([], this.tree.getRoot(), selectedValues);
callback({ callback({
items: result items: result
}); });
function doCheck(floor, parentValues, node, selected) { function doCheck(parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
if (selected == null || BI.isEmpty(selected)) { if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) { BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(child.value); newParents.push(child.value);
var llen = self._getChildCount(newParents); var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen); createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {}); doCheck(newParents, child, {});
}); });
return; return;
} }
@ -17267,7 +17254,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(node.value); newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]); doCheck(newParents, node, selected[k]);
}) })
} }
@ -17357,9 +17344,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
if (self._isMatch(current, keyword)) { if (self._isMatch(current, keyword)) {
return true; return true;
} }
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -17495,9 +17479,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked]; return [true, checked];
} }
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(current); newParents.push(current);
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -17529,7 +17510,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
text: node.text, text: node.text,
value: node.value, value: node.value,
title: node.title, title: node.title,
isParent: parentValues.length + 1 < self.floors, isParent: node.getChildrenLength() > 0,
open: isOpen, open: isOpen,
checked: checked, checked: checked,
halfCheck: half, halfCheck: half,
@ -17613,7 +17594,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
value: nodes[i].value, value: nodes[i].value,
text: nodes[i].text, text: nodes[i].text,
times: 1, times: 1,
isParent: parentValues.length + 1 < this.floors, isParent: nodes[i].getChildrenLength() > 0,
checked: state[0], checked: state[0],
halfCheck: state[1] halfCheck: state[1]
}) })
@ -17660,14 +17641,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function getCheckState(current, parentValues, valueMap, checkState) { function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half; var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false; var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) { if (BI.has(valueMap, current)) {
//可能是半选 //可能是半选
if (valueMap[current][0] === 1) { if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues); var values = BI.clone(parentValues);
values.push(current); values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) { var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true; halfCheck = true;
} }
} else if (valueMap[current][0] === 2) { } else if (valueMap[current][0] === 2) {

35
docs/widget.js

@ -17189,16 +17189,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree(); this.tree = new BI.Tree();
this.tree.initTree(nodes); this.tree.initTree(nodes);
this._initFloors();
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
}, },
_itemsCreator: function (options, callback) { _itemsCreator: function (options, callback) {
@ -17242,23 +17232,20 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return; return;
} }
doCheck(0, [], this.tree.getRoot(), selectedValues); doCheck([], this.tree.getRoot(), selectedValues);
callback({ callback({
items: result items: result
}); });
function doCheck(floor, parentValues, node, selected) { function doCheck(parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
if (selected == null || BI.isEmpty(selected)) { if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) { BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(child.value); newParents.push(child.value);
var llen = self._getChildCount(newParents); var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen); createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {}); doCheck(newParents, child, {});
}); });
return; return;
} }
@ -17267,7 +17254,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(node.value); newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]); doCheck(newParents, node, selected[k]);
}) })
} }
@ -17357,9 +17344,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
if (self._isMatch(current, keyword)) { if (self._isMatch(current, keyword)) {
return true; return true;
} }
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -17495,9 +17479,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked]; return [true, checked];
} }
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(current); newParents.push(current);
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -17529,7 +17510,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
text: node.text, text: node.text,
value: node.value, value: node.value,
title: node.title, title: node.title,
isParent: parentValues.length + 1 < self.floors, isParent: node.getChildrenLength() > 0,
open: isOpen, open: isOpen,
checked: checked, checked: checked,
halfCheck: half, halfCheck: half,
@ -17613,7 +17594,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
value: nodes[i].value, value: nodes[i].value,
text: nodes[i].text, text: nodes[i].text,
times: 1, times: 1,
isParent: parentValues.length + 1 < this.floors, isParent: nodes[i].getChildrenLength() > 0,
checked: state[0], checked: state[0],
halfCheck: state[1] halfCheck: state[1]
}) })
@ -17660,14 +17641,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function getCheckState(current, parentValues, valueMap, checkState) { function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half; var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false; var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) { if (BI.has(valueMap, current)) {
//可能是半选 //可能是半选
if (valueMap[current][0] === 1) { if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues); var values = BI.clone(parentValues);
values.push(current); values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) { var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true; halfCheck = true;
} }
} else if (valueMap[current][0] === 2) { } else if (valueMap[current][0] === 2) {

35
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -16,16 +16,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree(); this.tree = new BI.Tree();
this.tree.initTree(nodes); this.tree.initTree(nodes);
this._initFloors();
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
}, },
_itemsCreator: function (options, callback) { _itemsCreator: function (options, callback) {
@ -69,23 +59,20 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
return; return;
} }
doCheck(0, [], this.tree.getRoot(), selectedValues); doCheck([], this.tree.getRoot(), selectedValues);
callback({ callback({
items: result items: result
}); });
function doCheck(floor, parentValues, node, selected) { function doCheck(parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
if (selected == null || BI.isEmpty(selected)) { if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) { BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(child.value); newParents.push(child.value);
var llen = self._getChildCount(newParents); var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen); createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {}); doCheck(newParents, child, {});
}); });
return; return;
} }
@ -94,7 +81,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(node.value); newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents)); createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]); doCheck(newParents, node, selected[k]);
}) })
} }
@ -184,9 +171,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
if (self._isMatch(current, keyword)) { if (self._isMatch(current, keyword)) {
return true; return true;
} }
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -322,9 +306,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked]; return [true, checked];
} }
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues); var newParents = BI.clone(parentValues);
newParents.push(current); newParents.push(current);
var children = self._getChildren(newParents); var children = self._getChildren(newParents);
@ -356,7 +337,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
text: node.text, text: node.text,
value: node.value, value: node.value,
title: node.title, title: node.title,
isParent: parentValues.length + 1 < self.floors, isParent: node.getChildrenLength() > 0,
open: isOpen, open: isOpen,
checked: checked, checked: checked,
halfCheck: half, halfCheck: half,
@ -440,7 +421,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
value: nodes[i].value, value: nodes[i].value,
text: nodes[i].text, text: nodes[i].text,
times: 1, times: 1,
isParent: parentValues.length + 1 < this.floors, isParent: nodes[i].getChildrenLength() > 0,
checked: state[0], checked: state[0],
halfCheck: state[1] halfCheck: state[1]
}) })
@ -487,14 +468,14 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
function getCheckState(current, parentValues, valueMap, checkState) { function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half; var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false; var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) { if (BI.has(valueMap, current)) {
//可能是半选 //可能是半选
if (valueMap[current][0] === 1) { if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues); var values = BI.clone(parentValues);
values.push(current); values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) { var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true; halfCheck = true;
} }
} else if (valueMap[current][0] === 2) { } else if (valueMap[current][0] === 2) {

Loading…
Cancel
Save