fix(接口定义): 【优化】降低新手用户使用门槛

This commit is contained in:
fit2-zhao 2021-01-22 10:35:53 +08:00
parent 526e3baa13
commit eb47d5151c
6 changed files with 32 additions and 7 deletions

View File

@ -209,7 +209,7 @@
},
addTab(tab) {
if (tab.name === 'add') {
this.handleCommand("ADD");
this.handleTabsEdit(this.$t('api_test.definition.request.fast_debug'), "debug");
}
},
handleCommand(e) {

View File

@ -169,10 +169,27 @@
let bodyFiles = this.getBodyUploadFiles(data);
this.$fileUpload(this.reqUrl, null, bodyFiles, data, () => {
this.$success(this.$t('commons.save_success'));
if (this.reqUrl.endsWith('/create')) {
this.saveTestCase(data);
}
this.reqUrl = "/api/definition/update";
this.$emit('saveApi', data);
});
},
saveTestCase(row) {
let tmp = {request: JSON.parse(JSON.stringify(row.request))};
tmp.projectId = getCurrentProjectID();
tmp.active = true;
tmp.priority = "P0";
tmp.name = row.name;
tmp.request.path = row.path;
tmp.request.method = row.method;
tmp.apiDefinitionId = row.id;
let bodyFiles = this.getBodyUploadFiles(tmp);
let url = "/api/testcase/create";
this.$fileUpload(url, null, bodyFiles, tmp, (response) => {
});
},
setParameters(data) {
data.projectId = this.projectId;
this.request.name = this.currentApi.name;
@ -185,6 +202,9 @@
data.request.protocol = this.currentProtocol;
}
data.id = data.request.id;
if (!data.method) {
data.method = this.currentProtocol;
}
data.response = this.response;
},
getBodyUploadFiles(data) {

View File

@ -6,7 +6,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -43,7 +43,7 @@
export default {
name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters,MsJmxStep},
components: {MsRequestResultTail, MsResponseResult, MsRequestMetric, MsResponseText, MsRun, MsBasisParameters, MsJmxStep},
props: {
currentProtocol: String,
scenario: Boolean,
@ -119,6 +119,7 @@
},
saveAs() {
let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj);
}
}

View File

@ -19,7 +19,7 @@
@command="handleCommand" size="small" v-if="testCase===undefined && !scenario">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-form-item>
@ -58,7 +58,7 @@
export default {
name: "ApiConfig",
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun,MsJmxStep},
components: {MsRequestResultTail, MsResponseResult, MsApiRequestForm, MsRequestMetric, MsResponseText, MsRun, MsJmxStep},
props: {
currentProtocol: String,
testCase: {},
@ -155,6 +155,8 @@
saveAs() {
this.$refs['debugForm'].validate((valid) => {
if (valid) {
this.debugForm.id = null;
this.request.id = getUUID();
this.debugForm.request = this.request;
this.debugForm.userId = getCurrentUser().id;
this.debugForm.status = "Underway";

View File

@ -6,7 +6,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@ -122,6 +122,7 @@
},
saveAs() {
let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj);
}
}

View File

@ -15,7 +15,7 @@
@command="handleCommand" size="small" style="float: right;margin-right: 20px">
{{$t('commons.test')}}
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as')}}</el-dropdown-item>
<el-dropdown-item command="save_as">{{$t('api_test.definition.request.save_as_case')}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-form-item>
@ -131,6 +131,7 @@
},
saveAs() {
let obj = {request: this.request};
obj.request.id = getUUID();
this.$emit('saveAs', obj);
}
}