itemCard.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <div class="card-box">
  3. <div class="card-img" :class="cardClass" :style="cardStyle" @click="cardClick"></div>
  4. <div v-if="progress.show" class="card-progress">
  5. <el-progress :percentage="progress.percent.toFixed(0)" :stroke-width="10" :status="progressStatus" />
  6. <div class="progress-name">{{ progress.name }}</div>
  7. </div>
  8. </div>
  9. </template>
  10. <script setup lang="ts">
  11. import { computed } from 'vue';
  12. interface Props {
  13. type: 'training' | 'report' | 'report_share';
  14. size?: string;
  15. active?: boolean;
  16. progress?: {
  17. show: boolean;
  18. name: string;
  19. percent: number;
  20. };
  21. }
  22. const props = withDefaults(defineProps<Props>(), {
  23. type: 'training',
  24. size: '25rem',
  25. active: false,
  26. progress: () => {
  27. return { show: false, name: '', percent: 0 };
  28. },
  29. });
  30. const emits = defineEmits(['click']);
  31. const progressStatus = computed(() => {
  32. return props.progress.percent == 100 ? 'success' : '';
  33. });
  34. const cardClass = computed(() => {
  35. let className = props.active ? props.type : props.type + '_gray';
  36. return [className];
  37. });
  38. const cardStyle = computed(() => {
  39. return {
  40. width: props.size,
  41. height: props.size,
  42. };
  43. });
  44. const cardClick = () => {
  45. if (props.active) emits('click', props.type);
  46. };
  47. </script>
  48. <style lang="scss" scoped>
  49. .card-img {
  50. background-size: 100% auto;
  51. background-repeat: no-repeat;
  52. background-position: center center;
  53. cursor: pointer;
  54. // &.training {
  55. // background-image: url(/src/assets/student/step/training.png);
  56. // }
  57. // &.training_gray {
  58. // background-image: url(/src/assets/student/step/training.png);
  59. // cursor: not-allowed;
  60. // }
  61. &.training {
  62. background-image: url(/src/assets/student/step/LiLunYuShiXunXueXi_Yes.webp);
  63. }
  64. &.training_gray {
  65. background-image: url(/src/assets/student/step/LiLunYuShiXunXueXi_No.webp);
  66. cursor: not-allowed;
  67. }
  68. &.assessment {
  69. background-image: url(/src/assets/student/step/LiLunYuShiXunKaoHe_Yes.webp);
  70. }
  71. &.assessment_gray {
  72. background-image: url(/src/assets/student/step/LiLunYuShiXunKaoHe_No.webp);
  73. cursor: not-allowed;
  74. }
  75. &.report {
  76. background-image: url(/src/assets/student/step/report.png);
  77. }
  78. &.report_gray {
  79. background-image: url(/src/assets/student/step/report_gray.png);
  80. cursor: not-allowed;
  81. }
  82. &.report_share {
  83. background-image: url(/src/assets/student/step/report_share.png);
  84. }
  85. &.report_share_gray {
  86. background-image: url(/src/assets/student/step/report_share_gray.png);
  87. cursor: not-allowed;
  88. }
  89. }
  90. .card-progress {
  91. margin-left: 4rem;
  92. .progress-name {
  93. padding-right: 2rem;
  94. line-height: 3rem;
  95. color: white;
  96. text-align: center;
  97. font-size: 1rem;
  98. }
  99. }
  100. :deep(.el-progress__text) {
  101. color: white;
  102. min-width: unset;
  103. }
  104. </style>