refactor: 复制测试可填写测试名称

This commit is contained in:
chenjianxing 2020-08-26 17:20:56 +08:00
parent 7dba6df7b1
commit 1f6fffad2c
6 changed files with 105 additions and 10 deletions

View File

@ -133,12 +133,7 @@ public class APITestService {
public void copy(SaveAPITestRequest request) {
checkQuota();
request.setName(request.getName() + " Copy");
try {
checkNameExist(request);
} catch (Exception e) {
request.setName(request.getName() + " " + new Random().nextInt(1000));
}
checkNameExist(request);
// copy test
ApiTest copy = get(request.getId());

View File

@ -51,6 +51,9 @@
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
:total="total"/>
</el-card>
<api-copy-dialog ref="apiCopy" @refresh="search"/>
</ms-main-container>
</ms-container>
</template>
@ -67,9 +70,11 @@ import MsTableOperators from "../../common/components/MsTableOperators";
import {_filter, _sort} from "@/common/js/utils";
import {TEST_CONFIGS} from "../../common/components/search/search-components";
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
import ApiCopyDialog from "./components/ApiCopyDialog";
export default {
components: {
ApiCopyDialog,
OneClickOperation,
MsTableOperators,
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
@ -192,10 +197,7 @@ export default {
});
},
handleCopy(test) {
this.result = this.$post("/api/copy", {projectId: test.projectId, id: test.id, name: test.name}, () => {
this.$success(this.$t('commons.copy_success'));
this.search();
});
this.$refs.apiCopy.open(test);
},
init() {
this.projectId = this.$route.params.projectId;

View File

@ -0,0 +1,95 @@
<template>
<el-dialog :title="$t('api_test.copy')"
:visible.sync="dialogFormVisible"
:before-close="close"
width="30%">
<el-row type="flex" justify="center">
<el-col :span="18">
<el-form :model="form" :rules="rules" ref="testForm" @submit.native.prevent>
<el-form-item
:label="$t('schedule.test_name')"
:label-width="formLabelWidth"
prop="name">
<el-input v-model="form.name"></el-input>
</el-form-item>
</el-form>
</el-col>
</el-row>
<template v-slot:footer>
<ms-dialog-footer
@cancel="close"
@confirm="saveTest"/>
</template>
</el-dialog>
</template>
<script>
import {listenGoBack, removeGoBackListener} from "../../../../../common/js/utils";
import MsDialogFooter from "../../../common/components/MsDialogFooter";
export default {
components: {MsDialogFooter},
data() {
return {
name: "MsApiCopyDialog",
form: {
name: '',
},
rules:{
name :[
{required: true, message: this.$t('test_track.case.input_name'), trigger: 'blur'},
{ max: 60, message: this.$t('test_track.length_less_than') + '60', trigger: 'blur' }
]
},
formLabelWidth: '80px',
dialogFormVisible: false,
test: {}
}
},
props: {
treeNodes: {
type: Array
},
currentProject: {
type: Object
}
},
methods: {
open(test) {
listenGoBack(this.close);
this.test = test;
this.dialogFormVisible = true;
},
saveTest() {
this.$refs['testForm'].validate((valid) => {
if (valid) {
this.$post("/api/copy", {projectId: this.test.projectId, id: this.test.id, name: this.form.name}, () => {
this.$success(this.$t('commons.copy_success'));
this.dialogFormVisible = false;
this.$emit("refresh");
});
} else {
return false;
}
});
},
close() {
this.form.name = '';
removeGoBackListener(this.close);
this.dialogFormVisible = false;
}
}
}
</script>
<style scoped>
</style>

View File

@ -378,6 +378,7 @@ export default {
create_performance_test: "Create Performance Test",
export_config: "Export",
enable_validate_tip: "No request available",
copy: "Copy Test",
environment: {
name: "Environment Name",
socket: "Socket",

View File

@ -379,6 +379,7 @@ export default {
create_performance_test: "创建性能测试",
export_config: "导出",
enable_validate_tip: "没有可用请求",
copy: "复制测试",
environment: {
name: "环境名称",
socket: "环境域名",

View File

@ -377,6 +377,7 @@ export default {
create_performance_test: "創建性能測試",
export_config: "匯出",
enable_validate_tip: "沒有可用請求",
copy: "復制測試",
environment: {
name: "環境名稱",
socket: "環境域名",