student-stat-table.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <view class="h-full">
  3. <ie-table v-if="data.length > 0" :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 v-else class="bg-[#F6F8FA] text-center py-50 text-26 text-fore-light rounded-5">暂无数据</view>
  15. </view>
  16. </template>
  17. <script lang="ts" setup>
  18. import { TableColumnConfig, TableConfig } from '@/types';
  19. import { TeachClass, StudentPlanStudyRecord } from '@/types/study';
  20. const props = defineProps({
  21. teachClass: {
  22. type: Object as PropType<TeachClass>,
  23. default: () => ({})
  24. },
  25. data: {
  26. type: Array as PropType<StudentPlanStudyRecord[]>,
  27. default: () => []
  28. }
  29. });
  30. const tableConfig: TableConfig = {
  31. border: true,
  32. stripe: false,
  33. emptyText: '暂无数据',
  34. loading: false,
  35. rowKey: 'id'
  36. }
  37. const tableColumns: TableColumnConfig[] = [
  38. {
  39. prop: '',
  40. label: '序号',
  41. type: 'index',
  42. flex: 0.5
  43. },
  44. {
  45. prop: 'name',
  46. label: '姓名',
  47. slot: 'name'
  48. },
  49. {
  50. prop: 'total',
  51. label: '题量',
  52. flex: 0.6
  53. },
  54. {
  55. prop: 'time',
  56. label: '天数',
  57. flex: 0.6
  58. },
  59. {
  60. prop: 'rate',
  61. label: '正确率',
  62. slot: 'rate'
  63. }
  64. ]
  65. const emit = defineEmits<{
  66. rowClick: [row: StudentPlanStudyRecord]
  67. }>();
  68. const handleRowClick = (row: StudentPlanStudyRecord) => {
  69. emit('rowClick', row);
  70. }
  71. // const openKnowledgeDetail = inject(OPEN_KNOWLEDGE_DETAIL);
  72. // const handleRowClick = (row: StudentPlanStudyRecord) => {
  73. // openKnowledgeDetail?.(row.id, row.name);
  74. // }
  75. </script>
  76. <style lang="scss" scoped></style>