statistic.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import dayjs from "dayjs";
  4. import ReCol from "@/components/ReCol";
  5. import { useTransition } from "@vueuse/core";
  6. defineOptions({
  7. name: "Statistic"
  8. });
  9. const value = ref(Date.now() + 1000 * 60 * 60 * 7);
  10. const value1 = ref(Date.now() + 1000 * 60 * 60 * 24 * 2);
  11. const value2 = ref(dayjs().add(1, "month").startOf("month"));
  12. const source = ref(0);
  13. const outputValue = useTransition(source, {
  14. duration: 1500
  15. });
  16. source.value = 36000;
  17. function reset() {
  18. value1.value = Date.now() + 1000 * 60 * 60 * 24 * 2;
  19. }
  20. </script>
  21. <template>
  22. <div>
  23. <el-card shadow="never">
  24. <template #header>
  25. <div class="card-header">
  26. <el-link
  27. v-tippy="{
  28. content: '点击查看详细文档'
  29. }"
  30. href="https://element-plus.org/zh-CN/component/statistic.html"
  31. target="_blank"
  32. style="font-size: 16px; font-weight: 800"
  33. >
  34. 统计组件
  35. </el-link>
  36. </div>
  37. <el-link
  38. class="mt-2"
  39. href="https://github.com/pure-admin/vue-pure-admin/blob/main/src/views/components/statistic.vue"
  40. target="_blank"
  41. >
  42. 代码位置 src/views/components/statistic.vue
  43. </el-link>
  44. </template>
  45. <el-row :gutter="24">
  46. <re-col :value="6" :xs="24" :sm="24">
  47. <el-statistic title="需求人数" :value="outputValue" />
  48. </re-col>
  49. <re-col :value="6" :xs="24" :sm="24">
  50. <el-countdown title="距离答疑结束还剩" :value="value" />
  51. </re-col>
  52. <re-col :value="6" :xs="24" :sm="24">
  53. <el-countdown
  54. title="VIP到期时间还剩"
  55. format="HH:mm:ss"
  56. :value="value1"
  57. />
  58. <el-button class="mt-2!" type="primary" text bg @click="reset">
  59. 重置
  60. </el-button>
  61. </re-col>
  62. <re-col :value="6" :xs="24" :sm="24">
  63. <el-countdown format="DD天 HH时 mm分 ss秒" :value="value2">
  64. <template #title>
  65. <div style="display: inline-flex; align-items: center">
  66. <IconifyIconOnline icon="ep:calendar" class="mr-2" />
  67. 距离下个月还剩
  68. </div>
  69. </template>
  70. </el-countdown>
  71. <div class="mt-2">{{ value2.format("YYYY-MM-DD") }}</div>
  72. </re-col>
  73. </el-row>
  74. </el-card>
  75. </div>
  76. </template>
  77. <style scoped>
  78. .el-col {
  79. text-align: center;
  80. }
  81. </style>