2021-03-13 13:01:28 +08:00
|
|
|
<template>
|
2022-11-18 11:07:06 +08:00
|
|
|
<div class="dashboard-card">
|
|
|
|
<el-card shadow="never" class="box-card" style="height: 100%">
|
|
|
|
<div slot="header" class="clearfix">
|
|
|
|
<span class="dashboard-title">{{ $t('test_track.home.case_maintenance') }}</span>
|
2022-11-15 16:25:14 +08:00
|
|
|
</div>
|
2022-11-18 11:07:06 +08:00
|
|
|
|
|
|
|
<div v-loading="loading" element-loading-background="#FFFFFF">
|
|
|
|
<div v-show="loadError"
|
|
|
|
style="width: 100%; height: 300px; display: flex; flex-direction: column; justify-content: center;align-items: center">
|
|
|
|
<img style="height: 100px;width: 100px;"
|
2022-12-12 12:34:12 +08:00
|
|
|
src="/assets/module/figma/icon_load_error.svg"/>
|
2022-11-18 11:07:06 +08:00
|
|
|
<span class="addition-info-title" style="color: #646A73">{{ $t("home.dashboard.public.load_error") }}</span>
|
|
|
|
</div>
|
|
|
|
<div v-show="!loadError">
|
|
|
|
<el-container>
|
2022-11-21 18:22:45 +08:00
|
|
|
<ms-chart ref="chart1" :options="caseOption" :autoresize="true" style="width: 100%;height: 340px;"></ms-chart>
|
2022-11-18 11:07:06 +08:00
|
|
|
</el-container>
|
|
|
|
</div>
|
2022-11-15 16:25:14 +08:00
|
|
|
</div>
|
2022-11-18 11:07:06 +08:00
|
|
|
</el-card>
|
|
|
|
</div>
|
2021-03-13 13:01:28 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-10-10 13:41:39 +08:00
|
|
|
import MsChart from "metersphere-frontend/src/components/chart/MsChart";
|
2022-11-15 16:25:14 +08:00
|
|
|
import {getCurrentProjectID} from "metersphere-frontend/src/utils/token";
|
|
|
|
import {getTrackCaseBar} from "@/api/track";
|
2021-03-13 13:01:28 +08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "CaseMaintenance",
|
|
|
|
components: {MsChart},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-11-15 16:25:14 +08:00
|
|
|
loading: false,
|
|
|
|
loadError: false,
|
|
|
|
caseOption: {}
|
2021-03-13 13:01:28 +08:00
|
|
|
}
|
2022-11-15 16:25:14 +08:00
|
|
|
},
|
|
|
|
activated() {
|
|
|
|
this.search();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search() {
|
|
|
|
this.loading = true;
|
|
|
|
this.loadError = false;
|
|
|
|
let selectProjectId = getCurrentProjectID();
|
|
|
|
getTrackCaseBar(selectProjectId)
|
|
|
|
.then(r => {
|
|
|
|
this.loading = false;
|
|
|
|
this.loadError = false;
|
|
|
|
let data = r.data;
|
|
|
|
this.setBarOption(data);
|
|
|
|
}).catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
this.loadError = true;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
setBarOption(data) {
|
|
|
|
let xAxis = [];
|
|
|
|
data.map(d => {
|
|
|
|
if (!xAxis.includes(d.xAxis)) {
|
|
|
|
xAxis.push(d.xAxis);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
let yAxis1 = data.filter(d => d.groupName === 'FUNCTIONCASE').map(d => [d.xAxis, d.yAxis]);
|
|
|
|
let yAxis2 = data.filter(d => d.groupName === 'RELEVANCECASE').map(d => [d.xAxis, d.yAxis]);
|
|
|
|
let option = {
|
|
|
|
tooltip: {
|
|
|
|
trigger: 'axis',
|
|
|
|
axisPointer: {
|
|
|
|
type: 'shadow'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
xAxis: {
|
|
|
|
type: 'category',
|
2022-11-16 15:18:58 +08:00
|
|
|
data: xAxis,
|
|
|
|
axisTick:{
|
|
|
|
show:false // 不显示坐标轴刻度线
|
|
|
|
},
|
2022-11-15 16:25:14 +08:00
|
|
|
},
|
|
|
|
yAxis: {
|
|
|
|
type: 'value',
|
|
|
|
axisLine: {
|
|
|
|
show: false
|
|
|
|
},
|
|
|
|
axisTick: {
|
|
|
|
show: false
|
2022-11-24 17:07:44 +08:00
|
|
|
},
|
|
|
|
min: 0,
|
|
|
|
max: data.length === 0 ? 40 : null
|
2022-11-15 16:25:14 +08:00
|
|
|
},
|
2022-11-18 11:07:06 +08:00
|
|
|
grid: {
|
|
|
|
left: 0,
|
|
|
|
containLabel: true,
|
2022-11-21 18:22:45 +08:00
|
|
|
top: 80,
|
2022-11-18 11:07:06 +08:00
|
|
|
right: 24,
|
|
|
|
width: 600,
|
2022-11-21 18:22:45 +08:00
|
|
|
height: 255
|
2022-11-18 11:07:06 +08:00
|
|
|
},
|
2022-11-15 16:25:14 +08:00
|
|
|
legend: {
|
2022-11-16 15:18:58 +08:00
|
|
|
itemWidth: 8,
|
|
|
|
itemHeight: 8,
|
|
|
|
data: [{icon: 'rect', name: this.$t('test_track.home.function_case_count')}, {icon: 'rect', name: this.$t('test_track.home.relevance_case_count')}],
|
|
|
|
orient: 'horizontal',
|
2022-11-18 11:07:06 +08:00
|
|
|
left: '0',
|
2022-11-21 18:22:45 +08:00
|
|
|
top: '24'
|
2022-11-15 16:25:14 +08:00
|
|
|
},
|
|
|
|
series: [
|
|
|
|
{
|
|
|
|
name: this.$t('test_track.home.function_case_count'),
|
|
|
|
data: yAxis1,
|
|
|
|
type: 'bar',
|
|
|
|
barWidth: 16,
|
2022-11-24 14:49:28 +08:00
|
|
|
barMinHeight: 5,
|
2022-11-15 16:25:14 +08:00
|
|
|
itemStyle: {
|
2022-11-16 15:18:58 +08:00
|
|
|
color: '#AA4FBF',
|
|
|
|
barBorderRadius: [2, 2, 0, 0]
|
2022-11-15 16:25:14 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: this.$t('test_track.home.relevance_case_count'),
|
|
|
|
data: yAxis2,
|
|
|
|
type: 'bar',
|
|
|
|
barWidth: 16,
|
2022-11-24 14:49:28 +08:00
|
|
|
barMinHeight: 5,
|
2022-11-16 15:18:58 +08:00
|
|
|
itemStyle: {
|
|
|
|
color: '#F9CB2E',
|
|
|
|
barBorderRadius: [2, 2, 0, 0]
|
|
|
|
}
|
2022-11-15 16:25:14 +08:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
this.caseOption = option;
|
|
|
|
},
|
2021-03-13 13:01:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.no-shadow-card{
|
|
|
|
-webkit-box-shadow: 0 0px 0px 0 rgba(0,0,0,.1);
|
|
|
|
box-shadow: 0 0px 0px 0 rgba(0,0,0,.1);
|
|
|
|
}
|
|
|
|
|
2022-10-10 13:41:39 +08:00
|
|
|
.el-card :deep( .el-card__header ) {
|
2021-03-13 13:01:28 +08:00
|
|
|
border-bottom: 0px solid #EBEEF5;
|
|
|
|
padding-bottom: 0px;
|
|
|
|
}
|
|
|
|
</style>
|