feat: 数据授权(初版)

master
rouchen 2024-04-27 19:50:59 +08:00
parent a3c1acf83a
commit 5d3d0b3c76
5 changed files with 339 additions and 167 deletions

View File

@ -121,13 +121,7 @@ export function selectChildAll() {
method: 'post'
})
}
//查询所有部门列表
export function selectDept() {
return request({
url: '/kvt/kvt/selectDept',
method: 'post'
})
}
//查询字典
export function selectDictionaryy(id) {
return request({

View File

@ -1,33 +1,34 @@
<template>
<div class="app-container">
<h4 class="form-header h4">基本信息</h4>
55555555
{{DataSource}}
<el-form ref="form" :model="DataSource" label-width="120px">
<el-row>
<el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="form.name" disabled/>
<el-input v-model="DataSource.name" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="系统名称" prop="userName">
<el-input v-model="form.systemName" disabled/>
<el-input v-model="DataSource.systemName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName">
<el-input v-model="form.databaseName" disabled/>
<el-input v-model="DataSource.databaseName" disabled/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-model="activeName">
<el-tab-pane label="部门授权" name="dept">
<el-table
ref="deptTable"
v-loading="loading"
:data="deptList"
:data="deptlists"
:normalizer="normalizer"
:default-expand-all="true"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
@ -44,17 +45,21 @@
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权" >
<!-- :active-value="1"-->
<!-- :inactive-value="0"-->
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
<el-tab-pane label="用户授权" name="user">
<el-table ref="table" v-loading="loading" :data="userList">
<el-table-column align="center" label="用户名称" prop="userName"/>
@ -67,11 +72,14 @@
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
<!-- :active-value="1"-->
<!-- :inactive-value="0"-->
</el-switch>
</template>
</el-table-column>
@ -90,7 +98,9 @@ import { listDept } from '@/api/system/dept'
export default {
name: "AuthDataSource",
props: [
"DataSource"
"deptlists",
"DataSource",
"userList"
],
data() {
return {
@ -102,27 +112,62 @@ export default {
pageNum: 1,
pageSize: 1,
//
baseInfo: {
},
baseInfo: {},
//
deptList: [],
//
userList: []
// //
// userList: []
};
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init()
},
watch: {
'activeName.status'(newVal) {
if (newVal === 0) {
alert("闭关")
//
} else if (newVal === 1) {
alert("打开")
//
}
},
'userList.status'(newVal) {
if (newVal === 0) {
alert("闭关")
//
} else if (newVal === 1) {
alert("打开")
//
}
}
},
methods: {
parseTime,
init(){
let response = [];
listDept().then(res => {
console.log(res)
this.deptList = res.date
})
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.deptId,
label: node.deptName,
children: node.children
};
},
// init(){
// let response = [];
// listDept().then(res => {
// console.log(res)
// this.deptList = res.date
// })
// "code": 200,
// "msg": "",
@ -165,43 +210,43 @@ export default {
// },
// ]
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": "测试部门"
}
}
]
}
// 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": ""
// }
// }
// ]
// }
},
};

View File

@ -1,6 +1,7 @@
<template>
<div class="app-container">
<h4 class="form-header h4">基本信息</h4>
2222
{{DataSource}}
<el-form ref="form" :model="DataSource" label-width="120px">
<el-row>
@ -36,13 +37,13 @@
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-model="activeName">
<el-tab-pane label="部门授权" name="dept">
<el-table
ref="deptTable"
v-loading="loading"
:data="deptList"
:data="deptlists"
:normalizer="normalizer"
:default-expand-all="true"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
@ -59,7 +60,7 @@
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
@ -70,6 +71,7 @@
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
{{userList}}
<el-tab-pane label="用户授权" name="user">
<el-table ref="table" v-loading="loading" :data="userList">
<el-table-column align="center" label="用户名称" prop="userName"/>
@ -82,11 +84,16 @@
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
v-model="scope.row.status"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权" >
<!-- :active-value="1"-->
<!-- :inactive-value="0"-->
</el-switch>
</template>
</el-table-column>
@ -101,12 +108,13 @@
import { parseTime } from '@/utils/muyu'
import { listDept } from '@/api/system/dept'
import { selectDept } from '@/api/kvt/kvt'
export default {
name: "AuthTable",
props: [
"DataSource"
"DataSource",
"deptlists",
"userList"
],
data() {
return {
@ -118,98 +126,124 @@ export default {
pageNum: 1,
pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
tableName: "sys_user",
tableAsName: "用户表",
total: "12546条",
},
baseInfo: {},
//
deptList: [],
//
userList: []
// //
// userList: []
};
},
watch: {
'activeName.status'(newVal) {
if (newVal === 0) {
//
} else if (newVal === 1) {
alert("打开")
//
}
},
'userList.status'(newVal) {
if (newVal === 0) {
//
} else if (newVal === 1) {
alert("打开")
//
}
}
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
// this.init()
},
mounted() {
this.selectDept()
},
// mounted() {
// this.selectDept()
// },
methods: {
parseTime,
init(){
let response = {
"code": 200,
"msg": "操作成功",
"data": [
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.deptId,
label: node.deptName,
children: node.children
};
},
// 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": []
// // }
// ]
// }
// this.deptList = this.handleTree(response.data, "deptId");
// this.userList = [
// {
// "createBy": 1,
// "createTime": "2023-09-29 11:47:27",
// "createBy": "admin",
// "createTime": "2023-04-23 16:11:38",
// "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": []
// "remark": "",
// "userId": 1,
// "deptId": 103,
// "userName": "admin",
// "nickName": "",
// "email": "ry@163.com",
// "phonenumber": "15888888888",
// "isAuth": true,
// "dept": {
// "deptName": ""
// }
]
}
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": "测试部门"
}
}
]
},
selectDept(){
listDept().then(res => {
console.log(res)
this.deptList = res.date
})
}
// },
// {
// "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": ""
// }
// }
// ]
// },
// selectDept(){
// listDept().then(res => {
// console.log(res)
// this.deptList = res.date
// })
// },
},
};
</script>

