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

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

parent b1a7c623
...@@ -35,3 +35,12 @@ export function selectTaskParticipationStatistics() { ...@@ -35,3 +35,12 @@ export function selectTaskParticipationStatistics() {
method: 'post' method: 'post'
}) })
} }
// 科恩 首页对接测试
export function selectTest(data) {
return request({
url: '/system/testCase/getUseCaseMsg',
method: 'post',
data:data
})
}
...@@ -4,15 +4,51 @@ ...@@ -4,15 +4,51 @@
<script> <script>
export default { export default {
name: 'UseCaseRisk', name: 'UseCaseRisk',
props: {
riskLevel: {
type: Array,
default: null
}
},
data() { data() {
return { return {
chart: null chart: null,
medium: 0,
low: 0,
height: 0
} }
}, },
created() {
this.riskPercentage()
},
mounted() { mounted() {
this.init() this.init()
}, },
methods: { 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() { init() {
// 2.初始化 // 2.初始化
this.chart = this.$echarts.init(this.$refs.chart) this.chart = this.$echarts.init(this.$refs.chart)
...@@ -55,8 +91,8 @@ export default { ...@@ -55,8 +91,8 @@ export default {
}, },
data: [ data: [
{ {
value: 20, value: this.height,
name: 'Good', name: '高危',
title: { title: {
offsetCenter: ['-40%', '80%'] offsetCenter: ['-40%', '80%']
}, },
...@@ -65,8 +101,8 @@ export default { ...@@ -65,8 +101,8 @@ export default {
} }
}, },
{ {
value: 40, value: this.medium,
name: 'Better', name: '中危',
title: { title: {
offsetCenter: ['0%', '80%'] offsetCenter: ['0%', '80%']
}, },
...@@ -75,8 +111,8 @@ export default { ...@@ -75,8 +111,8 @@ export default {
} }
}, },
{ {
value: 60, value: this.low,
name: 'Perfect', name: '低危',
title: { title: {
offsetCenter: ['40%', '80%'] offsetCenter: ['40%', '80%']
}, },
......
...@@ -4,6 +4,12 @@ ...@@ -4,6 +4,12 @@
<script> <script>
export default { export default {
name: 'UseCaseTest', name: 'UseCaseTest',
props: {
testType: {
type: Array,
default: null
}
},
data() { data() {
return { return {
chart: null chart: null
...@@ -13,6 +19,18 @@ export default { ...@@ -13,6 +19,18 @@ export default {
this.init() this.init()
}, },
methods: { 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() { init() {
// 2.初始化 // 2.初始化
this.chart = this.$echarts.init(this.$refs.chart) this.chart = this.$echarts.init(this.$refs.chart)
...@@ -56,9 +74,18 @@ export default { ...@@ -56,9 +74,18 @@ export default {
type: 'bar', type: 'bar',
barWidth: '20', barWidth: '20',
data: [ data: [
{ itemStyle: { color: '#7F69E8' }, value: 200 }, {
{ itemStyle: { color: '#1A6FD7' }, value: 150 }, itemStyle: { color: '#7F69E8' },
{ itemStyle: { color: '#13BE24' }, value: 120 } value: this.testTypeFilter('MANUAL')
},
{
itemStyle: { color: '#1A6FD7' },
value: this.testTypeFilter('MANUAL')
},
{
itemStyle: { color: '#13BE24' },
value: this.testTypeFilter('MANUAL')
}
] ]
} }
] ]
......
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
<div class="textLayout"> <div class="textLayout">
<span class="cardOneTitle">测试方法数量</span <span class="cardOneTitle">测试方法数量</span
><span class="cardOneNumber">{{ ><span class="cardOneNumber">{{
quantityStatisticsForm.numberMethods userCaseMsg.testMethodCount
? quantityStatisticsForm.numberMethods ? userCaseMsg.testMethodCount
: 0 : 0
}}</span> }}</span>
</div> </div>
...@@ -63,9 +63,7 @@ ...@@ -63,9 +63,7 @@
<div class="textLayout"> <div class="textLayout">
<span class="cardOneTitle">测试用例数量</span <span class="cardOneTitle">测试用例数量</span
><span class="cardOneNumber">{{ ><span class="cardOneNumber">{{
quantityStatisticsForm.numberUseCases userCaseMsg.useCaseCount ? userCaseMsg.useCaseCount : 0
? quantityStatisticsForm.numberUseCases
: 0
}}</span> }}</span>
</div> </div>
</li> </li>
...@@ -103,8 +101,8 @@ ...@@ -103,8 +101,8 @@
<div class="textLayout"> <div class="textLayout">
<span class="cardOneTitle">测试场景数量</span <span class="cardOneTitle">测试场景数量</span
><span class="cardOneNumber">{{ ><span class="cardOneNumber">{{
quantityStatisticsForm.numberScenes userCaseMsg.testScenarioCount
? quantityStatisticsForm.numberScenes ? userCaseMsg.testScenarioCount
: 0 : 0
}}</span> }}</span>
</div> </div>
...@@ -208,7 +206,7 @@ ...@@ -208,7 +206,7 @@
<el-col :span="14"> <el-col :span="14">
<div class="cardStyle"> <div class="cardStyle">
<div style="display: flex"> <div style="display: flex">
<UseCaseRisk></UseCaseRisk> <UseCaseRisk :risk-level="userCaseMsg.riskLevel"></UseCaseRisk>
<div style="width: 50%; display: flex; align-items: center"> <div style="width: 50%; display: flex; align-items: center">
<div <div
style=" style="
...@@ -226,28 +224,28 @@ ...@@ -226,28 +224,28 @@
<div> <div>
<iconpark-icon name="gaowei" size="24"></iconpark-icon> <iconpark-icon name="gaowei" size="24"></iconpark-icon>
</div> </div>
<div class="lineLast">83</div> <div class="lineLast">{{ riskLevelFilter('HIGH') }}</div>
</div> </div>
<div class="dangerousCard" style="background: #fef6e9"> <div class="dangerousCard" style="background: #fef6e9">
<div class="lineOne">中危</div> <div class="lineOne">中危</div>
<div> <div>
<iconpark-icon name="zhongwei" size="24"></iconpark-icon> <iconpark-icon name="zhongwei" size="24"></iconpark-icon>
</div> </div>
<div class="lineLast">45</div> <div class="lineLast">{{ riskLevelFilter('MEDIUM') }}</div>
</div> </div>
<div class="dangerousCard" style="background: #e8f1fb"> <div class="dangerousCard" style="background: #e8f1fb">
<div class="lineOne">低危</div> <div class="lineOne">低危</div>
<div> <div>
<iconpark-icon name="diwei" size="24"></iconpark-icon> <iconpark-icon name="diwei" size="24"></iconpark-icon>
</div> </div>
<div class="lineLast">78</div> <div class="lineLast">{{ riskLevelFilter('LOW') }}</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="dashed-divider"></div> <div class="dashed-divider"></div>
<div> <div>
<UseCaseTest></UseCaseTest> <UseCaseTest :test-type="userCaseMsg.testType"></UseCaseTest>
</div> </div>
</div> </div>
</el-col> </el-col>
...@@ -333,7 +331,8 @@ import AverageTest from './echartHome/averageTest.vue' ...@@ -333,7 +331,8 @@ import AverageTest from './echartHome/averageTest.vue'
import { import {
selectAverageInspectionRate, selectAverageInspectionRate,
selectQuantityStatistics, selectQuantityStatistics,
selectTaskParticipationStatistics selectTaskParticipationStatistics,
selectTest
} from '../api/system/home' } from '../api/system/home'
import { getDicts } from '../api/system/dict/data' import { getDicts } from '../api/system/dict/data'
...@@ -352,15 +351,33 @@ export default { ...@@ -352,15 +351,33 @@ export default {
averageTestShow: false, averageTestShow: false,
averageInspectionRate: [], averageInspectionRate: [],
taskCompleted: [], taskCompleted: [],
taskCompletedGroup: [] taskCompletedGroup: [],
userCaseMsg: {}
} }
}, },
created() { created() {
this.getAverageInspectionRate()
this.getQuantityStatistics() this.getQuantityStatistics()
this.getTestHome()
this.getTaskCompleted() this.getTaskCompleted()
}, },
mounted() {
this.getAverageInspectionRate()
},
methods: { 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() { getTaskCompleted() {
selectTaskParticipationStatistics().then(res => { selectTaskParticipationStatistics().then(res => {
this.taskCompleted = res.data 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