practice-history.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <view class="flex-1 min-h-1 bg-white">
  3. <practice-history-student v-if="isStudent" />
  4. <teacher-class-view v-else>
  5. <template #default="{ teachClass }">
  6. <view class="type-wrap">
  7. <view v-for="item in typeList" :key="item.value" class="type-item"
  8. :class="{ 'is-active': currentType === item.value }" @click="handleTypeChange(item.value)">{{ item.label }}
  9. </view>
  10. </view>
  11. <view class="mt-30 w-fit mx-auto">
  12. <ie-tab :options="tabList" v-model="currentSort" />
  13. </view>
  14. <view class="mt-30">
  15. <practice-history-teacher :teach-class="teachClass" :current-type="currentType" :current-sort="currentSort" />
  16. </view>
  17. </template>
  18. </teacher-class-view>
  19. </view>
  20. </template>
  21. <script lang="ts" setup>
  22. import practiceHistoryStudent from './practice-history-student.vue';
  23. import practiceHistoryTeacher from './practice-history-teacher.vue';
  24. import teacherClassView from '@/pagesStudy/components/teacher-class-view.vue';
  25. import { OPEN_PRACTICE_DETAIL } from '@/types/injectionSymbols';
  26. import { useTransferPage } from '@/hooks/useTransferPage';
  27. import { useUserStore } from '@/store/userStore';
  28. const { transferTo } = useTransferPage();
  29. const currentType = ref('rate');
  30. const typeList = ref([
  31. {
  32. label: '按正确率',
  33. value: 'rate'
  34. },
  35. {
  36. label: '按刷题天数',
  37. value: 'time'
  38. },
  39. {
  40. label: '按刷题题量',
  41. value: 'total'
  42. }
  43. ])
  44. const currentSort = ref('asc');
  45. const tabList = ref([
  46. {
  47. label: '升序',
  48. value: 'asc'
  49. },
  50. {
  51. label: '降序',
  52. value: 'desc'
  53. }
  54. ])
  55. const { isStudent } = storeToRefs(useUserStore());
  56. const handleTypeChange = (value: string) => {
  57. currentType.value = value;
  58. }
  59. const openPracticeDetail = (recordId: number, name: string) => {
  60. transferTo('/pagesStudy/pages/study-practice-detail/study-practice-detail', {
  61. data: {
  62. recordId,
  63. name
  64. }
  65. });
  66. }
  67. provide(OPEN_PRACTICE_DETAIL, openPracticeDetail);
  68. </script>
  69. <style lang="scss" scoped>
  70. .type-wrap {
  71. @apply mt-40 mx-auto p-10 bg-white border border-solid border-border rounded-8 w-fit flex gap-x-10;
  72. }
  73. .type-item {
  74. @apply text-28 text-fore-light px-30 py-8 rounded-5;
  75. }
  76. .is-active {
  77. @apply bg-back text-fore-title font-bold;
  78. }
  79. </style>