fix(工作台): 仪表盘Card跳转权限控制

--bug=1025906 --user=宋昌昌 【工作台】项目只有首页权限从工作台中查看测试计划提示异常 https://www.tapd.cn/55049933/s/1368856
This commit is contained in:
song-cc-rock 2023-05-05 17:04:50 +08:00 committed by xiaomeinvG
parent c952c69852
commit c43861ba43
5 changed files with 37 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<workstation-detail <workstation-detail
:is-creation="true" :is-creation="true"
v-if="projectId !== '' && projectId !== 'no_such_project'" v-if="projectId !== '' && projectId !== 'no_such_project' && currentTodo !== 'empty'"
:current-todo-name="currentTodo" :current-todo-name="currentTodo"
></workstation-detail> ></workstation-detail>
</template> </template>
@ -26,6 +26,7 @@ export default {
methods: { methods: {
setDefaultCurrentTodo() { setDefaultCurrentTodo() {
// TABTAB // TABTAB
// ,
if (hasPermissions('PROJECT_TRACK_CASE:READ')) { if (hasPermissions('PROJECT_TRACK_CASE:READ')) {
this.currentTodo = 'track_case'; this.currentTodo = 'track_case';
} else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) { } else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) {
@ -40,6 +41,8 @@ export default {
this.currentTodo = 'api_automation'; this.currentTodo = 'api_automation';
} else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) { } else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) {
this.currentTodo = 'performance'; this.currentTodo = 'performance';
} else {
this.currentTodo = 'empty'
} }
} }
}, },

View File

