|
|
@ -51,12 +51,12 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
some(this.items, (i, item) => { |
|
|
|
some(this.items, (i, item) => { |
|
|
|
if (item.value === v || `${item.value}` === v) { |
|
|
|
if (item.value === v || `${item.value}` === v) { |
|
|
|
text = item.text; |
|
|
|
text = item.text; |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return text; |
|
|
|
return text; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -104,7 +104,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
callback({}); |
|
|
|
callback({}); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -128,7 +128,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
createOneJson(child, node.id, llen); |
|
|
|
createOneJson(child, node.id, llen); |
|
|
|
doCheck(newParents, child, {}); |
|
|
|
doCheck(newParents, child, {}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
each(selected, k => { |
|
|
|
each(selected, k => { |
|
|
@ -181,7 +181,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
callback({}); |
|
|
|
callback({}); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -300,7 +300,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
newParents.push(current); |
|
|
|
newParents.push(current); |
|
|
|
if (this._isMatch(parents, current, keyword)) { |
|
|
|
if (this._isMatch(parents, current, keyword)) { |
|
|
|
searched && searched.push(newParents); |
|
|
|
searched && searched.push(newParents); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -323,7 +323,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
result.push(next); |
|
|
|
result.push(next); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return can; |
|
|
|
return can; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -333,7 +333,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -346,7 +346,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -362,7 +362,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -372,20 +372,14 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
const selectedValues = op.selectedValues; |
|
|
|
const selectedValues = op.selectedValues; |
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
if (selectedValues == null || isEmpty(selectedValues)) { |
|
|
|
callback({}); |
|
|
|
callback({}); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
each(selectedValues, (k, v) => { |
|
|
|
each(selectedValues, (k, v) => { |
|
|
|
result.push([k]); |
|
|
|
result.push([k]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
dealWithSelectedValues(selectedValues, []); |
|
|
|
const isAllSelected = (selected, parents) => isEmpty(selected) || this._getChildCount(parents) === size(selected); |
|
|
|
|
|
|
|
|
|
|
|
const jo = {}; |
|
|
|
|
|
|
|
each(result, (i, strs) => { |
|
|
|
|
|
|
|
this._buildTree(jo, strs); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
callback(jo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dealWithSelectedValues(selected, parents) { |
|
|
|
function dealWithSelectedValues(selected, parents) { |
|
|
|
if (selected == null || isEmpty(selected)) { |
|
|
|
if (selected == null || isEmpty(selected)) { |
|
|
@ -404,11 +398,19 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
can = false; |
|
|
|
can = false; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return can && isAllSelected(selected, parents); |
|
|
|
return can && isAllSelected(selected, parents); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isAllSelected = (selected, parents) => isEmpty(selected) || this._getChildCount(parents) === size(selected); |
|
|
|
dealWithSelectedValues(selectedValues, []); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const jo = {}; |
|
|
|
|
|
|
|
each(result, (i, strs) => { |
|
|
|
|
|
|
|
this._buildTree(jo, strs); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
callback(jo); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_reqInitTreeNode(op, callback) { |
|
|
|
_reqInitTreeNode(op, callback) { |
|
|
@ -461,15 +463,15 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
return find.find.length > 0 || find.match.length > 0; |
|
|
|
return find.find.length > 0 || find.match.length > 0; |
|
|
|
}), |
|
|
|
}), |
|
|
|
result |
|
|
|
result |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return output; |
|
|
|
return output; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function nodeSearch(deep, parentValues, current, isAllSelect, result) { |
|
|
|
function nodeSearch(deep, parentValues, current, isAllSelect, result) { |
|
|
|
if (self._isMatch(parentValues, current, keyword)) { |
|
|
|
if (self._isMatch(parentValues, current, keyword)) { |
|
|
@ -483,7 +485,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
true, |
|
|
|
true, |
|
|
|
result |
|
|
|
result |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return [true, checked]; |
|
|
|
return [true, checked]; |
|
|
|
} |
|
|
|
} |
|
|
|
const newParents = clone(parentValues); |
|
|
|
const newParents = clone(parentValues); |
|
|
@ -510,9 +512,9 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
checked = isCurAllSelected || (isSelected(parentValues, current) && checked); |
|
|
|
checked = isCurAllSelected || (isSelected(parentValues, current) && checked); |
|
|
|
createOneJson(parentValues, current, true, checked, false, false, result); |
|
|
|
createOneJson(parentValues, current, true, checked, false, false, result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return [can, checked]; |
|
|
|
return [can, checked]; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { |
|
|
|
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) { |
|
|
|
const node = self._getTreeNode(parentValues, value); |
|
|
|
const node = self._getTreeNode(parentValues, value); |
|
|
@ -529,14 +531,14 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
flag, |
|
|
|
flag, |
|
|
|
disabled: node.disabled, |
|
|
|
disabled: node.disabled, |
|
|
|
}); |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isHalf(parentValues, value) { |
|
|
|
function isHalf(parentValues, value) { |
|
|
|
const find = findSelectedObj(parentValues); |
|
|
|
const find = findSelectedObj(parentValues); |
|
|
|
if (find == null) { |
|
|
|
if (find == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return any(find, (v, ob) => { |
|
|
|
return any(find, (v, ob) => { |
|
|
|
if (v === value) { |
|
|
|
if (v === value) { |
|
|
|
if (ob != null && !isEmpty(ob)) { |
|
|
|
if (ob != null && !isEmpty(ob)) { |
|
|
@ -551,7 +553,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
if (find == null) { |
|
|
|
if (find == null) { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return any(find, (v, ob) => { |
|
|
|
return any(find, (v, ob) => { |
|
|
|
if (v === value) { |
|
|
|
if (v === value) { |
|
|
|
if (ob != null && isEmpty(ob)) { |
|
|
|
if (ob != null && isEmpty(ob)) { |
|
|
@ -566,7 +568,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
if (find == null) { |
|
|
|
if (find == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return any(find, v => { |
|
|
|
return any(find, v => { |
|
|
|
if (v === value) { |
|
|
|
if (v === value) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -584,10 +586,10 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
if (find == null) { |
|
|
|
if (find == null) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return find; |
|
|
|
return find; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -626,7 +628,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
// 不是上面那种情况就先看在节点没有带有明确半选的时候,通过节点自身的checked和valueMap的状态能都得到选中信息
|
|
|
|
// 不是上面那种情况就先看在节点没有带有明确半选的时候,通过节点自身的checked和valueMap的状态能都得到选中信息
|
|
|
|
check = ((tempCheck || checked) && !half) || has(valueMap, current); |
|
|
|
check = ((tempCheck || checked) && !half) || has(valueMap, current); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return [check, halfCheck]; |
|
|
|
return [check, halfCheck]; |
|
|
|
}; |
|
|
|
}; |
|
|
|
const getResult = (parentValues, checkState) => { |
|
|
|
const getResult = (parentValues, checkState) => { |
|
|
@ -636,33 +638,33 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
if (isEmpty(selected)) { |
|
|
|
if (isEmpty(selected)) { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this._getChildCount(parents) !== size(selected)) { |
|
|
|
if (this._getChildCount(parents) !== size(selected)) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return every(selected, value => isAllSelected(selected[value], concat(parents, value))); |
|
|
|
return every(selected, value => isAllSelected(selected[value], concat(parents, value))); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
function dealWithSelectedValue(parentValues, selectedValues) { |
|
|
|
function dealWithSelectedValue(parentValues, selectedValues) { |
|
|
|
const valueMap = {}, |
|
|
|
const valueMap = {}, |
|
|
|
parents = (parentValues || []).slice(0); |
|
|
|
parents = (parentValues || []).slice(0); |
|
|
|
each(parentValues, (i, v) => { |
|
|
|
each(parentValues, (i, v) => { |
|
|
|
parents.push(v); |
|
|
|
parents.push(v); |
|
|
|
|
|
|
|
|
|
|
|
selectedValues = selectedValues[v] || {}; |
|
|
|
selectedValues = selectedValues[v] || {}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
each(selectedValues, (value, obj) => { |
|
|
|
each(selectedValues, (value, obj) => { |
|
|
|
const currentParents = concat(parents, value); |
|
|
|
const currentParents = concat(parents, value); |
|
|
|
|
|
|
|
|
|
|
|
if (isNull(obj)) { |
|
|
|
if (isNull(obj)) { |
|
|
|
valueMap[value] = [0, 0]; |
|
|
|
valueMap[value] = [0, 0]; |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (isEmpty(obj)) { |
|
|
|
if (isEmpty(obj)) { |
|
|
|
valueMap[value] = [2, 0]; |
|
|
|
valueMap[value] = [2, 0]; |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const nextNames = {}; |
|
|
|
const nextNames = {}; |
|
|
@ -676,7 +678,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
// valueMap的数组第一个参数为不选: 0, 半选: 1, 全选:2, 第二个参数为改节点下选中的子节点个数(子节点全选或者不存在)
|
|
|
|
// valueMap的数组第一个参数为不选: 0, 半选: 1, 全选:2, 第二个参数为改节点下选中的子节点个数(子节点全选或者不存在)
|
|
|
|
valueMap[value] = [1, size(nextNames)]; |
|
|
|
valueMap[value] = [1, size(nextNames)]; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return valueMap; |
|
|
|
return valueMap; |
|
|
|
} |
|
|
|
} |
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
|
valueMap = dealWithSelectedValue(parentValues, selectedValues); |
|
|
@ -773,7 +775,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
|
|
|
|
|
|
|
|
_getAddedValueNode(parentValues, selectedValues) { |
|
|
|
_getAddedValueNode(parentValues, selectedValues) { |
|
|
|
const nodes = this._getChildren(parentValues); |
|
|
|
const nodes = this._getChildren(parentValues); |
|
|
|
|
|
|
|
|
|
|
|
return map(difference(keys(selectedValues), map(nodes, "value")), (idx, v) => { |
|
|
|
return map(difference(keys(selectedValues), map(nodes, "value")), (idx, v) => { |
|
|
|
return { |
|
|
|
return { |
|
|
|
id: UUID(), |
|
|
|
id: UUID(), |
|
|
@ -796,7 +798,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
} |
|
|
|
} |
|
|
|
pNode = pNode[parentValues[i]]; |
|
|
|
pNode = pNode[parentValues[i]]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return pNode; |
|
|
|
return pNode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -837,12 +839,12 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
const find = Func.getSearchResult([node.text || node.value], keyword); |
|
|
|
const find = Func.getSearchResult([node.text || node.value], keyword); |
|
|
|
if (o.allowSearchValue && node.value) { |
|
|
|
if (o.allowSearchValue && node.value) { |
|
|
|
const valueFind = Func.getSearchResult([node.value], keyword); |
|
|
|
const valueFind = Func.getSearchResult([node.value], keyword); |
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
valueFind.find.length > 0 || valueFind.match.length > 0 || find.find.length > 0 || find.match.length > 0 |
|
|
|
valueFind.find.length > 0 || valueFind.match.length > 0 || find.find.length > 0 || find.match.length > 0 |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return find.find.length > 0 || find.match.length > 0; |
|
|
|
return find.find.length > 0 || find.match.length > 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -919,7 +921,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
queue = queue.concat(childNodes); |
|
|
|
queue = queue.concat(childNodes); |
|
|
|
nodes = nodes.concat(childNodes); |
|
|
|
nodes = nodes.concat(childNodes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return nodes; |
|
|
|
return nodes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -972,7 +974,7 @@ export class AbstractTreeValueChooser extends Widget { |
|
|
|
r[child.value] = {}; |
|
|
|
r[child.value] = {}; |
|
|
|
fill(newParents, child, null, r[child.value]); |
|
|
|
fill(newParents, child, null, r[child.value]); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
each(selected, k => { |
|
|
|
each(selected, k => { |
|
|
|