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

fix: #3269

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