refactor(用户组和权限): 权限显示优化

This commit is contained in:
shiziyuan9527 2021-05-31 16:52:58 +08:00 committed by 刘瑞斌
parent f5092b9cdd
commit 8a87431476
3 changed files with 40 additions and 19 deletions

View File

@ -858,11 +858,11 @@
}, },
{ {
"id": "PROJECT_PERFORMANCE_TEST", "id": "PROJECT_PERFORMANCE_TEST",
"name": "性能测试" "name": "测试"
}, },
{ {
"id": "PROJECT_PERFORMANCE_REPORT", "id": "PROJECT_PERFORMANCE_REPORT",
"name": "性能测试报告" "name": "报告"
} }
] ]
} }

View File

@ -16,7 +16,8 @@
label="功能菜单" label="功能菜单"
width="180"> width="180">
<template v-slot:default="scope"> <template v-slot:default="scope">
<span>{{ userGroupType[scope.row.type] ? userGroupType[scope.row.type] : scope.row.type }}</span> <span v-if="scope.row.type !== 'PROJECT'">{{ userGroupType[scope.row.type] ? userGroupType[scope.row.type] : scope.row.type }}</span>
<span v-else>{{_computedMenuName(scope.row.resource)}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
@ -44,7 +45,7 @@
<script> <script>
import GroupOperator from "@/business/components/settings/system/group/GroupOperator"; import GroupOperator from "@/business/components/settings/system/group/GroupOperator";
import GroupPermission from "@/business/components/settings/system/group/GroupPermission"; import GroupPermission from "@/business/components/settings/system/group/GroupPermission";
import {USER_GROUP_SCOPE} from "@/common/js/table-constants"; import {PROJECT_GROUP_SCOPE, USER_GROUP_SCOPE} from "@/common/js/table-constants";
export default { export default {
name: "EditPermission", name: "EditPermission",
@ -83,13 +84,26 @@ export default {
let data = result.data; let data = result.data;
if (data) { if (data) {
this.tableData = data.permissions; this.tableData = data.permissions;
this._getUniteMenu();
}
})
},
_getUniteMenu() {
let menu = ['TRACK', 'API', 'PERFORMANCE'];
for (let i = 0; i < this.tableData.length; i++) { for (let i = 0; i < this.tableData.length; i++) {
if (i === 0) { if (i === 0) {
this.spanArr.push(1); this.spanArr.push(1);
this.pos = 0 this.pos = 0
} else { } else {
// //
if (this.tableData[i].type === this.tableData[i - 1].type) { let sign = false;
if (this.tableData[i].type !== 'PROJECT') {
sign = this.tableData[i].type === this.tableData[i - 1].type;
} else {
sign = !menu.includes(this.tableData[i].resource.id.split('_')[1]) ?
true : this.tableData[i].resource.id.split('_')[1] === this.tableData[i - 1].resource.id.split('_')[1]
}
if (sign) {
this.spanArr[this.pos] += 1; this.spanArr[this.pos] += 1;
this.spanArr.push(0); this.spanArr.push(0);
} else { } else {
@ -98,8 +112,9 @@ export default {
} }
} }
} }
} },
}) _computedMenuName(resource) {
return PROJECT_GROUP_SCOPE[resource.id.split('_')[1]] ? PROJECT_GROUP_SCOPE[resource.id.split('_')[1]] : '项目';
}, },
onSubmit() { onSubmit() {
let param = {}; let param = {};

View File

@ -97,3 +97,9 @@ export const USER_GROUP_SCOPE = {
'WORKSPACE': '工作空间', 'WORKSPACE': '工作空间',
'PROJECT': '项目' 'PROJECT': '项目'
} }
export const PROJECT_GROUP_SCOPE = {
'TRACK': '测试跟踪',
'API': '接口测试',
'PERFORMANCE': '性能测试'
}