Commit 583d6470 authored by 高滢's avatar 高滢

feat(首页): 测试接口对接

parent b1a7c623
......@@ -35,3 +35,12 @@ export function selectTaskParticipationStatistics() {
method: 'post'
})
}
// 科恩 首页对接测试
export function selectTest(data) {
return request({
url: '/system/testCase/getUseCaseMsg',
method: 'post',
data:data
})
}
......@@ -4,15 +4,51 @@
<script>
export default {
name: 'UseCaseRisk',
props: {
riskLevel: {
type: Array,
default: null
}
},
data() {
return {
chart: null
chart: null,
medium: 0,
low: 0,
height: 0
}
},
created() {
this.riskPercentage()
},
mounted() {
this.init()
},
methods: {
riskPercentage() {
if (this.riskLevel) {
var total = 0
for (const item of this.riskLevel) {
total += item.count
}
var mediumObj = this.riskLevel.filter(obj => obj.value === 'MEDIUM')
if (mediumObj.length > 0 && total > 0) {
var a = mediumObj[0].count / total
this.medium = Math.round(a * 100)
console.log('323', a)
}
var lowObj = this.riskLevel.filter(obj => obj.value === 'LOW')
if (lowObj.length > 0 && total > 0) {
var c = lowObj[0].count / total
this.low = Math.round(c * 100)
}
var heightObj = this.riskLevel.filter(obj => obj.value === 'HIGH')
if (heightObj.length > 0 && total > 0) {
var b = heightObj[0].count / total
this.height = Math.round(b * 100)
}
}
},
init() {
// 2.初始化
this.chart = this.$echarts.init(this.$refs.chart)
......@@ -55,8 +91,8 @@ export default {
},
data: [
{
value: 20,
name: 'Good',
value: this.height,
name: '高危',
title: {
offsetCenter: ['-40%', '80%']
},
......@@ -65,8 +101,8 @@ export default {
}
},
{
value: 40,
name: 'Better',
value: this.medium,
name: '中危',
title: {
offsetCenter: ['0%', '80%']
},
......@@ -75,8 +111,8 @@ export default {
}
},
{
value: 60,
name: 'Perfect',
value: this.low,
name: '低危',
title: {
offsetCenter: ['40%', '80%']
},
......
......@@ -4,6 +4,12 @@
<script>
export default {
name: 'UseCaseTest',
props: {
testType: {
type: Array,
default: null
}
},
data() {
return {
chart: null
......@@ -13,6 +19,18 @@ export default {
this.init()
},
methods: {
testTypeFilter(value) {
if (this.testType) {
var obj = this.testType.filter(obj => obj.value === value)
if (obj.length > 0) {
return obj[0].count
} else {
return 0
}
} else {
return 0
}
},
init() {
// 2.初始化
this.chart = this.$echarts.init(this.$refs.chart)
......@@ -56,9 +74,18 @@ export default {
type: 'bar',
barWidth: '20',
data: [
{ itemStyle: { color: '#7F69E8' }, value: 200 },
{ itemStyle: { color: '#1A6FD7' }, value: 150 },
{ itemStyle: { color: '#13BE24' }, value: 120 }
{
itemStyle: { color: '#7F69E8' },
value: this.testTypeFilter('MANUAL')
},
{
itemStyle: { color: '#1A6FD7' },
value: this.testTypeFilter('MANUAL')
},
{
itemStyle: { color: '#13BE24' },
value: this.testTypeFilter('MANUAL')
}
]
}
]
......
......@@ -49,8 +49,8 @@
<div class="textLayout">
<span class="cardOneTitle">测试方法数量</span
><span class="cardOneNumber">{{
quantityStatisticsForm.numberMethods
? quantityStatisticsForm.numberMethods
userCaseMsg.testMethodCount
? userCaseMsg.testMethodCount
: 0
}}</span>
</div>
......@@ -63,9 +63,7 @@
<div class="textLayout">
<span class="cardOneTitle">测试用例数量</span
><span class="cardOneNumber">{{
quantityStatisticsForm.numberUseCases
? quantityStatisticsForm.numberUseCases
: 0
userCaseMsg.useCaseCount ? userCaseMsg.useCaseCount : 0
}}</span>
</div>
</li>
......@@ -103,8 +101,8 @@
<div class="textLayout">
<span class="cardOneTitle">测试场景数量</span
><span class="cardOneNumber">{{
quantityStatisticsForm.numberScenes
? quantityStatisticsForm.numberScenes
userCaseMsg.testScenarioCount
? userCaseMsg.testScenarioCount
: 0
}}</span>
</div>
......@@ -208,7 +206,7 @@
<el-col :span="14">
<div class="cardStyle">
<div style="display: flex">
<UseCaseRisk></UseCaseRisk>
<UseCaseRisk :risk-level="userCaseMsg.riskLevel"></UseCaseRisk>
<div style="width: 50%; display: flex; align-items: center">
<div
style="
......@@ -226,28 +224,28 @@
<div>
<iconpark-icon name="gaowei" size="24"></iconpark-icon>
</div>
<div class="lineLast">83</div>
<div class="lineLast">{{ riskLevelFilter('HIGH') }}</div>
</div>
<div class="dangerousCard" style="background: #fef6e9">
<div class="lineOne">中危</div>
<div>
<iconpark-icon name="zhongwei" size="24"></iconpark-icon>
</div>
<div class="lineLast">45</div>
<div class="lineLast">{{ riskLevelFilter('MEDIUM') }}</div>
</div>
<div class="dangerousCard" style="background: #e8f1fb">
<div class="lineOne">低危</div>
<div>
<iconpark-icon name="diwei" size="24"></iconpark-icon>
</div>
<div class="lineLast">78</div>
<div class="lineLast">{{ riskLevelFilter('LOW') }}</div>
</div>
</div>
</div>
</div>
<div class="dashed-divider"></div>
<div>
<UseCaseTest></UseCaseTest>
<UseCaseTest :test-type="userCaseMsg.testType"></UseCaseTest>
</div>
</div>
</el-col>
......@@ -333,7 +331,8 @@ import AverageTest from './echartHome/averageTest.vue'
import {
selectAverageInspectionRate,
selectQuantityStatistics,
selectTaskParticipationStatistics
selectTaskParticipationStatistics,
selectTest
} from '../api/system/home'
import { getDicts } from '../api/system/dict/data'
......@@ -352,15 +351,33 @@ export default {
averageTestShow: false,
averageInspectionRate: [],
taskCompleted: [],
taskCompletedGroup: []
taskCompletedGroup: [],
userCaseMsg: {}
}
},
created() {
this.getAverageInspectionRate()
this.getQuantityStatistics()
this.getTestHome()
this.getTaskCompleted()
},
mounted() {
this.getAverageInspectionRate()
},
methods: {
getTestHome() {
selectTest({ name: '汽车整车信息安全技术要求' }).then(res => {
this.userCaseMsg = res.data
console.log('res', res)
})
},
riskLevelFilter(value) {
var obj = this.userCaseMsg.riskLevel.filter(obj => obj.value === value)
if (obj.length > 0) {
return obj[0].count
} else {
return 0
}
},
getTaskCompleted() {
selectTaskParticipationStatistics().then(res => {
this.taskCompleted = res.data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment