提交 8e5c7263 authored 作者: 王鹏飞's avatar 王鹏飞

fix: #3269

上级 e79295c1
<script setup lang="ts">
import type { ExperimentRecord, ExperimentRecordFile } from '../types'
import type { ExperimentInfo, ExperimentRecord, ExperimentRecordFile } from '../types'
import { ElMessage, ElMessageBox } from 'element-plus'
import ImageViewer from '@/components/ImageViewer.vue'
import { uploadExperimentPicture, getExperimentReport, getExperimentReportCache } from '../api'
const ResultScoreDialog = defineAsyncComponent(() => import('./ResultScoreDialog.vue'))
interface Props {
experiment_id?: string
data?: ExperimentInfo
}
const props = defineProps<Props>()
......@@ -21,6 +21,15 @@ const dialogVisible = $ref(false)
const canRemove = $computed(() => {
return !(detail?.status !== 0)
})
const hasScore = $computed(() => {
if (props.data?.report_upload_way === 2) {
// 在线报告
return props.data.is_commit_report ? detail?.is_check_report && detail?.status === 2 : detail?.status === 2
} else {
return detail?.status === 2
}
})
let imageViewerVisible = $ref<boolean>(false)
let imageViewerIndex = $ref<number>(0)
// 查看
......@@ -30,9 +39,9 @@ function handlePreview(index: number) {
}
// 删除
async function handleRemove(index: number, file: ExperimentRecordFile) {
if (!props.experiment_id) return
if (!props.data) return
let reportDetail: any = []
await getExperimentReportCache({ experiment_id: props.experiment_id }).then(res => {
await getExperimentReportCache({ experiment_id: props.data.id }).then(res => {
const report = res.data.report
if (report.detail) {
try {
......@@ -42,7 +51,7 @@ async function handleRemove(index: number, file: ExperimentRecordFile) {
}
}
})
await getExperimentReport({ experiment_id: props.experiment_id }).then(res => {
await getExperimentReport({ experiment_id: props.data.id }).then(res => {
const report = res.data.report
if (report.detail) {
try {
......@@ -64,9 +73,9 @@ async function handleRemove(index: number, file: ExperimentRecordFile) {
return
}
ElMessageBox.confirm('删除之后无法恢复,确认删除该截图吗?', '提示').then(() => {
if (!props.experiment_id) return
if (!props.data) return
const pictures = detail?.pictures.filter((item, i) => i !== index)
uploadExperimentPicture({ experiment_id: props.experiment_id, pictures: JSON.stringify(pictures) }).then(() => {
uploadExperimentPicture({ experiment_id: props.data.id, pictures: JSON.stringify(pictures) }).then(() => {
emit('update')
})
})
......@@ -74,10 +83,10 @@ async function handleRemove(index: number, file: ExperimentRecordFile) {
</script>
<template>
<template v-if="detail && experiment_id">
<template v-if="detail && data">
<div class="result-score">
<h2>我的成绩</h2>
<template v-if="detail.status === 2">
<template v-if="hasScore">
<p class="t1" @click="dialogVisible = !dialogVisible">{{ parseFloat(detail.score) }}</p>
<p class="t2">批改讲师:{{ detail.checker_user.real_name }}</p>
</template>
......@@ -101,8 +110,8 @@ async function handleRemove(index: number, file: ExperimentRecordFile) {
<ImageViewer v-model="imageViewerVisible" :index="imageViewerIndex" :items="detail.pictures"></ImageViewer>
<ResultScoreDialog
v-model="dialogVisible"
:experiment_id="experiment_id"
v-if="dialogVisible && experiment_id"></ResultScoreDialog>
:experiment_id="data.id"
v-if="dialogVisible && data"></ResultScoreDialog>
</template>
<el-empty description="暂无数据" v-else />
</template>
......
......@@ -104,6 +104,7 @@ export interface ExperimentRecord {
}
course: CourseType
student: ExperimentStudent
is_check_report: boolean
}
export interface ExperimentRecordFile {
url: string
......
......@@ -75,7 +75,11 @@ function fetchInfo() {
function fetchExperimentRecord() {
if (!form.experiment_id) return
getExperimentRecord({ experiment_id: form.experiment_id }).then(res => {
detail = Array.isArray(res.data.data) ? undefined : res.data.data
if (Array.isArray(res.data.data)) {
detail = undefined
} else {
detail = { ...res.data.data, is_check_report: res.data.is_check_report }
}
})
}
......@@ -237,7 +241,7 @@ function handleReportPreviewReady() {
<Discuss :experiment_id="form.experiment_id"></Discuss>
</el-tab-pane>
<el-tab-pane label="过程与结果" lazy>
<Result :experiment_id="form.experiment_id" @update="fetchExperimentRecord"></Result>
<Result :data="experimentInfo" @update="fetchExperimentRecord"></Result>
</el-tab-pane>
</el-tabs>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论