轻武器
This commit is contained in:
parent
d16804421a
commit
c8e7f0a424
|
|
@ -175,9 +175,9 @@
|
||||||
<el-table :data="state.detail.answers" stripe size="small" max-height="400">
|
<el-table :data="state.detail.answers" stripe size="small" max-height="400">
|
||||||
<el-table-column prop="questionNo" label="题号" width="60" align="center" />
|
<el-table-column prop="questionNo" label="题号" width="60" align="center" />
|
||||||
<el-table-column prop="questionContent" label="题目内容" min-width="250" show-overflow-tooltip />
|
<el-table-column prop="questionContent" label="题目内容" min-width="250" show-overflow-tooltip />
|
||||||
<el-table-column prop="answerValue" label="答案" width="70" align="center">
|
<el-table-column label="答案" width="200" align="center">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag size="small" type="primary">{{ row.answerValue }}</el-tag>
|
<span>{{ getScoreLabel(row.answerValue) }}({{ getScoreDescription(row.answerValue) }})</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
|
@ -282,6 +282,7 @@ import {
|
||||||
type AssessmentReport,
|
type AssessmentReport,
|
||||||
type AssessmentRecordQuery
|
type AssessmentRecordQuery
|
||||||
} from '@/api/business/assessmentRecord'
|
} from '@/api/business/assessmentRecord'
|
||||||
|
import { getScoreOptionList, type ScoreOptionItem } from '@/api/business/assessment'
|
||||||
|
|
||||||
// ============ Constants ============
|
// ============ Constants ============
|
||||||
|
|
||||||
|
|
@ -329,6 +330,7 @@ interface RecordPageState {
|
||||||
reportLoading: boolean
|
reportLoading: boolean
|
||||||
report: AssessmentReport | null
|
report: AssessmentReport | null
|
||||||
exportLoading: boolean
|
exportLoading: boolean
|
||||||
|
scoreOptionMap: Map<number, ScoreOptionItem>
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Refs ============
|
// ============ Refs ============
|
||||||
|
|
@ -356,7 +358,8 @@ const state = reactive<RecordPageState>({
|
||||||
reportVisible: false,
|
reportVisible: false,
|
||||||
reportLoading: false,
|
reportLoading: false,
|
||||||
report: null,
|
report: null,
|
||||||
exportLoading: false
|
exportLoading: false,
|
||||||
|
scoreOptionMap: new Map()
|
||||||
})
|
})
|
||||||
|
|
||||||
// ============ Helper Functions ============
|
// ============ Helper Functions ============
|
||||||
|
|
@ -375,6 +378,33 @@ function getStatusTagType(status: number): 'info' | 'primary' | 'warning' | 'suc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据答案值获取对应的评分标签
|
||||||
|
*/
|
||||||
|
function getScoreLabel(answerValue: number): string {
|
||||||
|
const option = state.scoreOptionMap.get(answerValue)
|
||||||
|
return option ? option.label : String(answerValue)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据答案值获取对应的评分描述
|
||||||
|
*/
|
||||||
|
function getScoreDescription(answerValue: number): string {
|
||||||
|
const option = state.scoreOptionMap.get(answerValue)
|
||||||
|
return option ? option.description : ''
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据答案值获取标签颜色
|
||||||
|
*/
|
||||||
|
function getScoreTagType(answerValue: number): 'danger' | 'warning' | 'info' | 'primary' | 'success' {
|
||||||
|
if (answerValue <= 2) return 'danger'
|
||||||
|
if (answerValue <= 4) return 'warning'
|
||||||
|
if (answerValue <= 6) return 'info'
|
||||||
|
if (answerValue <= 8) return 'primary'
|
||||||
|
return 'success'
|
||||||
|
}
|
||||||
|
|
||||||
// ============ API Functions ============
|
// ============ API Functions ============
|
||||||
|
|
||||||
/** 加载测评记录列表 */
|
/** 加载测评记录列表 */
|
||||||
|
|
@ -420,6 +450,10 @@ async function loadRecordDetail(id: number) {
|
||||||
const res = await getRecordDetail(id)
|
const res = await getRecordDetail(id)
|
||||||
if (res.code === 0) {
|
if (res.code === 0) {
|
||||||
state.detail = res.data
|
state.detail = res.data
|
||||||
|
// 加载评分标准映射(如果还没加载过)
|
||||||
|
if (state.scoreOptionMap.size === 0 && res.data?.assessmentTypeId) {
|
||||||
|
await loadScoreOptions(res.data.assessmentTypeId)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Error(res.message || '获取测评记录详情失败')
|
throw new Error(res.message || '获取测评记录详情失败')
|
||||||
}
|
}
|
||||||
|
|
@ -431,6 +465,20 @@ async function loadRecordDetail(id: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 加载评分标准 */
|
||||||
|
async function loadScoreOptions(assessmentTypeId: number) {
|
||||||
|
try {
|
||||||
|
const res = await getScoreOptionList({ page: 1, pageSize: 100, assessmentTypeId })
|
||||||
|
if (res.code === 0 && res.data?.list) {
|
||||||
|
state.scoreOptionMap = new Map(
|
||||||
|
res.data.list.map(item => [item.score, item])
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 评分标准加载失败不影响主流程
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 加载测评报告 */
|
/** 加载测评报告 */
|
||||||
async function loadRecordReport(id: number) {
|
async function loadRecordReport(id: number) {
|
||||||
state.reportLoading = true
|
state.reportLoading = true
|
||||||
|
|
@ -598,6 +646,13 @@ onMounted(() => {
|
||||||
color: var(--text-secondary, #909399);
|
color: var(--text-secondary, #909399);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.score-desc {
|
||||||
|
display: block;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary, #909399);
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
.pagination-wrapper {
|
.pagination-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user