refactor: 复制测试可填写测试名称
This commit is contained in:
parent
7dba6df7b1
commit
1f6fffad2c
|
@ -133,12 +133,7 @@ public class APITestService {
|
||||||
|
|
||||||
public void copy(SaveAPITestRequest request) {
|
public void copy(SaveAPITestRequest request) {
|
||||||
checkQuota();
|
checkQuota();
|
||||||
request.setName(request.getName() + " Copy");
|
checkNameExist(request);
|
||||||
try {
|
|
||||||
checkNameExist(request);
|
|
||||||
} catch (Exception e) {
|
|
||||||
request.setName(request.getName() + " " + new Random().nextInt(1000));
|
|
||||||
}
|
|
||||||
|
|
||||||
// copy test
|
// copy test
|
||||||
ApiTest copy = get(request.getId());
|
ApiTest copy = get(request.getId());
|
||||||
|
|
|
@ -51,6 +51,9 @@
|
||||||
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
<ms-table-pagination :change="search" :current-page.sync="currentPage" :page-size.sync="pageSize"
|
||||||
:total="total"/>
|
:total="total"/>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
|
||||||
|
<api-copy-dialog ref="apiCopy" @refresh="search"/>
|
||||||
|
|
||||||
</ms-main-container>
|
</ms-main-container>
|
||||||
</ms-container>
|
</ms-container>
|
||||||
</template>
|
</template>
|
||||||
|
@ -67,9 +70,11 @@ import MsTableOperators from "../../common/components/MsTableOperators";
|
||||||
import {_filter, _sort} from "@/common/js/utils";
|
import {_filter, _sort} from "@/common/js/utils";
|
||||||
import {TEST_CONFIGS} from "../../common/components/search/search-components";
|
import {TEST_CONFIGS} from "../../common/components/search/search-components";
|
||||||
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
import {ApiEvent, LIST_CHANGE} from "@/business/components/common/head/ListEvent";
|
||||||
|
import ApiCopyDialog from "./components/ApiCopyDialog";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
|
ApiCopyDialog,
|
||||||
OneClickOperation,
|
OneClickOperation,
|
||||||
MsTableOperators,
|
MsTableOperators,
|
||||||
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
|
MsApiTestStatus, MsMainContainer, MsContainer, MsTableHeader, MsTablePagination, MsTableOperator
|
||||||
|
@ -192,10 +197,7 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
handleCopy(test) {
|
handleCopy(test) {
|
||||||
this.result = this.$post("/api/copy", {projectId: test.projectId, id: test.id, name: test.name}, () => {
|
this.$refs.apiCopy.open(test);
|
||||||
this.$success(this.$t('commons.copy_success'));
|
|
||||||
this.search();
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
init() {
|
init() {
|
||||||
this.projectId = this.$route.params.projectId;
|
this.projectId = this.$route.params.projectId;
|
||||||
|
|
|
@ -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>
|
|
@ -378,6 +378,7 @@ export default {
|
||||||
create_performance_test: "Create Performance Test",
|
create_performance_test: "Create Performance Test",
|
||||||
export_config: "Export",
|
export_config: "Export",
|
||||||
enable_validate_tip: "No request available",
|
enable_validate_tip: "No request available",
|
||||||
|
copy: "Copy Test",
|
||||||
environment: {
|
environment: {
|
||||||
name: "Environment Name",
|
name: "Environment Name",
|
||||||
socket: "Socket",
|
socket: "Socket",
|
||||||
|
|
|
@ -379,6 +379,7 @@ export default {
|
||||||
create_performance_test: "创建性能测试",
|
create_performance_test: "创建性能测试",
|
||||||
export_config: "导出",
|
export_config: "导出",
|
||||||
enable_validate_tip: "没有可用请求",
|
enable_validate_tip: "没有可用请求",
|
||||||
|
copy: "复制测试",
|
||||||
environment: {
|
environment: {
|
||||||
name: "环境名称",
|
name: "环境名称",
|
||||||
socket: "环境域名",
|
socket: "环境域名",
|
||||||
|
|
|
@ -377,6 +377,7 @@ export default {
|
||||||
create_performance_test: "創建性能測試",
|
create_performance_test: "創建性能測試",
|
||||||
export_config: "匯出",
|
export_config: "匯出",
|
||||||
enable_validate_tip: "沒有可用請求",
|
enable_validate_tip: "沒有可用請求",
|
||||||
|
copy: "復制測試",
|
||||||
environment: {
|
environment: {
|
||||||
name: "環境名稱",
|
name: "環境名稱",
|
||||||
socket: "環境域名",
|
socket: "環境域名",
|
||||||
|
|
Loading…
Reference in New Issue