From 44c247cdeac9f0359f636db6544503edf519cd3c Mon Sep 17 00:00:00 2001 From: yaoxin <1752800946@qq.com> Date: Fri, 26 Apr 2024 17:54:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E4=BA=86=E8=B5=84?= =?UTF-8?q?=E4=BA=A7=E6=8E=88=E6=9D=83=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 资产授权功能包括,数据源分别给部门和用户的授权,数据源下的表分别给部门和用户的授权,以及给父级部门授权时,也会给此部门所有自己部门授权,取消授权也一样,用户授权也实现了,用户只能查看已授权的数据源和数据源下的表信息 --- src/api/etl/assetAccredit.js | 19 +- src/api/etl/sourceAccredit.js | 19 +- src/layout/components/Navbar.vue | 2 +- .../auth/AuthDataSource.vue | 327 +++++------------- .../etl/assetAuthorization/auth/AuthTable.vue | 132 ++++--- .../dashboard/OverallAssetStructure.vue | 2 +- .../etl/assets/dashboard/OverallAssets.vue | 4 +- .../dashboard/OverallSpecificAssets.vue | 2 +- 8 files changed, 222 insertions(+), 285 deletions(-) diff --git a/src/api/etl/assetAccredit.js b/src/api/etl/assetAccredit.js index 44bb71f..fa28aa9 100644 --- a/src/api/etl/assetAccredit.js +++ b/src/api/etl/assetAccredit.js @@ -9,6 +9,14 @@ export function listAccredit(query) { }) } +// 根据表id查询授权信息 +export function getAssetAccreditByDataAssetId(id) { + return request({ + url: '/etl/assetAccredit/GetAssetAccreditByDataAssetId?id='+id, + method: 'get' + }) +} + // 查询【请填写功能名称】详细 export function getAccredit(id) { return request({ @@ -18,7 +26,7 @@ export function getAccredit(id) { } // 新增【请填写功能名称】 -export function addAccredit(data) { +export function addAssetAccredit(data) { return request({ url: '/etl/assetAccredit', method: 'post', @@ -26,6 +34,15 @@ export function addAccredit(data) { }) } +// 新增【请填写功能名称】 +export function deleteAssetAccreditByAssetIds(data) { + return request({ + url: '/etl/assetAccredit/DeleteAssetAccreditByAssetIds', + method: 'post', + data: data + }) +} + // 修改【请填写功能名称】 export function updateAccredit(data) { return request({ diff --git a/src/api/etl/sourceAccredit.js b/src/api/etl/sourceAccredit.js index 16c5188..296d9b9 100644 --- a/src/api/etl/sourceAccredit.js +++ b/src/api/etl/sourceAccredit.js @@ -9,6 +9,14 @@ export function listAccredit(query) { }) } +// 根据数据源id查询授权信息 +export function getSourceAccreditByDataSourceId(id) { + return request({ + url: '/etl/sourceAccredit/GetSourceAccreditByDataSourceId?id='+id, + method: 'get' + }) +} + // 查询【请填写功能名称】详细 export function getAccredit(id) { return request({ @@ -18,7 +26,7 @@ export function getAccredit(id) { } // 新增【请填写功能名称】 -export function addAccredit(data) { +export function addSourceAccredit(data) { return request({ url: '/etl/sourceAccredit', method: 'post', @@ -26,6 +34,15 @@ export function addAccredit(data) { }) } +// 新增【请填写功能名称】 +export function deleteSourceAccreditBySourceIds(data) { + return request({ + url: '/etl/sourceAccredit/DeleteSourceAccreditBySourceIds', + method: 'post', + data: data + }) +} + // 修改【请填写功能名称】 export function updateAccredit(data) { return request({ diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 9ed9dd8..c409417 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -64,7 +64,7 @@ - + diff --git a/src/views/etl/assetAuthorization/auth/AuthDataSource.vue b/src/views/etl/assetAuthorization/auth/AuthDataSource.vue index 33de822..716fbe8 100644 --- a/src/views/etl/assetAuthorization/auth/AuthDataSource.vue +++ b/src/views/etl/assetAuthorization/auth/AuthDataSource.vue @@ -44,6 +44,7 @@ - @@ -67,6 +67,7 @@ - + @@ -86,8 +87,22 @@ import { parseTime } from '@/utils/muyu' import {listDept} from "@/api/system/dept"; import {listUser} from "@/api/system/user"; +import { + addAccredit, + addSourceAccredit, + deleteSourceAccreditBySourceIds, + getSourceAccreditByDataSourceId +} from "@/api/etl/sourceAccredit"; export default { + watch:{ + 'title':{ + handler(val) { + this.getSourceAccreditByDataSourceId() + }, + immediate: true + } + }, props:{ title:{} }, @@ -103,31 +118,97 @@ export default { pageSize: 10, total: 0 }, + sourceAccreditReq:{ + deptIds: null, + userId: null, + dataSourceId: null + }, // 基本信息 baseInfo: { - name: "测试1", - systemName: "云计算系统", - databaseName: "yunjisuan", }, // 部门列表 deptList: [], // 用户列表 - userList: [] + userList: [], + userAccreditIds: [], + deptAccreditIds: [] }; }, created() { this.loading = true; setTimeout(() => this.loading = false, 200) - this.getList() - this.getUserList() }, methods: { + recursion(deptInfo){ + let ids =[] + ids.push(deptInfo.deptId) + if (deptInfo.children){ + deptInfo.children.forEach(item => { + ids.push(item.deptId) + if (item.children){ + ids.push(...this.recursion(item)) + } + }) + } + return ids + }, + authChange(row) { + this.sourceAccreditReq={ + deptIds:null, + userId: null, + dataSourceId: null + } + if (row.nickName){ + this.sourceAccreditReq.userId = row.userId + this.sourceAccreditReq.dataSourceId = this.title.id + }else{ + let ids=this.recursion(row) + const uniqueIds = [...new Set(ids)]; + this.sourceAccreditReq.deptIds = uniqueIds + this.sourceAccreditReq.dataSourceId = this.title.id + } + if (row.isAuth){ + addSourceAccredit(this.sourceAccreditReq).then(res => { + this.getSourceAccreditByDataSourceId() + }) + }else{ + deleteSourceAccreditBySourceIds(this.sourceAccreditReq).then(res => { + this.getSourceAccreditByDataSourceId() + }) + } + + }, parseTime, + getSourceAccreditByDataSourceId(){ + if (this.title.id != undefined){ + getSourceAccreditByDataSourceId(this.title.id).then(response => { + this.deptAccreditIds = response.data.deptAccreditModelIds + this.userAccreditIds = response.data.userAccreditModelIds + setTimeout(() => this.getList(), 50) + setTimeout(() => this.getUserList(), 50) + }) + } + + }, + recursionAuth(deptInfo){ + deptInfo.isAuth = this.deptAccreditIds.indexOf(deptInfo.deptId) > -1 + if (deptInfo.children){ + deptInfo.children.forEach(item => { + item.isAuth = this.deptAccreditIds.indexOf(item.deptId) > -1 + if (item.children){ + this.recursionAuth(item) + } + }) + } + }, /** 查询部门列表 */ getList() { listDept(this.queryParams).then(response => { - console.log(response.data) this.deptList = this.handleTree(response.data, "deptId"); + this.deptList.forEach(dept => { + // dept.isAuth = this.deptAccreditIds.indexOf(dept.deptId) > -1 + this.recursionAuth(dept) + }) console.log(this.deptList) this.loading = false; }); @@ -136,235 +217,13 @@ export default { getUserList() { listUser(this.addDateRange(this.userQueryParams, [])).then(response => { this.userList = response.data.rows; + this.userList.forEach(user => { + user.isAuth = this.userAccreditIds.indexOf(user.userId) > -1 + }) this.userQueryParams.total = response.data.total; } ); }, - 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": "测试部门" - } - } - ] - } }, }; diff --git a/src/views/etl/assetAuthorization/auth/AuthTable.vue b/src/views/etl/assetAuthorization/auth/AuthTable.vue index 659ac55..ccc91fd 100644 --- a/src/views/etl/assetAuthorization/auth/AuthTable.vue +++ b/src/views/etl/assetAuthorization/auth/AuthTable.vue @@ -59,6 +59,7 @@ this.loading = false, 200) - this.getList() - this.getUserList() }, methods: { + recursion(deptInfo){ + let ids =[] + ids.push(deptInfo.deptId) + if (deptInfo.children){ + deptInfo.children.forEach(item => { + ids.push(item.deptId) + if (item.children){ + ids.push(...this.recursion(item)) + } + }) + } + return ids + }, + authChange(row) { + this.AssetAccreditReq={ + deptIds:null, + userId: null, + dataAssetId: null + } + if (row.nickName){ + this.AssetAccreditReq.userId = row.userId + this.AssetAccreditReq.dataAssetId = this.title.id + }else{ + let ids=this.recursion(row) + const uniqueIds = [...new Set(ids)]; + this.AssetAccreditReq.deptIds = uniqueIds + this.AssetAccreditReq.dataAssetId = this.title.id + } + if (row.isAuth){ + addAssetAccredit(this.AssetAccreditReq).then(res => { + this.getAssetAccreditByDataAssetId() + }) + }else{ + deleteAssetAccreditByAssetIds(this.AssetAccreditReq).then(res => { + this.getAssetAccreditByDataAssetId() + }) + } + + }, + recursionAuth(deptInfo){ + deptInfo.isAuth = this.deptAccreditIds.indexOf(deptInfo.deptId) > -1 + if (deptInfo.children){ + deptInfo.children.forEach(item => { + item.isAuth = this.deptAccreditIds.indexOf(item.deptId) > -1 + if (item.children){ + this.recursionAuth(item) + } + }) + } + }, + getAssetAccreditByDataAssetId() { + if (this.title.id != undefined) { + getAssetAccreditByDataAssetId(this.title.id).then(response => { + this.deptAccreditIds = response.data.deptAccreditModelIds + this.userAccreditIds = response.data.userAccreditModelIds + setTimeout(() => this.getList(), 50) + setTimeout(() => this.getUserList(), 50) + }) + } + }, /** 查询部门列表 */ getList() { listDept(this.queryParams).then(response => { - console.log(response.data) this.deptList = this.handleTree(response.data, "deptId"); - console.log(this.deptList) + this.deptList.forEach(dept => { + this.recursionAuth(dept) + }) this.loading = false; }); }, /** 查询用户列表 */ getUserList() { listUser(this.addDateRange(this.userQueryParams, [])).then(response => { - this.userList = response.data.rows; + this.userList = response.data.rows; + this.userList.forEach(user => { + user.isAuth = this.userAccreditIds.indexOf(user.userId) > -1 + }) this.userQueryParams.total = response.data.total; } ); }, parseTime, - init(){ - // 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": "测试部门" - } - } - ] - } + }, }; diff --git a/src/views/etl/assets/dashboard/OverallAssetStructure.vue b/src/views/etl/assets/dashboard/OverallAssetStructure.vue index 6544e2f..81f279e 100644 --- a/src/views/etl/assets/dashboard/OverallAssetStructure.vue +++ b/src/views/etl/assets/dashboard/OverallAssetStructure.vue @@ -230,7 +230,7 @@ export default { }) }, async update(row) { - await this.getDictionaryList() + this.getDictionaryList() this.form = row; this.formStatus = true; } diff --git a/src/views/etl/assets/dashboard/OverallAssets.vue b/src/views/etl/assets/dashboard/OverallAssets.vue index efc266b..994f0a6 100644 --- a/src/views/etl/assets/dashboard/OverallAssets.vue +++ b/src/views/etl/assets/dashboard/OverallAssets.vue @@ -6,7 +6,7 @@
- +
@@ -32,7 +32,7 @@
- +
diff --git a/src/views/etl/assets/dashboard/OverallSpecificAssets.vue b/src/views/etl/assets/dashboard/OverallSpecificAssets.vue index 3624c9d..ecfd00d 100644 --- a/src/views/etl/assets/dashboard/OverallSpecificAssets.vue +++ b/src/views/etl/assets/dashboard/OverallSpecificAssets.vue @@ -19,7 +19,7 @@
- +