fix(接口定义): 修复用例多次运行结果未及时更新问题。

This commit is contained in:
fit2-zhao 2021-06-07 16:34:06 +08:00 committed by BugKing
parent fecf24e514
commit 7e7d726832
3 changed files with 74 additions and 66 deletions

View File

@ -16,87 +16,91 @@
</template>
<script>
import ApiBaseComponent from "../common/ApiBaseComponent";
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
import ElCollapseTransition from "element-ui/src/transitions/collapse-transition";
import MsRequestMetric from "../../../definition/components/response/RequestMetric";
import ApiBaseComponent from "../common/ApiBaseComponent";
import MsRequestResultTail from "../../../definition/components/response/RequestResultTail";
import ElCollapseTransition from "element-ui/src/transitions/collapse-transition";
import MsRequestMetric from "../../../definition/components/response/RequestMetric";
export default {
name: "ApiResponseComponent",
components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric},
props: {apiItem: {}, result: {}, currentProtocol: String},
data() {
return {
isActive: false,
response: {responseResult: {}}
}
},
created() {
if (!this.result) {
this.getExecResult();
if (this.apiItem.isActive) {
// this.isActive = true;
}
} else {
this.response = this.result;
export default {
name: "ApiResponseComponent",
components: {ElCollapseTransition, MsRequestResultTail, ApiBaseComponent, MsRequestMetric},
props: {apiItem: {}, result: {}, currentProtocol: String},
data() {
return {
isActive: false,
response: {responseResult: {}}
}
},
created() {
if (!this.result || !this.result.responseResult) {
this.getExecResult();
if (this.apiItem.isActive) {
// this.isActive = true;
}
},
watch: {
result() {
} else {
this.response = this.result;
// this.isActive = true;
}
},
watch: {
result() {
if (this.result.responseResult) {
this.response = this.result;
this.isActive = true;
},
apiItem(){
} else {
this.getExecResult();
}
this.isActive = true;
},
methods: {
getExecResult() {
//
if (this.apiItem && this.apiItem.id) {
let url = "/api/definition/report/getReport/" + this.apiItem.id;
this.$get(url, response => {
if (response.data) {
let data = JSON.parse(response.data.content);
this.response = data;
this.$set(this.apiItem, 'responseData', data);
this.isActive = true;
}
});
}
},
active() {
this.isActive = !this.isActive;
apiItem() {
this.getExecResult();
}
},
methods: {
getExecResult() {
//
if (this.apiItem && this.apiItem.id) {
let url = "/api/definition/report/getReport/" + this.apiItem.id;
this.$get(url, response => {
if (response.data) {
let data = JSON.parse(response.data.content);
this.response = data;
this.$set(this.apiItem, 'responseData', data);
this.isActive = true;
}
});
}
},
active() {
this.isActive = !this.isActive;
}
}
}
</script>
<style scoped>
.header {
height: 30px;
line-height: 30px;
}
.header {
height: 30px;
line-height: 30px;
}
/deep/ .el-card__body {
padding: 15px;
}
/deep/ .el-card__body {
padding: 15px;
}
.icon.is-active {
transform: rotate(90deg);
}
.icon.is-active {
transform: rotate(90deg);
}
.el-icon-arrow-right {
float: left;
display: block;
height: 30px;
line-height: 30px;
}
.el-icon-arrow-right {
float: left;
display: block;
height: 30px;
line-height: 30px;
}
.metric-container {
margin-left: 25px;
}
.metric-container {
margin-left: 25px;
}
</style>

View File

@ -107,7 +107,7 @@
<esb-definition-response v-xpack v-if="showXpackCompnent" :currentProtocol="apiCase.request.protocol" :request="apiCase.request" :is-api-component="false" :show-options-button="false" :show-header="true" :api-item="apiCase"/>
</div>
<div v-else>
<api-response-component :currentProtocol="apiCase.request.protocol" :api-item="apiCase"/>
<api-response-component :currentProtocol="apiCase.request.protocol" :api-item="apiCase" :result="runResult"/>
</div>
<ms-jmx-step :request="apiCase.request" :response="apiCase.responseData"/>
@ -192,6 +192,7 @@
}
},
props: {
runResult:{},
apiCase: {
type: Object,
default() {

View File

@ -33,6 +33,7 @@
:environment="environment"
:is-case-edit="isCaseEdit"
:api="api"
:runResult="runResult"
:api-case="item" :index="index" ref="apiCaseItem"/>
</div>
</el-main>
@ -86,6 +87,7 @@ export default {
batchLoadingIds: [],
singleLoading: false,
singleRunId: "",
runResult: {},
runData: [],
selectdCases: [],
reportId: "",
@ -208,6 +210,7 @@ export default {
//
let obj = {envId: this.environment, show: true};
this.batchEdit(obj);
this.runResult = {testId: getUUID()};
this.$success(this.$t('organization.integration.successful_operation'));
},
errorRefresh() {
@ -434,7 +437,7 @@ export default {
this.$success(this.$t('commons.save_success'));
}
this.selectdCases = [];
this.getApiTest();
//this.getApiTest();
});
},
}