ZhangXianQiang
2024-03-12 05e80f0a0531e3b3d10836599f63189af0ee0524
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
<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">{{ item.value }}</div>
          <div class="data-lable">{{ item.name }}</div>
        </div>
      </div>
 
    </div>
  </div>
</template>
 
<script>
 
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,
    }
  },
}
</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>