fix(接口测试): 修复只读用户通过ctrl+s可以CASE的缺陷

--bug=1013085 --user=王孝刚 【接口测试】github #13424 只读用户 通过 ctrl s  可以
修改API/CASE/接口自动化场景 https://www.tapd.cn/55049933/s/1155713
This commit is contained in:
wxg0103 2022-05-11 10:07:55 +08:00 committed by 刘瑞斌
parent e348f33650
commit 0382e7c0ff
2 changed files with 16 additions and 10 deletions

View File

@ -43,7 +43,7 @@ import MsTag from "../../../../common/components/MsTag";
import MsEnvironmentSelect from "./MsEnvironmentSelect"; import MsEnvironmentSelect from "./MsEnvironmentSelect";
import {API_METHOD_COLOUR} from "../../model/JsonData"; import {API_METHOD_COLOUR} from "../../model/JsonData";
import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem"; import ApiCaseItem from "@/business/components/api/definition/components/case/ApiCaseItem";
import {getCurrentProjectID} from "@/common/js/utils"; import {hasPermission} from "@/common/js/utils";
export default { export default {
name: "ApiCaseHeader", name: "ApiCaseHeader",
@ -88,11 +88,13 @@ export default {
}, },
methods: { methods: {
keyDown(e) { keyDown(e) {
if (hasPermission('PROJECT_API_DEFINITION:READ+EDIT_CASE')) {
if (!(e.keyCode === 83 && (e.ctrlKey || e.metaKey))) { if (!(e.keyCode === 83 && (e.ctrlKey || e.metaKey))) {
return; return;
} }
e.preventDefault(); e.preventDefault();
this.saveTestCase(); this.saveTestCase();
}
}, },
refreshEnvironment() { refreshEnvironment() {
this.$refs.environmentSelect.refreshEnvironment(); this.$refs.environmentSelect.refreshEnvironment();

View File

@ -29,7 +29,7 @@
</el-col> </el-col>
<el-col :span="2"> <el-col :span="2">
<el-select size="mini" v-model="apiCase.priority" class="ms-api-select" @change="changePriority(apiCase)" <el-select size="mini" v-model="apiCase.priority" class="ms-api-select" @change="changePriority(apiCase)"
:disabled="loaded"> :disabled="readonly">
<el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/> <el-option v-for="grd in priorities" :key="grd.id" :label="grd.name" :value="grd.id"/>
</el-select> </el-select>
</el-col> </el-col>
@ -49,18 +49,20 @@
<el-row> <el-row>
<el-col :span="8"> <el-col :span="8">
<el-select size="small" v-model="apiCase.caseStatus" style="margin-right: 5px" <el-select size="small" v-model="apiCase.caseStatus" style="margin-right: 5px"
@change="saveTestCase(apiCase,true)" :disabled="loaded"> @change="saveTestCase(apiCase,true)" :disabled="readonly">
<el-option v-for="item in options" :key="item.id" :label="$t(item.label)" :value="item.id"/> <el-option v-for="item in options" :key="item.id" :label="$t(item.label)" :value="item.id"/>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="16"> <el-col :span="16">
<div class="tag-item" @click.stop> <div class="tag-item" @click.stop>
<el-tooltip :content="$t('commons.follow')" placement="bottom" effect="dark" v-if="!showFollow"> <el-tooltip :content="$t('commons.follow')" placement="bottom" effect="dark" v-if="!showFollow"
:disabled="true">
<i class="el-icon-star-off" <i class="el-icon-star-off"
style="color: #783987; font-size: 25px; margin-top: 2px; margin-right: 15px;cursor: pointer " style="color: #783987; font-size: 25px; margin-top: 2px; margin-right: 15px;cursor: pointer "
@click="saveFollow"/> @click="saveFollow"/>
</el-tooltip> </el-tooltip>
<el-tooltip :content="$t('commons.cancel')" placement="bottom" effect="dark" v-if="showFollow"> <el-tooltip :content="$t('commons.cancel')" placement="bottom" effect="dark" v-if="showFollow"
:disabled="true">
<i class="el-icon-star-on" <i class="el-icon-star-on"
style="color: #783987; font-size: 28px; margin-top: 2px; margin-right: 15px;cursor: pointer " style="color: #783987; font-size: 28px; margin-top: 2px; margin-right: 15px;cursor: pointer "
@click="saveFollow" v-if="showFollow"/> @click="saveFollow" v-if="showFollow"/>
@ -71,7 +73,7 @@
<el-row style="margin-top: 5px"> <el-row style="margin-top: 5px">
<div class="tag-item" @click.stop> <div class="tag-item" @click.stop>
<ms-input-tag :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase,true)" <ms-input-tag :currentScenario="apiCase" ref="tag" @keyup.enter.native="saveTestCase(apiCase,true)"
:disabled="loaded"/> :read-only="readonly"/>
</div> </div>
</el-row> </el-row>
</el-col> </el-col>
@ -266,6 +268,7 @@ export default {
isSave: false, isSave: false,
tagCount: 0, tagCount: 0,
requestCount: 0, requestCount: 0,
readonly: false
} }
}, },
props: { props: {
@ -308,6 +311,7 @@ export default {
if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') { if (requireComponent != null && JSON.stringify(esbDefinition) != '{}' && JSON.stringify(esbDefinitionResponse) != '{}') {
this.isXpack = true; this.isXpack = true;
} }
this.readonly = !hasPermission('PROJECT_API_DEFINITION:READ+EDIT_CASE');
if (this.apiCase && this.apiCase.id) { if (this.apiCase && this.apiCase.id) {
this.showFollow = false; this.showFollow = false;
this.$get('/api/testcase/follow/' + this.apiCase.id, response => { this.$get('/api/testcase/follow/' + this.apiCase.id, response => {