|
|
|
@ -413,6 +413,7 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
|
|
|
|
|
_reqInitTreeNode(op, callback) { |
|
|
|
|
let result = []; |
|
|
|
|
const self = this; |
|
|
|
|
const keyword = op.keyword || ""; |
|
|
|
|
const selectedValues = op.selectedValues; |
|
|
|
|
const lastSearchValue = op.lastSearchValue || ""; // 一次请求100个,但是搜索是拿全部的,lastSearchValue是上一次遍历到的节点索引
|
|
|
|
@ -425,8 +426,8 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const search = () => { |
|
|
|
|
const children = this._getChildren([]); |
|
|
|
|
function search(){ |
|
|
|
|
const children = self._getChildren([]); |
|
|
|
|
let start = children.length; |
|
|
|
|
if (lastSearchValue !== "") { |
|
|
|
|
for (let j = 0, len = start; j < len; j++) { |
|
|
|
@ -441,22 +442,22 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
const output = []; |
|
|
|
|
for (let i = start, len = children.length; i < len; i++) { |
|
|
|
|
let find; |
|
|
|
|
if (output.length < this._const.perPage) { |
|
|
|
|
if (output.length < self._const.perPage) { |
|
|
|
|
find = nodeSearch(1, [], children[i].value, false, result); |
|
|
|
|
} else if (output.length === this._const.perPage) { |
|
|
|
|
} else if (output.length === self._const.perPage) { |
|
|
|
|
find = nodeSearch(1, [], children[i].value, false, []); |
|
|
|
|
} |
|
|
|
|
if (find[0] === true) { |
|
|
|
|
output.push(children[i].value); |
|
|
|
|
} |
|
|
|
|
if (output.length > this._const.perPage) { |
|
|
|
|
if (output.length > self._const.perPage) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 深层嵌套的比较麻烦,这边先实现的是在根节点添加
|
|
|
|
|
if (op.times === 1) { |
|
|
|
|
const nodes = this._getAddedValueNode([], selectedValues); |
|
|
|
|
const nodes = self._getAddedValueNode([], selectedValues); |
|
|
|
|
result = concat( |
|
|
|
|
filter(nodes, (idx, node) => { |
|
|
|
|
const find = Func.getSearchResult([node.text || node.value], keyword); |
|
|
|
@ -470,8 +471,8 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
return output; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const nodeSearch = (deep, parentValues, current, isAllSelect, result) => { |
|
|
|
|
if (this._isMatch(parentValues, current, keyword)) { |
|
|
|
|
function nodeSearch(deep, parentValues, current, isAllSelect, result) { |
|
|
|
|
if (self._isMatch(parentValues, current, keyword)) { |
|
|
|
|
const checked = isAllSelect || isSelected(parentValues, current); |
|
|
|
|
createOneJson( |
|
|
|
|
parentValues, |
|
|
|
@ -487,7 +488,7 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
} |
|
|
|
|
const newParents = clone(parentValues); |
|
|
|
|
newParents.push(current); |
|
|
|
|
const children = this._getChildren(newParents); |
|
|
|
|
const children = self._getChildren(newParents); |
|
|
|
|
|
|
|
|
|
let can = false, |
|
|
|
|
checked = false; |
|
|
|
@ -513,8 +514,8 @@ export class AbstractTreeValueChooser extends Widget {
|
|
|
|
|
return [can, checked]; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const createOneJson = (parentValues, value, isOpen, checked, half, flag, result) => { |
|
|
|
|
const node = this._getTreeNode(parentValues, value); |
|
|
|
|
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { |
|
|
|
|
const node = self._getTreeNode(parentValues, value); |
|
|
|
|
result.push({ |
|
|
|
|
id: node.id, |
|
|
|
|
pId: node.pId, |
|
|
|
|