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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
| <template>
| <div class="data-container">
| <div class="data-content">
| <div class="icon-item" v-for="item, index in dataList" :style="{ backgroundColor: iconList[index].color }"
| :key="item.id">
| <div class="icon-container">
| <i :class="iconList[index].icon" class="icon-font"></i>
| </div>
| <div class="data-info">
| <div class="data-num" v-inserted :value="item.value">{{ item.value }}</div>
| <div class="data-lable">{{ item.name }}</div>
| </div>
| </div>
|
| </div>
| </div>
| </template>
|
| <script>
| import gsap from 'gsap';
| const nameList = {
| data1: '工单数',
| data2: '恢复数',
| data3: '待恢复数',
| data4: '超期待处理数',
| data5: '超期责任数',
| }
|
|
|
| export default {
| props: {
| activeData: {
| type: Object,
| default: () => { return { name: '自贡市', data1: 0, data2: 0, data3: 0, data4: 0, data5: 0 } },
| }
| },
| data() {
| return {
| dataList: [],
| iconList: [
| { icon: 'el-icon-tickets', color: '#7868d9' },
| { icon: 'el-icon-s-claim', color: '#3eba45' },
| { icon: 'el-icon-edit', color: '#3da7f8' },
| { icon: 'el-icon-warning', color: '#ffbe40' },
| { icon: 'el-icon-error', color: '#fe640d' },
| ]
| }
| },
| methods: {
| formatData(data) {
| if (data) {
| let temp = [];
| Object.keys(data).filter(key => key !== 'name').forEach((key, index) => {
| temp.push({
| id: index + 1,
| name: nameList[key],
| value: data[key]
| });
| });
| this.dataList = temp;
| }
|
| }
| },
| watch: {
| activeData: {
| handler(newVal, oldVal) {
| this.$nextTick(() => {
| this.formatData(newVal);
| })
| },
| immediate: true,
| }
| },
| directives: {
| inserted: {
| bind(el, binding) {
| let target = {
| count: 0
| };
| let finalNumber = el.innerText;
| gsap.to(target, {
| count: finalNumber,
| duration: 1,
| ease: "power2.out",
| onUpdate: () => {
| el.innerText = target.count.toFixed(0);
| }
| })
| },
| update(el, binding) {
| let target = {
| count: el.innerText
| };
| let finalNumber = el.getAttribute('value');
| gsap.to(target, {
| count: finalNumber,
| duration: 1,
| ease: "power2.out",
| onUpdate: () => {
| el.innerText = target.count.toFixed(0);
| }
| })
| }
| }
| }
| }
| </script>
|
| <style lang="scss" scoped>
| .data-container {
| height: 100%;
| }
|
| .data-content {
| height: 100%;
| display: flex;
| flex-direction: column;
| justify-content: space-around;
| }
|
| .icon-item {
| display: flex;
| border-radius: 10px;
| align-items: center;
| padding: 10px 10px;
| }
|
| .icon-container {
| display: flex;
| justify-content: center;
| align-items: center;
| border-radius: 8px;
| margin-right: 10px;
|
| .icon-font {
| font-size: 34px;
| color: #fff;
| }
| }
|
| .data-info {
| display: flex;
| height: 100%;
| flex-direction: column;
| justify-content: center;
| text-align: left;
| color: #fff;
|
| .data-num {
| font-size: 30px;
| }
|
| .data-lable {
| font-size: 16px;
| text-indent: 3px;
| }
| }
| </style>
|
|