practice-history.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. defineOptions({
  23. options: {
  24. virtualHost: true
  25. }
  26. });
  27. import practiceHistoryStudent from './practice-history-student.vue';
  28. import practiceHistoryTeacher from './practice-history-teacher.vue';
  29. import teacherClassView from '@/pagesStudy/components/teacher-class-view.vue';
  30. import { OPEN_PRACTICE_DETAIL } from '@/types/injectionSymbols';
  31. import { useTransferPage } from '@/hooks/useTransferPage';
  32. import { useUserStore } from '@/store/userStore';
  33. const { transferTo } = useTransferPage();
  34. const currentType = ref('rate');
  35. const typeList = ref([
  36. {
  37. label: '按正确率',
  38. value: 'rate'
  39. },
  40. {
  41. label: '按刷题天数',
  42. value: 'time'
  43. },
  44. {
  45. label: '按刷题题量',
  46. value: 'total'
  47. }
  48. ])
  49. const currentSort = ref('asc');
  50. const tabList = ref([
  51. {
  52. label: '升序',
  53. value: 'asc'
  54. },
  55. {
  56. label: '降序',
  57. value: 'desc'
  58. }
  59. ])
  60. const { isStudent } = storeToRefs(useUserStore());
  61. const handleTypeChange = (value: string) => {
  62. currentType.value = value;
  63. }
  64. const openPracticeDetail = (recordId: number, name: string) => {
  65. transferTo('/pagesStudy/pages/study-practice-detail/study-practice-detail', {
  66. data: {
  67. recordId,
  68. name
  69. }
  70. });
  71. }
  72. provide(OPEN_PRACTICE_DETAIL, openPracticeDetail);
  73. </script>
  74. <style lang="scss" scoped>
  75. .type-wrap {
  76. @apply mt-40 mx-auto p-10 bg-white border border-solid border-border rounded-8 w-fit flex gap-x-10;
  77. }
  78. .type-item {
  79. @apply text-28 text-fore-light px-30 py-8 rounded-5;
  80. }
  81. .is-active {
  82. @apply bg-back text-fore-title font-bold;
  83. }
  84. </style>