Merge branch 'main' of http://61.139.16.27:26684/zy_oyj/sgxt_web
This commit is contained in:
@ -52,31 +52,19 @@ const routes = computed(() => {
|
|||||||
const fRoutes = filterRoutes(router.getRoutes());
|
const fRoutes = filterRoutes(router.getRoutes());
|
||||||
const data = fRoutes.filter((item) => !EXCLUDE_NAMES.includes(item.name));
|
const data = fRoutes.filter((item) => !EXCLUDE_NAMES.includes(item.name));
|
||||||
const menusPermission = getItem("menusPermission");
|
const menusPermission = getItem("menusPermission");
|
||||||
console.log(JSON.parse(localStorage.getItem("menusPermission")));
|
// 如果 menusPermission 为 null 或 undefined,不显示菜单
|
||||||
console.log(
|
if (menusPermission === null || menusPermission === undefined) {
|
||||||
router.getRoutes().map((r) => ({ name: r.name, path: r.path })),
|
return [];
|
||||||
"xxx"
|
}
|
||||||
);
|
|
||||||
// menusPermission 里存的 name
|
|
||||||
router
|
|
||||||
.getRoutes()
|
|
||||||
.filter((r) => r.path === "/")
|
|
||||||
.map((r) => ({
|
|
||||||
name: r.name,
|
|
||||||
path: r.path,
|
|
||||||
children: r.children?.map((c) => ({ name: c.name, path: c.path }))
|
|
||||||
}));
|
|
||||||
console.log(JSON.parse(localStorage.getItem("menusPermission")));
|
|
||||||
const menusSet = new Set(
|
const menusSet = new Set(
|
||||||
Array.isArray(menusPermission)
|
Array.isArray(menusPermission)
|
||||||
? menusPermission.map((item) => `${item}`)
|
? menusPermission.map((item) => `${item}`)
|
||||||
: []
|
: []
|
||||||
);
|
);
|
||||||
console.log(menusSet);
|
|
||||||
|
|
||||||
const permissionFiltered = menusSet.size
|
const permissionFiltered = menusSet.size
|
||||||
? filterRoutesByMenusPermission(data, menusSet)
|
? filterRoutesByMenusPermission(data, menusSet)
|
||||||
: data;
|
: [];
|
||||||
return generateMenus(permissionFiltered);
|
return generateMenus(permissionFiltered);
|
||||||
});
|
});
|
||||||
if (!store.getters.token) {
|
if (!store.getters.token) {
|
||||||
|
|||||||
@ -434,15 +434,7 @@ export const publicRoutes = [
|
|||||||
icon: "article-create"
|
icon: "article-create"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// path: "/InformationReporting",
|
|
||||||
// name: "InformationReporting",
|
|
||||||
// component: () => import("@/views/backOfficeSystem/InformationReporting/index.vue"),
|
|
||||||
// meta: {
|
|
||||||
// title: "蜂群信息",
|
|
||||||
// icon: "article-create"
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// {
|
// {
|
||||||
// path: "/MakeAcomment",
|
// path: "/MakeAcomment",
|
||||||
// name: "MakeAcomment",
|
// name: "MakeAcomment",
|
||||||
@ -492,6 +484,14 @@ export const publicRoutes = [
|
|||||||
title: "线索发布",
|
title: "线索发布",
|
||||||
icon: "article"
|
icon: "article"
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
path: "/InformationReporting",
|
||||||
|
name: "InformationReporting",
|
||||||
|
component: () => import("@/views/backOfficeSystem/InformationReporting/index.vue"),
|
||||||
|
meta: {
|
||||||
|
title: "蜂群信息",
|
||||||
|
icon: "article-create"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// path: "/InformationFlows",
|
// path: "/InformationFlows",
|
||||||
|
|||||||
@ -15,8 +15,7 @@
|
|||||||
node-key="id"
|
node-key="id"
|
||||||
show-checkbox
|
show-checkbox
|
||||||
default-expand-all
|
default-expand-all
|
||||||
:check-strictly="false"
|
:check-strictly="checkStrictly"
|
||||||
@check="handleCheck"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
@ -31,7 +30,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { defineProps, watch, ref } from "vue";
|
import { defineProps, watch, ref, nextTick } from "vue";
|
||||||
import {
|
import {
|
||||||
saveRoleMenuInfo,
|
saveRoleMenuInfo,
|
||||||
getRoleMenuIds,
|
getRoleMenuIds,
|
||||||
@ -53,17 +52,37 @@ const closed = () => {
|
|||||||
emits("update:modelValue", false);
|
emits("update:modelValue", false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 实时记录选中状态
|
// 控制父子关联:操作时关联,回显时不关联
|
||||||
const currentCheckedKeys = ref([]);
|
const checkStrictly = ref(false);
|
||||||
const currentHalfCheckedKeys = ref([]);
|
|
||||||
|
|
||||||
// 勾选事件,实时记录完全选中 + 半选父节点
|
// 递归收集所有子节点id
|
||||||
const handleCheck = (data, checkInfo) => {
|
const getAllChildKeys = (node) => {
|
||||||
currentCheckedKeys.value = checkInfo.checkedKeys;
|
let keys = [];
|
||||||
currentHalfCheckedKeys.value = checkInfo.halfCheckedKeys;
|
if (node.sysMenuList && node.sysMenuList.length) {
|
||||||
|
node.sysMenuList.forEach((child) => {
|
||||||
|
keys.push(child.id);
|
||||||
|
keys = keys.concat(getAllChildKeys(child));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 提交时合并完全选中 + 半选父节点
|
// 递归收集所有祖先节点id
|
||||||
|
const getAllParentKeys = (nodeId, tree, parentKeys = []) => {
|
||||||
|
for (const node of tree) {
|
||||||
|
if (node.id === nodeId) return parentKeys;
|
||||||
|
if (node.sysMenuList && node.sysMenuList.length) {
|
||||||
|
const result = getAllParentKeys(nodeId, node.sysMenuList, [
|
||||||
|
...parentKeys,
|
||||||
|
node.id
|
||||||
|
]);
|
||||||
|
if (result) return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交:选中的节点 + 所有祖先节点都传给后端
|
||||||
const onComfirm = () => {
|
const onComfirm = () => {
|
||||||
const checkedKeys = treeRef.value.getCheckedKeys();
|
const checkedKeys = treeRef.value.getCheckedKeys();
|
||||||
const halfCheckedKeys = treeRef.value.getHalfCheckedKeys();
|
const halfCheckedKeys = treeRef.value.getHalfCheckedKeys();
|
||||||
@ -85,7 +104,6 @@ const getPermissionList = async () => {
|
|||||||
const res = await getMenuTree({ ssxt: "sgxt" });
|
const res = await getMenuTree({ ssxt: "sgxt" });
|
||||||
allPermission.value = res;
|
allPermission.value = res;
|
||||||
};
|
};
|
||||||
getPermissionList();
|
|
||||||
|
|
||||||
const treeRef = ref(null);
|
const treeRef = ref(null);
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
@ -93,22 +111,27 @@ const defaultProps = {
|
|||||||
label: "menuName"
|
label: "menuName"
|
||||||
};
|
};
|
||||||
|
|
||||||
//当前角色权限回显
|
// 回显:严格模式下只选中后端返回的节点,不自动关联父子
|
||||||
const getRolePermission = async () => {
|
const getRolePermission = async () => {
|
||||||
const checkedKeys = await getRoleMenuIds(props.roleId);
|
const checkedKeys = await getRoleMenuIds(props.roleId);
|
||||||
treeRef.value.setCheckedKeys(checkedKeys);
|
// 严格模式:回显时父子不关联,只选中返回的节点
|
||||||
|
checkStrictly.value = true;
|
||||||
|
await nextTick();
|
||||||
|
treeRef.value?.setCheckedKeys(checkedKeys);
|
||||||
|
// 恢复关联模式,后续用户操作时选中父节点会全选子节点
|
||||||
|
await nextTick();
|
||||||
|
checkStrictly.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.roleId,
|
() => props.modelValue,
|
||||||
(val) => {
|
async (val) => {
|
||||||
if (val) {
|
if (val && props.roleId) {
|
||||||
|
checkStrictly.value = false;
|
||||||
|
treeRef.value?.setCheckedKeys([]);
|
||||||
|
await getPermissionList();
|
||||||
getRolePermission();
|
getRolePermission();
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
immediate: true,
|
|
||||||
deep: true
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -75,7 +75,8 @@ function redirectAuth() {
|
|||||||
const idCardNoLoginLogin = (idCard, orgId) => {
|
const idCardNoLoginLogin = (idCard, orgId) => {
|
||||||
idCardNoLogin({
|
idCardNoLogin({
|
||||||
idCardNo: idCard,
|
idCardNo: idCard,
|
||||||
orgCode: orgId
|
orgCode: orgId,
|
||||||
|
ssxt: "sgxt"
|
||||||
}).then((resIdCard) => {
|
}).then((resIdCard) => {
|
||||||
// 登录成功后设置token和用户信息到store
|
// 登录成功后设置token和用户信息到store
|
||||||
store.commit("user/setToken", resIdCard.jwtToken);
|
store.commit("user/setToken", resIdCard.jwtToken);
|
||||||
|
|||||||
Reference in New Issue
Block a user