liuyu
4 小时以前 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<script lang="ts" setup>
import type { ExamPaperView } from './types';
 
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
 
import { useMessage } from '@jnpf/hooks';
import {
  Descriptions as ADescriptions,
  DescriptionsItem as ADescriptionsItem,
} from 'ant-design-vue';
 
import { getExamPaperView } from '#/api/x/tms/examScore';
import { labelOfType } from '#/views/x/tms/question/constants';
 
defineOptions({ name: 'TmsExamScorePaper' });
 
const route = useRoute();
const router = useRouter();
const { createMessage } = useMessage();
 
const loading = ref(false);
const paper = ref<ExamPaperView | null>(null);
 
onMounted(() => {
  loadPaper();
});
 
async function loadPaper() {
  const id = String(route.params.id || '');
  if (!id) {
    router.replace('/tms/examScore');
    return;
  }
  loading.value = true;
  try {
    paper.value = await getExamPaperView(id);
  } catch (e: any) {
    createMessage.error(e?.message || '加载试卷失败');
    router.back();
  } finally {
    loading.value = false;
  }
}
 
function stripHtml(html?: string) {
  if (!html) return '';
  return html.replace(/<[^>]+>/g, '').replace(/&nbsp;/g, ' ').trim();
}
 
function goBack() {
  if (paper.value?.summaryId) {
    router.push(`/tms/examScore/detail/${paper.value.summaryId}`);
  } else {
    router.back();
  }
}
</script>
 
<template>
  <div class="jnpf-content-wrapper tms-paper-page">
    <div class="jnpf-content-wrapper-center tms-paper-center">
      <div class="jnpf-content-wrapper-content tms-paper-wrap">
        <div class="paper-top">
          <div class="paper-header">
            <div>
              <div class="text-base font-medium">考生试卷详情</div>
              <div v-if="paper" class="mt-1 text-gray-400 text-sm">
                {{ paper.userName }}({{ paper.userId }}) · {{ paper.paperName }}
              </div>
            </div>
            <a-button @click="goBack">返回</a-button>
          </div>
 
          <ADescriptions v-if="paper" bordered :column="3" size="small" class="mb-3">
            <ADescriptionsItem label="培训主题" :span="2">{{ paper.taskSubject }}</ADescriptionsItem>
            <ADescriptionsItem label="培训编号">{{ paper.taskNo }}</ADescriptionsItem>
            <ADescriptionsItem label="考试开始">{{ paper.examStart || '-' }}</ADescriptionsItem>
            <ADescriptionsItem label="考试结束">{{ paper.examEnd || '-' }}</ADescriptionsItem>
            <ADescriptionsItem label="来源IP">{{ paper.sourceIp || '-' }}</ADescriptionsItem>
            <ADescriptionsItem label="成绩">
              <b class="text-primary">{{ paper.score }}</b> / {{ paper.totalScore }}
            </ADescriptionsItem>
            <ADescriptionsItem label="及格分">{{ paper.passScore }}</ADescriptionsItem>
            <ADescriptionsItem label="是否合格">
              <span :class="paper.passFlag === '1' ? 'text-green-600' : 'text-red-500'">
                {{ paper.passFlag === '1' ? '是' : '否' }}
              </span>
            </ADescriptionsItem>
          </ADescriptions>
        </div>
 
        <div class="paper-body">
          <a-spin :spinning="loading">
            <div
              v-for="(it, idx) in paper?.items || []"
              :key="it.id"
              class="paper-item"
              :class="{ subjective: it.isSubjective === '1' }"
            >
              <div class="mb-2 text-sm text-gray-500">
                第 {{ idx + 1 }} 题 · {{ labelOfType(it.questionType) }}
                (满分 {{ it.score }} · 得分 {{ it.gotScore }})
                <span
                  v-if="it.isSubjective !== '1'"
                  class="ml-2"
                  :class="it.isCorrect ? 'text-green-600' : 'text-red-500'"
                >
                  {{ it.isCorrect ? '正确' : '错误' }}
                </span>
                <span v-else class="ml-2 text-orange-500">主观题</span>
              </div>
              <div class="stem mb-3">{{ stripHtml(it.stem) }}</div>
              <div v-if="it.options?.length" class="mb-2 text-sm text-gray-600">
                <div v-for="opt in it.options" :key="opt.optionLabel">
                  {{ opt.optionLabel }}. {{ opt.optionContent }}
                </div>
              </div>
              <div class="text-sm answer-row">
                <div>考生答案:{{ it.userAnswer || '(未作答)' }}</div>
                <div v-if="it.correctAnswer">参考/正确答案:{{ it.correctAnswer }}</div>
              </div>
            </div>
          </a-spin>
        </div>
      </div>
    </div>
  </div>
</template>
 
<style scoped>
.tms-paper-page {
  min-height: 0;
}
 
.tms-paper-center {
  min-height: 0 !important;
}
 
.tms-paper-wrap {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  background: #fff;
  padding: 0;
}
 
.paper-top {
  flex-shrink: 0;
  padding: 16px 20px 0;
}
 
.paper-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}
 
.paper-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto !important;
  padding: 0 20px 32px;
}
 
.paper-item {
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
 
.paper-item.subjective {
  border-color: #ffd591;
  background: #fffbe6;
}
 
.stem {
  font-size: 15px;
  line-height: 1.7;
}
 
.answer-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
</style>