knowledge-table.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <view class="p-30">
  3. <ie-table :table-columns="tableColumns" :table-config="tableConfig" :data="data">
  4. <template #name="{ item }">
  5. <view class="">
  6. <text class="leading-38">{{ item.name }}</text>
  7. <text v-if="item.directed"
  8. class="ml-10 bg-[#F0FDF4] text-[#22C55E] border border-solid border-[#22C55E] text-20 rounded-4 px-10 py-2">定向</text>
  9. </view>
  10. </template>
  11. <template #rate="{ item }">
  12. {{ item.rate }}%
  13. </template>
  14. </ie-table>
  15. </view>
  16. </template>
  17. <script lang="ts" setup>
  18. import { Study, TableColumnConfig, TableConfig } from '@/types';
  19. const props = defineProps({
  20. data: {
  21. type: Array as PropType<Study.KnowledgeRecord[]>,
  22. default: () => []
  23. }
  24. });
  25. const tableConfig: TableConfig = {
  26. border: true,
  27. stripe: false,
  28. emptyText: '暂无数据',
  29. loading: false,
  30. rowKey: 'id'
  31. }
  32. const tableColumns: TableColumnConfig[] = [
  33. {
  34. prop: 'name',
  35. label: '知识点',
  36. flex: 2,
  37. slot: 'name',
  38. headerAlign: 'center',
  39. align: 'left'
  40. },
  41. {
  42. prop: 'rate',
  43. label: '正确率',
  44. flex: 1,
  45. slot: 'rate'
  46. },
  47. {
  48. prop: 'total',
  49. label: '题量',
  50. flex: 1
  51. }
  52. ]
  53. </script>
  54. <style lang="scss" scoped>
  55. .table-header {
  56. @apply flex items-center bg-[#EBF9FF] rounded-5;
  57. }
  58. .table-header-cell {
  59. @apply flex-1 text-center py-20 text-30 text-fore-light;
  60. }
  61. </style>