paper-work-history-detail.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <div>
  3. <dynamic-table :rows="rows" :columns="columns">
  4. <template #index="{$index}">
  5. {{ $index + 1 }}
  6. </template>
  7. <template #type="{display}">
  8. {{ translateType(display) }}
  9. </template>
  10. <template #title="{row, display}">
  11. {{ display }}({{ row.remark }})
  12. </template>
  13. <template #doneTime="{row, display}">
  14. <span>{{ row.isDo ? row.doneTime : '' }}</span>
  15. </template>
  16. <template #status="{row}">
  17. {{ row.isDo ? '已完成' : '未完成' }}
  18. </template>
  19. <template #rate="{row, display}">
  20. {{ row.isDo && display ? display + '%' : '' }}
  21. </template>
  22. <template #action="{row}">
  23. <el-button v-if="isPaperDone(row)" type="text" icon="el-icon-view"
  24. @click="$emit('paperView',row)">查看
  25. </el-button>
  26. </template>
  27. </dynamic-table>
  28. </div>
  29. </template>
  30. <script>
  31. import { getHomeworkStudents } from '@/api/webApi/homework'
  32. import DynamicTable from '@/components/dynamic-table/index'
  33. import consts from '@/common/mx-const'
  34. import HomeworkPaper from '@/views/questioncenter/components/homework-paper'
  35. export default {
  36. name: 'paper-work-history-detail',
  37. components: { HomeworkPaper, DynamicTable },
  38. props: ['workId', 'type'],
  39. data() {
  40. return {
  41. rows: []
  42. }
  43. },
  44. computed: {
  45. useVideo() {
  46. return !!consts.enum.homeworkTypes.find(t => t.value == this.type)?.useVideo
  47. },
  48. columns() {
  49. return [
  50. { prop: 'id', label: '序号', width: '80px', slotBody: 'index' },
  51. { prop: 'type', label: '类型', width: '120px', slotBody: 'type' },
  52. { prop: 'title', label: '学生', slotBody: 'title' },
  53. { prop: 'className', label: '班级', sortable: true },
  54. { prop: 'doneTime', label: '完成时间', width: '180px', slotBody: 'doneTime' },
  55. { prop: 'isDo', label: '状态', width: '120px', slotBody: 'status', sortable: true },
  56. { prop: 'scoreRate', label: this.useVideo ? '观看比例' : '得分率', width: '100px', slotBody: 'rate', sortable: true },
  57. { prop: 'action', label: '操作', width: '80px', slotBody: 'action', hidden: this.useVideo }
  58. ]
  59. }
  60. },
  61. mounted() {
  62. getHomeworkStudents({
  63. workId: this.workId
  64. }).then(res => {
  65. this.rows = res.data
  66. })
  67. },
  68. methods: {
  69. translateType(type) {
  70. const enumType = consts.enum.homeworkTypes.find(t => t.value == type)
  71. return enumType?.label || type
  72. },
  73. isPaperDone(row) {
  74. return row.isDo && consts.enum.homeworkTypes.find(t => t.value == row.type)?.usePaper
  75. }
  76. }
  77. }
  78. </script>
  79. <style scoped>
  80. </style>