widgetProgress.vue
3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<template>
<div class="progress" :style="styleColor">
<el-progress class="progress-content" :percentage="dataList.percentage" :strokeWidth="dataList.strokeWidth"
:showText="dataList.showText" :textInside="dataList.textInside" :color="dataList.color"></el-progress>
</div>
</template>
<script>
import { mapState } from 'vuex';
export default {
name: "WidgetProgress",
components: {},
props: {
value: Object,
ispreview: Boolean
},
data() {
return {
options: {}
};
},
computed: {
...mapState('dataSource', ['staticData']),
transStyle() {
return this.objToOne(this.options);
},
styleColor() {
let result = {
position: this.ispreview ? "absolute" : "static",
background: this.transStyle.background,
"text-align": this.transStyle.textAlign,
width: this.transStyle.width + "px",
height: this.transStyle.height + "px",
left: this.transStyle.left + "px",
top: this.transStyle.top + "px",
right: this.transStyle.right + "px",
"border-radius": this.transStyle.borderRadius + 'px',
"--percent-font-size": this.transStyle.percentFontSize + 'px',
"--percent-color": this.transStyle.percentColor,
"--under-color": this.transStyle.underColor
};
const { color1, color2, color3, color4, color5 } = this.transStyle;
const gradientList = [color1, color2, color3, color4, color5];
const gradientList1 = [];
gradientList.forEach(item => {
item && gradientList1.push(item);
});
if (gradientList1.length) {
if (gradientList1.length === 1) {
gradientList1.push(gradientList1[0]);
}
result["--line-gradient"] = `linear-gradient(to right, ${gradientList1.toString()})`;
}
return result;
},
dataList() {
let result = {
strokeWidth: this.transStyle.strokeWidth || 6,
showText: this.transStyle.showText,
textInside: this.transStyle.textInside,
color: this.transStyle.color,
percentage: 50
};
const percentage = this.staticData[this.transStyle.slectedDataType];
if (percentage && typeof percentage === 'number') {
result.percentage = percentage;
}
return result;
}
},
watch: {
value: {
handler(val) {
this.options = val;
},
deep: true
}
},
created() {
this.options = this.value;
},
mounted() { },
methods: {}
};
</script>
<style scoped lang="scss">
.progress {
display: flex;
align-items: center;
justify-content: center;
.progress-content {
display: flex;
align-items: center;
width: 100%;
/deep/ .el-progress-bar__outer {
background-color: var(--under-color, #EBEEF5);
}
/deep/ .el-progress-bar__inner {
background: var(--line-gradient, initial);
}
/deep/ .el-progress-bar__innerText,
/deep/ .el-progress__text {
font-size: var(--percent-font-size, initial) !important;
color: var(--percent-color, initial);
}
}
}
</style>