修改非严格模式下设置父节点, 子节点受影响

This commit is contained in:
maplemei 2020-12-04 15:28:25 +08:00
parent 4c9baac4b3
commit 16de57e340
4 changed files with 5 additions and 12 deletions

2
dist/static/2.js vendored

File diff suppressed because one or more lines are too long

2
dist/xm-select.js vendored

File diff suppressed because one or more lines are too long

View File

@ -20,7 +20,6 @@ var demo1 = xmSelect.render({
clickCheck: false, clickCheck: false,
strict: false strict: false
}, },
radio: true,
toolbar: { toolbar: {
show: true, show: true,
list: ['ALL', 'REVERSE', 'CLEAR'] list: ['ALL', 'REVERSE', 'CLEAR']
@ -34,7 +33,7 @@ var demo1 = xmSelect.render({
{name: '李四1', value: 2, selected: true}, {name: '李四1', value: 2, selected: true},
{name: '王五1', value: 3, disabled: true}, {name: '王五1', value: 3, disabled: true},
]}, ]},
{name: '奖品', value: -2, children: [ {name: '奖品', value: -2, disabled: true, children: [
{name: '奖品3', value: -3, children: [ {name: '奖品3', value: -3, children: [
{name: '苹果3', value: 14, selected: true}, {name: '苹果3', value: 14, selected: true},
{name: '香蕉3', value: 15}, {name: '香蕉3', value: 15},
@ -46,12 +45,6 @@ var demo1 = xmSelect.render({
]}, ]},
] ]
}, },
iconfont: {
select: '',
unselect: '',
half: '',
parent: 'hidden',
},
}) })
</script> </script>

View File

@ -64,7 +64,7 @@ class Framework extends Component{
item[disabled] = !enable item[disabled] = !enable
//严格模式下操作 //严格模式下操作
if(tree.strict || cascader.strict){ if(tree.show && tree.strict || cascader.show && cascader.strict){
if(enable){//启用父节点, 向上父节点启用 if(enable){//启用父节点, 向上父节点启用
let parent = item let parent = item
while(parent){ while(parent){
@ -171,7 +171,7 @@ class Framework extends Component{
//是否包含子节点 //是否包含子节点
item[optgroup] = true; item[optgroup] = true;
//严格的父子结构 //严格的父子结构
if(tree.strict || cascader.strict){ if(tree.show && tree.strict || cascader.show && cascader.strict){
if(item[selected] === true){ if(item[selected] === true){
delete item[selected] delete item[selected]
child.forEach(c => c[selected] = true) child.forEach(c => c[selected] = true)