student-stat-table.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <template>
  2. <view>
  3. <ie-table :table-columns="tableColumns" :table-config="tableConfig" :data="data" @rowClick="handleRowClick">
  4. <template #name="{ item }">
  5. <view class="flex items-center justify-center gap-10">
  6. <!-- <ie-image :src="item.avatar" class="w-60 h-60 bg-back" :round="999" /> -->
  7. <text class="flex-1 min-w-1 ellipsis-1">{{ item.name }}</text>
  8. </view>
  9. </template>
  10. <template #rate="{ item }">
  11. <text :class="[item.rate < 70 ? 'text-danger' : 'text-fore-title']">{{ item.rate }}%</text>
  12. </template>
  13. </ie-table>
  14. </view>
  15. </template>
  16. <script lang="ts" setup>
  17. import { TableColumnConfig, TableConfig } from '@/types';
  18. import { TeachClass, StudentPlanStudyRecord } from '@/types/study';
  19. const props = defineProps({
  20. teachClass: {
  21. type: Object as PropType<TeachClass>,
  22. default: () => ({})
  23. },
  24. data: {
  25. type: Array as PropType<StudentPlanStudyRecord[]>,
  26. default: () => []
  27. }
  28. });
  29. const tableConfig: TableConfig = {
  30. border: true,
  31. stripe: false,
  32. emptyText: '暂无数据',
  33. loading: false,
  34. rowKey: 'id'
  35. }
  36. const tableColumns: TableColumnConfig[] = [
  37. {
  38. prop: '',
  39. label: '序号',
  40. type: 'index',
  41. flex: 0.5
  42. },
  43. {
  44. prop: 'name',
  45. label: '姓名',
  46. slot: 'name'
  47. },
  48. {
  49. prop: 'total',
  50. label: '题量',
  51. flex: 0.6
  52. },
  53. {
  54. prop: 'time',
  55. label: '天数',
  56. flex: 0.6
  57. },
  58. {
  59. prop: 'rate',
  60. label: '正确率',
  61. slot: 'rate'
  62. }
  63. ]
  64. const emit = defineEmits<{
  65. rowClick: [row: StudentPlanStudyRecord]
  66. }>();
  67. const handleRowClick = (row: StudentPlanStudyRecord) => {
  68. emit('rowClick', row);
  69. }
  70. // const openKnowledgeDetail = inject(OPEN_KNOWLEDGE_DETAIL);
  71. // const handleRowClick = (row: StudentPlanStudyRecord) => {
  72. // openKnowledgeDetail?.(row.id, row.name);
  73. // }
  74. </script>
  75. <style lang="scss" scoped></style>