Browse Source

feat: 补充角色权限

main
xuziqiang 6 months ago
parent
commit
112c701799
  1. 3
      hx-ai-intelligent/src/api/origanizemanage.ts
  2. 5
      hx-ai-intelligent/src/router/organizationManage.ts
  3. 178
      hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue
  4. 2
      hx-ai-intelligent/vite.config.ts

3
hx-ai-intelligent/src/api/origanizemanage.ts

@ -28,4 +28,7 @@ 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
hx-ai-intelligent/src/router/organizationManage.ts

@ -83,11 +83,11 @@ const organizationManage = {
name: 'AuthorityManage', name: 'AuthorityManage',
meta: { title: '部门/权限', hideChildren: true, icon: 'dicizhishou' }, meta: { title: '部门/权限', hideChildren: true, icon: 'dicizhishou' },
component: Base, component: Base,
redirect: { name: 'authorityManageIndex' }, redirect: { name: 'AuthorityManageIndex' },
children: [ children: [
{ {
path: 'index', path: 'index',
name: 'authorityManageIndex', name: 'AuthorityManageIndex',
component: () => import('/@/view/organizationManage/departmentManage/index.vue'), component: () => import('/@/view/organizationManage/departmentManage/index.vue'),
meta: { meta: {
title: '部门/权限', title: '部门/权限',
@ -97,7 +97,6 @@ const organizationManage = {
}, },
], ],
}, },
], ],
}; };
export default organizationManage; export default organizationManage;

178
hx-ai-intelligent/src/view/organizationManage/departmentManage/index.vue

