refactor(场景自动化): 场景步骤显示所属项目名

This commit is contained in:
shiziyuan9527 2021-02-22 16:01:39 +08:00
parent 5f0821174a
commit 354892fd9c
2 changed files with 27 additions and 1 deletions

View File

@ -15,6 +15,7 @@
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="request.referenced ==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<span style="margin-left: 20px;">{{getProjectName(request.projectId)}}</span>
<ms-run :debug="true" :reportId="reportId" :run-data="runData"
@runRefresh="runRefresh" ref="runTest"/>
@ -94,6 +95,7 @@ export default {
reportId: "",
runData: [],
isShowInput: false,
projects: []
}
},
created() {
@ -102,6 +104,7 @@ export default {
}
//
this.getApiInfo();
this.getWsProjects();
if (this.request.protocol === 'HTTP') {
this.setUrl(this.request.url);
this.setUrl(this.request.path);
@ -270,6 +273,18 @@ export default {
this.loading = false
})
},
getWsProjects() {
this.$get("/project/listAll", res => {
this.projects = res.data;
})
},
getProjectName(id) {
const project = this.projects.find(p => p.id === id);
if (project) {
return project.name;
}
return '';
}
}
}
</script>

View File

@ -16,6 +16,8 @@
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Deleted'" type="danger">{{$t('api_test.automation.reference_deleted')}}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='Copy'">{{ $t('commons.copy') }}</el-tag>
<el-tag size="mini" style="margin-left: 20px" v-if="scenario.referenced==='REF'">{{ $t('api_test.scenario.reference') }}</el-tag>
<span style="margin-left: 20px;">{{scenario.projectName}}</span>
</template>
</api-base-component>
@ -41,6 +43,7 @@
watch: {},
created() {
if (this.scenario.id && this.scenario.referenced === 'REF' && !this.scenario.loaded) {
this.getWsProjects();
this.result = this.$get("/api/automation/getApiScenario/" + this.scenario.id, response => {
if (response.data) {
this.scenario.loaded = true;
@ -52,6 +55,8 @@
}
this.scenario.disabled = true;
this.scenario.name = response.data.name;
const project = this.projects.find(p => p.id === this.scenario.projectId);
this.scenario.projectName = project.name;
this.$emit('refReload');
} else {
this.scenario.referenced = "Deleted";
@ -63,7 +68,8 @@
data() {
return {
loading: false,
isShowInput: false
isShowInput: false,
projects: []
}
},
computed: {
@ -109,6 +115,11 @@
}
}
},
getWsProjects() {
this.$get("/project/listAll", res => {
this.projects = res.data;
})
}
}
}
</script>