feat:完善资产授权
parent
6338280a5e
commit
b3b6a8fb7f
|
@ -20,9 +20,9 @@ export function getAsset_auth(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加字典类型
|
//添加字典类型
|
||||||
export function addAccredis(data){
|
export function addAccredit(data){
|
||||||
return request({
|
return request({
|
||||||
url:'/data/source/dictType/addDictType',
|
url:'/data/asset_auth/add',
|
||||||
method:'post',
|
method:'post',
|
||||||
data:data
|
data:data
|
||||||
})
|
})
|
||||||
|
@ -30,8 +30,8 @@ export function addAccredis(data){
|
||||||
// 删除字典类型
|
// 删除字典类型
|
||||||
export function delAccredit(id) {
|
export function delAccredit(id) {
|
||||||
return request({
|
return request({
|
||||||
url: '/data/source/dictType/delDictType/' + id,
|
url: '/data/asset_auth/deletes/' + id,
|
||||||
method: 'get'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,3 +24,11 @@ export function delDictType(id) {
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 根据对象查询字典数据列表
|
||||||
|
export function getDictData(data) {
|
||||||
|
return request({
|
||||||
|
url: 'data/source/dictType/getDictData',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -144,14 +144,14 @@
|
||||||
<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.dictType" :label="dict.dictType"
|
<el-option v-for="dict 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>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-table :data="checkedDictData" striped border>
|
<el-table :data="dictDataList" striped border>
|
||||||
<el-table-column property="dictLabel" label="字典标签"/>
|
<el-table-column property="dictLabel" label="字典标签"/>
|
||||||
<el-table-column property="dictValue" label="字典值"/>
|
<el-table-column property="dictValue" label="字典值"/>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
@ -160,15 +160,15 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button @click="formStatus = false">取 消</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
<el-button type="primary" @click="editTableData">确 定</el-button>
|
<el-button type="primary" @click="editTableData">确 定</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {selectTableData, updTableData} from "@/api/source/data";
|
import {selectTableData, updTableData} from "@/api/data/source";
|
||||||
import {getDictDataList} from "@/api/source/dictType";
|
import {getDictData, getDictDataList} from "@/api/data/dictType";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'OverallAssetStructure',
|
name: 'OverallAssetStructure',
|
||||||
|
@ -196,7 +196,9 @@ export default {
|
||||||
form: {},
|
form: {},
|
||||||
formStatus: false,
|
formStatus: false,
|
||||||
checkedDictData: [],
|
checkedDictData: [],
|
||||||
dictMap: []
|
dictDataList: [],
|
||||||
|
dictMap: [],
|
||||||
|
dictTypeReq: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -208,14 +210,31 @@ export default {
|
||||||
update(row) {
|
update(row) {
|
||||||
this.form = row;
|
this.form = row;
|
||||||
this.formStatus = true;
|
this.formStatus = true;
|
||||||
this.checkedDictData = [];
|
this.getDictData()
|
||||||
|
if (row.dictKey !== "") {
|
||||||
|
this.dictTypeReq.assetId = this.assetId
|
||||||
|
this.dictTypeReq.dictType = row.dictKey
|
||||||
|
getDictData(this.dictTypeReq).then(res => {
|
||||||
|
this.dictDataList = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectedDict() {
|
selectedDict(row) {
|
||||||
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? []
|
// this.dictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? []
|
||||||
|
this.dictTypeReq.assetId = this.assetId
|
||||||
|
this.dictTypeReq.dictType = row
|
||||||
|
getDictData(this.dictTypeReq).then(res => {
|
||||||
|
this.dictDataList = res.data
|
||||||
|
})
|
||||||
},
|
},
|
||||||
selectDictData(dictKey) {
|
selectDictData(dictKey) {
|
||||||
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === dictKey)[0].dictData ?? []
|
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === dictKey)[0].dictData ?? []
|
||||||
},
|
},
|
||||||
|
cancel() {
|
||||||
|
this.formStatus = false
|
||||||
|
this.init()
|
||||||
|
this.dictDataList = []
|
||||||
|
},
|
||||||
editTableData() {
|
editTableData() {
|
||||||
if (this.form.isDict === 'N') {
|
if (this.form.isDict === 'N') {
|
||||||
this.form.dictKey = "";
|
this.form.dictKey = "";
|
||||||
|
|
|
@ -209,7 +209,7 @@ export default {
|
||||||
checkTableName(checkTab) {
|
checkTableName(checkTab) {
|
||||||
console.log(checkTab)
|
console.log(checkTab)
|
||||||
this.childrenParams = this.childrenList.findLast(item => item.name === checkTab.name)
|
this.childrenParams = this.childrenList.findLast(item => item.name === checkTab.name)
|
||||||
console.log(this.childrenParams)
|
// console.log(this.childrenParams)
|
||||||
},
|
},
|
||||||
// 添加字典按钮
|
// 添加字典按钮
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ import {
|
||||||
getTableDataCount,
|
getTableDataCount,
|
||||||
selectTableData,
|
selectTableData,
|
||||||
selectTableDataCount
|
selectTableDataCount
|
||||||
} from "@/api/source/data";
|
} from "@/api/data/source";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'assetStructure',
|
name: 'assetStructure',
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
import {parseTime} from '@/utils/muyu'
|
import {parseTime} from '@/utils/muyu'
|
||||||
import {listUser} from "@/api/system/user";
|
import {listUser} from "@/api/system/user";
|
||||||
import {listDept} from "@/api/system/dept";
|
import {listDept} from "@/api/system/dept";
|
||||||
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/source/assetAccredit";
|
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/data/asset_auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "AuthDataSource",
|
name: "AuthDataSource",
|
||||||
|
@ -112,7 +112,7 @@ export default {
|
||||||
userList: [],
|
userList: [],
|
||||||
deptData: [],
|
deptData: [],
|
||||||
idType: "dept",
|
idType: "dept",
|
||||||
dataType: "source",
|
authType: "source",
|
||||||
assetAccreditQueryReq: {}
|
assetAccreditQueryReq: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -146,7 +146,7 @@ export default {
|
||||||
},
|
},
|
||||||
setAuth() {
|
setAuth() {
|
||||||
this.assetAccreditQueryReq.idType = this.idType
|
this.assetAccreditQueryReq.idType = this.idType
|
||||||
this.assetAccreditQueryReq.dataType = this.dataType
|
this.assetAccreditQueryReq.authType = this.authType
|
||||||
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
let data;
|
let data;
|
||||||
|
@ -157,12 +157,12 @@ export default {
|
||||||
}
|
}
|
||||||
data.forEach(da => {
|
data.forEach(da => {
|
||||||
res.data.forEach(as => {
|
res.data.forEach(as => {
|
||||||
if (this.idType === 'dept' && da.deptId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
|
if (this.idType === 'dept' && da.deptId === as.authId && this.assetParams.id === parseInt(as.authData)) {
|
||||||
this.$set(da, 'isAuth', true)
|
this.$set(da, 'isAuth', true)
|
||||||
this.$set(da, 'assetAccreditId', as.id)
|
this.$set(da, 'authId', as.id)
|
||||||
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
|
} else if (this.idType === 'user' && da.userId === as.authId && this.assetParams.id === parseInt(as.authData)) {
|
||||||
this.$set(da, 'isAuth', true)
|
this.$set(da, 'isAuth', true)
|
||||||
this.$set(da, "assetAccreditId", as.id)
|
this.$set(da, "authId", as.id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -174,10 +174,10 @@ export default {
|
||||||
accreditChange(val, row, id) {
|
accreditChange(val, row, id) {
|
||||||
if (val) {
|
if (val) {
|
||||||
addAccredit({
|
addAccredit({
|
||||||
accreditId: id,
|
authId: id,
|
||||||
idType: this.idType,
|
idType: this.idType,
|
||||||
dataId: this.assetParams.id,
|
authData: this.assetParams.id,
|
||||||
dataType: this.dataType
|
authType: this.authType
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.$message.success("授权成功")
|
this.$message.success("授权成功")
|
||||||
this.setAuth()
|
this.setAuth()
|
||||||
|
|
|
@ -103,7 +103,7 @@
|
||||||
import {parseTime} from '@/utils/muyu'
|
import {parseTime} from '@/utils/muyu'
|
||||||
import {listDept} from "@/api/system/dept";
|
import {listDept} from "@/api/system/dept";
|
||||||
import {listUser} from "@/api/system/user";
|
import {listUser} from "@/api/system/user";
|
||||||
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/source/assetAccredit";
|
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/data/asset_auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "AuthTable",
|
name: "AuthTable",
|
||||||
|
@ -127,7 +127,7 @@ export default {
|
||||||
userList: [],
|
userList: [],
|
||||||
deptData: [],
|
deptData: [],
|
||||||
idType: "dept",
|
idType: "dept",
|
||||||
dataType: "table",
|
authType: "table",
|
||||||
assetAccreditQueryReq: {}
|
assetAccreditQueryReq: {}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -159,7 +159,7 @@ export default {
|
||||||
},
|
},
|
||||||
setAuth() {
|
setAuth() {
|
||||||
this.assetAccreditQueryReq.idType = this.idType
|
this.assetAccreditQueryReq.idType = this.idType
|
||||||
this.assetAccreditQueryReq.dataType = this.dataType
|
this.assetAccreditQueryReq.authType = this.authType
|
||||||
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
|
||||||
let data;
|
let data;
|
||||||
if (this.idType === 'dept') {
|
if (this.idType === 'dept') {
|
||||||
|
@ -169,12 +169,13 @@ export default {
|
||||||
}
|
}
|
||||||
data.forEach(da => {
|
data.forEach(da => {
|
||||||
res.data.forEach(as => {
|
res.data.forEach(as => {
|
||||||
if (this.idType === 'dept' && da.deptId === as.accreditId && as.dataType === 'table' && this.baseInfo.childrenParams.id === as.dataId) {
|
let tableName = as.authData.split(',')[1]
|
||||||
|
if (this.idType === 'dept' && da.deptId === as.authId && this.baseInfo.childrenParams.name === tableName) {
|
||||||
this.$set(da, 'isAuth', true)
|
this.$set(da, 'isAuth', true)
|
||||||
this.$set(da, 'assetAccreditId', as.id)
|
this.$set(da, 'authId', as.id)
|
||||||
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'table' && this.baseInfo.childrenParams.id === as.dataId) {
|
} else if (this.idType === 'user' && da.userId === as.authId && this.baseInfo.childrenParams.name === tableName) {
|
||||||
this.$set(da, 'isAuth', true)
|
this.$set(da, 'isAuth', true)
|
||||||
this.$set(da, "assetAccreditId", as.id)
|
this.$set(da, "authId", as.id)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -186,10 +187,10 @@ export default {
|
||||||
accreditChange(val, row, id) {
|
accreditChange(val, row, id) {
|
||||||
if (val) {
|
if (val) {
|
||||||
addAccredit({
|
addAccredit({
|
||||||
accreditId: id,
|
authId: id,
|
||||||
idType: this.idType,
|
idType: this.idType,
|
||||||
dataId: this.baseInfo.childrenParams.id,
|
authData: this.baseInfo.assetParams.id + ',' + this.baseInfo.childrenParams.name,
|
||||||
dataType: this.dataType
|
authType: this.authType
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.$message.success("授权成功")
|
this.$message.success("授权成功")
|
||||||
this.setAuth()
|
this.setAuth()
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
|
|
||||||
import AuthDataSource from './auth/AuthDataSource.vue'
|
import AuthDataSource from './auth/AuthDataSource.vue'
|
||||||
import AuthTable from './auth/AuthTable.vue'
|
import AuthTable from './auth/AuthTable.vue'
|
||||||
import {getAssetList, getChildrenList} from "@/api/source/data";
|
import {getAssetList, getChildrenList} from "@/api/data/source";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'assetStructure',
|
name: 'assetStructure',
|
||||||
|
|
|
@ -0,0 +1,155 @@
|
||||||
|
<template>
|
||||||
|
<el-container :style="{height: mainHeight + 'px'}">
|
||||||
|
<el-aside>
|
||||||
|
<el-tree :data="assetStructureList"
|
||||||
|
:load="expandTable"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
lazy
|
||||||
|
@node-click="(data) => showAuth=data.type"
|
||||||
|
: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.as + '(' + data.dataTotal+'条)' }}</div>
|
||||||
|
</div>
|
||||||
|
</el-tree>
|
||||||
|
</el-aside>
|
||||||
|
<el-container>
|
||||||
|
<el-main>
|
||||||
|
<el-card>
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>资产模型基本信息</span>
|
||||||
|
</div>
|
||||||
|
<el-descriptions border :column="2">
|
||||||
|
<el-descriptions-item label="表名称">sys_user</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="表备注">用户表</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="数据量">12536</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否核心">
|
||||||
|
<el-tag size="small">是</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="box-card" style="margin-top: 20px">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>模型数据</span>
|
||||||
|
</div>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="6" v-for="asset in assetShowList" style="margin-top: 20px">
|
||||||
|
<el-descriptions :title="asset.key" direction="vertical" border :column="1">
|
||||||
|
<el-descriptions-item label="Type">
|
||||||
|
<el-tag size="small">{{asset.type}}</el-tag>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="Value">{{asset.value}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
</el-card>
|
||||||
|
</el-main>
|
||||||
|
</el-container>
|
||||||
|
</el-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "AssetShow",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
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: []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
assetShowList: [
|
||||||
|
{key: "测试.sys_user.id", type: "String", value: 1},
|
||||||
|
{key: "测试.sys_user.name", type: "String", value: "张三"},
|
||||||
|
{key: "测试.sys_user.age", type: "Integer", value: 18},
|
||||||
|
{key: "测试.sys_user.email", type: "String", value: "123@136.com"},
|
||||||
|
{key: "测试.sys_user.sex", type: "String", value: "Y"},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
expandTable( node, resolve){
|
||||||
|
if (node.level === 0) return resolve(this.assetStructureList);
|
||||||
|
const {data} = node;
|
||||||
|
if (data.type === 'dataTable') {
|
||||||
|
return resolve([])
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
resolve(this.childrenList)
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.el-aside {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 400px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
.el-main {
|
||||||
|
background-color: #f1f1f1;
|
||||||
|
}
|
||||||
|
.custom-tree-node{
|
||||||
|
height: 30px;
|
||||||
|
}
|
||||||
|
.el-descriptions-row>th{
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in New Issue