yudao-init/src/views/copilot/efficiency/components/sub/std/ProgressBar.vue

134 lines
2.6 KiB
Vue
Raw Normal View History

2024-05-08 16:38:05 +08:00
<!--
2024-04-29 13:26:38 +08:00
filename: ProgressBar.vue
author: liubin
date: 2024-04-29 09:18:30
2024-05-08 16:38:05 +08:00
description:
2024-04-29 13:26:38 +08:00
-->
<template>
2024-06-07 11:13:59 +08:00
<div class="progress-bar" :data-title="title" :data-rate="current + '%'">
2024-05-11 16:40:29 +08:00
<div class="progress-bar__rate" :style="{ width: dataRate == '-' ? 0 : dataRate }"></div>
2024-04-29 13:26:38 +08:00
</div>
</template>
<script>
export default {
name: "ProgressBar",
components: {},
props: {
value: {
type: Number,
default: 0,
},
2024-06-07 11:13:59 +08:00
target: {
type: Number,
default: 0,
},
previous: {
type: Number,
default: 0,
},
current: {
type: Number,
default: 0,
},
2024-05-29 17:05:55 +08:00
// total: {
// type: Number,
// default: 0,
// },
2024-04-29 13:26:38 +08:00
title: {
type: String,
default: "",
},
},
data() {
2024-05-29 17:05:55 +08:00
return {};
2024-04-29 13:26:38 +08:00
},
computed: {
dataRate() {
2024-06-07 11:13:59 +08:00
// if (this.current != 0 && this.target != 0) {
2024-06-27 09:28:04 +08:00
console.log( '1111111111', this.current, this.target,this.previous);
2024-06-07 11:13:59 +08:00
return this.current == 0 && this.target == 0
? 0
: this.current != 0 && this.target != 0
? `${((this.current / this.target) * 100).toFixed(2)}%`
2024-07-09 17:01:11 +08:00
: this.current != 0 && this.target == 0 && this.current >= 100 ? 100 + '%' : this.current != 0 && this.target == 0 && this.current < 100 ? parseFloat(this.current).toFixed(2) + '%' : 0 + '%'
2024-06-07 11:13:59 +08:00
// } else if(this.previous != 0) {
// return this.previous + '%'
// }
2024-04-29 13:26:38 +08:00
},
},
methods: {},
};
</script>
<style scoped lang="scss">
.progress-bar {
2024-04-29 14:18:52 +08:00
height: 10px;
2024-04-29 13:26:38 +08:00
background-color: #002f6b;
border-radius: 4px;
2024-04-29 14:18:52 +08:00
margin-bottom: 12px;
2024-04-29 13:26:38 +08:00
position: relative;
&:before {
content: attr(data-title);
display: inline-block;
color: #fff;
position: absolute;
2024-04-29 14:18:52 +08:00
bottom: -200%;
2024-04-29 13:26:38 +08:00
font-size: 12px;
}
&:after {
content: attr(data-rate);
display: inline-block;
color: #fff;
position: absolute;
2024-04-29 14:18:52 +08:00
bottom: -200%;
2024-05-29 17:05:55 +08:00
right: 0;
2024-04-29 13:26:38 +08:00
font-size: 12px;
}
2024-04-29 14:18:52 +08:00
&:first-child {
&:after {
color: #11eae3;
}
}
2024-05-29 17:05:55 +08:00
2024-04-29 14:18:52 +08:00
&:nth-child(2) {
&:after {
color: #0e65fd;
}
}
2024-04-29 13:26:38 +08:00
.progress-bar__rate {
2024-04-29 14:18:52 +08:00
position: absolute;
2024-04-29 13:26:38 +08:00
display: inline-block;
height: 100%;
width: 0;
border-radius: 4px;
2024-05-29 17:05:55 +08:00
background: linear-gradient(to right,
#004c5e11 10%,
#004c5e,
#0ac0c0,
#11eae3);
2024-04-29 13:26:38 +08:00
}
2024-04-29 14:18:52 +08:00
&:first-child {
.progress-bar__rate {
2024-05-29 17:05:55 +08:00
background: linear-gradient(to right,
#004c5e11 10%,
#004c5e,
#0ac0c0,
#11eae3);
2024-04-29 14:18:52 +08:00
}
}
&:nth-child(2) {
.progress-bar__rate {
background: linear-gradient(to right, #0048a811, #0048a8, #0e65fd);
}
}
2024-04-29 13:26:38 +08:00
}
</style>