@ -39,21 +39,28 @@
formLayout="vertical" formLayout="vertical"
class="form" /> class="form" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="部门权限"> <a-tab-pane key="2" :disabled="disabled" tab="部门权限">
<a-tree <a-tree
:tree-data="apartmentAdminTreeData" :tree-data="apartmentAdminTreeData"
:fieldNames="{ children: 'menus', title: 'label', key: 'permissionId' }"
v-model:checkedKeys="ApartcheckedKeys" v-model:checkedKeys="ApartcheckedKeys"
checkable checkable
:selectable="false"
defaultExpandAll defaultExpandAll
@select="ApartmentSelect"> @select="ApartmentSelect">
<template #title="{ title }"> <template #title="data"> {{ data.label }}</template>
{{ title }}
</template>
</a-tree> </a-tree>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
<ns-button style="margin: 20px" type="primary" @click="CancelApartment">取消</ns-button> <div v-show="activeKey === '1'">
<ns-button type="primary" @click="ApartmentSure">确定</ns-button> <ns-button style="margin: 16px" type="primary" @click="CancelApartment">取消</ns-button>
<ns-button type="primary" :disabled="disabled" @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>
@ -61,9 +68,7 @@
<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 :disabled="disabled2" style="margin: 10px" type="primary" @click="addUser" <ns-button style="margin: 10px" type="primary" @click="addUser">新增角色</ns-button>
>新增角色</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
@ -87,21 +92,25 @@
formLayout="vertical" formLayout="vertical"
class="form" /> class="form" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="角色权限"> <a-tab-pane key="2" :disabled="disabled2" 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' }"
:selectable="false"
checkable checkable
@select="UserSelect"> @select="UserSelect" />
<template #title="{ title }">
{{ title }}
</template>
</a-tree>
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
<ns-button style="margin: 20px" type="primary" @click="CancelUser">取消</ns-button> <div v-show="activeKey2 === '1'">
<ns-button type="primary" @click="UserSure"> 确定</ns-button> <ns-button style="margin: 16px" type="primary" @click="CancelUser">取消</ns-button>
<ns-button 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>
@ -112,7 +121,7 @@
import { Modal } from 'ant-design-vue'; import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { http } from '/nerv-lib/util/http'; import { http } from '/nerv-lib/util/http';
import { cloneDeep } from 'lodash-es'; import { cloneDeep, get } from 'lodash-es';
import { formConfig, formConfig2 } from './config'; import { formConfig, formConfig2 } from './config';
import { department } from '/@/api/origanizemanage'; import { department } from '/@/api/origanizemanage';
import { permission } from '/@/api/origanizemanage'; import { permission } from '/@/api/origanizemanage';
@ -140,34 +149,18 @@
const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId; const projectId = JSON.parse(sessionStorage.getItem('userInfo')).projectId;
const userAdminTreeData = ref([]); const userAdminTreeData = ref([]);
const apartmentTreeData = ref([]); const apartmentTreeData = ref([]);
const apartmentAdminTreeData = ref([]);
const userTreeData = ref([]); const userTreeData = ref([]);
const getPermissionTree = (params) => { const getPermissionTree = (params) => {
return http.post(permission.permissionTree, params); return http.post(permission.permissionTree, params).then((res) => {
apartmentAdminTreeData.value = get(res, 'data.data');
userAdminTreeData.value = get(res, 'data.data');
});
}; };
getPermissionTree({ projectId }); getPermissionTree({ projectId });
const apartmentAdminTreeData = [
{
title: '首页',
key: '0-0',
children: [
{
title: '控制台',
key: '0-0-0',
children: [
{ title: 'leaf', key: '0-0-0-0' },
{ title: 'leaf', key: '0-0-0-1' },
],
},
{
title: '用户管理',
key: '0-0-1',
children: [{ key: '0-0-1-0', title: 'sss' }],
},
],
},
];
watch(ApartcheckedKeys, () => { watch(ApartcheckedKeys, () => {
console.log('checkedKeys', ApartcheckedKeys.value); console.log('checkedKeys', ApartcheckedKeys.value);
}); });
@ -183,6 +176,7 @@
apartmentTreeData.value = res.data; apartmentTreeData.value = res.data;
}); });
//
const getTree = () => { const getTree = () => {
getDepartList({ orgId }).then((res) => { getDepartList({ orgId }).then((res) => {
apartmentTreeData.value = res.data; apartmentTreeData.value = res.data;
@ -190,14 +184,17 @@
}); });
}; };
const getUserTree = (params = { deptId: selectRef.value.deptInfo.deptId }) => { //
const getUserTree = (params = { deptId: selectRef.value?.deptInfo?.deptId }) => {
http.post(department.queryRoleTree, params).then((res) => { http.post(department.queryRoleTree, params).then((res) => {
userTreeData.value = res.data; userTreeData.value = res.data;
}); });
}; };
// //
watchEffect(() => { watchEffect(() => {
if (selectRef.value) getUserTree(); if (selectRef.value) {
getUserTree();
}
}); });
const opMap: any = { const opMap: any = {
@ -284,7 +281,7 @@
onOk() { onOk() {
http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => { http.post(department.deptDel, { deptId: selectRef.value.deptInfo.deptId }).then(() => {
getTree(); getTree();
clearData(); clearApartData();
}); });
}, },
onCancel() { onCancel() {
@ -307,13 +304,78 @@
class: 'test', class: 'test',
}); });
}; };
const clearData = () => {
const clearApartData = () => {
selectRef.value = {}; selectRef.value = {};
formData.value = {}; formData.value = {};
opMap.type = ''; opMap.type = '';
opMap.fuc = ''; opMap.fuc = '';
selectKey.value = ''; selectKey.value = '';
}; };
//
const apartmentPermission = () => {
http
.post(department.addPermission, {
deptId: selectRef.value?.deptInfo.deptId,
projectId,
permissionVoList: ApartcheckedKeys.value.map((item) => {
return { permissionId: item };
}),
})
.then(() => {
NsMessage.success('保存成功');
});
};
//
const rolePermission = () => {
http
.post(department.addRolePermission, {
// deptId: selectRef.value?.deptInfo.deptId,
roleId: selectRef2.value?.roleId,
projectId,
permissionVoList: UsercheckedKeys.value.map((item) => {
return { permissionId: item };
}),
})
.then(() => {
NsMessage.success('保存成功');
});
};
//
const getDeptPermission = () => {
http
.post(department.queryDeptPermission, { deptId: selectRef.value?.deptInfo.deptId })
.then((res) => {
ApartcheckedKeys.value = res.data.map((item) => {
return item.permissionId;
});
});
};
//
const getRolePermission = () => {
http
.post(department.queryRolePermission, { roleId: selectRef2.value?.roleId })
.then((res) => {
UsercheckedKeys.value = res.data.map((item) => {
return item.permissionId;
});
});
};
/**
* 默认选中视为编辑部门
* type editDpet
*/
const apartmentChoose = () => {
opMap.type = 'editDpet';
opMap.fuc = (params) => {
return http.post(department.deptEdit, params);
};
};
// //
const SelectApartmentTree = (selectedKeys: any, info: any) => { const SelectApartmentTree = (selectedKeys: any, info: any) => {
const { selected } = info; const { selected } = info;
@ -322,12 +384,21 @@
selectKey.value = selectedKeys[0]; selectKey.value = selectedKeys[0];
selectRef.value = info.node.dataRef; selectRef.value = info.node.dataRef;
formData.value = cloneDeep(info.node.dataRef.deptInfo); formData.value = cloneDeep(info.node.dataRef.deptInfo);
apartmentChoose();
ApartcheckedKeys.value.splice(0);
getDeptPermission();
// getUserTree({ deptId: selectRef.value.deptInfo.deptId });
};
/**
* 默认选中视为编辑角色
* type editDpet
*/
const roleChoose = () => {
opMap.type = 'editDpet'; opMap.type = 'editDpet';
opMap.fuc = (params) => { opMap.fuc = (params) => {
return http.post(department.deptEdit, params); return http.post(department.deptEdit, params);
}; };
// getUserTree({ deptId: selectRef.value.deptInfo.deptId });
}; };
// //
@ -339,14 +410,15 @@
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);
opMap.type = 'editRole'; roleChoose();
opMap.fuc = (params) => { UsercheckedKeys.value.splice(0);
return http.post(department.editRole, params); getRolePermission();
};
}; };
const CancelApartment = () => { const CancelApartment = () => {
disabled.value = true; disabled.value = true;
//
// clearApartData();
}; };
const CancelUser = () => { const CancelUser = () => {
@ -382,10 +454,9 @@
opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value }); opMap.fuc && opMap.fuc({ ...formData.value, selectRef: selectRef.value });
} }
}; };
const UserSure = () => { const UserSure = () => {
disabled2.value = !disabled2.value; disabled2.value = !disabled2.value;
console.log(formData2.value, 'formData2');
console.log(opMap.type, 'opMap.type');
const typeArr = ['addUserSon', 'addUser', 'editRole']; const typeArr = ['addUserSon', 'addUser', 'editRole'];
if (typeArr.includes(opMap.type)) { if (typeArr.includes(opMap.type)) {
opMap.fuc && opMap.fuc &&
@ -403,7 +474,6 @@
else { else {
console.log('ss'); console.log('ss');
} }
formData2.value = {};
}; };
return { return {
@ -436,6 +506,8 @@
UsercheckedKeys, UsercheckedKeys,
UserSelect, UserSelect,
formRef, formRef,
apartmentPermission,
rolePermission,
}; };
}, },
}); });

2
hx-ai-intelligent/vite.config.ts

@ -12,7 +12,7 @@ const proxy = {
changeOrigin: true, changeOrigin: true,
}, },
'/carbon-smart': { '/carbon-smart': {
target: 'http://123.60.103.97:8224', target: 'http://192.168.112.144:8224',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/carbon-smart/, ''), rewrite: (path) => path.replace(/^\/carbon-smart/, ''),
}, },

Loading…
Cancel
Save