DataCard.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <!-- 数据卡片 -->
  2. <script setup lang="ts">
  3. import SvgIcon from "@/components/SvgIcon/index.vue";
  4. import { useTransition, TransitionPresets } from "@vueuse/core";
  5. const props = defineProps({
  6. classes: {
  7. type: Number,
  8. default: 0,
  9. required: true,
  10. },
  11. teachers: {
  12. type: Number,
  13. default: 0,
  14. required: true,
  15. },
  16. students: {
  17. type: Number,
  18. default: 0,
  19. required: true,
  20. },
  21. equipments: {
  22. type: Number,
  23. default: 0,
  24. required: true,
  25. },
  26. trainings: {
  27. type: Number,
  28. default: 0,
  29. required: true,
  30. },
  31. });
  32. // 卡片数字动效
  33. function countNumber(number) {
  34. return useTransition(number, {
  35. duration: 5000,
  36. transition: TransitionPresets.easeOutExpo,
  37. });
  38. }
  39. // 全部班级
  40. const classCount = ref(0);
  41. const classCountOutput = countNumber(classCount);
  42. // 全部教师
  43. const teacherCount = ref(0);
  44. const teacherCountOutput = countNumber(teacherCount);
  45. // 全部学生
  46. const studentCount = ref(0);
  47. const studentCountOutput = countNumber(studentCount);
  48. // 设备套数
  49. const equipmentCount = ref(0);
  50. const equipmentCountOutput = countNumber(equipmentCount);
  51. // 累计训练次数
  52. const trainingCount = ref(0);
  53. const trainingCountOutput = countNumber(trainingCount);
  54. onMounted(() => {
  55. classCount.value = <number>props.classes;
  56. teacherCount.value = <number>props.teachers;
  57. studentCount.value = <number>props.students;
  58. equipmentCount.value = <number>props.equipments;
  59. trainingCount.value = <number>props.trainings;
  60. });
  61. </script>
  62. <template>
  63. <el-row :gutter="40" class="data-card">
  64. <el-col :xs="24" :sm="12" :md="8" :lg="5">
  65. <div class="card c1">
  66. <span class="n">{{ Math.round(classCountOutput) }}</span
  67. ><span>全部班级</span>
  68. </div>
  69. </el-col>
  70. <el-col :xs="24" :sm="12" :md="8" :lg="5">
  71. <div class="card c2">
  72. <span class="n">{{ Math.round(teacherCountOutput) }}</span
  73. ><span>全部教师</span>
  74. </div>
  75. </el-col>
  76. <el-col :xs="24" :sm="12" :md="8" :lg="5">
  77. <div class="card c3">
  78. <span class="n">{{ Math.round(studentCountOutput) }}</span
  79. ><span>全部学生</span>
  80. </div>
  81. </el-col>
  82. <el-col :xs="24" :sm="12" :md="8" :lg="5">
  83. <div class="card c4">
  84. <span class="n">{{ Math.round(equipmentCountOutput) }}</span
  85. ><span>设备套数</span>
  86. </div>
  87. </el-col>
  88. <el-col :xs="24" :sm="12" :md="8" :lg="5">
  89. <div class="card c5">
  90. <span class="n">{{ Math.round(trainingCountOutput) }}</span
  91. ><span>累计训练次数</span>
  92. </div>
  93. </el-col>
  94. </el-row>
  95. </template>
  96. <style lang="scss" scoped>
  97. @media only screen and (min-width: 1200px) {
  98. .el-col-lg-5 {
  99. display: block;
  100. max-width: 20%;
  101. min-width: 285px;
  102. flex: 0 0 20%;
  103. }
  104. }
  105. .data-card {
  106. margin: 0 auto !important;
  107. padding: 22px 42px;
  108. background: #ffffff;
  109. border-radius: 30px;
  110. .card {
  111. box-sizing: border-box;
  112. width: 265px;
  113. height: 134px;
  114. max-width: 100%;
  115. padding: 32px 0 0 145px;
  116. margin: 20px 0;
  117. background-size: 100% auto;
  118. background-repeat: no-repeat;
  119. &.c1 {
  120. background-image: url("../../../assets/index/classes.png");
  121. }
  122. &.c2 {
  123. background-image: url("../../../assets/index/teachers.png");
  124. }
  125. &.c3 {
  126. background-image: url("../../../assets/index/students.png");
  127. }
  128. &.c4 {
  129. background-image: url("../../../assets/index/equipments.png");
  130. }
  131. &.c5 {
  132. background-image: url("../../../assets/index/trainings.png");
  133. }
  134. span {
  135. display: block;
  136. color: #142141;
  137. &.n {
  138. font-size: 26px;
  139. font-weight: bold;
  140. }
  141. }
  142. }
  143. }
  144. @media only screen and (max-width: 1200px) {
  145. .data-card .card {
  146. padding: 32px 0 0 74px;
  147. text-align: center;
  148. white-space: nowrap;
  149. }
  150. }
  151. </style>