knowledge-history-teacher.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <view class="mt-40 flex items-center justify-end gap-x-10">
  3. <text class="text-24 text-fore-light">平均正确率</text>
  4. <text class="text-30 text-fore-title font-bold">{{ averageRate.toFixed(1) }}%</text>
  5. </view>
  6. <view class="mt-10">
  7. <progress :percent="averageRate" stroke-width="12" activeColor="#68D119" backgroundColor="#F2F2F2"
  8. :border-radius="8" class="custom-progress" />
  9. </view>
  10. <view class="mt-76">
  11. <student-stat-table :teach-class="teachClass" :data="studentStatData" @rowClick="handleRowClick" />
  12. </view>
  13. </template>
  14. <script lang="ts" setup>
  15. import { OPEN_KNOWLEDGE_DETAIL } from '@/types/injectionSymbols';
  16. import studentStatTable from './student-stat-table.vue';
  17. import { StudentPlanStudyRecord, TeachClass } from '@/types/study';
  18. import { getClassKnowledgeRecord } from '@/api/modules/study';
  19. const openKnowledgeDetail = inject(OPEN_KNOWLEDGE_DETAIL);
  20. const props = defineProps({
  21. teachClass: {
  22. type: Object as PropType<TeachClass>,
  23. default: () => ({})
  24. }
  25. });
  26. const studentStatData = ref<StudentPlanStudyRecord[]>([]);
  27. const averageRate = ref(0);
  28. const loadData = async () => {
  29. getClassKnowledgeRecord({
  30. classId: props.teachClass.classId,
  31. }).then(res => {
  32. studentStatData.value = res.data.list;
  33. averageRate.value = res.data.rate;
  34. })
  35. }
  36. const handleRowClick = (row: StudentPlanStudyRecord) => {
  37. openKnowledgeDetail?.(row.id, row.name);
  38. }
  39. watch(() => props.teachClass, (newVal) => {
  40. if (newVal.classId) {
  41. loadData();
  42. }
  43. }, {
  44. deep: true,
  45. immediate: true
  46. });
  47. </script>
  48. <style lang="scss" scoped></style>