From 344b3c188b059bc857cc594c75ef5527d8a7aeaf Mon Sep 17 00:00:00 2001
From: yinbangzhong <zhongbangyin@126.com>
Date: 星期六, 17 八月 2024 20:42:59 +0800
Subject: [PATCH] 添加校验
---
src/views/authority/role/index.vue | 48 +++++++++++++++++++++++++++++++++++++++---------
src/views/authority/users/index.vue | 5 -----
src/views/authority/organization/index.vue | 2 +-
src/views/authority/resource/index.vue | 3 ++-
4 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/src/views/authority/organization/index.vue b/src/views/authority/organization/index.vue
index 65ae930..72e93f8 100644
--- a/src/views/authority/organization/index.vue
+++ b/src/views/authority/organization/index.vue
@@ -7,7 +7,7 @@
<a-card
:title="$t('menu.organization.title')"
:bordered="false"
- style=" 'width': '100%'; height: calc(100vh - 250px);; 'overflow-y': 'auto' "
+ style=" 'width': '100%'; height: calc(100vh - 250px); overflow-y:auto "
>
<a-tree
class="tree-demo"
diff --git a/src/views/authority/resource/index.vue b/src/views/authority/resource/index.vue
index cd23097..7c94293 100644
--- a/src/views/authority/resource/index.vue
+++ b/src/views/authority/resource/index.vue
@@ -6,12 +6,13 @@
<a-card
:title="$t('menu.resource.title')"
:bordered="false"
- style=" 'width': '100%'; height: calc(100vh - 250px); 'overflow-y': 'auto' "
+ style=" 'width': '100%'; height: calc(100vh - 250px); overflow-y:auto "
>
<a-tree
class="tree-demo"
draggable
blockNode
+ :default-expand-all=true
:data="treeData"
:show-line="showLine"
:fieldNames="{
diff --git a/src/views/authority/role/index.vue b/src/views/authority/role/index.vue
index 48ceba2..ab8fd8a 100644
--- a/src/views/authority/role/index.vue
+++ b/src/views/authority/role/index.vue
@@ -148,7 +148,6 @@
title: 'menuName',
children: 'children',
}"
- :check-strictly="checkStrictlyMenu"
>
</a-tree>
</a-tab-pane>
@@ -214,7 +213,7 @@
'margin': '1px',
}"
class="card-demo"
- title="鐢ㄦ埛鎵�鏈夋潈闄�"
+ title="瑙掕壊鎵�鏈夋潈闄�"
hoverable
>
<a-space wrap>
@@ -336,18 +335,51 @@
let resourcevisible = ref(false);
let selectRole = ref({});
+
+ const eachChildrenAdd=(node)=>{
+ if (node.children?.length > 0) {
+ node.children.forEach((child) => {
+ checkStrictlyMenu.value.push({ menuId: child.menuId, menuName: child.menuName });
+ eachChildrenAdd(child);
+ });
+ }
+ }
+
+ const findChild = (node, val): boolean => {
+ let isExist = false;
+ if (node.children?.length > 0) {
+ node.children.forEach((child) => {
+ if (val.menuId == child.menuId) {
+ isExist = isExist || true;
+ } else {
+ isExist = isExist || findChild(child, val);
+ }
+ });
+ }
+ return isExist;
+ };
+
const onCheckMenu = (newCheckedKeys, event) => {
let o = { menuId: event.node.menuId, menuName: event.node.menuName };
if (event.checked) {
checkStrictlyMenu.value.push(o);
+ eachChildrenAdd(event.node);
+ if (event.halfCheckedNodes?.length > 0) {
+ event.halfCheckedNodes.forEach((child) => {
+ let e = { menuId: child.menuId, menuName: child.menuName };
+ if (checkStrictlyMenu.value.find((item) => item.menuId === e.menuId) == undefined) {
+ checkStrictlyMenu.value.push(e);
+ }
+ });
+ }
} else {
+ let menus=[];
checkStrictlyMenu.value.forEach((val, idx, array) => {
- // val: 褰撳墠鍊�
- if (val.menuId == event.node.menuId) {
- checkStrictlyMenu.value.splice(idx, 1);
- return true;
+ if (val.menuId != event.node.menuId && !findChild(event.node, val)) {
+ menus.push({ menuId: val.menuId, menuName: val.menuName });
}
});
+ checkStrictlyMenu.value = menus;
}
};
const onCheckKnowledge = (newCheckedKeys, event) => {
@@ -402,9 +434,7 @@
}
};
- const handleRemove = (key) => {
- checkStrictly.value = checkStrictly.value.filter((tag) => tag !== key);
- };
+
const handleMenuRemove = (key) => {
checkStrictlyMenu.value = checkStrictlyMenu.value.filter(
(tag) => tag !== key
diff --git a/src/views/authority/users/index.vue b/src/views/authority/users/index.vue
index b62cead..d6110cc 100644
--- a/src/views/authority/users/index.vue
+++ b/src/views/authority/users/index.vue
@@ -195,7 +195,6 @@
title: 'deptName',
children: 'children',
}"
- :check-strictly="checkStrictly"
>
</a-tree>
</a-card>
@@ -238,7 +237,6 @@
<a-tag
v-for="(tag, index) of checkStrictlyMenu"
:key="tag.menuId"
- @close="handleMenuRemove(tag)"
>
{{ tag.menuName }}
</a-tag>
@@ -249,7 +247,6 @@
<a-tag
v-for="(tag, index) of checkStrictlyKnowledge"
:key="tag.knowledgeId"
- @close="handleKnowledgeRemove(tag)"
>
{{ tag.knowledgeName }}
</a-tag>
@@ -260,14 +257,12 @@
<a-tag
v-for="(tag, index) of checkStrictlyDialog"
:key="tag.dialogId"
- @close="handleDialogRemove(tag)"
>
{{ tag.dialogName }}
</a-tag>
<a-tag
v-for="(tag, index) of checkStrictlyAgent"
:key="tag.agentId"
- @close="handleDialogRemove(tag)"
>
{{ tag.agentName }}
</a-tag>
--
Gitblit v1.8.0