orgChange(itemIndex,everyIndex,e){
console.log(itemIndex,everyIndex,e)
this.$nextTick(()=>{
// console.log(this.$refs[`${itemIndex}cascaderOrgg${everyIndex}`],"节点")
// console.log(this.$refs[`${itemIndex}cascaderOrgg${everyIndex}`][0].getCheckedNodes())
})
let list = this.linkSetting.recordProcessList[this.digit].processStepDetailDtoList[itemIndex].processStepExcuteConditionList[everyIndex].list
let checkResult = this.linkSetting.recordProcessList[this.digit].processStepDetailDtoList[itemIndex].processStepExcuteConditionList[everyIndex].checkResult
const selectedOption = this.getOptionByValue(e[0],list); // 获取当前选中节点对应的选项对象
console.log(selectedOption,"selectedOption")
if (selectedOption && selectedOption.childrenList) {
//如果匹配到了,则禁用节点
console.log("走的第一个")
let fun = (arrList)=>{
arrList.forEach(child => {
this.$set(child,'disabled',true)
if(child.childrenList){
fun(child.childrenList)
}
});
}
fun(selectedOption.childrenList)
}else{
//如果没有匹配到,则取消节点的禁用
console.log("走的第二个")
list.forEach((item,index)=>{
this.$set(item,'disabled',false)
let fun2 = (arr)=>{
arr.forEach((ele,eleIndex)=>{
this.$set(ele,'disabled',false)
if(ele.childrenList){
fun2(ele.childrenList)
}
})
}
if(item.childrenList && item.childrenList.length){
fun2(item.childrenList)
}
})
}
//先选下级再选上级,选了上级之后要删除调上次选的下级
if (this.lastSelectedOption && selectedOption && selectedOption.level < this.lastSelectedOption.level) {
console.log(this.lastSelectedOption,"this.lastSelectedOption")
console.log(selectedOption.level,"selectedOption.level")
console.log(this.lastSelectedOption.level,"this.lastSelectedOption.level")
// 如果当前选中节点的层级比上一次选中节点的层级小,则清空已选中的下级节点
const lastSelectedValue = this.lastSelectedOption.orgId;
const valueIndex = e.indexOf(lastSelectedValue);
console.log(valueIndex,"valueIndex第几个")
console.log(checkResult,"checkResult前")
checkResult =checkResult.splice(valueIndex,1);
console.log(checkResult,"checkResult")
}
this.lastSelectedOption = selectedOption; // 保存当前选中的选项对象
},
// 根据值找到对应的选项对象
getOptionByValue(value,list) {
let targetOption = null;
const findOption = (options) => {
options.some(option => {
if (option.orgId === value) {
targetOption = option;
return true;
}
if (option.childrenList) {
return findOption(option.childrenList);
}
return false;
});
};
findOption(list);
return targetOption;
},
级联选择器--选择了上级就不能选择下级
于 2023-12-05 16:40:14 首次发布