|
|
@@ -46,6 +46,7 @@ const lastPeople = ref(false);
|
|
|
const openTree = ref([]);
|
|
|
const backScreen = ref(props.checkUser);
|
|
|
const thisFoler = ref(props.upFolderData);
|
|
|
+const allCheck = ref(true);
|
|
|
const allTreeProps = {
|
|
|
label: "label",
|
|
|
children: "children",
|
|
|
@@ -116,11 +117,30 @@ function antherClose(tag) {
|
|
|
})
|
|
|
treeRef.value.setCheckedKeys(result);
|
|
|
}
|
|
|
-function allTreeChange(e) {
|
|
|
- // console.log('e',e);
|
|
|
+function allTreeChange(e,node,noOne) {
|
|
|
+ // console.log('e',e.disabled);
|
|
|
+ // console.log('e',e.id);
|
|
|
+ if(!noOne){
|
|
|
+ allCheck.value = true
|
|
|
+ }
|
|
|
+ let checkedKeysArr
|
|
|
+ let hasThis
|
|
|
+ if(node){
|
|
|
+ checkedKeysArr = JSON.parse(JSON.stringify(node));
|
|
|
+ // console.log("chooseTagData", checkedKeysArr.checkedKeys?.find(item => item == e.id));
|
|
|
+ if(e.disabled && checkedKeysArr.checkedKeys?.find(item => item == e.id)){ // 判断是全选还是全不选
|
|
|
+ allCheck.value = true
|
|
|
+ }else if(e.disabled && !checkedKeysArr.checkedKeys?.find(item => item == e.id)){
|
|
|
+ allCheck.value = false
|
|
|
+ }
|
|
|
+ // 判断当前是勾选还是取消勾选
|
|
|
+ if(checkedKeysArr.checkedKeys.find(item => item == e.id)){
|
|
|
+ hasThis = true
|
|
|
+ }
|
|
|
+ }
|
|
|
if(e.children){
|
|
|
e.children.forEach(par=>{
|
|
|
- allTreeChange(par)
|
|
|
+ allTreeChange(par,null,true)
|
|
|
})
|
|
|
}
|
|
|
const id = e.id;
|
|
|
@@ -130,16 +150,26 @@ function allTreeChange(e) {
|
|
|
const existingIndex = chooseTagData.value.findIndex(
|
|
|
(item) => item.userId === id
|
|
|
);
|
|
|
+ console.log('allCheck.value',allCheck.value);
|
|
|
if (existingIndex !== -1) {
|
|
|
// 如果已存在,删除该项
|
|
|
chooseTagData.value.splice(existingIndex, 1);
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ if(allCheck.value){
|
|
|
// 选择操作,将数据添加到 needTagData 中
|
|
|
chooseTagData.value.push({
|
|
|
userId: id,
|
|
|
userName: label,
|
|
|
disabled: disabled,
|
|
|
});
|
|
|
+ if(!noOne && !hasThis){
|
|
|
+ const existingIndex = chooseTagData.value.findIndex(
|
|
|
+ (item) => item.userId === id
|
|
|
+ );
|
|
|
+ if (existingIndex !== -1) {
|
|
|
+ chooseTagData.value.splice(existingIndex, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (chooseTagData.value.length === 1) {
|
|
|
lastPeople.value = true;
|
|
|
@@ -148,7 +178,7 @@ function allTreeChange(e) {
|
|
|
}
|
|
|
chooseTagData.value = chooseTagData.value.filter((item) => !item.disabled);
|
|
|
emit("setUsers", toRaw(chooseTagData.value));
|
|
|
- console.log("chooseTagData", chooseTagData.value);
|
|
|
+ // console.log("chooseTagData", chooseTagData.value);
|
|
|
}
|
|
|
// 获取用户树
|
|
|
function getAllUser() {
|