liuyu
3 小时以前 82a74ba0402ab546ba524d23ce62198c4d00d2f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script lang="ts" setup>
import type { ActionItem, BasicColumn } from '@jnpf/ui/vxeTable';
 
import type { GradeExamListItem, GradeSessionListItem } from './types';
 
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import { BasicVxeTable, TableAction, useVxeTable } from '@jnpf/ui/vxeTable';
 
import { getGradeExamList, getGradeSessionInfo } from '#/api/x/tms/examGrade';
 
import { colorOfGradeStatus, labelOfGradeStatus } from './constants';
 
defineOptions({ name: 'TmsExamGradeSession' });
 
const route = useRoute();
const router = useRouter();
const { createMessage } = useMessage();
 
const session = ref<GradeSessionListItem | null>(null);
const sessionId = String(route.params.id || '');
 
const columns: BasicColumn[] = [
  { title: '考生', dataIndex: 'userName', width: 120 },
  { title: '部门', dataIndex: 'deptName', minWidth: 140 },
  { title: '交卷时间', dataIndex: 'submitTime', width: 170 },
  {
    title: '客观题得分',
    dataIndex: 'objectiveScore',
    width: 110,
    align: 'center',
    customRender: ({ record }) => (record as GradeExamListItem).objectiveScore ?? '-',
  },
  {
    title: '主观题得分',
    dataIndex: 'subjectiveScore',
    width: 110,
    align: 'center',
    customRender: ({ record }) => (record as GradeExamListItem).subjectiveScore ?? '-',
  },
  {
    title: '总分',
    dataIndex: 'totalScore',
    width: 90,
    align: 'center',
    customRender: ({ record }) => (record as GradeExamListItem).totalScore ?? '-',
  },
  {
    title: '阅卷状态',
    dataIndex: 'gradeStatus',
    width: 100,
    align: 'center',
    slots: { default: 'gradeStatus' },
  },
];
 
const [registerTable, { reload }] = useVxeTable({
  api: fetchList,
  columns,
  immediate: false,
  rowKey: 'id',
  useSearchForm: false,
  pagination: false,
  actionColumn: {
    width: 100,
    title: '操作',
    dataIndex: 'action',
    fixed: 'right',
  },
});
 
onMounted(async () => {
  if (!sessionId) {
    router.replace('/tms/examGrade');
    return;
  }
  try {
    session.value = await getGradeSessionInfo(sessionId);
    reload();
  } catch (e: any) {
    createMessage.error(e?.message || '加载失败');
    router.replace('/tms/examGrade');
  }
});
 
async function fetchList() {
  return { data: await getGradeExamList(sessionId) };
}
 
function goBack() {
  router.push('/tms/examGrade');
}
 
function handleMark(record: GradeExamListItem) {
  router.push(`/tms/examGrade/mark/${record.id}`);
}
 
function getTableActions(record: GradeExamListItem): ActionItem[] {
  if (record.gradeStatus === 'pending') {
    return [{ label: '阅卷', onClick: handleMark.bind(null, record) }];
  }
  return [{ label: '查看', onClick: handleMark.bind(null, record) }];
}
</script>
 
<template>
  <div class="jnpf-content-wrapper">
    <div class="jnpf-content-wrapper-center">
      <div class="jnpf-content-wrapper-content">
        <BasicVxeTable @register="registerTable">
          <template #tableTitle>
            <div class="flex items-center gap-3">
              <a-button @click="goBack">返回</a-button>
              <div>
                <div class="text-base font-medium">
                  {{ session?.paperName || '答卷列表' }}
                </div>
                <div class="mt-1 text-gray-400 text-sm">
                  {{ session?.taskNo }} · {{ session?.taskSubject }}
                </div>
              </div>
            </div>
          </template>
          <template #gradeStatus="{ record }">
            <span :style="{ color: colorOfGradeStatus(record.gradeStatus) }">
              {{ labelOfGradeStatus(record.gradeStatus) }}
            </span>
          </template>
          <template #action="{ record }">
            <TableAction :actions="getTableActions(record)" />
          </template>
        </BasicVxeTable>
      </div>
    </div>
  </div>
</template>