@ -8,9 +8,9 @@
</el-row> </el-row>
<el-row> <el-row>
<div class="row-card"> <div class="row-card">
<el-card v-for="(option,index) in contentArray" :key="index" <el-card v-for="(option,index) in contentArray" :key="index" :class="!hasPermissions(option.permission) ? 'no-permission' : ''"
body-style="padding-top: 16px; padding-left: 16px; padding-bottom: 16px;" body-style="padding-top: 16px; padding-left: 16px; padding-bottom: 16px;"
class="card-info" shadow="never" @click.native="gotoDetail(option.name)"> class="card-info" shadow="never" @click.native="gotoDetail(option.name, option.permission)">
<div class="card-name">{{option.label}}</div> <div class="card-name">{{option.label}}</div>
<div class="card-value">{{option.value}}</div> <div class="card-value">{{option.value}}</div>
</el-card> </el-card>
@ -24,6 +24,7 @@
import {getFollowTotalCount, getUpcomingTotalCount} from "@/api/workstation"; import {getFollowTotalCount, getUpcomingTotalCount} from "@/api/workstation";
import {getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token"; import {getCurrentWorkspaceId} from "metersphere-frontend/src/utils/token";
import {hasPermissions} from "metersphere-frontend/src/utils/permission"
export default { export default {
name: "MyUpcomingCard", name: "MyUpcomingCard",
@ -42,48 +43,62 @@ export default {
name: 'track_case', name: 'track_case',
value:0, value:0,
label: this.$t('workstation.table_name.track_case'), label: this.$t('workstation.table_name.track_case'),
permission: 'PROJECT_TRACK_CASE:READ'
}, },
{ {
name:"track_plan", name:"track_plan",
value:0, value:0,
label: this.$t('workstation.table_name.track_plan'), label: this.$t('workstation.table_name.track_plan'),
permission: 'PROJECT_TRACK_PLAN:READ'
}, },
{ {
name:"track_review", name:"track_review",
value:0, value:0,
label: this.$t('workstation.table_name.track_review'), label: this.$t('workstation.table_name.track_review'),
permission: 'PROJECT_TRACK_REVIEW:READ'
}, },
{ {
name:"track_issue", name:"track_issue",
value:0, value:0,
label: this.$t('workstation.table_name.track_issue'), label: this.$t('workstation.table_name.track_issue'),
permission: 'PROJECT_TRACK_ISSUE:READ'
}, },
{ {
name:"api_definition", name:"api_definition",
value:0, value:0,
label: this.$t('workstation.table_name.api_definition'), label: this.$t('workstation.table_name.api_definition'),
permission: 'PROJECT_API_DEFINITION:READ'
}, },
{ {
name:"api_case", name:"api_case",
value:0, value:0,
label: this.$t('workstation.table_name.api_case'), label: this.$t('workstation.table_name.api_case'),
permission: 'PROJECT_API_DEFINITION:READ'
}, },
{ {
name:"api_automation", name:"api_automation",
value:0, value:0,
label: this.$t('workstation.table_name.api_automation'), label: this.$t('workstation.table_name.api_automation'),
permission: 'PROJECT_API_SCENARIO:READ'
}, },
{ {
name:"performance", name:"performance",
value:0, value:0,
label: this.$t('workstation.table_name.performance'), label: this.$t('workstation.table_name.performance'),
permission: 'PROJECT_PERFORMANCE_TEST:READ'
}, },
], ],
title:"", title:"",
}; };
}, },
methods:{ methods:{
gotoDetail(name){ hasPermissions(permission) {
return hasPermissions(permission);
},
gotoDetail(name, permission){
if (!hasPermissions(permission)) {
return;
}
if (this.cardType === 'upcoming') { if (this.cardType === 'upcoming') {
let upcoming =this.$router.resolve({ let upcoming =this.$router.resolve({
path: "/workstation/upcoming", path: "/workstation/upcoming",
@ -158,6 +173,12 @@ export default {
background: #F5F6F7; background: #F5F6F7;
} }
} }
.no-permission {
background: #F5F6F7;
&:hover {
cursor: not-allowed;
}
}
.top-css { .top-css {
left: 24px; left: 24px;
font-weight: 650; font-weight: 650;

View File

@ -1,7 +1,7 @@
<template> <template>
<workstation-detail <workstation-detail
:is-focus="true" :is-focus="true"
v-if="projectId !== '' && projectId !== 'no_such_project'" v-if="projectId !== '' && projectId !== 'no_such_project' && currentTodo !== 'empty'"
:current-todo-name="currentTodo" :current-todo-name="currentTodo"
/> />
</template> </template>
@ -24,6 +24,7 @@ export default {
methods: { methods: {
setDefaultCurrentTodo() { setDefaultCurrentTodo() {
// TABTAB // TABTAB
// ,
if (hasPermissions('PROJECT_TRACK_CASE:READ')) { if (hasPermissions('PROJECT_TRACK_CASE:READ')) {
this.currentTodo = 'track_case'; this.currentTodo = 'track_case';
} else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) { } else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) {
@ -38,6 +39,8 @@ export default {
this.currentTodo = 'api_automation'; this.currentTodo = 'api_automation';
} else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) { } else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) {
this.currentTodo = 'performance'; this.currentTodo = 'performance';
} else {
this.currentTodo = 'empty'
} }
} }
}, },

View File

@ -5,7 +5,7 @@
<el-tab-pane name="track_review" :label="$t('workstation.table_name.track_review')" v-if="disabled(['PROJECT_TRACK_REVIEW:READ'])"></el-tab-pane> <el-tab-pane name="track_review" :label="$t('workstation.table_name.track_review')" v-if="disabled(['PROJECT_TRACK_REVIEW:READ'])"></el-tab-pane>
<el-tab-pane name="track_issue" :label= "$t('workstation.table_name.track_issue')" v-if="disabled(['PROJECT_TRACK_ISSUE:READ'])"></el-tab-pane> <el-tab-pane name="track_issue" :label= "$t('workstation.table_name.track_issue')" v-if="disabled(['PROJECT_TRACK_ISSUE:READ'])"></el-tab-pane>
<el-tab-pane name="api_definition" :label= "$t('workstation.table_name.api_definition')" v-if="disabled(['PROJECT_API_DEFINITION:READ'])"></el-tab-pane> <el-tab-pane name="api_definition" :label= "$t('workstation.table_name.api_definition')" v-if="disabled(['PROJECT_API_DEFINITION:READ'])"></el-tab-pane>
<el-tab-pane name="api_case" :label= "$t('workstation.table_name.api_case')" v-if="disabled(['PROJECT_API_SCENARIO:READ'])"></el-tab-pane> <el-tab-pane name="api_case" :label= "$t('workstation.table_name.api_case')" v-if="disabled(['PROJECT_API_DEFINITION:READ'])"></el-tab-pane>
<el-tab-pane name="api_automation" :label= "$t('workstation.table_name.api_automation')" v-if="disabled(['PROJECT_API_SCENARIO:READ'])"></el-tab-pane> <el-tab-pane name="api_automation" :label= "$t('workstation.table_name.api_automation')" v-if="disabled(['PROJECT_API_SCENARIO:READ'])"></el-tab-pane>
<el-tab-pane name="performance" :label= "$t('workstation.table_name.performance')" v-if="disabled(['PROJECT_PERFORMANCE_TEST:READ'])"></el-tab-pane> <el-tab-pane name="performance" :label= "$t('workstation.table_name.performance')" v-if="disabled(['PROJECT_PERFORMANCE_TEST:READ'])"></el-tab-pane>
</el-tabs> </el-tabs>

View File

@ -2,7 +2,7 @@
<workstation-detail <workstation-detail
:is-upcoming="true" :is-upcoming="true"
:current-todo-name="currentTodo" :current-todo-name="currentTodo"
v-if="projectId !== '' && projectId !== 'no_such_project'" v-if="projectId !== '' && projectId !== 'no_such_project' && currentTodo !== 'empty'"
></workstation-detail> ></workstation-detail>
</template> </template>
<script> <script>
@ -25,6 +25,7 @@ export default {
methods: { methods: {
setDefaultCurrentTodo() { setDefaultCurrentTodo() {
// TABTAB // TABTAB
// ,
if (hasPermissions('PROJECT_TRACK_CASE:READ')) { if (hasPermissions('PROJECT_TRACK_CASE:READ')) {
this.currentTodo = 'track_case'; this.currentTodo = 'track_case';
} else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) { } else if (hasPermissions('PROJECT_TRACK_PLAN:READ')) {
@ -39,6 +40,8 @@ export default {
this.currentTodo = 'api_automation'; this.currentTodo = 'api_automation';
} else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) { } else if (hasPermissions('PROJECT_PERFORMANCE_TEST:READ')) {
this.currentTodo = 'performance'; this.currentTodo = 'performance';
} else {
this.currentTodo = 'empty'
} }
} }
}, },