MarkHistoryList.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. watch(
  52. () => props.id,
  53. () => {
  54. if (props.id) {
  55. props.type === 'task'
  56. ? getMarkScoreHistoryListWithTask({ taskId: props.id })
  57. : getMarkScoreHistoryListWithSecret({ secretNumber: props.id })
  58. }
  59. }
  60. )
  61. const { fetch: getMarkScoreHistoryListWithTask, result: scoreHistoryList } = useFetch('getMarkScoreHistoryListWithTask')
  62. const { fetch: getMarkScoreHistoryListWithSecret, result: scoreHistoryListWithSecret } = useFetch(
  63. 'getMarkScoreHistoryListWithSecret'
  64. )
  65. const tableData = computed(() => {
  66. return props.type === 'task' ? scoreHistoryList.value : scoreHistoryListWithSecret.value
  67. })
  68. const columns = computed<EpTableColumn<ExtractArrayValue<ExtractApiResponse<'getMarkScoreHistoryListWithTask'>>>[]>(
  69. () => [
  70. { label: '评卷员', prop: 'markerName' },
  71. {
  72. label: `分数${props.showLevel ? '(档次)' : ''}`,
  73. prop: 'markScore',
  74. formatter(row) {
  75. return `${row.markScore}${props.showLevel ? `(${row.scoreLevel})` : ''}`
  76. },
  77. },
  78. { label: '类型' },
  79. { label: '评卷时间', prop: 'markTime' },
  80. ]
  81. )
  82. </script>
  83. <style scoped lang="scss"></style>