<template>
  <view>
    <ie-table :table-columns="tableColumns" :table-config="tableConfig" :data="data" @rowClick="handleRowClick">
      <template #name="{ item }">
        <view class="flex items-center justify-center">
          <ie-image :src="item.avatar" class="w-60 h-60 bg-back" :round="999" />
          <text class="ml-10 flex-1 min-w-1 ellipsis-1">{{ item.name }}</text>
        </view>
      </template>
    </ie-table>
  </view>
</template>
<script lang="ts" setup>
import { TableColumnConfig, TableConfig } from '@/types';
import { TeachClass, StudentStat } from '@/types/study';
const props = defineProps({
  teachClass: {
    type: Object as PropType<TeachClass>,
    default: () => ({})
  },
  data: {
    type: Array as PropType<StudentStat[]>,
    default: () => []
  }
});
const tableConfig: TableConfig = {
  border: true,
  stripe: false,
  emptyText: '暂无数据',
  loading: false,
  rowKey: 'id'
}
const tableColumns: TableColumnConfig[] = [
  {
    prop: '',
    label: '序号',
    type: 'index',
    flex: 0.5
  },
  {
    prop: 'name',
    label: '姓名',
    slot: 'name'
  },
  {
    prop: 'questionNum',
    label: '题量',
    flex: 0.6
  },
  {
    prop: 'dateNum',
    label: '天数',
    flex: 0.6
  },
  {
    prop: 'rate',
    label: '正确率'
  }
]
const emit = defineEmits<{
  rowClick: [row: StudentStat]
}>();
const handleRowClick = (row: StudentStat) => {
  emit('rowClick', row);
}
// const openKnowledgeDetail = inject(OPEN_KNOWLEDGE_DETAIL);
// const handleRowClick = (row: StudentStat) => {
//   openKnowledgeDetail?.(row.id, row.name);
// }
</script>
<style lang="scss" scoped></style>