复制接口测试

This commit is contained in:
q4speed 2020-05-29 16:29:57 +08:00
parent 9472430209
commit 34d2fac553
5 changed files with 75 additions and 6 deletions

View File

@ -3,16 +3,17 @@
<ms-main-container>
<el-card class="table-card" v-loading="result.loading">
<template v-slot:header>
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search" :title="$t('commons.test')"
<ms-table-header :is-tester-permission="true" :condition.sync="condition" @search="search"
:title="$t('commons.test')"
@create="create" :createTip="$t('load_test.create')"/>
</template>
<el-table :data="tableData" class="table-content">
<el-table-column :label="$t('commons.name')" width="150" show-overflow-tooltip>
<el-table-column :label="$t('commons.name')" width="250" show-overflow-tooltip>
<template v-slot:default="scope">
<el-link type="info" @click="handleEdit(scope.row)">{{ scope.row.name }}</el-link>
</template>
</el-table-column>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="150" show-overflow-tooltip/>
<el-table-column prop="projectName" :label="$t('load_test.project_name')" width="200" show-overflow-tooltip/>
<el-table-column prop="userName" :label="$t('api_test.creator')" width="150" show-overflow-tooltip/>
<el-table-column width="250" :label="$t('commons.create_time')">
<template v-slot:default="scope">
@ -31,7 +32,7 @@
</el-table-column>
<el-table-column width="150" :label="$t('commons.operating')">
<template v-slot:default="scope">
<ms-table-operator :is-tester-permission="true" @editClick="handleEdit(scope.row)" @deleteClick="handleDelete(scope.row)"/>
<ms-table-operators :buttons="buttons" :row="scope.row"/>
</template>
</el-table-column>
</el-table>
@ -49,9 +50,13 @@
import MsContainer from "../../common/components/MsContainer";
import MsMainContainer from "../../common/components/MsMainContainer";
import MsApiTestStatus from "./ApiTestStatus";
import MsTableOperators from "../../common/components/MsTableOperators";
export default {
components: {MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator},
components: {
MsTableOperators,
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
},
data() {
return {
result: {},
@ -62,7 +67,19 @@
currentPage: 1,
pageSize: 5,
total: 0,
loading: false
loading: false,
buttons: [
{
tip: this.$t('commons.edit'), icon: "el-icon-edit",
exec: this.handleEdit
}, {
tip: this.$t('commons.copy'), icon: "el-icon-copy-document", type: "success",
exec: this.handleCopy
}, {
tip: this.$t('commons.delete'), icon: "el-icon-delete", type: "danger",
exec: this.handleDelete
}
]
}
},
@ -111,6 +128,12 @@
}
});
},
handleCopy(test) {
this.result = this.$post("/api/copy", {id: test.id}, () => {
this.$success(this.$t('commons.delete_success'));
this.search();
});
},
init() {
this.projectId = this.$route.params.projectId;
this.search();

View File

@ -0,0 +1,43 @@
<template>
<span>
<ms-table-operator-button v-for="(btn, index) in buttons" :key="index" :isTesterPermission="isTesterPermission(btn)"
:tip="btn.tip" :icon="btn.icon" :type="btn.type"
@exec="click(btn)" @click.stop="clickStop(btn)"/>
</span>
</template>
<script>
import MsTableOperatorButton from "./MsTableOperatorButton";
export default {
name: "MsTableOperators",
components: {MsTableOperatorButton},
props: {
row: Object,
buttons: Array
},
methods: {
click(btn) {
if (btn.exec instanceof Function) {
btn.exec(this.row);
}
},
clickStop(btn) {
if (btn.stop instanceof Function) {
btn.stop(this.row);
}
},
},
computed: {
isTesterPermission() {
return function (btn) {
return btn.isTesterPermission !== false;
}
}
}
}
</script>
<style scoped>
</style>

View File

@ -11,6 +11,7 @@ export default {
'save_success': 'Saved successfully',
'delete_success': 'Deleted successfully',
'modify_success': 'Modify Success',
'copy_success': 'Copy Success',
'delete_cancel': 'Deleted Cancel',
'confirm': 'Confirm',
'cancel': 'Cancel',

View File

@ -10,6 +10,7 @@ export default {
'save': '保存',
'save_success': '保存成功',
'delete_success': '删除成功',
'copy_success': '复制成功',
'modify_success': '修改成功',
'delete_cancel': '已取消删除',
'confirm': '确定',

View File

@ -10,6 +10,7 @@ export default {
'save': '保存',
'save_success': '保存成功',
'delete_success': '刪除成功',
'copy_success': '複製成功',
'modify_success': '修改成功',
'delete_cancel': '已取消刪除',
'confirm': '確定',