MarkHistoryList.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <scoring-panel-container v-model="visible" class="mark-history-list" title="给分记录">
  3. <template #default>
  4. <slot :data="tableData">
  5. <base-table highlight-current-row size="small" :data="tableData" :columns="columns"></base-table>
  6. </slot>
  7. </template>
  8. </scoring-panel-container>
  9. </template>
  10. <script setup lang="ts" name="MarkHistoryList">
  11. /** 给分记录 */
  12. import { computed, withDefaults, watch, defineComponent, useSlots } from 'vue'
  13. import BaseDialog from '@/components/element/BaseDialog.vue'
  14. import BaseTable from '@/components/element/BaseTable.vue'
  15. import useVModel from '@/hooks/useVModel'
  16. import useFetch from '@/hooks/useFetch'
  17. import type { ExtractApiResponse } from 'api-type'
  18. import type { EpTableColumn } from 'global-type'
  19. const props = withDefaults(
  20. defineProps<{
  21. modelValue?: boolean
  22. type?: 'task' | 'secret'
  23. id: number | string | undefined
  24. modal?: boolean
  25. showLevel?: boolean
  26. }>(),
  27. {
  28. type: 'task',
  29. modelValue: true,
  30. modal: true,
  31. showLevel: false,
  32. }
  33. )
  34. const visible = useVModel(props, 'modelValue')
  35. const LessRenderComponent = defineComponent({
  36. name: 'LessRender',
  37. inheritAttrs: false,
  38. props: {
  39. modelValue: {
  40. type: Boolean,
  41. default: false,
  42. },
  43. },
  44. render() {
  45. return this.modelValue ? useSlots()?.default?.() : null
  46. },
  47. })
  48. const ScoringPanelContainer = computed(() => {
  49. return props.modal ? BaseDialog : LessRenderComponent
  50. })
  51. const { fetch: getMarkScoreHistoryListWithTask, result: scoreHistoryList } = useFetch('getMarkScoreHistoryListWithTask')
  52. const { fetch: getMarkScoreHistoryListWithSecret, result: scoreHistoryListWithSecret } = useFetch(
  53. 'getMarkScoreHistoryListWithSecret'
  54. )
  55. watch(
  56. () => props.id,
  57. () => {
  58. if (props.id) {
  59. props.type === 'task'
  60. ? getMarkScoreHistoryListWithTask({ taskId: props.id })
  61. : getMarkScoreHistoryListWithSecret({ secretNumber: props.id })
  62. }
  63. },
  64. { immediate: true }
  65. )
  66. const tableData = computed(() => {
  67. return props.type === 'task' ? scoreHistoryList.value : scoreHistoryListWithSecret.value
  68. })
  69. const columns = computed<EpTableColumn<ExtractArrayValue<ExtractApiResponse<'getMarkScoreHistoryListWithTask'>>>[]>(
  70. () => [
  71. { label: '评卷员', prop: 'markerName' },
  72. {
  73. label: `分数${props.showLevel ? '(档次)' : ''}`,
  74. prop: 'markScore',
  75. formatter(row) {
  76. return `${row.markScore}${props.showLevel ? `(${row.scoreLevel})` : ''}`
  77. },
  78. },
  79. { label: '类型' },
  80. { label: '评卷时间', prop: 'markTime' },
  81. ]
  82. )
  83. </script>
  84. <style scoped lang="scss"></style>