Files
dvcp_v2_webapp/project/dvui/layout/AiDvSummary/components/Summary8.vue
yanran200730 7453962f52 党建大屏
2022-05-11 18:07:04 +08:00

125 lines
2.2 KiB
Vue

<template>
<div class="Summary8">
<div class="summary5-item" v-for="(item, index) in arr" :key="index">
<div class="left">
<DonutChart :ratio="item.ratio"></DonutChart>
</div>
<div class="right">
<h2>{{ item[keys] }}</h2>
<p>{{ item[value] }}</p>
</div>
</div>
</div>
</template>
<script>
import DonutChart from './DonutChart'
export default {
name: 'Summary8',
components: {
DonutChart
},
props: {
data: {
type: Array,
default: () => []
},
keys: {
type: String,
default: 'key'
},
value: {
type: String,
default: 'value'
}
},
watch: {
data: {
handler (v) {
if (!v.length) return []
let sum = 0
v.forEach(x => {
sum = x[this.value] + sum
})
this.arr = v.map(v => {
return {
...v,
ratio: Number((v[this.value] / sum).toFixed(2)) * 100
}
})
},
immediate: true,
deep: true
}
},
data () {
return {
arr: []
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.Summary8 {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
width: 100%;
height: 100%;
div {
box-sizing: border-box;
}
.summary5-item {
display: flex;
position: relative;
align-items: center;
.right {
min-width: 90px;
}
.left {
display: flex;
position: relative;
align-items: center;
justify-content: center;
margin-right: 20px;
width: 90px;
height: 90px;
}
h2 {
margin-bottom: 12px;
color: #fff;
font-size: 16px;
font-weight: normal;
}
p {
font-size: 26px;
font-weight: bold;
color: #CEE1FF;
text-shadow: 0px 2px 4px rgba(117, 9, 9, 0.1);
background: linear-gradient(180deg, #FFF6C7 0%, #FF9A02 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
</style>