api测试点击一行只读

This commit is contained in:
chenjianxing 2020-06-05 10:59:53 +08:00
parent cb3b90a033
commit 8af9a73d9a
2 changed files with 20 additions and 10 deletions

View File

@ -5,27 +5,27 @@
<el-container class="test-container" v-loading="result.loading"> <el-container class="test-container" v-loading="result.loading">
<el-header> <el-header>
<el-row type="flex" align="middle"> <el-row type="flex" align="middle">
<el-input class="test-name" v-model="test.name" maxlength="60" :placeholder="$t('api_test.input_name')" <el-input :disabled="isReadOnly" class="test-name" v-model="test.name" maxlength="60" :placeholder="$t('api_test.input_name')"
show-word-limit> show-word-limit>
<el-select class="test-project" v-model="test.projectId" slot="prepend" <el-select :disabled="isReadOnly" class="test-project" v-model="test.projectId" slot="prepend"
:placeholder="$t('api_test.select_project')"> :placeholder="$t('api_test.select_project')">
<el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/> <el-option v-for="project in projects" :key="project.id" :label="project.name" :value="project.id"/>
</el-select> </el-select>
</el-input> </el-input>
<el-button type="primary" plain :disabled="isDisabled" @click="saveTest"> <el-button type="primary" plain :disabled="isDisabled || isReadOnly" @click="saveTest">
{{$t('commons.save')}} {{$t('commons.save')}}
</el-button> </el-button>
<el-button type="primary" plain v-if="!isShowRun" :disabled="isDisabled" @click="saveRunTest"> <el-button type="primary" plain v-if="!isShowRun" :disabled="isDisabled || isReadOnly" @click="saveRunTest">
{{$t('load_test.save_and_run')}} {{$t('load_test.save_and_run')}}
</el-button> </el-button>
<el-button type="primary" plain v-if="isShowRun" @click="runTest"> <el-button :disabled="isReadOnly" type="primary" plain v-if="isShowRun" @click="runTest">
{{$t('api_test.run')}} {{$t('api_test.run')}}
</el-button> </el-button>
<el-button type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button> <el-button :disabled="isReadOnly" type="warning" plain @click="cancel">{{$t('commons.cancel')}}</el-button>
<el-dropdown trigger="click" @command="handleCommand"> <el-dropdown trigger="click" @command="handleCommand">
<el-button class="el-dropdown-link more" icon="el-icon-more" plain/> <el-button class="el-dropdown-link more" icon="el-icon-more" plain/>
@ -33,7 +33,7 @@
<el-dropdown-item command="report" :disabled="test.status !== 'Completed'"> <el-dropdown-item command="report" :disabled="test.status !== 'Completed'">
{{$t('api_report.title')}} {{$t('api_report.title')}}
</el-dropdown-item> </el-dropdown-item>
<el-dropdown-item command="performance" :disabled="create"> <el-dropdown-item command="performance" :disabled="create || isReadOnly">
{{$t('api_test.create_performance_test')}} {{$t('api_test.create_performance_test')}}
</el-dropdown-item> </el-dropdown-item>
</el-dropdown-menu> </el-dropdown-menu>
@ -42,7 +42,7 @@
<ms-api-report-dialog :test-id="id" ref="reportDialog"/> <ms-api-report-dialog :test-id="id" ref="reportDialog"/>
</el-row> </el-row>
</el-header> </el-header>
<ms-api-scenario-config :scenarios="test.scenarioDefinition" ref="config"/> <ms-api-scenario-config :is-read-only="isReadOnly" :scenarios="test.scenarioDefinition" ref="config"/>
</el-container> </el-container>
</el-card> </el-card>
</div> </div>
@ -69,7 +69,8 @@
result: {}, result: {},
projects: [], projects: [],
change: false, change: false,
test: new Test() test: new Test(),
isReadOnly: false
} }
}, },
@ -86,6 +87,10 @@
methods: { methods: {
init() { init() {
let projectId; let projectId;
this.isReadOnly = false;
if (this.$route.path.indexOf('/api/test/view') >= 0) {
this.isReadOnly = true;
}
if (this.id) { if (this.id) {
this.create = false; this.create = false;
this.getTest(this.id); this.getTest(this.id);

View File

@ -7,7 +7,7 @@
:title="$t('commons.test')" :title="$t('commons.test')"
@create="create" :createTip="$t('load_test.create')"/> @create="create" :createTip="$t('load_test.create')"/>
</template> </template>
<el-table :data="tableData" class="table-content" @sort-change="sort" @row-click="handleEdit" <el-table :data="tableData" class="table-content" @sort-change="sort" @row-click="handleView"
@filter-change="filter"> @filter-change="filter">
<el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip> <el-table-column prop="name" :label="$t('commons.name')" width="250" show-overflow-tooltip>
</el-table-column> </el-table-column>
@ -124,6 +124,11 @@
path: '/api/test/edit?id=' + test.id, path: '/api/test/edit?id=' + test.id,
}) })
}, },
handleView(test) {
this.$router.push({
path: '/api/test/view?id=' + test.id,
})
},
handleDelete(test) { handleDelete(test) {
this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', { this.$alert(this.$t('load_test.delete_confirm') + test.name + "", '', {
confirmButtonText: this.$t('commons.confirm'), confirmButtonText: this.$t('commons.confirm'),