statistic.vue 931 B

123456789101112131415161718192021222324
  1. <template>
  2. <el-statistic :style="{ '--el-statistic-content-color': color }" :title="title" :value="formatValue">
  3. <template #suffix>{{ formatSuffix }}</template>
  4. </el-statistic>
  5. </template>
  6. <script setup>
  7. import XEUtils from "xe-utils";
  8. const props = defineProps({
  9. title: { type: String, default: "" },
  10. value: { type: Number, default: 0 },
  11. color: { type: String, default: "var(--el-color-primary)" },
  12. });
  13. const formatValue = computed(() => props.value >= 10000 ? XEUtils.round(XEUtils.divide(props.value, 10000)) : XEUtils.round(props.value));
  14. const formatSuffix = computed(() => props.value >= 10000 ? "万元" : "元");
  15. </script>
  16. <style scoped>
  17. .el-statistic :deep(.el-statistic__head) {margin-bottom: 10px;font-size: 15px;font-weight: 500;color: #555;}
  18. .el-statistic :deep(.el-statistic__number) {font-size: 22px;}
  19. .el-statistic :deep(.el-statistic__suffix) {font-size: 12px;color: #999;}
  20. </style>