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