feat:授权正确展示部门和用户

master
20300 2024-04-27 20:18:51 +08:00
parent 2933a0f5de
commit be3c2204aa
3 changed files with 69 additions and 300 deletions

View File

@ -0,0 +1,8 @@
import request from '@/utils/request'
export function getAllUserAndDept(dataType,dataId) {
return request({
url: '/data/permissions/getAllUserAndDept?dataType='+dataType+'&dataId='+dataId,
method: 'get'
})
}

View File

@ -58,7 +58,7 @@
<el-table ref="table" v-loading="loading" :data="userList">
<el-table-column align="center" label="用户名称" prop="userName"/>
<el-table-column align="center" label="用户昵称" prop="nickName"/>
<el-table-column align="center" label="用户部门" prop="dept.deptName"/>
<el-table-column align="center" label="用户部门" prop="sysDept.deptName"/>
<el-table-column align="center" label="用户邮箱" prop="email"/>
<el-table-column align="center" label="用户手机号" prop="phonenumber"/>
<el-table-column align="center" label="创建时间" prop="createTime" />
@ -97,249 +97,34 @@ export default {
pageNum: 1,
pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
},
baseInfo: {},
//
deptList: [],
//
userList: []
};
},
props: {
userAndDeptDataPermissionsListResp: {
type: Object
}
},
watch: {
userAndDeptDataPermissionsListResp: {
handler(newValue,oldValue){
this.baseInfo = newValue.dataInfo
this.deptList = this.handleTree(newValue.deptDataPermissionList,"deptId")
console.log("前台deptList:",this.deptList)
this.userList = newValue.userDataPermissionsList
}
}
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init()
},
methods: {
parseTime,
init(){
let response = {
"code": 200,
"msg": "操作成功",
"data": [
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 100,
"parentId": 0,
"ancestors": "0",
"deptName": "muyu牧鱼科技",
"orderNum": 0,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 101,
"parentId": 100,
"ancestors": "0,100",
"deptName": "深圳总公司",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 102,
"parentId": 100,
"ancestors": "0,100",
"deptName": "长沙分公司",
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 103,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "研发部门",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 104,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "市场部门",
"isAuth": true,
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 105,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "测试部门",
"orderNum": 3,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 106,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "财务部门",
"orderNum": 4,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 107,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "运维部门",
"orderNum": 5,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 108,
"parentId": 102,
"ancestors": "0,100,102",
"deptName": "市场部门",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 109,
"parentId": 102,
"ancestors": "0,100,102",
"deptName": "财务部门",
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
}
]
}
this.deptList = this.handleTree(response.data, "deptId");
this.userList = [
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "管理员",
"userId": 1,
"deptId": 103,
"userName": "admin",
"nickName": "智能车联",
"email": "ry@163.com",
"phonenumber": "15888888888",
"isAuth": true,
"dept": {
"deptName": "研发部门"
}
},
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "测试员",
"userId": 2,
"deptId": 105,
"userName": "ry",
"nickName": "智能车联",
"email": "ry@qq.com",
"phonenumber": "15666666666",
"dept": {
"deptName": "测试部门"
}
}
]
}
},
};
</script>

View File

@ -2,30 +2,30 @@
<el-container :style="{height: mainHeight + 'px'}">
<el-aside>
<el-tree :data="assetStructureList"
:load="expandTable"
:expand-on-click-node="false"
:load="expandTable"
lazy
@node-click="(data) => showAuth=data.type"
:props="defaultProps">
@node-click="(data) => showAssets=data.type">
<div class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="data.type === 'dataSource'">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div @click="getTableStructure" v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
<div @click="getDeptAndUser(data.dataSource)" v-if="data.type === 'dataSource'">{{ data.dataSource.name + '('+data.dataSource.dataSourceDatabaseName + '-' + data.dataSource.fromSystem+')' }}</div>
<div v-if="data.type === 'dataTable'">{{ data.dataTable.tableName + '-'+data.dataTable.tableAnnotation + '(' + data.dataTable.recordCount+')' }}</div>
</div>
</el-tree>
</el-aside>
<el-container>
<el-main>
<auth-data-source v-if="showAuth === 'dataSource'"/>
<auth-table v-else-if="showAuth === 'dataTable'"/>
<auth-data-source :userAndDeptDataPermissionsListResp="userAndDeptDataPermissionsListResp" v-if="showAssets === 'dataSource'"/>
<auth-table v-else-if="showAssets === 'dataTable'"/>
</el-main>
</el-container>
</el-container>
</template>
<script>
import AuthDataSource from './auth/AuthDataSource.vue'
import AuthTable from './auth/AuthTable.vue'
import {Table} from "element-ui";
import {queryBigStructure} from "@/api/dataSource/data";
import {getAllUserAndDept} from "@/api/dataSource/Permissions";
export default {
name: 'assetStructure',
@ -34,77 +34,56 @@ export default {
return Table
}
},
components: { AuthTable, AuthDataSource },
components: { AuthDataSource, AuthTable },
data() {
return {
assetsModelList: [],
dataBaseConnectObj: {},
mainHeight: window.innerHeight - 85,
defaultProps: {
children: 'childrenList',
label: 'name'
},
showAuth: null,
assetStructureList: [
{
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
type: "dataSource"
},
{
name: "测试2",
systemName: "网站系统",
databaseName: "wangzhan",
type: "dataSource"
},
{
name: "测试3",
systemName: "物联网系统",
databaseName: "wulianwang",
type: "dataSource"
},
{
name: "测试4",
systemName: "传媒系统",
databaseName: "chuanmei",
type: "dataSource"
},
],
childrenList: [
{
name: "sys_user",
as: "用户表",
dataTotal: 635847,
type: "dataTable",
childrenList: []
},
{
name: "sys_dept",
as: "部门表",
dataTotal: 362548,
type: "dataTable",
childrenList: []
},
{
name: "sys_notice",
as: "通知公告",
dataTotal: 6347,
type: "dataTable",
childrenList: []
}
]
assetStructureList: [],
showAssets: null,
title: null,
dataType: null,
userAndDeptDataPermissionsListResp: {}
}
},
methods: {
getDeptAndUser(dataSource){
this.dataType = "dataSource"
getAllUserAndDept(this.dataType,dataSource.id).then(
res => {
this.userAndDeptDataPermissionsListResp = res.data
this.userAndDeptDataPermissionsListResp.dataInfo = dataSource
console.log("后台响应对象:",this.userAndDeptDataPermissionsListResp)
}
)
},
getBigStructure() {
queryBigStructure().then(
res => {
this.assetStructureList = res.data.dataSourceDecorationList
console.log("BigStructure",this.assetStructureList)
}
)
},
expandTable( node, resolve){
if (node.level === 0) return resolve(this.assetStructureList);
if (node.level > 1) return resolve([]);
const {data} = node;
if (data.type === 'dataSource') {
this.title = data.name + '('+data.dataSource.dataSourceDatabaseName + '-' + data.dataSource.fromSystem+')'
}
if (data.type === 'dataTable') {
return resolve([])
this.title = data.tableName + '('+data.dataTable.tableAnnotation + '-' + data.dataTable.recordCount+')'
}
setTimeout(() => {
resolve(this.childrenList)
resolve(data.dataTableList)
this.showAuth = data.type;
}, 500);
}
},
created() {
this.getBigStructure()
}
}
</script>
@ -118,7 +97,4 @@ export default {
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node{
height: 30px;
}
</style>