feat: 权限逻辑处理
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
const BASE_URL = '/carbon-smart';
|
const BASE_URL = '/carbon-smart';
|
||||||
export enum permission {
|
export enum permission {
|
||||||
add = `${BASE_URL}/admin/permission/save`,
|
add = `${BASE_URL}/admin/permission/save`,
|
||||||
permissionTree = `${BASE_URL}/api/dept/QueryOrgPermission`,
|
queryOrgPermission = `${BASE_URL}/api/dept/queryOrgPermission`,
|
||||||
|
queryRolePermission = `${BASE_URL}/api/dept/queryRolePermission`,
|
||||||
|
queryFilterDeptPermission = `${BASE_URL}/api/dept/queryFilterDeptPermission`,
|
||||||
|
queryDeptPermission = `${BASE_URL}/api/dept/queryDeptPermission`,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum origanizemanage {
|
export enum origanizemanage {
|
||||||
@@ -18,7 +21,7 @@ export enum origanizemanage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum department {
|
export enum department {
|
||||||
dartList = `${BASE_URL}/api/user/queryDeptTree`,
|
queryDeptTree = `${BASE_URL}/api/dept/queryDeptTree`,
|
||||||
deptSave = `${BASE_URL}/api/dept/save`,
|
deptSave = `${BASE_URL}/api/dept/save`,
|
||||||
deptEdit = `${BASE_URL}/api/dept/edit`,
|
deptEdit = `${BASE_URL}/api/dept/edit`,
|
||||||
deptDel = `${BASE_URL}/api/dept/del`,
|
deptDel = `${BASE_URL}/api/dept/del`,
|
||||||
@@ -28,7 +31,4 @@ export enum department {
|
|||||||
addRole = `${BASE_URL}/api/dept/addRole`,
|
addRole = `${BASE_URL}/api/dept/addRole`,
|
||||||
editRole = `${BASE_URL}/api/dept/editRole`,
|
editRole = `${BASE_URL}/api/dept/editRole`,
|
||||||
queryRoleTree = `${BASE_URL}/api/dept/queryRoleTree`,
|
queryRoleTree = `${BASE_URL}/api/dept/queryRoleTree`,
|
||||||
|
|
||||||
queryDeptPermission = `${BASE_URL}/api/dept/queryDeptPermission`,
|
|
||||||
queryRolePermission = `${BASE_URL}/api/dept/queryRolePermission`,
|
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ import { http } from '/nerv-lib/saas';
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import { permission } from '/@/api/origanizemanage';
|
import { permission } from '/@/api/origanizemanage';
|
||||||
|
|
||||||
// const { linkList } = sessionStorage.getItem('userInfo')
|
// const { permissionVos } = sessionStorage.getItem('userInfo');
|
||||||
// ? JSON.parse(sessionStorage.getItem('userInfo')!)
|
// ? JSON.parse(sessionStorage.getItem('userInfo')!)
|
||||||
// : [{}];
|
// : [{}];
|
||||||
// const value = ref(linkList[0]?.orgId);
|
// const value = ref(linkList[0]?.orgId);
|
||||||
@@ -19,7 +19,7 @@ const transform = (data, map) => {
|
|||||||
export const appConfig = {
|
export const appConfig = {
|
||||||
projectType: 'web',
|
projectType: 'web',
|
||||||
baseApi: '/api',
|
baseApi: '/api',
|
||||||
enablePermissions: false,
|
enablePermissions: true,
|
||||||
// themeColor: '#eee',
|
// themeColor: '#eee',
|
||||||
siderPosition: 'left',
|
siderPosition: 'left',
|
||||||
baseHeader: '/parkingManage',
|
baseHeader: '/parkingManage',
|
||||||
@@ -70,9 +70,13 @@ export const appConfig = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
userLoginApi: '/carbon-smart/user/login',
|
userLoginApi: (params) => {
|
||||||
|
return http.post('/carbon-smart/user/login', { ...params });
|
||||||
|
},
|
||||||
userResourceApi: () => {
|
userResourceApi: () => {
|
||||||
return { data: mockResource.menus };
|
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
|
||||||
|
return { data: res.data.permissionVos };
|
||||||
|
});
|
||||||
},
|
},
|
||||||
userInfoApi: () => {
|
userInfoApi: () => {
|
||||||
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
|
return http.post('/carbon-smart/user/login/logInInfo').then((res) => {
|
||||||
@@ -85,9 +89,8 @@ export const appConfig = {
|
|||||||
orgName: 'orgName',
|
orgName: 'orgName',
|
||||||
projectId: 'projectId',
|
projectId: 'projectId',
|
||||||
linkList: 'linkList',
|
linkList: 'linkList',
|
||||||
permissionInfoList: 'permissionInfoList',
|
permissionVos: 'permissionVos',
|
||||||
});
|
});
|
||||||
|
|
||||||
return { data: { ...trD } };
|
return { data: { ...trD } };
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -4,25 +4,24 @@ const home = {
|
|||||||
name: 'home',
|
name: 'home',
|
||||||
meta: { title: '首页', icon: 'dicizhishou', index: 0, hideChildren: true },
|
meta: { title: '首页', icon: 'dicizhishou', index: 0, hideChildren: true },
|
||||||
redirect: { name: 'homeIndex' },
|
redirect: { name: 'homeIndex' },
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'homeModule',
|
|
||||||
name: 'HomeModule',
|
|
||||||
meta: { title: '首页', hideChildren: true, icon: 'dicizhishou' },
|
|
||||||
component: Base,
|
|
||||||
redirect: { name: 'homeIndex' },
|
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'index',
|
path: 'index',
|
||||||
name: 'homeIndex',
|
name: 'homeIndex',
|
||||||
|
meta: { title: '首页', hideChildren: true, icon: 'dicizhishou' },
|
||||||
component: () => import('/@/view/developing.vue'),
|
component: () => import('/@/view/developing.vue'),
|
||||||
meta: {
|
redirect: { name: 'homeIndex' },
|
||||||
title: '首页',
|
// children: [
|
||||||
keepAlive: true,
|
// {
|
||||||
// backApi: [],
|
// path: 'index',
|
||||||
},
|
// name: 'homeIndex',
|
||||||
},
|
// meta: {
|
||||||
],
|
// title: '首页',
|
||||||
|
// keepAlive: true,
|
||||||
|
// // backApi: [],
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
@@ -3,27 +3,8 @@ const organizationManage = {
|
|||||||
path: '/organizationManage',
|
path: '/organizationManage',
|
||||||
name: 'organizationManage',
|
name: 'organizationManage',
|
||||||
meta: { title: '组织管理', icon: 'dicizhishou', index: 99 },
|
meta: { title: '组织管理', icon: 'dicizhishou', index: 99 },
|
||||||
redirect: { name: 'EnterpriseManage' },
|
redirect: { name: 'UserManage' },
|
||||||
children: [
|
children: [
|
||||||
{
|
|
||||||
path: 'enterpriseManage',
|
|
||||||
name: 'EnterpriseManage',
|
|
||||||
meta: { title: '企业管理', hideChildren: true, icon: 'dicizhishou' },
|
|
||||||
component: Base,
|
|
||||||
redirect: { name: 'enterpriseManageIndex' },
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
path: 'index',
|
|
||||||
name: 'enterpriseManageIndex',
|
|
||||||
component: () => import('/@/view/organizationManage/enterpriseManage/index.vue'),
|
|
||||||
meta: {
|
|
||||||
title: '企业管理',
|
|
||||||
keepAlive: true,
|
|
||||||
// backApi: [],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: 'userManage',
|
path: 'userManage',
|
||||||
name: 'UserManage',
|
name: 'UserManage',
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<a-tree
|
<a-tree
|
||||||
v-if="apartmentTreeData?.length"
|
v-if="apartmentTreeData?.length"
|
||||||
:tree-data="apartmentTreeData"
|
:tree-data="apartmentTreeData"
|
||||||
:checkedKeys="['0-0']"
|
v-model:checkedKeys="deptTreeCheckedKeys"
|
||||||
defaultExpandAll
|
defaultExpandAll
|
||||||
@select="SelectApartmentTree">
|
@select="SelectApartmentTree">
|
||||||
<template #title="data">
|
<template #title="data">
|
||||||
@@ -29,8 +29,13 @@
|
|||||||
:model="formData"
|
:model="formData"
|
||||||
formLayout="vertical"
|
formLayout="vertical"
|
||||||
class="form" />
|
class="form" />
|
||||||
|
<!-- <ns-button style="margin: 16px" type="primary" @click="CancelApartment"
|
||||||
|
>取消
|
||||||
|
</ns-button>
|
||||||
|
<ns-button v-show="disabled" type="primary" @click="deptEdit">编辑</ns-button>
|
||||||
|
<ns-button v-show="!disabled" type="primary" @click="ApartmentSure">确定</ns-button> -->
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="2" :disabled="disabled" tab="部门权限">
|
<a-tab-pane key="2" :disabled="!selectKey?.length" tab="部门权限">
|
||||||
<a-tree
|
<a-tree
|
||||||
:tree-data="apartmentAdminTreeData"
|
:tree-data="apartmentAdminTreeData"
|
||||||
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }"
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }"
|
||||||
@@ -38,21 +43,18 @@
|
|||||||
checkable
|
checkable
|
||||||
:selectable="false"
|
:selectable="false"
|
||||||
defaultExpandAll
|
defaultExpandAll
|
||||||
|
@check="deptCheck"
|
||||||
@select="ApartmentSelect">
|
@select="ApartmentSelect">
|
||||||
<template #title="data"> {{ data.label }}</template>
|
<template #title="data"> {{ data.label }}</template>
|
||||||
</a-tree>
|
</a-tree>
|
||||||
|
<ns-button style="margin-left: 16px" type="primary" @click="apartmentPermission"
|
||||||
|
>确定
|
||||||
|
</ns-button>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
<div v-show="activeKey === '1'">
|
|
||||||
<ns-button style="margin: 16px" type="primary" @click="CancelApartment">取消 </ns-button>
|
<ns-button style="margin: 16px" type="primary" @click="CancelApartment">取消 </ns-button>
|
||||||
<ns-button v-show="disabled" type="primary" @click="deptEdit">编辑</ns-button>
|
<ns-button v-show="disabled" type="primary" @click="deptEdit">编辑</ns-button>
|
||||||
<ns-button v-show="!disabled" type="primary" @click="ApartmentSure">确定</ns-button>
|
<ns-button v-show="!disabled" type="primary" @click="ApartmentSure">确定</ns-button>
|
||||||
</div>
|
|
||||||
<div v-show="activeKey === '2'">
|
|
||||||
<ns-button style="margin-left: 16px" type="primary" @click="apartmentPermission"
|
|
||||||
>确定</ns-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,7 +62,13 @@
|
|||||||
<div class="ns-table-title">角色管理</div>
|
<div class="ns-table-title">角色管理</div>
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="12" class="tree">
|
<a-col :span="12" class="tree">
|
||||||
<ns-button style="margin: 10px" type="primary" @click="addUser">新增角色</ns-button>
|
<ns-button
|
||||||
|
:disabled="!selectKey?.length"
|
||||||
|
style="margin: 10px"
|
||||||
|
type="primary"
|
||||||
|
@click="addUser"
|
||||||
|
>新增角色</ns-button
|
||||||
|
>
|
||||||
<ns-button :disabled="disabled2" type="primary" @click="addUserSon">新增子角色</ns-button>
|
<ns-button :disabled="disabled2" type="primary" @click="addUserSon">新增子角色</ns-button>
|
||||||
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="deleteUser"
|
<ns-button :disabled="disabled2" style="margin: 10px" type="primary" @click="deleteUser"
|
||||||
>删除</ns-button
|
>删除</ns-button
|
||||||
@@ -83,31 +91,25 @@
|
|||||||
:model="formData2"
|
:model="formData2"
|
||||||
formLayout="vertical"
|
formLayout="vertical"
|
||||||
class="form" />
|
class="form" />
|
||||||
|
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button>
|
||||||
|
<ns-button v-show="disabled2" type="primary" @click="roleEdit"> 编辑 </ns-button>
|
||||||
|
<ns-button v-show="!disabled2" type="primary" @click="UserSure"> 确定 </ns-button>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
<a-tab-pane key="2" :disabled="disabled2" tab="角色权限">
|
<a-tab-pane key="2" :disabled="!selectKey2?.length" tab="角色权限">
|
||||||
<a-tree
|
<a-tree
|
||||||
v-if="userAdminTreeData?.length"
|
|
||||||
:tree-data="userAdminTreeData"
|
:tree-data="userAdminTreeData"
|
||||||
v-model:checkedKeys="UsercheckedKeys"
|
v-model:checkedKeys="UsercheckedKeys"
|
||||||
defaultExpandAll
|
defaultExpandAll
|
||||||
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }"
|
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }"
|
||||||
:selectable="false"
|
:selectable="false"
|
||||||
checkable
|
checkable
|
||||||
|
@check="roleCheck"
|
||||||
@select="UserSelect" />
|
@select="UserSelect" />
|
||||||
|
<ns-button style="margin: 16px" type="primary" @click="rolePermission">
|
||||||
|
确定
|
||||||
|
</ns-button>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
<div v-show="activeKey2 === '1'">
|
|
||||||
<ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button>
|
|
||||||
<ns-button v-show="disabled2" type="primary" :disabled="disabled2" @click="UserSure">
|
|
||||||
确定</ns-button
|
|
||||||
>
|
|
||||||
<ns-button v-show="!disabled2" type="primary" :disabled="disabled2" @click="UserSure">
|
|
||||||
确定</ns-button
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
<div v-show="activeKey2 === '2'">
|
|
||||||
<ns-button style="margin: 16px" type="primary" @click="rolePermission"> 确定</ns-button>
|
|
||||||
</div>
|
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</div>
|
</div>
|
||||||
@@ -134,6 +136,7 @@
|
|||||||
const activeKey2 = ref('1');
|
const activeKey2 = ref('1');
|
||||||
const disabled = ref(true);
|
const disabled = ref(true);
|
||||||
const disabled2 = ref(true);
|
const disabled2 = ref(true);
|
||||||
|
const deptTreeCheckedKeys = ref(['0-0-0']);
|
||||||
const ApartcheckedKeys = ref<string[]>([]);
|
const ApartcheckedKeys = ref<string[]>([]);
|
||||||
const UsercheckedKeys = ref<string[]>([]);
|
const UsercheckedKeys = ref<string[]>([]);
|
||||||
const selectKey = ref();
|
const selectKey = ref();
|
||||||
@@ -148,9 +151,13 @@
|
|||||||
const apartmentAdminTreeData = ref([]);
|
const apartmentAdminTreeData = ref([]);
|
||||||
const userTreeData = ref([]);
|
const userTreeData = ref([]);
|
||||||
const getPermissionTree = (params) => {
|
const getPermissionTree = (params) => {
|
||||||
return http.post(permission.permissionTree, params).then((res) => {
|
return http.post(permission.queryOrgPermission, params).then((res) => {
|
||||||
apartmentAdminTreeData.value = get(res, 'data.data');
|
apartmentAdminTreeData.value = get(res, 'data');
|
||||||
userAdminTreeData.value = get(res, 'data.data');
|
});
|
||||||
|
};
|
||||||
|
const getRolePermissionTree = (params) => {
|
||||||
|
return http.post(permission.queryFilterDeptPermission, params).then((res) => {
|
||||||
|
userAdminTreeData.value = get(res, 'data');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,16 +172,27 @@
|
|||||||
|
|
||||||
// 部门树
|
// 部门树
|
||||||
const getDepartList = (params) => {
|
const getDepartList = (params) => {
|
||||||
return http.post(department.dartList, params);
|
return http.post(department.queryDeptTree, params).then((res) => {
|
||||||
|
const result = res.data.map((item, index) => {
|
||||||
|
item['deptInfo'] = item.orgInfo;
|
||||||
|
item['deptInfo'] = item.orgInfo;
|
||||||
|
item['deptInfo']['deptName'] = item?.orgInfo?.orgName;
|
||||||
|
item['own'] = !index;
|
||||||
|
item['children'] = item.deptTrees;
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
getDepartList({ orgId }).then((res) => {
|
getDepartList({ orgId }).then((res) => {
|
||||||
apartmentTreeData.value = res.data;
|
apartmentTreeData.value = res;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 获取部门树
|
// 获取部门树
|
||||||
const getTree = () => {
|
const getTree = () => {
|
||||||
getDepartList({ orgId }).then((res) => {
|
getDepartList({ orgId }).then((res) => {
|
||||||
apartmentTreeData.value = res.data;
|
apartmentTreeData.value = res;
|
||||||
NsMessage.success('操作成功');
|
NsMessage.success('操作成功');
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -199,18 +217,19 @@
|
|||||||
callback: null,
|
callback: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
function fetch(api, params) {
|
|
||||||
return http.post(api, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
const addApartment = () => {
|
const addApartment = () => {
|
||||||
disabled.value = false;
|
disabled.value = false;
|
||||||
opMap.type = 'addDept';
|
opMap.type = 'addDept';
|
||||||
formData.value = {};
|
formData.value = {};
|
||||||
|
let sourceOrgId = '';
|
||||||
|
if (!selectRef.value.own) {
|
||||||
|
sourceOrgId = orgId;
|
||||||
|
}
|
||||||
opMap.fuc = (params) => {
|
opMap.fuc = (params) => {
|
||||||
return http.post(department.deptSave, {
|
return http.post(department.deptSave, {
|
||||||
...params,
|
...params,
|
||||||
orgId,
|
orgId: selectRef.value.deptInfo?.orgId,
|
||||||
|
sourceOrgId,
|
||||||
projectId,
|
projectId,
|
||||||
orgName,
|
orgName,
|
||||||
});
|
});
|
||||||
@@ -222,13 +241,22 @@
|
|||||||
disabled.value = false;
|
disabled.value = false;
|
||||||
opMap.type = 'addson';
|
opMap.type = 'addson';
|
||||||
formData.value = {};
|
formData.value = {};
|
||||||
|
let sourceOrgId = '';
|
||||||
|
if (!selectRef.value.own) {
|
||||||
|
sourceOrgId = orgId;
|
||||||
|
}
|
||||||
opMap.fuc = (params) => {
|
opMap.fuc = (params) => {
|
||||||
|
if (!selectRef.value?.deptInfo?.deptId) {
|
||||||
|
NsMessage.warn('请选择部门');
|
||||||
|
return;
|
||||||
|
}
|
||||||
return http.post(department.deptSave, {
|
return http.post(department.deptSave, {
|
||||||
...params,
|
...params,
|
||||||
orgId,
|
orgId,
|
||||||
projectId,
|
projectId,
|
||||||
pdeptId: selectRef.value.deptInfo.deptId,
|
pdeptId: selectRef.value.deptInfo.deptId,
|
||||||
deptName: selectRef.value.deptInfo.deptName,
|
sourceOrgId,
|
||||||
|
// deptName: selectRef.value.deptInfo.deptName,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -311,6 +339,58 @@
|
|||||||
opMap.fuc = '';
|
opMap.fuc = '';
|
||||||
selectKey.value = '';
|
selectKey.value = '';
|
||||||
};
|
};
|
||||||
|
const clearRoleData = () => {
|
||||||
|
selectRef2.value = {};
|
||||||
|
formData2.value = {};
|
||||||
|
opMap.type = '';
|
||||||
|
opMap.fuc = '';
|
||||||
|
selectKey2.value = '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const deptTotalCheckedKeys = ref([]);
|
||||||
|
const roleTotalCheckedKeys = ref([]);
|
||||||
|
// 部门权限选择
|
||||||
|
const deptCheck = (checked, { halfCheckedKeys }) => {
|
||||||
|
console.log(checked, halfCheckedKeys);
|
||||||
|
|
||||||
|
const result = checked.map((item) => {
|
||||||
|
return {
|
||||||
|
halfCheck: false,
|
||||||
|
permissionId: item,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const finalResult = halfCheckedKeys
|
||||||
|
.map((item) => {
|
||||||
|
return {
|
||||||
|
halfCheck: true,
|
||||||
|
permissionId: item,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.concat(result);
|
||||||
|
|
||||||
|
deptTotalCheckedKeys.value = finalResult;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 角色权限选择
|
||||||
|
const roleCheck = (checked, { halfCheckedKeys }) => {
|
||||||
|
console.log(checked, halfCheckedKeys);
|
||||||
|
|
||||||
|
const result = checked.map((item) => {
|
||||||
|
return {
|
||||||
|
halfCheck: false,
|
||||||
|
permissionId: item,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const finalResult = halfCheckedKeys
|
||||||
|
.map((item) => {
|
||||||
|
return {
|
||||||
|
halfCheck: true,
|
||||||
|
permissionId: item,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.concat(result);
|
||||||
|
roleTotalCheckedKeys.value = finalResult;
|
||||||
|
};
|
||||||
|
|
||||||
// 保存部门权限
|
// 保存部门权限
|
||||||
const apartmentPermission = () => {
|
const apartmentPermission = () => {
|
||||||
@@ -318,9 +398,7 @@
|
|||||||
.post(department.addPermission, {
|
.post(department.addPermission, {
|
||||||
deptId: selectRef.value?.deptInfo.deptId,
|
deptId: selectRef.value?.deptInfo.deptId,
|
||||||
projectId,
|
projectId,
|
||||||
permissionVoList: ApartcheckedKeys.value.map((item) => {
|
permissionVoList: deptTotalCheckedKeys.value,
|
||||||
return { permissionId: item };
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
NsMessage.success('保存成功');
|
NsMessage.success('保存成功');
|
||||||
@@ -333,9 +411,7 @@
|
|||||||
// deptId: selectRef.value?.deptInfo.deptId,
|
// deptId: selectRef.value?.deptInfo.deptId,
|
||||||
roleId: selectRef2.value?.roleId,
|
roleId: selectRef2.value?.roleId,
|
||||||
projectId,
|
projectId,
|
||||||
permissionVoList: UsercheckedKeys.value.map((item) => {
|
permissionVoList: roleTotalCheckedKeys.value,
|
||||||
return { permissionId: item };
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
NsMessage.success('保存成功');
|
NsMessage.success('保存成功');
|
||||||
@@ -345,22 +421,28 @@
|
|||||||
// 获取部门拥有的权限
|
// 获取部门拥有的权限
|
||||||
const getDeptPermission = () => {
|
const getDeptPermission = () => {
|
||||||
http
|
http
|
||||||
.post(department.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId })
|
.post(permission.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
ApartcheckedKeys.value = res.data.map((item) => {
|
ApartcheckedKeys.value = res.data
|
||||||
|
?.filter((item) => !item.halfCheck)
|
||||||
|
.map((item) => {
|
||||||
return item.permissionId;
|
return item.permissionId;
|
||||||
});
|
});
|
||||||
|
deptTotalCheckedKeys.value = res.data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// 获取角色拥有的权限
|
// 获取角色拥有的权限
|
||||||
const getRolePermission = () => {
|
const getRolePermission = () => {
|
||||||
http
|
http
|
||||||
.post(department.queryRolePermission, { roleId: selectRef2.value?.roleId })
|
.post(permission.queryRolePermission, { roleId: selectRef2.value?.roleId })
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
UsercheckedKeys.value = res.data.map((item) => {
|
UsercheckedKeys.value = res.data
|
||||||
|
?.filter((item) => !item.halfCheck)
|
||||||
|
.map((item) => {
|
||||||
return item.permissionId;
|
return item.permissionId;
|
||||||
});
|
});
|
||||||
|
roleTotalCheckedKeys.value = res.data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -377,6 +459,7 @@
|
|||||||
|
|
||||||
// 部门编辑
|
// 部门编辑
|
||||||
const deptEdit = () => {
|
const deptEdit = () => {
|
||||||
|
disabledTree();
|
||||||
disabled.value = false;
|
disabled.value = false;
|
||||||
apartmentChoose();
|
apartmentChoose();
|
||||||
};
|
};
|
||||||
@@ -404,24 +487,27 @@
|
|||||||
* type editDpet
|
* type editDpet
|
||||||
*/
|
*/
|
||||||
const roleChoose = () => {
|
const roleChoose = () => {
|
||||||
opMap.type = 'editDpet';
|
opMap.type = 'editRole';
|
||||||
opMap.fuc = (params) => {
|
opMap.fuc = (params) => {
|
||||||
return http.post(department.deptEdit, params);
|
return http.post(department.editRole, params);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
const roleEdit = () => {
|
||||||
|
disabled2.value = false;
|
||||||
|
roleChoose();
|
||||||
|
};
|
||||||
// 角色选择
|
// 角色选择
|
||||||
const SelectUserTree = (selectedKeys: any, info: any) => {
|
const SelectUserTree = (selectedKeys: any, info: any) => {
|
||||||
const { selected } = info;
|
const { selected } = info;
|
||||||
disabled2.value = !selected;
|
// disabled2.value = !selected;
|
||||||
console.log(selectedKeys, 'selectedKeys');
|
|
||||||
console.log(info, 'info');
|
if (!selectedKeys?.length) return;
|
||||||
selectKey2.value = selectedKeys[0];
|
selectKey2.value = selectedKeys[0];
|
||||||
selectRef2.value = info.node.dataRef;
|
selectRef2.value = info.node.dataRef;
|
||||||
formData2.value = cloneDeep(info.node.dataRef);
|
formData2.value = cloneDeep(info.node.dataRef);
|
||||||
roleChoose();
|
|
||||||
UsercheckedKeys.value.splice(0);
|
UsercheckedKeys.value.splice(0);
|
||||||
getRolePermission();
|
getRolePermission();
|
||||||
|
getRolePermissionTree({ deptId: selectRef.value.deptInfo.deptId });
|
||||||
};
|
};
|
||||||
|
|
||||||
const CancelApartment = () => {
|
const CancelApartment = () => {
|
||||||
@@ -452,6 +538,7 @@
|
|||||||
opMap.fuc &&
|
opMap.fuc &&
|
||||||
opMap.fuc(formData.value).then(() => {
|
opMap.fuc(formData.value).then(() => {
|
||||||
getTree();
|
getTree();
|
||||||
|
clearApartData();
|
||||||
disabled.value = true;
|
disabled.value = true;
|
||||||
});
|
});
|
||||||
} else if (opMap.type === 'deptDelete') {
|
} else if (opMap.type === 'deptDelete') {
|
||||||
@@ -466,6 +553,7 @@
|
|||||||
opMap.fuc &&
|
opMap.fuc &&
|
||||||
opMap.fuc(formData2.value).then(() => {
|
opMap.fuc(formData2.value).then(() => {
|
||||||
getUserTree();
|
getUserTree();
|
||||||
|
clearRoleData();
|
||||||
});
|
});
|
||||||
} else if (selectRef2.value && opMap.type === 'addson')
|
} else if (selectRef2.value && opMap.type === 'addson')
|
||||||
selectRef2.value['children'] = [
|
selectRef2.value['children'] = [
|
||||||
@@ -480,6 +568,13 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const disabledTree = (data, disabled) => {
|
||||||
|
console.log(userAdminTreeData.value, 'userAdminTreeData.value');
|
||||||
|
userAdminTreeData.value.map((item) => {
|
||||||
|
item['disabled'] = disabled;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
disabled,
|
disabled,
|
||||||
disabled2,
|
disabled2,
|
||||||
@@ -513,6 +608,12 @@
|
|||||||
apartmentPermission,
|
apartmentPermission,
|
||||||
rolePermission,
|
rolePermission,
|
||||||
deptEdit,
|
deptEdit,
|
||||||
|
selectKey,
|
||||||
|
selectKey2,
|
||||||
|
deptTreeCheckedKeys,
|
||||||
|
deptCheck,
|
||||||
|
roleCheck,
|
||||||
|
roleEdit,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -62,7 +62,9 @@ export const appConfig = {
|
|||||||
// },
|
// },
|
||||||
// },
|
// },
|
||||||
timeout: 60 * 1000,
|
timeout: 60 * 1000,
|
||||||
userLoginApi: '/carbon-smart/user/login',
|
userLoginApi: (params) => {
|
||||||
|
return http.post('/carbon-smart/user/login', { ...params, operation: true });
|
||||||
|
},
|
||||||
userResourceApi: () => {
|
userResourceApi: () => {
|
||||||
return { data: [] };
|
return { data: [] };
|
||||||
},
|
},
|
||||||
|
@@ -109,9 +109,9 @@ export const appConfigStore = defineStore({
|
|||||||
userLogin(data: loginData) {
|
userLogin(data: loginData) {
|
||||||
if (this.userLoginApi) {
|
if (this.userLoginApi) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
// return httpRequest({ api: this.userLoginApi, params: data, pathParams: {}, requestConfig });
|
return httpRequest({ api: this.userLoginApi, params: data, pathParams: {}, requestConfig });
|
||||||
|
|
||||||
return http.post(this.userLoginApi, data);
|
// return http.post(this.userLoginApi, data);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { appConfigStore } from '/nerv-base/store/modules/app-config';
|
import { appConfigStore } from '/nerv-base/store/modules/app-config';
|
||||||
export const authorizationService = defineStore({
|
export const authorizationService = defineStore({
|
||||||
@@ -72,6 +70,8 @@ export const authorizationService = defineStore({
|
|||||||
this.dealResourceTree(this.userResourceList);
|
this.dealResourceTree(this.userResourceList);
|
||||||
} else {
|
} else {
|
||||||
const res = await this.appConfig.userResource();
|
const res = await this.appConfig.userResource();
|
||||||
|
console.log(res, 'hshshhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh');
|
||||||
|
|
||||||
this.userResourceList = res.data ? res.data : [];
|
this.userResourceList = res.data ? res.data : [];
|
||||||
if (this.appConfig.defaultResource) {
|
if (this.appConfig.defaultResource) {
|
||||||
this.userResourceList.push(this.appConfig.defaultResource);
|
this.userResourceList.push(this.appConfig.defaultResource);
|
||||||
@@ -92,6 +92,8 @@ export const authorizationService = defineStore({
|
|||||||
//初始化菜单树
|
//初始化菜单树
|
||||||
async initMenuResource() {
|
async initMenuResource() {
|
||||||
const res = await this.appConfig.userResource();
|
const res = await this.appConfig.userResource();
|
||||||
|
console.log(res, 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
|
||||||
|
|
||||||
this.initMenus = [];
|
this.initMenus = [];
|
||||||
if (this.appConfig.resourceName && res.data && res.data.length) {
|
if (this.appConfig.resourceName && res.data && res.data.length) {
|
||||||
res.data.forEach((item) => {
|
res.data.forEach((item) => {
|
||||||
|
@@ -105,6 +105,8 @@
|
|||||||
loading.value = false;
|
loading.value = false;
|
||||||
if (configStore.enablePermissions) {
|
if (configStore.enablePermissions) {
|
||||||
const res = await configStore.userResource();
|
const res = await configStore.userResource();
|
||||||
|
console.log(res, 'cccccccccccccccccccccccccccccc');
|
||||||
|
|
||||||
if (configStore.customApplication) {
|
if (configStore.customApplication) {
|
||||||
await useAuthorization.initMenuResource();
|
await useAuthorization.initMenuResource();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user