提交 8bff36fb authored 作者: lhh's avatar lhh

update

上级 9c46ba44
......@@ -86,3 +86,8 @@ export function updateTrainCount(data: { competition_id: string }) {
export function getScoreReport(params: { competition_id: string }) {
return httpRequest.get('/api/lab/v1/student/competition/score-report', { params })
}
// 上传实验报告
export function uploadExperimentReport(data: { experiment_id: string; file: string }) {
return httpRequest.post('/api/lab/v1/student/experiment-record/upload-report', data)
}
\ No newline at end of file
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import type { ExperimentRecord } from '../types'
import { ElMessage } from 'element-plus'
import dayjs from 'dayjs'
import { uploadExperimentReport } from '../api'
interface Props {
data: any
}
const props = defineProps<Props>()
const detail = $ref(inject<any>('detail'))
const emit = defineEmits<{
(e: 'update'): void
(e: 'update:modelValue', visible: boolean): void
}>()
const formRef = $ref<FormInstance>()
const form = reactive<any>({ files: [] })
watchEffect(() => {
form.files = detail?.file ? [detail.file] : []
})
const rules = ref<FormRules>({
files: [{ required: true, message: '请上传实验报告文件', trigger: 'blur' }]
})
// 提交
function handleSubmit() {
formRef?.validate().then(update)
}
// 修改
const update = () => {
const [file] = form.files
uploadExperimentReport({
experiment_id: props.data,
file: JSON.stringify({ name: file.name, url: file.url, upload_time: dayjs().format('YYYY-MM-DD HH:mm:ss') })
}).then(() => {
ElMessage({ message: '上传成功', type: 'success' })
emit('update')
emit('update:modelValue', false)
})
}
</script>
<template>
<el-dialog
title="上传实验报告"
:close-on-click-modal="false"
width="600px"
@update:modelValue="$emit('update:modelValue')"
>
<el-form ref="formRef" :model="form" :rules="rules">
<el-form-item label="实验报告文件" prop="files">
<AppUpload
v-model="form.files"
:limit="1"
accept=".doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,.pdf,application/pdf,.ppt,.pptx,application/vnd.ms-powerpoint"
>
<template #tip>实验报告文件只能上传一个,支持格式包含:doc docx pdf ppt pptx,大小不超过50M</template>
</AppUpload>
</el-form-item>
<el-row justify="center">
<el-button type="primary" round auto-insert-space @click="handleSubmit">保存</el-button>
<el-button round auto-insert-space @click="$emit('update:modelValue', false)">取消</el-button>
</el-row>
</el-form>
</el-dialog>
</template>
......@@ -12,6 +12,7 @@ const Book = defineAsyncComponent(() => import('../components/Book.vue'))
const Video = defineAsyncComponent(() => import('../components/Video.vue'))
const Discuss = defineAsyncComponent(() => import('../components/Discuss.vue'))
const Result = defineAsyncComponent(() => import('../components/Result.vue'))
const ReportDialog = defineAsyncComponent(() => import('../components/ReportDialog.vue'))
const route = useRoute()
......@@ -122,6 +123,7 @@ const handleShowHead = function () {
isHeadShow = !isHeadShow
}
let experimentId = $ref('')
const getExperimentId = computed(() => {
const item = competition?.train_platform_configs.find((item: any) => item.platform_key === route.query.type)
let value = '0'
......@@ -131,8 +133,11 @@ const getExperimentId = computed(() => {
? item?.url.substring(item?.url.indexOf('experiment_id=') + 14, item?.url.length + 1)
: '0'
}
experimentId = value
return value
})
const reportDialogVisible = $ref(false)
</script>
<template>
......@@ -163,6 +168,7 @@ const getExperimentId = computed(() => {
<el-button type="primary" :icon="HomeFilled" @click="handleBackHome">返回首页</el-button>
<div>
<el-button type="primary" :loading="screenshotLoading" @click="handleCapture">截图</el-button>
<el-button type="primary" @click="reportDialogVisible = true">上传实验报告</el-button>
</div>
</el-row>
</AppCard>
......@@ -189,7 +195,9 @@ const getExperimentId = computed(() => {
</div>
</template>
</DragPanel>
<ReportDialog v-model="reportDialogVisible" :data="experimentId" v-if="reportDialogVisible && experimentId"></ReportDialog>
</template>
<!-- 上传报告 -->
<style lang="scss" scoped>
.close-btn {
......
......@@ -274,7 +274,8 @@ function handleReportPreviewReady() {
<el-button
type="primary"
:disabled="disabled"
v-if="experimentInfo?.report_upload_way === 2 && !experimentInfo?.is_commit_report">
v-if="experimentInfo?.report_upload_way === 2 && !experimentInfo?.is_commit_report"
>
<router-link :to="`/student/lab/report/${form.experiment_id}`" target="_blank">在线实验报告</router-link>
</el-button>
<el-button
......@@ -308,22 +309,26 @@ function handleReportPreviewReady() {
v-model="reportDialogVisible"
:data="experimentInfo"
@update="fetchExperimentRecord"
v-if="reportDialogVisible && experimentInfo"></ReportDialog>
v-if="reportDialogVisible && experimentInfo"
></ReportDialog>
<ReportFilePreview
v-model="reportFilePreviewVisible"
:data="experimentInfo"
v-if="reportFilePreviewVisible && experimentInfo"></ReportFilePreview>
v-if="reportFilePreviewVisible && experimentInfo"
></ReportFilePreview>
<!-- 实验准备 -->
<PrepareDialog
v-model="prepareDialogVisible"
:data="experimentInfo"
v-if="prepareDialogVisible && experimentInfo"></PrepareDialog>
v-if="prepareDialogVisible && experimentInfo"
></PrepareDialog>
<!-- 实验结果 -->
<ResultDialog
v-model="resultDialogVisible"
:data="experimentInfo"
v-if="resultDialogVisible && experimentInfo"></ResultDialog>
v-if="resultDialogVisible && experimentInfo"
></ResultDialog>
<!-- 导出在线报告 -->
<template v-if="experimentInfo?.id && isExport">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论