liuyu
21 小时以前 93c133349a5ccd7a328371fa113dce69d5611f21
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
139
140
141
142
143
144
145
146
147
148
149
150
<script lang="ts" setup>
import type { ActionItem, BasicColumn } from '@jnpf/ui/vxeTable';
 
import type { GradeExamListItem, GradeSessionListItem } from './types';
 
import { onActivated, 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 { TMS_BTN } from '#/views/x/tms/shared/ui';
 
import { colorOfGradeStatus, labelOfGradeStatus, loadExamGradeDics } from './constants';
 
import '#/views/x/tms/shared/page.css';
 
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 {
    await loadExamGradeDics();
    await refreshSession();
  } catch (e: any) {
    createMessage.error(e?.message || '加载失败');
    router.replace('/tms/examGrade');
  }
});
 
onActivated(() => {
  if (!sessionId) return;
  void refreshSession();
});
 
async function refreshSession() {
  session.value = await getGradeSessionInfo(sessionId);
  reload();
}
 
async function fetchList() {
  const list = await getGradeExamList(sessionId);
  return { data: Array.isArray(list) ? list : [] };
}
 
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: TMS_BTN.grade, onClick: handleMark.bind(null, record) }];
  }
  return [{ label: TMS_BTN.detail, 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="tms-page-header" style="margin-bottom: 0">
              <div>
                <div class="tms-page-header__title">{{ session?.paperName || '答卷列表' }}</div>
                <div class="tms-page-header__sub">{{ session?.taskNo }} · {{ session?.taskSubject }}</div>
              </div>
              <div class="tms-page-header__actions">
                <a-button @click="goBack">{{ TMS_BTN.back }}</a-button>
              </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>