fix(用户组和权限): 报表统计下权限控制#1005247

--bug=1005247 --user=lyh 【用户权限】-只读用户可以删除测试报告+下载报表统计
https://www.tapd.cn/55049933/s/1030255
This commit is contained in:
shiziyuan9527 2021-07-28 16:58:50 +08:00 committed by 刘瑞斌
parent dba9a89465
commit d875caa82a
8 changed files with 73 additions and 13 deletions

View File

@ -8,4 +8,5 @@ public class GroupPermission {
private String name;
private String resourceId;
private Boolean checked = false;
private Boolean license = false;
}

View File

@ -6,4 +6,5 @@ import lombok.Data;
public class GroupResource {
private String id;
private String name;
private Boolean license = false;
}

View File

@ -0,0 +1,15 @@
-- 项目管理员
insert into user_group_permission (id, group_id, permission_id, module_id)
values (UUID(), 'project_admin', 'PROJECT_REPORT_ANALYSIS:READ', 'PROJECT_REPORT_ANALYSIS');
insert into user_group_permission (id, group_id, permission_id, module_id)
values (UUID(), 'project_admin', 'PROJECT_REPORT_ANALYSIS:READ+EXPORT', 'PROJECT_REPORT_ANALYSIS');
-- 项目成员
insert into user_group_permission (id, group_id, permission_id, module_id)
values (UUID(), 'project_member', 'PROJECT_REPORT_ANALYSIS:READ', 'PROJECT_REPORT_ANALYSIS');
insert into user_group_permission (id, group_id, permission_id, module_id)
values (UUID(), 'project_member', 'PROJECT_REPORT_ANALYSIS:READ+EXPORT', 'PROJECT_REPORT_ANALYSIS');
-- 只读
insert into user_group_permission (id, group_id, permission_id, module_id)
values (UUID(), 'read_only', 'PROJECT_REPORT_ANALYSIS:READ', 'PROJECT_REPORT_ANALYSIS');

View File

@ -19,7 +19,8 @@
"id": "SYSTEM_USER:READ+EDIT",
"name": "编辑用户",
"resourceId": "SYSTEM_USER"
}, {
},
{
"id": "SYSTEM_USER:READ+DELETE",
"name": "删除用户",
"resourceId": "SYSTEM_USER"
@ -783,6 +784,18 @@
"id": "PROJECT_PERFORMANCE_REPORT:READ+EXPORT",
"name": "导出报告",
"resourceId": "PROJECT_PERFORMANCE_REPORT"
},
{
"id": "PROJECT_REPORT_ANALYSIS:READ",
"name": "查看",
"resourceId": "PROJECT_REPORT_ANALYSIS",
"license": true
},
{
"id": "PROJECT_REPORT_ANALYSIS:READ+EXPORT",
"name": "导出",
"resourceId": "PROJECT_REPORT_ANALYSIS",
"license": true
}
],
"resource": [
@ -921,6 +934,11 @@
{
"id": "PROJECT_PERFORMANCE_REPORT",
"name": "报告"
},
{
"id": "PROJECT_REPORT_ANALYSIS",
"name": "报表",
"license": true
}
]
}

View File

@ -10,14 +10,18 @@
:span-method="objectSpanMethod"
border
:data="tableData"
class="permission-table"
:row-class-name="handleLicenseResource"
style="width: 100%">
<el-table-column
prop="type"
:label="$t('group.functional_menu')"
width="180">
<template v-slot:default="scope">
<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>
<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>
</el-table-column>
<el-table-column
@ -25,7 +29,7 @@
:label="$t('group.operation_object')"
width="180">
<template v-slot:default="scope">
{{scope.row.resource.name}}
{{ scope.row.resource.name }}
</template>
</el-table-column>
<el-table-column
@ -46,7 +50,9 @@
</el-table-column>
</el-table>
</div>
<el-button type="primary" @click="onSubmit" size="small" style="margin-top: 10px;margin-left: 5px;">{{ $t('commons.confirm') }}</el-button>
<el-button type="primary" @click="onSubmit" size="small" style="margin-top: 10px;margin-left: 5px;">
{{ $t('commons.confirm') }}
</el-button>
<el-button @click="cancel" size="small">{{ $t('commons.cancel') }}</el-button>
</el-dialog>
</template>
@ -54,6 +60,7 @@
<script>
import GroupPermission from "@/business/components/settings/system/group/GroupPermission";
import {PROJECT_GROUP_SCOPE, USER_GROUP_SCOPE} from "@/common/js/table-constants";
import {hasLicense} from "@/common/js/utils";
export default {
name: "EditPermission",
@ -93,7 +100,7 @@ export default {
})
},
_getUniteMenu() {
let menu = ['TRACK', 'API', 'PERFORMANCE'];
let menu = ['TRACK', 'API', 'PERFORMANCE', 'REPORT'];
for (let i = 0; i < this.tableData.length; i++) {
if (i === 0) {
this.spanArr.push(1);
@ -136,7 +143,7 @@ export default {
cancel() {
this.dialogVisible = false;
},
objectSpanMethod({row, column, rowIndex, columnIndex}) {
objectSpanMethod({rowIndex, columnIndex}) {
if (columnIndex === 0) {
const _row = this.spanArr[rowIndex];
const _col = _row > 0 ? 1 : 0;
@ -148,11 +155,21 @@ export default {
},
handleSelectAll(check, permissions) {
permissions.map(p => p.checked = check);
},
handleLicenseResource(row) {
if (!row.row.resource.license) {
return;
}
if (!hasLicense()) {
return 'hidden-row';
}
}
}
}
</script>
<style scoped>
.permission-table >>> .hidden-row {
display: none;
}
</style>

View File

@ -1,7 +1,12 @@
<template>
<div>
<span v-for="(permission, index) in permissions" :key="index" style="margin-right: 25px;">
<el-checkbox v-model="permission['checked']" @change="change($event, permission)">
<span v-for="(permission, index) in permissions" :key="index">
<el-checkbox v-if="permission.license" v-xpack class="permission-checkbox"
v-model="permission['checked']" @change="change($event, permission)">
{{ permission.name }}
</el-checkbox>
<el-checkbox v-else class="permission-checkbox"
v-model="permission['checked']" @change="change($event, permission)">
{{ permission.name }}
</el-checkbox>
</span>
@ -51,5 +56,7 @@ export default {
</script>
<style scoped>
.permission-checkbox {
margin-right: 25px;
}
</style>

@ -1 +1 @@
Subproject commit 34379f3a7e7d52b4a9c0194325b3ea02db5cc8eb
Subproject commit 34430c98ba5cbfefa6d911ef9be9f593a2368f69

View File

@ -101,5 +101,6 @@ export const USER_GROUP_SCOPE = {
export const PROJECT_GROUP_SCOPE = {
'TRACK': '测试跟踪',
'API': '接口测试',
'PERFORMANCE': '性能测试'
'PERFORMANCE': '性能测试',
'REPORT': '报告统计'
}