practice-history.vue 2.4 KB

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