refactor: 测试计划报告优化

This commit is contained in:
chenjianxing 2020-12-23 16:58:56 +08:00
parent 9143b48e05
commit cae9c24e4f
3 changed files with 95 additions and 46 deletions

View File

@ -1,12 +1,9 @@
<template> <template>
<common-component :title="$t('test_track.plan_view.failure_case')"> <common-component :title="$t('test_track.plan_view.failure_case')">
<template> <functional-failure-cases-list v-if="showFunctional" :functional-test-cases="failureTestCases.functionalTestCases"/>
<functional-failure-cases-list :functional-test-cases="failureTestCases.functionalTestCases"/> <api-failure-cases-list v-if="showApi" :api-test-cases="failureTestCases.apiTestCases"/>
<api-failure-cases-list :api-test-cases="failureTestCases.apiTestCases"/> <scenario-failure-cases-list v-if="showScenario" :scenario-test-cases="failureTestCases.scenarioTestCases"/>
<scenario-failure-cases-list :scenario-test-cases="failureTestCases.scenarioTestCases"/>
</template>
</common-component> </common-component>
</template> </template>
@ -81,6 +78,17 @@
} }
} }
}, },
computed: {
showFunctional() {
return this.failureTestCases.functionalTestCases.length > 0 || (this.failureTestCases.apiTestCases.length <= 0 && this.failureTestCases.scenarioTestCases.length <= 0);
},
showApi() {
return this.failureTestCases.apiTestCases.length > 0;
},
showScenario() {
return this.failureTestCases.scenarioTestCases.length > 0;
}
},
methods: { methods: {
goFailureTestCase(row) { goFailureTestCase(row) {
hub.$emit("openFailureTestCase", row); hub.$emit("openFailureTestCase", row);
@ -98,7 +106,7 @@
} }
.failure-cases-list { .failure-cases-list {
margin-bottom: 30px; margin-bottom: 40px;
} }
</style> </style>

View File

@ -2,25 +2,25 @@
<common-component :title="$t('test_track.plan_view.result_statistics')"> <common-component :title="$t('test_track.plan_view.result_statistics')">
<template> <div :class="{'show-one': isShowOne}">
<div class="char-item"> <div class="char-item" v-if="showFunctional">
<ms-pie-chart v-if="isShow" :text="'功能测试用例'" <ms-pie-chart v-if="isShow" :text="'功能测试用例'"
:name="$t('test_track.plan_view.test_result')" :data="functionalCharData"/> :name="$t('test_track.plan_view.test_result')" :data="functionalCharData"/>
</div> </div>
<div class="char-item"> <div class="char-item" v-if="showApi">
<ms-pie-chart v-if="isShow" :text="'接口测试用例'" <ms-pie-chart v-if="isShow" :text="'接口测试用例'"
:name="$t('test_track.plan_view.test_result')" :data="apiCharData"/> :name="$t('test_track.plan_view.test_result')" :data="apiCharData"/>
</div> </div>
<div class="char-item"> <div class="char-item" v-if="showScenario">
<ms-pie-chart v-if="isShow" :text="'场景测试用例'" <ms-pie-chart v-if="isShow" :text="'场景测试用例'"
:name="$t('test_track.plan_view.test_result')" :data="scenarioCharData"/> :name="$t('test_track.plan_view.test_result')" :data="scenarioCharData"/>
</div> </div>
</template> </div>
</common-component> </common-component>
@ -76,6 +76,30 @@
} }
} }
}, },
computed: {
showFunctional() {
return this.executeResult.functionalResult.length > 0 || (this.executeResult.apiResult.length <= 0 && this.executeResult.scenarioResult.length <= 0);
},
showApi() {
return this.executeResult.apiResult.length > 0;
},
showScenario() {
return this.executeResult.scenarioResult.length > 0;
},
isShowOne() {
let count = 0;
if (this.showFunctional) {
count++;
}
if (this.showApi) {
count++;
}
if (this.showScenario) {
count++;
}
return count === 1;
}
},
watch: { watch: {
executeResult() { executeResult() {
this.getCharData(); this.getCharData();
@ -141,4 +165,8 @@
display: inline-block; display: inline-block;
} }
.show-one .char-item {
display: block;
}
</style> </style>

View File

@ -1,17 +1,16 @@
<template> <template>
<div> <div v-loading="result.loading">
<el-row type="flex" class="head-bar"> <el-row type="flex" class="head-bar">
<el-col :span="12"> <el-col :span="12">
</el-col> </el-col>
<el-col v-if="!reportId" :span="12" class="head-right"> <el-col v-if="!reportId" :span="11" class="head-right">
<el-button :disabled="!isTestManagerOrTestUser" plain size="mini" @click="openTemplateReport"> <el-button :disabled="!isTestManagerOrTestUser" plain size="mini" @click="openTemplateReport">
{{$t('test_track.plan_view.create_report')}} {{$t('test_track.plan_view.create_report')}}
</el-button> </el-button>
</el-col> </el-col>
<el-col v-else :span="12" class="head-right"> <el-col v-else :span="11" class="head-right">
<el-button :disabled="!isTestManagerOrTestUser" plain size="mini" @click="handleSave"> <el-button :disabled="!isTestManagerOrTestUser" plain size="mini" @click="handleSave">
{{$t('commons.save')}} {{$t('commons.save')}}
</el-button> </el-button>
@ -227,12 +226,13 @@
} }
.head-bar { .head-bar {
background: white; /*background: white;*/
height: 45px; /*height: 45px;*/
line-height: 45px; /*line-height: 45px;*/
padding: 0 10px; /*padding-left: 10px;*/
border: 1px solid #EBEEF5; /*padding: 0 10px;*/
box-shadow: 0 0 2px 0 rgba(31, 31, 31, 0.15), 0 1px 2px 0 rgba(31, 31, 31, 0.15); /*border: 1px solid #EBEEF5;*/
/*box-shadow: 0 0 2px 0 rgba(31, 31, 31, 0.15), 0 1px 2px 0 rgba(31, 31, 31, 0.15);*/
} }
.container { .container {
@ -247,6 +247,19 @@
.head-right { .head-right {
text-align: right; text-align: right;
} }
.head-bar .el-button {
margin-bottom: 10px;
width: 80px;
}
.head-bar {
position: fixed;
right: 10px;
padding: 20px;
}
</style> </style>