feat:资产授权修改
parent
8eb1ab16f0
commit
6338280a5e
|
@ -144,7 +144,7 @@
|
|||
<el-col :span="24">
|
||||
<el-form-item label="字典">
|
||||
<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>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -167,8 +167,8 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import {selectTableData, updTableData} from "@/api/data/source";
|
||||
import {getDictDataList} from "@/api/data/dictType";
|
||||
import {selectTableData, updTableData} from "@/api/source/data";
|
||||
import {getDictDataList} from "@/api/source/dictType";
|
||||
|
||||
export default {
|
||||
name: 'OverallAssetStructure',
|
||||
|
@ -208,6 +208,7 @@ export default {
|
|||
update(row) {
|
||||
this.form = row;
|
||||
this.formStatus = true;
|
||||
this.checkedDictData = [];
|
||||
},
|
||||
selectedDict() {
|
||||
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? []
|
||||
|
@ -217,7 +218,7 @@ export default {
|
|||
},
|
||||
editTableData() {
|
||||
if (this.form.isDict === 'N') {
|
||||
this.form.dictKey = null;
|
||||
this.form.dictKey = "";
|
||||
}
|
||||
updTableData(this.form).then(res => {
|
||||
this.$message.success("修改成功");
|
||||
|
|
|
@ -41,7 +41,7 @@ import {
|
|||
getTableDataCount,
|
||||
selectTableData,
|
||||
selectTableDataCount
|
||||
} from "@/api/data/source";
|
||||
} from "@/api/source/data";
|
||||
|
||||
export default {
|
||||
name: 'assetStructure',
|
||||
|
@ -56,7 +56,7 @@ export default {
|
|||
assetStructureList: [],
|
||||
childrenList: [],
|
||||
tableDataList: [],
|
||||
childrenParams: null,
|
||||
childrenParams: {},
|
||||
assetId: 0,
|
||||
showAssets: null,
|
||||
title: null,
|
||||
|
@ -79,10 +79,8 @@ export default {
|
|||
const {data} = node;
|
||||
if (data.type === 'dataSource') {
|
||||
this.assetId = data.id
|
||||
console.log(this.assetId)
|
||||
getChildrenList(data.id).then(res => {
|
||||
this.childrenList = res.data
|
||||
|
||||
})
|
||||
}
|
||||
// this.showAssets = data.type;
|
||||
|
@ -103,7 +101,6 @@ export default {
|
|||
this.showAssets = data.type;
|
||||
if (data.type === 'dataSource') {
|
||||
this.assetId = data.id
|
||||
console.log(this.assetId)
|
||||
getTableDataCount(data.id).then(res => {
|
||||
this.count = res.data
|
||||
})
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<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-col :offset="2" :span="8">
|
||||
<el-form-item label="数据接入名称" prop="nickName">
|
||||
<el-input v-model="baseInfo.name" disabled/>
|
||||
<el-input v-model="assetParams.name" disabled/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<el-form-item label="系统名称" prop="userName">
|
||||
<el-input v-model="baseInfo.systemName" disabled/>
|
||||
<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="baseInfo.databaseName" disabled/>
|
||||
<el-input v-model="assetParams.databaseName" disabled/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</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-table
|
||||
ref="deptTable"
|
||||
|
@ -31,19 +31,20 @@
|
|||
: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" >
|
||||
<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" >
|
||||
<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="已授权"
|
||||
|
@ -61,12 +62,13 @@
|
|||
<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" >
|
||||
<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="已授权"
|
||||
|
@ -83,262 +85,109 @@
|
|||
|
||||
<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 {
|
||||
name: "AuthDataSource",
|
||||
props: {
|
||||
assetParams: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
activeName: "dept",
|
||||
// 分页信息
|
||||
total: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
// 基本信息
|
||||
baseInfo: {
|
||||
name: "测试1",
|
||||
systemName: "云计算系统",
|
||||
databaseName: "yunjisuan",
|
||||
},
|
||||
// 部门列表
|
||||
deptList: [],
|
||||
// 用户列表
|
||||
userList: []
|
||||
userList: [],
|
||||
deptData: [],
|
||||
idType: "dept",
|
||||
dataType: "source",
|
||||
assetAccreditQueryReq: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
idType: {
|
||||
handler() {
|
||||
this.setAuth();
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loading = true;
|
||||
setTimeout(() => this.loading = false, 200)
|
||||
this.init()
|
||||
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": "测试部门"
|
||||
}
|
||||
init() {
|
||||
listDept().then(res => {
|
||||
this.deptData = res.data
|
||||
this.deptList = this.handleTree(res.data, "deptId");
|
||||
})
|
||||
listUser().then(res => {
|
||||
console.log(res)
|
||||
this.userList = res.data.rows
|
||||
})
|
||||
// setTimeout(() => {
|
||||
// this.setAuth();
|
||||
// }, 600);
|
||||
},
|
||||
setAuth() {
|
||||
this.assetAccreditQueryReq.idType = this.idType
|
||||
this.assetAccreditQueryReq.dataType = this.dataType
|
||||
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
||||
console.log(res)
|
||||
let 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()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -5,38 +5,38 @@
|
|||
<el-row>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<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-col>
|
||||
</el-row>
|
||||
</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-table
|
||||
ref="deptTable"
|
||||
|
@ -46,19 +46,20 @@
|
|||
: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" >
|
||||
<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" >
|
||||
<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="已授权"
|
||||
|
@ -76,12 +77,13 @@
|
|||
<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" >
|
||||
<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="已授权"
|
||||
|
@ -98,265 +100,106 @@
|
|||
|
||||
<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 {
|
||||
name: "AuthTable",
|
||||
props: {
|
||||
baseInfo: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
activeName: "dept",
|
||||
// 分页信息
|
||||
total: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
// 基本信息
|
||||
baseInfo: {
|
||||
name: "测试1",
|
||||
systemName: "云计算系统",
|
||||
databaseName: "yunjisuan",
|
||||
tableName: "sys_user",
|
||||
tableAsName: "用户表",
|
||||
total: "12546条",
|
||||
},
|
||||
// 部门列表
|
||||
deptList: [],
|
||||
// 用户列表
|
||||
userList: []
|
||||
userList: [],
|
||||
deptData: [],
|
||||
idType: "dept",
|
||||
dataType: "table",
|
||||
assetAccreditQueryReq: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
idType: {
|
||||
handler() {
|
||||
this.setAuth();
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loading = true;
|
||||
setTimeout(() => this.loading = false, 200)
|
||||
this.init()
|
||||
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": "测试部门"
|
||||
}
|
||||
init() {
|
||||
listDept().then(res => {
|
||||
console.log(res)
|
||||
this.deptData = res.data
|
||||
this.deptList = this.handleTree(res.data, "deptId");
|
||||
})
|
||||
listUser().then(res => {
|
||||
console.log(res)
|
||||
this.userList = res.data.rows
|
||||
})
|
||||
},
|
||||
setAuth() {
|
||||
this.assetAccreditQueryReq.idType = this.idType
|
||||
this.assetAccreditQueryReq.dataType = this.dataType
|
||||
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
||||
let 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 === '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)
|
||||
}
|
||||
})
|
||||
})
|
||||
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.baseInfo.childrenParams.id,
|
||||
dataType: this.dataType
|
||||
}).then(res => {
|
||||
this.$message.success("授权成功")
|
||||
this.setAuth()
|
||||
})
|
||||
} else {
|
||||
delAccredit(row.assetAccreditId).then(res => {
|
||||
this.$message.success("取消授权成功")
|
||||
this.setAuth()
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,194 +1,111 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<h4 class="form-header h4">基本信息</h4>
|
||||
<el-form ref="form" :model="assetParams" label-width="120px">
|
||||
<el-row>
|
||||
<el-col :offset="2" :span="8">
|
||||
<el-form-item label="数据接入名称" prop="nickName">
|
||||
<el-input v-model="assetParams.name" disabled/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :offset="2" :span="8">
|
||||
<el-form-item label="系统名称" prop="userName">
|
||||
<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>
|
||||
<el-container :style="{height: mainHeight + 'px'}">
|
||||
<el-aside>
|
||||
<el-tree :data="assetStructureList"
|
||||
:load="expandTable"
|
||||
:expand-on-click-node="false"
|
||||
lazy
|
||||
@node-click="showAssetsFun"
|
||||
:props="defaultProps">
|
||||
<div class="custom-tree-node" slot-scope="{ node, data }">
|
||||
<div v-if="data.type === 'dataSource'">{{
|
||||
data.name + '(' + data.databaseName + '-' + data.systemName + ')'
|
||||
}}
|
||||
</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>
|
||||
|
||||
<script>
|
||||
|
||||
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";
|
||||
import AuthDataSource from './auth/AuthDataSource.vue'
|
||||
import AuthTable from './auth/AuthTable.vue'
|
||||
import {getAssetList, getChildrenList} from "@/api/source/data";
|
||||
|
||||
export default {
|
||||
name: "AuthDataSource",
|
||||
props: {
|
||||
assetParams: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
},
|
||||
name: 'assetStructure',
|
||||
components: {AuthTable, AuthDataSource},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 分页信息
|
||||
total: 0,
|
||||
pageNum: 1,
|
||||
pageSize: 1,
|
||||
// 部门列表
|
||||
deptList: [],
|
||||
// 用户列表
|
||||
userList: [],
|
||||
deptData: [],
|
||||
idType: "dept",
|
||||
dataType: "source",
|
||||
assetAccreditQueryReq: {}
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
idType: {
|
||||
handler() {
|
||||
this.setAuth();
|
||||
mainHeight: window.innerHeight - 85,
|
||||
defaultProps: {
|
||||
children: 'childrenList',
|
||||
label: 'name'
|
||||
},
|
||||
immediate: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.loading = true;
|
||||
setTimeout(() => this.loading = false, 200)
|
||||
this.init();
|
||||
},
|
||||
methods: {
|
||||
parseTime,
|
||||
init() {
|
||||
listDept().then(res => {
|
||||
this.deptData = res.data
|
||||
this.deptList = this.handleTree(res.data, "deptId");
|
||||
})
|
||||
listUser().then(res => {
|
||||
console.log(res)
|
||||
this.userList = res.data.rows
|
||||
})
|
||||
// setTimeout(() => {
|
||||
// this.setAuth();
|
||||
// }, 600);
|
||||
},
|
||||
setAuth() {
|
||||
this.assetAccreditQueryReq.idType = this.idType
|
||||
this.assetAccreditQueryReq.dataType = this.dataType
|
||||
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
||||
console.log(res)
|
||||
let 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()
|
||||
})
|
||||
showAuth: null,
|
||||
assetStructureList: [],
|
||||
childrenList: [],
|
||||
baseInfo: {
|
||||
assetParams: {},
|
||||
childrenParams: {},
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
methods: {
|
||||
expandTable(node, resolve) {
|
||||
if (node.level === 0) return resolve(this.assetStructureList);
|
||||
const {data} = node;
|
||||
if (data.type === 'dataSource') {
|
||||
this.baseInfo.assetParams = data
|
||||
getChildrenList(data.id).then(res => {
|
||||
this.childrenList = res.data
|
||||
})
|
||||
}
|
||||
if (data.type === 'dataTable') {
|
||||
this.baseInfo.childrenParams = data
|
||||
return resolve([])
|
||||
}
|
||||
setTimeout(() => {
|
||||
resolve(this.childrenList)
|
||||
}, 500);
|
||||
},
|
||||
showAssetsFun(data) {
|
||||
this.showAuth = data.type
|
||||
if (data.type === 'dataSource') {
|
||||
this.baseInfo.assetParams = data
|
||||
// getChildrenList(data.id).then(res => {
|
||||
// this.childrenList = res.data
|
||||
// })
|
||||
}
|
||||
if (data.type === 'dataTable') {
|
||||
this.baseInfo.childrenParams = data
|
||||
}
|
||||
},
|
||||
getAssetStructureList() {
|
||||
getAssetList().then(res => {
|
||||
this.assetStructureList = res.data
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.getAssetStructureList()
|
||||
}
|
||||
}
|
||||
</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>
|
||||
|
|
Loading…
Reference in New Issue