View File

@ -7,16 +7,17 @@
lazy
@node-click="(data) => showAuth=data.type"
:props="defaultProps">
<div class="custom-tree-node" @click="selectDepartmen(data.databaseName)" slot-scope="{ node, data }">
<div v-if="data.type === 1">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div v-if="data.type === 2">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
<div class="custom-tree-node" slot-scope="{ node, data }">
<div v-if="data.type === 1" @click="selectData(node)">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>
<div v-if="data.type === 2" @click="selectTable(node)">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>
</div>
</el-tree>
</el-aside>
<el-container>
<el-main>
<auth-data-source v-if="showAuth === 1" v-bind:DataSource="assetStructureList"/>
<auth-table v-else-if="showAuth === 2" v-bind:DataSource="assetStructureList"/>
<auth-data-source v-if="showAuth === 1" v-bind:deptlists="deptList" v-bind:DataSource="authTable" v-bind:userList="userLis" />
<auth-table v-else-if="showAuth === 2" v-bind:deptlists ="deptList" v-bind:DataSource="authTable" v-bind:userList="userLis"/>
</el-main>
</el-container>
</el-container>
@ -25,7 +26,9 @@
import AuthDataSource from './auth/AuthDataSource.vue'
import AuthTable from './auth/AuthTable.vue'
import { selectDataSource, selectDepartmen } from '@/api/kvt/kvt'
import { selectChild, selectChildAll, selectDataSource, selectDepartmen, selectDictionaryy } from '@/api/kvt/kvt'
import { listDept } from '@/api/system/dept'
import { deptTreeSelect, listUser } from '@/api/system/user'
export default {
name: 'assetStructure',
@ -80,22 +83,87 @@ export default {
// type: "dataTable",
// childrenList: []
// }
]
],
deptList: [],
selectDepartmen: [],
authTable: [],
userLis: [],
//
queryParams: {
deptName: undefined,
status: undefined,
dateRange:undefined
},
}
},
created() {
this.selectDataSource()
},
methods: {
//
selectDepartmen(databaseName){
selectDepartmen(databaseName).then(res => {
console.log(res)
this.childrenList = res.data
console.log("res",this.assertChild)
})
selectData(node){
console.log("nodenodddd",node)
let authTable ={}
const name = node.data.name
const systemName =node.data.systemName
const databaseName =node.data.databaseName
authTable = {
name,
systemName,
databaseName
}
this.authTable =authTable
this.loading = true;
listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "deptId");
this.loading = false;
});
this.loading = true;
listUser().then(response => {
this.userLis = response.data.rows;
console.log("userListuserList",this.userLis)
this.loading = false;
}
);
},
//
selectTable(node){
let authTable ={}
const name = node.parent.data.name
const systemName =node.parent.data.systemName
const databaseName =node.parent.data.databaseName
const tableName =node.data.name
const tableAsName =node.data.as
const total =node.data.dataTotal
authTable ={
name,
systemName,
databaseName,
tableName,
tableAsName,
total
}
this.authTable =authTable
//
this.loading = true;
listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "deptId");
this.loading = false;
});
//
this.loading = true;
listUser().then(response => {
this.userLis = response.data.rows;
console.log("userListuserList",this.userLis)
this.loading = false;
}
);
},
// getList() {
//
// },
//
selectDataSource(){
selectDataSource().then(res => {
@ -103,14 +171,46 @@ export default {
})
},
expandTable( node, resolve){
console.log("node",node)
if (node.level === 0) return resolve(this.assetStructureList);
const {data} = node;
if (data.type === 'dataTable') {
if (data.type == 1){
selectDepartmen(data.databaseName).then(res=>{
console.log("resssss",res)
this.childrenList = res.data
})
selectDictionaryy(data.id).then(res => {
console.log("rrrr",res)
this.dictAddName = res.data
})
}
// if (node.level === 2){
// let authTable ={}
// const name = node.parent.data.name
// const systemName =node.parent.data.systemName
// const databaseName =node.parent.data.databaseName
// const tableName =node.data.name
// const tableAsName =node.data.as
// const total =node.data.dataTotal
// authTable ={
// name,
// systemName,
// databaseName,
// tableName,
// tableAsName,
// total
// }
// this.authTable =authTable
// console.log("aaaaaaaaaaaaaaaaaaaaa",this.authTable)
// }
if (data.type === 2) {
return resolve([])
}
setTimeout(() => {
resolve(this.childrenList)
}, 500);
}
}
}

View File

@ -514,7 +514,6 @@ export default {
deptTreeSelect().then(response => {
console.log("aaa",response)
this.deptOptions = response.data;
});
},
//