feat:完善资产授权

ruoyi_test
sunshine7058 2024-05-04 14:20:18 +08:00
parent 6338280a5e
commit b3b6a8fb7f
9 changed files with 219 additions and 36 deletions

View File

@ -20,9 +20,9 @@ export function getAsset_auth(id) {
}
//添加字典类型
export function addAccredis(data){
export function addAccredit(data){
return request({
url:'/data/source/dictType/addDictType',
url:'/data/asset_auth/add',
method:'post',
data:data
})
@ -30,8 +30,8 @@ export function addAccredis(data){
// 删除字典类型
export function delAccredit(id) {
return request({
url: '/data/source/dictType/delDictType/' + id,
method: 'get'
url: '/data/asset_auth/deletes/' + id,
method: 'delete'
})
}

View File

@ -24,3 +24,11 @@ export function delDictType(id) {
method: 'get'
})
}
// 根据对象查询字典数据列表
export function getDictData(data) {
return request({
url: 'data/source/dictType/getDictData',
method: 'post',
data: data
})
}

View File

@ -144,14 +144,14 @@
<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.dictType" :label="dict.dictType"
<el-option v-for="dict in dictMap" :key="dict.dictType" :label="dict.dictType"
:value="dict.dictType"></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<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="dictValue" label="字典值"/>
</el-table>
@ -160,15 +160,15 @@
</el-row>
</el-form>
<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>
</div>
</el-dialog>
</div>
</template>
<script>
import {selectTableData, updTableData} from "@/api/source/data";
import {getDictDataList} from "@/api/source/dictType";
import {selectTableData, updTableData} from "@/api/data/source";
import {getDictData, getDictDataList} from "@/api/data/dictType";
export default {
name: 'OverallAssetStructure',
@ -196,7 +196,9 @@ export default {
form: {},
formStatus: false,
checkedDictData: [],
dictMap: []
dictDataList: [],
dictMap: [],
dictTypeReq: {}
}
},
methods: {
@ -208,14 +210,31 @@ export default {
update(row) {
this.form = row;
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() {
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === this.form.dictKey)[0].dictData ?? []
selectedDict(row) {
// 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) {
this.checkedDictData = this.dictMap.filter(dict => dict.dictType === dictKey)[0].dictData ?? []
},
cancel() {
this.formStatus = false
this.init()
this.dictDataList = []
},
editTableData() {
if (this.form.isDict === 'N') {
this.form.dictKey = "";

View File

@ -209,7 +209,7 @@ export default {
checkTableName(checkTab) {
console.log(checkTab)
this.childrenParams = this.childrenList.findLast(item => item.name === checkTab.name)
console.log(this.childrenParams)
// console.log(this.childrenParams)
},
//
handleAdd() {

View File

@ -41,7 +41,7 @@ import {
getTableDataCount,
selectTableData,
selectTableDataCount
} from "@/api/source/data";
} from "@/api/data/source";
export default {
name: 'assetStructure',

View File

@ -88,7 +88,7 @@
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 {addAccredit, delAccredit, listAssetAccredit} from "@/api/data/asset_auth";
export default {
name: "AuthDataSource",
@ -112,7 +112,7 @@ export default {
userList: [],
deptData: [],
idType: "dept",
dataType: "source",
authType: "source",
assetAccreditQueryReq: {}
};
},
@ -146,7 +146,7 @@ export default {
},
setAuth() {
this.assetAccreditQueryReq.idType = this.idType
this.assetAccreditQueryReq.dataType = this.dataType
this.assetAccreditQueryReq.authType = this.authType
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
console.log(res)
let data;
@ -157,12 +157,12 @@ export default {
}
data.forEach(da => {
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, 'assetAccreditId', as.id)
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'source' && this.assetParams.id === as.dataId) {
this.$set(da, 'authId', as.id)
} else if (this.idType === 'user' && da.userId === as.authId && this.assetParams.id === parseInt(as.authData)) {
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) {
if (val) {
addAccredit({
accreditId: id,
authId: id,
idType: this.idType,
dataId: this.assetParams.id,
dataType: this.dataType
authData: this.assetParams.id,
authType: this.authType
}).then(res => {
this.$message.success("授权成功")
this.setAuth()

View File

@ -103,7 +103,7 @@
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";
import {addAccredit, delAccredit, listAssetAccredit} from "@/api/data/asset_auth";
export default {
name: "AuthTable",
@ -127,7 +127,7 @@ export default {
userList: [],
deptData: [],
idType: "dept",
dataType: "table",
authType: "table",
assetAccreditQueryReq: {}
};
},
@ -159,7 +159,7 @@ export default {
},
setAuth() {
this.assetAccreditQueryReq.idType = this.idType
this.assetAccreditQueryReq.dataType = this.dataType
this.assetAccreditQueryReq.authType = this.authType
listAssetAccredit(this.assetAccreditQueryReq).then(res => {
let data;
if (this.idType === 'dept') {
@ -169,12 +169,13 @@ export default {
}
data.forEach(da => {
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, 'assetAccreditId', as.id)
} else if (this.idType === 'user' && da.userId === as.accreditId && as.dataType === 'table' && this.baseInfo.childrenParams.id === as.dataId) {
this.$set(da, 'authId', as.id)
} else if (this.idType === 'user' && da.userId === as.authId && this.baseInfo.childrenParams.name === tableName) {
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) {
if (val) {
addAccredit({
accreditId: id,
authId: id,
idType: this.idType,
dataId: this.baseInfo.childrenParams.id,
dataType: this.dataType
authData: this.baseInfo.assetParams.id + ',' + this.baseInfo.childrenParams.name,
authType: this.authType
}).then(res => {
this.$message.success("授权成功")
this.setAuth()

View File

@ -31,7 +31,7 @@
import AuthDataSource from './auth/AuthDataSource.vue'
import AuthTable from './auth/AuthTable.vue'
import {getAssetList, getChildrenList} from "@/api/source/data";
import {getAssetList, getChildrenList} from "@/api/data/source";
export default {
name: 'assetStructure',

View File

@ -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>