ke_junjie
2025-06-04 bb6e2230bb8ded3c5546bc4e4c282ee343754475
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
<template>
  <div class="width99 padding-top2 margintopbot flex justify-between align-center">
    <div
      class="didproject-title flex justify-around align-center border borderradius overflow pointer"
      v-for="(item, index) in titlelist"
      :key="index"
    >
      <div class="height width35 flex align-center justify-center overflow padding10">
        <svg-icon class="fontsize4rem text-center" :style="'color:' + item.color" :icon-class="item.icon" />
      </div>
      <div class="heigth width55 padding10 overflow">
        <p class="fontsiez1rem">{{ item.titel }}</p>
 
        <p class="text-center fontsize2rem fontweight600 color409EFF margin-top15">
          <countTo :startVal="startVal" :endVal="item.mun" :duration="3000"></countTo>
        </p>
      </div>
    </div>
  </div>
</template>
 
<script>
import countTo from 'vue-count-to';
import { GetHomeNumData, GetHomeBarItemData } from '@/api/Didproject';
export default {
  data() {
    return {
      startVal: 0,
      titlelist: [
        {
          icon: 'in-storage',
          titel: '今日入库零件数',
          mun: 0,
          color: '#40C9C6'
        },
        {
          icon: 'skill',
          titel: '今日出库零件数',
          mun: 0,
          color: '#F4516C'
        },
        {
          icon: 'example',
          titel: '今日入库器具数',
          mun: 0,
          color: '#36A3F7'
        },
        {
          icon: 'trade',
          titel: '今日出库器具数',
          mun: 0,
          color: '#34BFA3'
        },
        {
          icon: 'record-chart',
          titel: '超期零件数量',
          mun: 1,
          color: '#ffc637'
        }
      ],
      cleartime: null
    };
  },
  components: { countTo },
  mounted() {
    this.GetHomeNumData();
    this.cleartime = setInterval(() => {
      this.GetHomeNumData();
    }, 60000);
  },
  methods: {
    //今日出入库数据
    GetHomeNumData() {
      if (this.cleartime) {
        clearInterval(this.cleartime);
        this.cleartime = null;
      }
      // no 编号;title 标题;value 数量
      GetHomeNumData().then(res => {
        let data = res.data || [];
        this.titlelist.forEach(item => {
          data.forEach(element => {
            if (item.titel == element.titel) {
              item.mun = element.value;
            }
          });
        });
      });
    }
  },
  beforeDestroy() {
    if (this.cleartime) {
      clearInterval(this.cleartime);
      this.cleartime = null;
    }
  }
};
</script>
 
<style lang="scss" scoped>
.didproject-title {
  width: 18%;
  padding: 0px 0;
  box-shadow: 0 0 4px #c1c9d0;
  background: #f0f2f5;
  transition: all 0.3s;
  &:hover {
    box-shadow: 0 0 4px #99b7e2;
  }
}
</style>