Blame view

admin-web-master/src/views/dashboard/components/miniCard.vue 1.41 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="miniCardComponents">
      <span class="title">{{ title }}</span>
      <h2>{{ nums }}</h2>
      <span class="gray">{{ precent }}:</span>
      <span
        class="precent"
        :class="{
          redP : precentData > 0,
          greenP: precentData < 0
        }"
      >
        {{ precentData || 0 }}%
      </span>
      <span v-if="precentData > 0" class="triangle up"></span>
      <span v-if="precentData < 0" class="triangle down"></span>
    </div>
  </template>
  
  <script>
  export default {
    props: {
      title: {
        type: String,
        default: ''
      },
      precent: {
        type: String,
        default: ''
      },
      nums: {
        type: Number,
        default: 0
      },
      precentData: {
        type: Number,
        default: 0
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .miniCardComponents{
    $red: #D04A41;
    $green: #427A0A;
    margin-right: 50px;
    h2{
      margin: 12px 0;
      font-weight: bold;
    }
    .title{
      font-size: 16px;
      font-weight: 700;
    }
    .gray{
      color: #929292;
    }
    .precent{
      margin: 0 8px;
    }
    .redP{
      color: $red;
    }
    .greenP{
      color: $green;
    }
    .triangle{
      width: 0;
      height: 0;
      position: relative;
      border: 8px solid;
    }
    .up{
      position: relative;
      top: -12px;
      border-color: transparent transparent $red transparent;
    }
    .down{
      position: relative;
      top: 12px;
      border-color: $green transparent transparent transparent;
    }
  }
  </style>