|
@@ -10,11 +10,12 @@ import { t } from '@/i18n';
|
|
|
import {
|
|
|
addCharacter,
|
|
|
addDevicePermissions,
|
|
|
+ addGrantRolePermissions,
|
|
|
deleteCharacter,
|
|
|
getAllGroupList,
|
|
|
getFindRolesByOrgIds,
|
|
|
+ getPermissionCheckTree,
|
|
|
getSubOrgsByToken,
|
|
|
- getSubPermList,
|
|
|
updateCharacter,
|
|
|
} from '@/api';
|
|
|
|
|
@@ -159,7 +160,11 @@ const editorPermission = () => {
|
|
|
editorChecked.value = false;
|
|
|
};
|
|
|
const cancelPermission = () => {
|
|
|
- getDeviceGroupList();
|
|
|
+ if (permissions.value === 'dataPermissions') {
|
|
|
+ getDeviceGroupList();
|
|
|
+ } else {
|
|
|
+ getFunctionPermList();
|
|
|
+ }
|
|
|
editorChecked.value = true;
|
|
|
};
|
|
|
|
|
@@ -179,10 +184,23 @@ const savePermission = () => {
|
|
|
getDeviceGroupList();
|
|
|
});
|
|
|
} else {
|
|
|
- console.log(operationpermissions.value);
|
|
|
- console.log(checkedFatherKeys.value);
|
|
|
- console.log(checkedKeys.value);
|
|
|
- console.log([...new Set([...checkedKeys.value, ...checkedFatherKeys.value])]);
|
|
|
+ let data: number[] = [];
|
|
|
+ operationpermissions.value.forEach((item) => {
|
|
|
+ if (item.list.length) {
|
|
|
+ data = [...new Set([...data, ...item.list])];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ handleRequest(async () => {
|
|
|
+ if (!checkedKeys.value.length) {
|
|
|
+ checkedFatherKeys.value = [];
|
|
|
+ }
|
|
|
+ await addGrantRolePermissions({
|
|
|
+ roleId: characterListId.value,
|
|
|
+ permissionIds: [...new Set([...checkedKeys.value, ...checkedFatherKeys.value, ...data])],
|
|
|
+ });
|
|
|
+ getFunctionPermList();
|
|
|
+ });
|
|
|
}
|
|
|
editorChecked.value = true;
|
|
|
};
|
|
@@ -207,7 +225,15 @@ const getFindRolesByOrg = (id: number) => {
|
|
|
if (!characterListId.value) {
|
|
|
characterListId.value = data[0].id;
|
|
|
getDeviceGroupList();
|
|
|
+ getFunctionPermList();
|
|
|
+ } else {
|
|
|
+ getDeviceGroupList();
|
|
|
+ getFunctionPermList();
|
|
|
}
|
|
|
+ } else {
|
|
|
+ pagePermissionsTree.value = [];
|
|
|
+ treeStructure.value = [];
|
|
|
+ operationpermissions.value = [];
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -260,7 +286,8 @@ const transformData = (data: TreeStructure[]): OperationPermissions[] => {
|
|
|
const transformed = {
|
|
|
value: item.id,
|
|
|
label: item.menuName,
|
|
|
- list: [],
|
|
|
+ list: item.subPermissions?.filter((sub) => sub.checked === 1).map((sub) => sub.id) || [],
|
|
|
+ ...item,
|
|
|
// 保留其他属性(如果需要)
|
|
|
...(item.subPermissions && {
|
|
|
subPermissions: transformData(item.subPermissions),
|
|
@@ -273,12 +300,27 @@ const transformData = (data: TreeStructure[]): OperationPermissions[] => {
|
|
|
|
|
|
const getFunctionPermList = () => {
|
|
|
handleRequest(async () => {
|
|
|
- const data = await getSubPermList(0);
|
|
|
- if (data.length) {
|
|
|
- treeStructure.value = transformTreeData(data[0].subPermissions[0].subPermissions);
|
|
|
- operationpermissions.value = transformData(data[0].subPermissions[1].subPermissions);
|
|
|
- console.log(operationpermissions.value);
|
|
|
- checkedKeys.value = [10601, 10602, 10901, 107, 102, 103, 106, 109];
|
|
|
+ // const data = await getSubPermList(0);
|
|
|
+ const dataCheck = await getPermissionCheckTree(characterListId.value);
|
|
|
+ checkedKeys.value = [];
|
|
|
+ expandedKeys.value = [];
|
|
|
+ if (dataCheck.length) {
|
|
|
+ treeStructure.value = transformTreeData(dataCheck[0].subPermissions[0].subPermissions);
|
|
|
+ operationpermissions.value = transformData(dataCheck[0].subPermissions[1].subPermissions);
|
|
|
+ dataCheck[0].subPermissions[0].subPermissions.forEach((item) => {
|
|
|
+ if (item.subPermissions) {
|
|
|
+ item.subPermissions.forEach((i) => {
|
|
|
+ if (i.checked === 1) {
|
|
|
+ checkedKeys.value.push(i.id);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ expandedKeys.value.push(item.id);
|
|
|
+ } else {
|
|
|
+ if (item.checked === 1) {
|
|
|
+ checkedKeys.value.push(item.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -295,6 +337,8 @@ const selectAll = () => {
|
|
|
const addRadioGroup = () => {
|
|
|
if (permissions.value === 'functionPermissions') {
|
|
|
getDeviceGroupList();
|
|
|
+ } else {
|
|
|
+ getFunctionPermList();
|
|
|
}
|
|
|
editorChecked.value = true;
|
|
|
};
|