refactor(测试跟踪):用例评审结果分布组件优化

--bug=1023471 --user=王旭 【测试跟踪】首页 - 用例评审 结果分布 统计错误 https://www.tapd.cn/55049933/s/1354654
This commit is contained in:
WangXu10 2023-03-22 17:43:27 +08:00 committed by fit2-zhao
parent bad0eac479
commit 4718431789
4 changed files with 35 additions and 89 deletions

View File

@ -1,31 +1,12 @@
<template>
<div class="y-progress" :style="{'width':againPercent + '%','background-color':tip[3].fillStyle || '#ccc'}">
<a class="y-progress_text" :style="{'width':((again/total)*100)+'%'}">
<span class="y-tooltip" v-text="tip[3].text.replace('X',again>total?total:again)"></span>
</a>
<div class="y-progress" :style="{'width':'100%','background-color':tip[3].fillStyle || '#ccc'}">
<div
v-for="(item, index) in statusCountItems"
:key="index"
class="y-progress_bar"
:style="{'width':underwayPercent+ '%','background-color':tip[0].fillStyle || '#000'}"
:style="{'width':percent(statusCountItems,index) + '%','background-color':tip[index].fillStyle || '#ccc'}"
>
<a class="y-progress_text" :style="{'width':((underway/total)*100)+'%'}">
<span class="y-tooltip" v-text="tip[0].text.replace('X',underway>total?total:underway)"></span>
</a>
</div>
<div
class="y-progress_bar"
:style="{'width':unPassPercent+'%','background-color':tip[2].fillStyle || '#080'}"
>
<a class="y-progress_text" :style="{'width':((unPass/total)*100)+'%'}">
<span class="y-tooltip" v-text="tip[2].text.replace('X',unPass>total?total:unPass)"></span>
</a>
</div>
<div
class="y-progress_bar"
:style="{'width':passPercent+'%','background-color':tip[1].fillStyle || '#9c3'}"
>
<a class="y-progress_text" :style="{'width':((pass/total)*100)+'%'}">
<span class="y-tooltip" v-text="tip[1].text.replace('X',pass>total?total:pass)"></span>
</a>
</div>
</div>
</template>
@ -42,52 +23,26 @@ export default {
type: Number,
default: 0
},
pass: {
type: Number,
default: 0
},
tip: {
type: Array,
default: () => []
},
unPass: {
type: Number,
default: 0
statusCountItems: {
type: Array,
default: () => []
},
again: {
type: Number,
default: 0
},
underway: {
type: Number,
default: 0
}
},
computed: {
passPercent() {
if (this.pass >= this.total) {
return 1e2;
methods: {
percent(statusCountItems,index) {
var item = 0;
for (let i = statusCountItems.length - 1; i >= 0; i--) {
item += statusCountItems[i-index].value;
if(index===i){
var number = parseInt((item / this.total) * 100);
return number;
}
}
return parseInt((this.pass / this.total) * 100);
},
unPassPercent() {
if (this.unPass >= this.total) {
return 1e2;
}
return parseInt(((this.unPass + this.pass)/this.total) * 100);
},
againPercent() {
if (this.again >= this.total) {
return 1e2;
}
return parseInt(((this.again + this.pass + this.unPass + this.underway)/ this.total) * 100);
},
underwayPercent() {
if (this.underway >= this.total) {
return 1e2;
}
return parseInt(((this.underway + this.pass + this.unPass)/ this.total) * 100);
},
}
},
};
</script>

View File

@ -26,21 +26,9 @@ let YanProgress1 = {
type: Number,
default: 0
},
"pass": {
type: Number,
default: 0
},
"unPass": {
type: Number,
default: 0
},
"again": {
type: Number,
default: 0
},
"underway": {
type: Number,
default: 0
"statusCountItems": {
type: Array,
default: () => []
},
"tip": {
type: Array,

View File

@ -1801,7 +1801,7 @@ export default {
color: #646a73;
align-items: center;
margin-left: px2rem(8);
padding: 0.2rem;
padding: -1px 0.2rem;
.version-icon {
width: 20.17px;

View File

@ -55,10 +55,7 @@
<el-tooltip :content="getResultTip(scope.row)"
placement="top" :enterable="false" class="item" effect="dark">
<ms-yan-progress :total="scope.row.caseCount"
:pass="getResultCount(scope.row, 'Pass')"
:unPass="getResultCount(scope.row, 'UnPass')"
:underway="getResultCount(scope.row, 'Underway')"
:again="getResultCount(scope.row, 'Again')"
:statusCountItems="getResultCount(scope.row)"
:tip="tip"/>
</el-tooltip>
</template>
@ -103,10 +100,10 @@ export default {
pageSize: 5,
total: 0,
tip: [
{text: "X", fillStyle: '#FFD131'},
{text: "X", fillStyle: '#AA4FBF'},//
{text: "X", fillStyle: '#55B040'},//
{text: "X", fillStyle: '#F76964'},//
{text: "X", fillStyle: '#FFD131'}
{text: "X", fillStyle: '#55B040'},//
]
}
},
@ -154,10 +151,16 @@ export default {
},
getResultCount(row, status) {
if (row.statusCountItems) {
let result = row.statusCountItems.filter(item => status === item.key);
if (result && result.length > 0) {
return result[0].value;
}
let statusCount =
[{key: "Pass", value: 0}, {key: "UnPass", value: 0}, {key: "Underway", value: 0}, {key: "Again", value: 0}];
row.statusCountItems.forEach(item => {
statusCount.forEach(status => {
if(item.key===status.key) {
status.value = item.value
}
})
});
return statusCount;
}
return 0;
},