Browse Source

feat: 补充角色权限

main
xuziqiang 4 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`,
editRole = `${BASE_URL}/api/dept/editRole`,
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',
meta: { title: '部门/权限', hideChildren: true, icon: 'dicizhishou' },
component: Base,
redirect: { name: 'authorityManageIndex' },
redirect: { name: 'AuthorityManageIndex' },
children: [
{
path: 'index',
name: 'authorityManageIndex',
name: 'AuthorityManageIndex',
component: () => import('/@/view/organizationManage/departmentManage/index.vue'),
meta: {
title: '部门/权限',
@ -97,7 +97,6 @@ const organizationManage = {
},
],
},
],
};
export default organizationManage;

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

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

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

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

Loading…
Cancel
Save