MarkHistoryList.vue 2.7 KB

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