CardGroupIndex.vue
2.96 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<script>
export default {
// 指标卡片组
name: 'CardGroupIndex',
components: {},
props: {
// 数据列表
data: {
type: Array,
default: () => [],
},
// isArrow: {
// type: Boolean,
// default: false
// },
defaultProps: {
type: Object,
default: () => ({
title: 'title',
tips: 'tips',
value: 'value',
title1: 'title1',
value1: 'value1',
noArrow: 'noArrow',
}),
},
},
data() {
return {}
},
computed: {},
watch: {},
created() {},
mounted() {},
methods: {
getClass(value) {
let val = Number(value)
if (val > 0) {
return 'ascend'
} else if (val < 0) {
return 'descend'
}
},
getArrow(value) {
let val = Number(value)
if (val > 0) {
return '↑'
} else if (val < 0) {
return '↓'
} else {
return ''
}
},
},
}
</script>
<template>
<ul class="card-group-index flex">
<li v-for="(row, index) in data" :key="index" class="card-index-li">
<div class="label">
<span>{{ row[defaultProps.title] }}</span>
<div v-if="row[defaultProps.tips] !== undefined" class="fr">
<el-popover trigger="hover" :content="row[defaultProps.tips]" placement="top-start">
<i slot="reference" class="el-icon-warning-outline"></i>
</el-popover>
</div>
</div>
<div class="mt10 value">{{ row[defaultProps.value] || 0 }}</div>
<div class="mt15" v-if="row[defaultProps.title1] !== undefined || row[defaultProps.value1] !== undefined">
{{ row[defaultProps.title1] }}
<span class="fr" :class="row[defaultProps.noArrow] || getClass(row[defaultProps.value1])">
{{ row[defaultProps.noArrow] ? '' : getArrow(row[defaultProps.value1]) }}
{{ Math.abs(row[defaultProps.value1]) || 0 }}
</span>
</div>
</li>
</ul>
</template>
<style lang="scss" scoped>
// 指标卡片
.card-index-li {
position: relative;
flex: auto;
// min-width: 200px;
max-width: 240px;
background: #fff;
border-radius: var(--border-radius-big);
border: 1px solid #edf2f9;
line-height: 1;
padding: 22px 20px;
margin-right: 10px;
margin-bottom: var(--card-margin);
// // 6个以上的换行 需定宽并使用 media query
// &:nth-child(n + 8) {
// margin-top: var(--card-margin);ç
// }
&:last-child {
margin-right: 0;
}
.card-icon {
position: absolute;
top: 0;
right: 0;
}
.label {
position: relative;
font-size: 14px;
}
.value,
.value2 {
font-size: 20px;
font-weight: bold;
}
.value2 {
font-size: 24px;
line-height: 1.15;
}
.el-icon-warning-outline {
color: #999;
}
.icon-arrow {
position: absolute;
}
.el-radio,
.el-checkbox {
position: relative;
float: right;
margin-right: 0;
top: -8px;
}
.descend {
color: green;
}
.ascend {
color: red;
}
}
</style>