feat:资产授权修改

ruoyi_test
sunshine7058 2024-05-01 20:30:09 +08:00
parent 8eb1ab16f0
commit 6338280a5e
5 changed files with 292 additions and 685 deletions

View File

@ -144,7 +144,7 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="字典"> <el-form-item label="字典">
<el-select v-model="form.dictKey" @change="selectedDict"> <el-select v-model="form.dictKey" @change="selectedDict">
<el-option v-for="(dict,index) in dictMap" :key="dict.id" :label="dict.dictType" <el-option v-for="(dict,index) in dictMap" :key="dict.dictType" :label="dict.dictType"
:value="dict.dictType"></el-option> :value="dict.dictType"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -167,8 +167,8 @@
</div> </div>
</template> </template>
<script> <script>
import {selectTableData, updTableData} from "@/api/data/source"; import {selectTableData, updTableData} from "@/api/source/data";
import {getDictDataList} from "@/api/data/dictType"; import {getDictDataList} from "@/api/source/dictType";
export default { export default {
name: 'OverallAssetStructure', name: 'OverallAssetStructure',
@ -208,6 +208,7 @@ export default {
update(row) { update(row) {
this.form = row; this.form = row;
this.formStatus = true; this.formStatus = true;
this.checkedDictData = [];
}, },
selectedDict() { selectedDict() {
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? [] this.checkedDictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? []
@ -217,7 +218,7 @@ export default {
}, },
editTableData() { editTableData() {
if (this.form.isDict === 'N') { if (this.form.isDict === 'N') {
this.form.dictKey = null; this.form.dictKey = "";
} }
updTableData(this.form).then(res => { updTableData(this.form).then(res => {
this.$message.success("修改成功"); this.$message.success("修改成功");

View File

@ -41,7 +41,7 @@ import {
getTableDataCount, getTableDataCount,
selectTableData, selectTableData,
selectTableDataCount selectTableDataCount
} from "@/api/data/source"; } from "@/api/source/data";
export default { export default {
name: 'assetStructure', name: 'assetStructure',
@ -56,7 +56,7 @@ export default {
assetStructureList: [], assetStructureList: [],
childrenList: [], childrenList: [],
tableDataList: [], tableDataList: [],
childrenParams: null, childrenParams: {},
assetId: 0, assetId: 0,
showAssets: null, showAssets: null,
title: null, title: null,
@ -79,10 +79,8 @@ export default {
const {data} = node; const {data} = node;
if (data.type === 'dataSource') { if (data.type === 'dataSource') {
this.assetId = data.id this.assetId = data.id
console.log(this.assetId)
getChildrenList(data.id).then(res => { getChildrenList(data.id).then(res => {
this.childrenList = res.data this.childrenList = res.data
}) })
} }
// this.showAssets = data.type; // this.showAssets = data.type;
@ -103,7 +101,6 @@ export default {
this.showAssets = data.type; this.showAssets = data.type;
if (data.type === 'dataSource') { if (data.type === 'dataSource') {
this.assetId = data.id this.assetId = data.id
console.log(this.assetId)
getTableDataCount(data.id).then(res => { getTableDataCount(data.id).then(res => {
this.count = res.data this.count = res.data
}) })

View File

@ -1,27 +1,27 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<h4 class="form-header h4">基本信息</h4> <h4 class="form-header h4">基本信息</h4>
<el-form ref="form" :model="baseInfo" label-width="120px"> <el-form ref="form" :model="assetParams" label-width="120px">
<el-row> <el-row>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName"> <el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="baseInfo.name" disabled/> <el-input v-model="assetParams.name" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="系统名称" prop="userName"> <el-form-item label="系统名称" prop="userName">
<el-input v-model="baseInfo.systemName" disabled/> <el-input v-model="assetParams.systemName" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName"> <el-form-item label="数据库名称" prop="nickName">
<el-input v-model="baseInfo.databaseName" disabled/> <el-input v-model="assetParams.databaseName" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-tabs type="border-card" v-model="activeName"> <el-tabs type="border-card" v-model="idType">
<el-tab-pane label="部门授权" name="dept"> <el-tab-pane label="部门授权" name="dept">
<el-table <el-table
ref="deptTable" ref="deptTable"
@ -44,6 +44,7 @@
<el-switch <el-switch
style="display: block" style="display: block"
v-model="scope.row.isAuth" v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.deptId)"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949" inactive-color="#ff4949"
active-text="已授权" active-text="已授权"
@ -67,6 +68,7 @@
<el-switch <el-switch
style="display: block" style="display: block"
v-model="scope.row.isAuth" v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.userId)"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949" inactive-color="#ff4949"
active-text="已授权" active-text="已授权"
@ -84,262 +86,109 @@
<script> <script>
import {parseTime} from '@/utils/muyu' import {parseTime} from '@/utils/muyu'
import {listUser} from "@/api/system/user";
import {listDept} from "@/api/system/dept";
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/source/assetAccredit";
export default { export default {
name: "AuthDataSource", name: "AuthDataSource",
props: {
assetParams: {
type: Object,
default: {}
}
},
data() { data() {
return { return {
// //
loading: true, loading: true,
activeName: "dept",
// //
total: 0, total: 0,
pageNum: 1, pageNum: 1,
pageSize: 1, pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
},
// //
deptList: [], deptList: [],
// //
userList: [] userList: [],
deptData: [],
idType: "dept",
dataType: "source",
assetAccreditQueryReq: {}
}; };
}, },
watch: {
idType: {
handler() {
this.setAuth();
},
immediate: true
}
},
created() { created() {
this.loading = true; this.loading = true;
setTimeout(() => this.loading = false, 200) setTimeout(() => this.loading = false, 200)
this.init() this.init();
}, },
methods: { methods: {
parseTime, parseTime,
init() { init() {
let response = { listDept().then(res => {
"code": 200, this.deptData = res.data
"msg": "操作成功", this.deptList = this.handleTree(res.data, "deptId");
"data": [ })
{ listUser().then(res => {
"createBy": 1, console.log(res)
"createTime": "2023-09-29 11:47:27", this.userList = res.data.rows
"updateBy": null, })
"updateTime": null, // setTimeout(() => {
"deptId": 100, // this.setAuth();
"parentId": 0, // }, 600);
"ancestors": "0",
"deptName": "muyu牧鱼科技",
"orderNum": 0,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
}, },
{ setAuth() {
"createBy": 1, this.assetAccreditQueryReq.idType = this.idType
"createTime": "2023-09-29 11:47:27", this.assetAccreditQueryReq.dataType = this.dataType
"updateBy": null, listAssetAccredit(this.assetAccreditQueryReq).then(res => {
"updateTime": null, console.log(res)
"deptId": 101, let data;
"parentId": 100, if (this.idType === 'dept') {
"ancestors": "0,100", data = this.deptData
"deptName": "深圳总公司", } else {
"orderNum": 1, data = this.userList
"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": []
} }
] data.forEach(da => {
res.data.forEach(as => {
if (this.idType === 'dept' && da.deptId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, 'assetAccreditId', as.id)
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, "assetAccreditId", as.id)
} }
this.deptList = this.handleTree(response.data, "deptId"); })
this.userList = [ })
{ if (this.idType === 'dept') {
"createBy": "admin", this.deptList = this.handleTree(this.deptData, "deptId")
"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": "研发部门"
} }
})
}, },
{ accreditChange(val, row, id) {
"createBy": "admin", if (val) {
"createTime": "2023-04-23 16:11:38", addAccredit({
"updateBy": null, accreditId: id,
"updateTime": null, idType: this.idType,
"remark": "测试员", dataId: this.assetParams.id,
"userId": 2, dataType: this.dataType
"deptId": 105, }).then(res => {
"userName": "ry", this.$message.success("授权成功")
"nickName": "数据处理", this.setAuth()
"email": "ry@qq.com", })
"phonenumber": "15666666666", } else {
"dept": { delAccredit(row.assetAccreditId).then(res => {
"deptName": "测试部门" this.$message.success("取消授权成功")
this.setAuth()
})
} }
} }
]
}
}, },
}; };
</script> </script>

View File

@ -5,38 +5,38 @@
<el-row> <el-row>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName"> <el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="baseInfo.name" disabled/> <el-input v-model="baseInfo.assetParams.name" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="系统名称" prop="userName"> <el-form-item label="系统名称" prop="userName">
<el-input v-model="baseInfo.systemName" disabled/> <el-input v-model="baseInfo.assetParams.systemName" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName"> <el-form-item label="数据库名称" prop="nickName">
<el-input v-model="baseInfo.databaseName" disabled/> <el-input v-model="baseInfo.assetParams.databaseName" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="表名称" prop="nickName"> <el-form-item label="表名称" prop="nickName">
<el-input v-model="baseInfo.tableName" disabled/> <el-input v-model="baseInfo.childrenParams.name" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="表中文名" prop="nickName"> <el-form-item label="表中文名" prop="nickName">
<el-input v-model="baseInfo.tableAsName" disabled/> <el-input v-model="baseInfo.childrenParams.annotation" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :offset="2" :span="8"> <el-col :offset="2" :span="8">
<el-form-item label="数据量" prop="nickName"> <el-form-item label="数据量" prop="nickName">
<el-input v-model="baseInfo.total" disabled/> <el-input v-model="baseInfo.childrenParams.dataTotal" disabled/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<el-tabs type="border-card" v-model="activeName"> <el-tabs type="border-card" v-model="idType">
<el-tab-pane label="部门授权" name="dept"> <el-tab-pane label="部门授权" name="dept">
<el-table <el-table
ref="deptTable" ref="deptTable"
@ -59,6 +59,7 @@
<el-switch <el-switch
style="display: block" style="display: block"
v-model="scope.row.isAuth" v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.deptId)"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949" inactive-color="#ff4949"
active-text="已授权" active-text="已授权"
@ -82,6 +83,7 @@
<el-switch <el-switch
style="display: block" style="display: block"
v-model="scope.row.isAuth" v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.userId)"
active-color="#13ce66" active-color="#13ce66"
inactive-color="#ff4949" inactive-color="#ff4949"
active-text="已授权" active-text="已授权"
@ -99,265 +101,106 @@
<script> <script>
import {parseTime} from '@/utils/muyu' import {parseTime} from '@/utils/muyu'
import {listDept} from "@/api/system/dept";
import {listUser} from "@/api/system/user";
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/source/assetAccredit";
export default { export default {
name: "AuthTable", name: "AuthTable",
props: {
baseInfo: {
type: Object,
default: null
}
},
data() { data() {
return { return {
// //
loading: true, loading: true,
activeName: "dept",
// //
total: 0, total: 0,
pageNum: 1, pageNum: 1,
pageSize: 1, pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
tableName: "sys_user",
tableAsName: "用户表",
total: "12546条",
},
// //
deptList: [], deptList: [],
// //
userList: [] userList: [],
deptData: [],
idType: "dept",
dataType: "table",
assetAccreditQueryReq: {}
}; };
}, },
watch: {
idType: {
handler() {
this.setAuth();
},
immediate: true
}
},
created() { created() {
this.loading = true; this.loading = true;
setTimeout(() => this.loading = false, 200) setTimeout(() => this.loading = false, 200)
this.init() this.init();
}, },
methods: { methods: {
parseTime, parseTime,
init() { init() {
let response = { listDept().then(res => {
"code": 200, console.log(res)
"msg": "操作成功", this.deptData = res.data
"data": [ this.deptList = this.handleTree(res.data, "deptId");
{ })
"createBy": 1, listUser().then(res => {
"createTime": "2023-09-29 11:47:27", console.log(res)
"updateBy": null, this.userList = res.data.rows
"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": []
}, },
{ setAuth() {
"createBy": 1, this.assetAccreditQueryReq.idType = this.idType
"createTime": "2023-09-29 11:47:27", this.assetAccreditQueryReq.dataType = this.dataType
"updateBy": null, listAssetAccredit(this.assetAccreditQueryReq).then(res => {
"updateTime": null, let data;
"deptId": 101, if (this.idType === 'dept') {
"parentId": 100, data = this.deptData
"ancestors": "0,100", } else {
"deptName": "深圳总公司", data = this.userList
"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": []
} }
] data.forEach(da => {
res.data.forEach(as => {
if (this.idType === 'dept' && da.deptId === as.accreditId && as.dataType === 'table' && this.baseInfo.childrenParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, 'assetAccreditId', as.id)
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'table' && this.baseInfo.childrenParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, "assetAccreditId", as.id)
} }
this.deptList = this.handleTree(response.data, "deptId"); })
this.userList = [ })
{ if (this.idType === 'dept') {
"createBy": "admin", this.deptList = this.handleTree(this.deptData, "deptId")
"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": "研发部门"
} }
})
}, },
{ accreditChange(val, row, id) {
"createBy": "admin", if (val) {
"createTime": "2023-04-23 16:11:38", addAccredit({
"updateBy": null, accreditId: id,
"updateTime": null, idType: this.idType,
"remark": "测试员", dataId: this.baseInfo.childrenParams.id,
"userId": 2, dataType: this.dataType
"deptId": 105, }).then(res => {
"userName": "ry", this.$message.success("授权成功")
"nickName": "数据处理", this.setAuth()
"email": "ry@qq.com", })
"phonenumber": "15666666666", } else {
"dept": { delAccredit(row.assetAccreditId).then(res => {
"deptName": "测试部门" this.$message.success("取消授权成功")
this.setAuth()
})
} }
} }
]
}
}, },
}; };
</script> </script>

View File

@ -1,194 +1,111 @@
<template> <template>
<div class="app-container"> <el-container :style="{height: mainHeight + 'px'}">
<h4 class="form-header h4">基本信息</h4> <el-aside>
<el-form ref="form" :model="assetParams" label-width="120px"> <el-tree :data="assetStructureList"
<el-row> :load="expandTable"
<el-col :offset="2" :span="8"> :expand-on-click-node="false"
<el-form-item label="数据接入名称" prop="nickName"> lazy
<el-input v-model="assetParams.name" disabled/> @node-click="showAssetsFun"
</el-form-item> :props="defaultProps">
</el-col> <div class="custom-tree-node" slot-scope="{ node, data }">
<el-col :offset="2" :span="8"> <div v-if="data.type === 'dataSource'">{{
<el-form-item label="系统名称" prop="userName"> data.name + '(' + data.databaseName + '-' + data.systemName + ')'
<el-input v-model="assetParams.systemName" disabled/> }}
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName">
<el-input v-model="assetParams.databaseName" disabled/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-model="idType">
<el-tab-pane label="部门授权" name="dept">
<el-table
ref="deptTable"
v-loading="loading"
:data="deptList"
:default-expand-all="true"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
>
<el-table-column label="部门名称" prop="deptName"></el-table-column>
<el-table-column label="部门负责人" prop="leader"></el-table-column>
<el-table-column label="邮箱" prop="email"></el-table-column>
<el-table-column align="center" label="创建时间" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" prop="createTime">
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.deptId)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</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"/>
<el-table-column align="center" label="用户昵称" prop="nickName"/>
<el-table-column align="center" label="用户部门" prop="dept.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"/>
<el-table-column align="center" label="操作" prop="createTime">
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="(val)=>accreditChange(val,scope.row,scope.row.userId)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</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-tabs>
</div> </div>
<div v-if="data.type === 'dataTable'">{{
data.name + '-' + data.annotation + '(' + data.dataTotal + '条)'
}}
</div>
</div>
</el-tree>
</el-aside>
<el-container>
<el-main>
<auth-data-source v-if="showAuth === 'dataSource'" :asset-params="baseInfo.assetParams"/>
<auth-table v-else-if="showAuth === 'dataTable'" :base-info="baseInfo"/>
</el-main>
</el-container>
</el-container>
</template> </template>
<script> <script>
import {parseTime} from '@/utils/muyu' import AuthDataSource from './auth/AuthDataSource.vue'
import {listUser} from "@/api/system/user"; import AuthTable from './auth/AuthTable.vue'
import {listDept} from "@/api/system/dept"; import {getAssetList, getChildrenList} from "@/api/source/data";
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/source/assetAccredit";
export default { export default {
name: "AuthDataSource", name: 'assetStructure',
props: { components: {AuthTable, AuthDataSource},
assetParams: {
type: Object,
default: {}
}
},
data() { data() {
return { return {
// mainHeight: window.innerHeight - 85,
loading: true, defaultProps: {
// children: 'childrenList',
total: 0, label: 'name'
pageNum: 1,
pageSize: 1,
//
deptList: [],
//
userList: [],
deptData: [],
idType: "dept",
dataType: "source",
assetAccreditQueryReq: {}
};
}, },
watch: { showAuth: null,
idType: { assetStructureList: [],
handler() { childrenList: [],
this.setAuth(); baseInfo: {
}, assetParams: {},
immediate: true childrenParams: {},
}
} }
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init();
}, },
methods: { methods: {
parseTime, expandTable(node, resolve) {
init() { if (node.level === 0) return resolve(this.assetStructureList);
listDept().then(res => { const {data} = node;
this.deptData = res.data if (data.type === 'dataSource') {
this.deptList = this.handleTree(res.data, "deptId"); this.baseInfo.assetParams = data
getChildrenList(data.id).then(res => {
this.childrenList = res.data
}) })
listUser().then(res => { }
console.log(res) if (data.type === 'dataTable') {
this.userList = res.data.rows this.baseInfo.childrenParams = data
}) return resolve([])
// setTimeout(() => { }
// this.setAuth(); setTimeout(() => {
// }, 600); resolve(this.childrenList)
}, 500);
}, },
setAuth() { showAssetsFun(data) {
this.assetAccreditQueryReq.idType = this.idType this.showAuth = data.type
this.assetAccreditQueryReq.dataType = this.dataType if (data.type === 'dataSource') {
listAssetAccredit(this.assetAccreditQueryReq).then(res => { this.baseInfo.assetParams = data
console.log(res) // getChildrenList(data.id).then(res => {
let data; // this.childrenList = res.data
if (this.idType === 'dept') { // })
data = this.deptData
} else {
data = this.userList
}
data.forEach(da => {
res.data.forEach(as => {
if (this.idType === 'dept' && da.deptId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, 'assetAccreditId', as.id)
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
this.$set(da, 'isAuth', true)
this.$set(da, "assetAccreditId", as.id)
}
})
})
if (this.idType === 'dept') {
this.deptList = this.handleTree(this.deptData, "deptId")
}
})
},
accreditChange(val, row, id) {
if (val) {
addAccredit({
accreditId: id,
idType: this.idType,
dataId: this.assetParams.id,
dataType: this.dataType
}).then(res => {
this.$message.success("授权成功")
this.setAuth()
})
} else {
delAccredit(row.assetAccreditId).then(res => {
this.$message.success("取消授权成功")
this.setAuth()
})
} }
if (data.type === 'dataTable') {
this.baseInfo.childrenParams = data
} }
}, },
}; getAssetStructureList() {
getAssetList().then(res => {
this.assetStructureList = res.data
})
},
},
created() {
this.getAssetStructureList()
}
}
</script> </script>
<style scoped lang="scss">
.el-aside {
margin: 0;
padding: 0;
width: 400px;
background-color: white;
}
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node {
height: 30px;
}
</style>