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

bug fixes

上级 70b2a0cb
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import type { RecordItem, FileItem } from '../types' import type { RecordItem, FileItem } from '../types'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { getExperimentScore, getExperimentScoreTemplate, updateExperimentScore } from '../api' import { getExperimentScore, getExperimentScoreTemplate, updateExperimentScore, getExperimentReport } from '../api'
const ScoreViewPicturesDialog = defineAsyncComponent(() => import('./ScoreViewPicturesDialog.vue')) const ScoreViewPicturesDialog = defineAsyncComponent(() => import('./ScoreViewPicturesDialog.vue'))
const ScoreViewPrepareDialog = defineAsyncComponent(() => import('./ScoreViewPrepareDialog.vue')) const ScoreViewPrepareDialog = defineAsyncComponent(() => import('./ScoreViewPrepareDialog.vue'))
...@@ -20,8 +20,9 @@ const emit = defineEmits<{ ...@@ -20,8 +20,9 @@ const emit = defineEmits<{
let experiment = $ref<any>() let experiment = $ref<any>()
let detail = $ref<any>() let detail = $ref<any>()
function fetchInfo() { async function fetchInfo() {
getExperimentScore({ experiment_id: props.data.experiment_id, student_id: props.data.student_id }).then(res => { await getExperimentScore({ experiment_id: props.data.experiment_id, student_id: props.data.student_id }).then(
async res => {
experiment = res.data.experiment experiment = res.data.experiment
detail = res.data.achievement detail = res.data.achievement
if (detail.score_details) { if (detail.score_details) {
...@@ -35,20 +36,24 @@ function fetchInfo() { ...@@ -35,20 +36,24 @@ function fetchInfo() {
} }
}) })
} catch (error) { } catch (error) {
fetchTemplate() await fetchTemplate()
console.log(error) console.log(error)
} }
} else { } else {
fetchTemplate() await fetchTemplate()
} }
}) if (experiment.report_upload_way === 2) {
await fetchReport()
}
}
)
} }
watchEffect(() => { watchEffect(() => {
fetchInfo() fetchInfo()
}) })
function fetchTemplate() { async function fetchTemplate() {
getExperimentScoreTemplate({ experiment_id: props.data.experiment_id }).then(res => { await getExperimentScoreTemplate({ experiment_id: props.data.experiment_id }).then(res => {
form.score_details = res.data.detail.rule_list.map((item: any) => { form.score_details = res.data.detail.rule_list.map((item: any) => {
return { return {
...item, ...item,
...@@ -59,6 +64,24 @@ function fetchTemplate() { ...@@ -59,6 +64,24 @@ function fetchTemplate() {
}) })
}) })
} }
// 获取实验报告分数
let report = $ref<any>()
async function fetchReport() {
await getExperimentReport({ experiment_id: props.data.experiment_id, student_id: props.data.student_id }).then(
res => {
report = res.data.detail
const reportScore = parseFloat(report.score || 0)
form.score_details = form.score_details.map((item: any) => {
if (item.type === 1) {
item.commit_score = reportScore
}
return item
})
}
)
}
// 实验报告文件 // 实验报告文件
const file = $computed<FileItem>(() => { const file = $computed<FileItem>(() => {
try { try {
...@@ -95,6 +118,15 @@ function handleSubmit() { ...@@ -95,6 +118,15 @@ function handleSubmit() {
} }
) )
} }
function scoreValue(value: any) {
if (typeof value !== 'number' && !value) {
return '--'
} else {
return value
}
}
const pictureVisible = $ref(false) const pictureVisible = $ref(false)
const prepareVisible = $ref(false) const prepareVisible = $ref(false)
const resultVisible = $ref(false) const resultVisible = $ref(false)
...@@ -140,7 +172,7 @@ const resultVisible = $ref(false) ...@@ -140,7 +172,7 @@ const resultVisible = $ref(false)
</el-row> </el-row>
</el-form-item> </el-form-item>
<div class="score-result"> <div class="score-result">
<p class="score-result__total">{{ score || '--' }}</p> <p class="score-result__total">{{ scoreValue(score) }}</p>
<el-table <el-table
:data="form.score_details" :data="form.score_details"
stripe stripe
...@@ -154,7 +186,11 @@ const resultVisible = $ref(false) ...@@ -154,7 +186,11 @@ const resultVisible = $ref(false)
<el-table-column label="操作" prop="commit_score" align="center"> <el-table-column label="操作" prop="commit_score" align="center">
<template #default="{ row }"> <template #default="{ row }">
<template v-if="row.type === 1"> <template v-if="row.type === 1">
<el-button text type="primary" v-if="experiment.report_upload_way === 2"> <el-button
text
type="primary"
@click="$emit('update:modelValue')"
v-if="experiment.report_upload_way === 2">
<router-link <router-link
:to="`/admin/lab/score/report?experiment_id=${data.experiment_id}&student_id=${data.student_id}`" :to="`/admin/lab/score/report?experiment_id=${data.experiment_id}&student_id=${data.student_id}`"
target="_blank" target="_blank"
...@@ -171,7 +207,7 @@ const resultVisible = $ref(false) ...@@ -171,7 +207,7 @@ const resultVisible = $ref(false)
step-strictly step-strictly
placeholder="请输入成绩" placeholder="请输入成绩"
style="width: 100px"></el-input-number> style="width: 100px"></el-input-number>
<el-button text type="primary"> <el-button text type="primary" v-if="file?.url">
<router-link :to="file.url" target="_blank">查阅报告</router-link> <router-link :to="file.url" target="_blank">查阅报告</router-link>
</el-button> </el-button>
</template> </template>
......
...@@ -20,7 +20,7 @@ onMounted(() => { ...@@ -20,7 +20,7 @@ onMounted(() => {
<template> <template>
<el-dialog title="查看实验准备" width="800px"> <el-dialog title="查看实验准备" width="800px">
<div v-html="detail.detail" v-if="detail"></div> <div class="dialog-html" v-html="detail.detail" v-if="detail"></div>
<template #footer> <template #footer>
<el-row justify="center"> <el-row justify="center">
<el-button round auto-insert-space @click="$emit('update:modelValue', false)">关闭</el-button> <el-button round auto-insert-space @click="$emit('update:modelValue', false)">关闭</el-button>
...@@ -28,3 +28,11 @@ onMounted(() => { ...@@ -28,3 +28,11 @@ onMounted(() => {
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<style lang="scss" scoped>
.dialog-html {
:deep(*) {
max-width: 100%;
}
}
</style>
...@@ -20,7 +20,7 @@ onMounted(() => { ...@@ -20,7 +20,7 @@ onMounted(() => {
<template> <template>
<el-dialog title="查看实验结果" width="800px"> <el-dialog title="查看实验结果" width="800px">
<div v-html="detail.detail" v-if="detail"></div> <div class="dialog-html" v-html="detail.detail" v-if="detail"></div>
<template #footer> <template #footer>
<el-row justify="center"> <el-row justify="center">
<el-button round auto-insert-space @click="$emit('update:modelValue', false)">关闭</el-button> <el-button round auto-insert-space @click="$emit('update:modelValue', false)">关闭</el-button>
...@@ -28,3 +28,11 @@ onMounted(() => { ...@@ -28,3 +28,11 @@ onMounted(() => {
</template> </template>
</el-dialog> </el-dialog>
</template> </template>
<style lang="scss" scoped>
.dialog-html {
:deep(*) {
max-width: 100%;
}
}
</style>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论