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

chore: 新增理论考试在实验详情

上级 7ade14e2
......@@ -86,11 +86,7 @@ export function getExperimentReportRule(params: { experiment_id: string }) {
return httpRequest.get('/api/resource/v1/backend/experiment-report/detail', { params })
}
// 更新实验报告规则
export function updateExperimentReportRule(data: {
experiment_id: string
report_upload_way: number
detail_list: string
}) {
export function updateExperimentReportRule(data: { experiment_id: string; report_upload_way: number; detail_list: string }) {
return httpRequest.post('/api/resource/v1/backend/experiment-report/save', data)
}
......@@ -153,4 +149,21 @@ export function getQuestionTags(params: { experiment_id: string }) {
// 获取群组
export function getQuestionGroup(params: { experiment_id: string }) {
return httpRequest.get('/api/resource/v1/backend/experiment-question/groups', { params })
}
\ No newline at end of file
}
// 获取实验下的所有理论考试
export function getAllExamList(params: { project: string; q?: string; name?: string; page?: number; 'per-page'?: number }) {
return httpRequest.get('/api/resource/v1/backend/exam/search-all-exam', { params })
}
// 获取实验的理论考试列表
export function getExamList(params: { experiment_id: string }) {
return httpRequest.get('/api/resource/v1/backend/experiment/exam-list', { params })
}
// 更新实验的理论考试
export function updateExam(data: { experiment_id: string; exam_id: string }) {
return httpRequest.post('/api/resource/v1/backend/experiment/exam-save', data)
}
// 删除实验的理论考试
export function deleteExam(data: { id: string }) {
return httpRequest.post('/api/resource/v1/backend/experiment/exam-delete', data)
}
<script setup lang="ts">
import { CirclePlus } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import AppList from '@/components/base/AppList.vue'
import { getExamList, deleteExam } from '../api'
const FormDialog = defineAsyncComponent(() => import('./ViewExamFormDialog.vue'))
interface Props {
id: string
}
const props = defineProps<Props>()
const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 列表配置
const listOptions = {
hasPagination: false,
remote: {
httpRequest: getExamList,
params: { experiment_id: props.id },
callback(res: any) {
return res?.list ? { list: res.list } : { list: [] }
}
},
columns: [
{ label: '序号', type: 'index', width: 60 },
{ label: '考试名称', prop: 'exam_info.name' },
{ label: '创建人', prop: 'created_operator_name' },
{ label: '创建时间', prop: 'created_time' },
{ label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 120 }
]
}
let dialogVisible = $ref(false)
const rowData = ref<any>()
// 新增
function handleAdd() {
rowData.value = undefined
dialogVisible = true
}
// 编辑
function handleUpdate(row: any) {
rowData.value = row
dialogVisible = true
}
// 查阅
// function handleView(row: any) {
// const [paper] = row.exam_info.paper_list
// if (!paper) return
// const qaURL = `${import.meta.env.VITE_QA_CENTER_URL}/paper/detail/${paper.paper_id}`
// window.open(qaURL)
// }
// 删除
function handleRemove(row: any) {
ElMessageBox.confirm('确定要删除吗?', '提示').then(() => {
deleteExam({ id: row.id }).then(() => {
ElMessage({ message: '删除成功', type: 'success' })
onUpdateSuccess()
})
})
}
function onUpdateSuccess() {
appList?.refetch()
}
</script>
<template>
<AppList v-bind="listOptions" ref="appList">
<template #header-buttons>
<el-button type="primary" :icon="CirclePlus" @click="handleAdd" v-permission="'competition-book-create'">新增</el-button>
</template>
<template #table-x="{ row }">
<el-button link round type="primary" @click="handleUpdate(row)" v-permission="'competition-book-update'">编辑</el-button>
<el-button link round type="danger" @click="handleRemove(row)" v-permission="'competition-book-delete'">删除</el-button>
</template>
</AppList>
<FormDialog v-model="dialogVisible" :id="id" :data="rowData" @update="onUpdateSuccess" v-if="dialogVisible"></FormDialog>
</template>
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage } from 'element-plus'
import { pick } from 'lodash-es'
import { updateExam, getAllExamList } from '../api'
interface Props {
id: string
data?: any
}
const props = defineProps<Props>()
const emit = defineEmits<{
(e: 'update'): void
(e: 'update:modelValue', visible: boolean): void
}>()
const formRef = ref<FormInstance>()
const form = reactive<any>({
experiment_id: props.id,
exam_id: ''
})
watchEffect(() => {
if (!props.data) return
Object.assign(form, props.data)
})
const rules = ref<FormRules>({
exam_id: [{ required: true, message: '请选择考试', trigger: 'change' }]
})
const isUpdate = $computed(() => {
return !!props.data?.id
})
const title = computed(() => {
return isUpdate ? '编辑理论考试' : '新增理论考试'
})
const examList = ref<Record<string, any>[]>([])
// 获取关联考试列表
function fetchExamList() {
getAllExamList({ project: 'x1', 'per-page': 1000 }).then(res => {
examList.value = res.data.list || []
})
}
onMounted(() => {
fetchExamList()
})
// 提交
function handleSubmit() {
formRef.value?.validate().then(() => {
const params = Object.assign({}, pick(form, ['experiment_id', 'exam_id']))
isUpdate ? handleUpdate(params) : handleUpdate(params)
})
}
// 修改
function handleUpdate(params: any) {
params.id = props.data?.id
updateExam(params).then(() => {
ElMessage({ message: '修改成功', type: 'success' })
emit('update')
emit('update:modelValue', false)
})
}
</script>
<template>
<el-dialog :title="title" :close-on-click-modal="false" width="600px" @update:modelValue="value => $emit('update:modelValue', value)">
<el-form ref="formRef" :model="form" :rules="rules" label-width="90px">
<el-form-item label="考试名称" prop="exam_id">
<el-select v-model="form.exam_id" filterable style="width: 100%">
<el-option v-for="item in examList" :key="item.exam_id" :label="item.name" :value="item.exam_id"></el-option>
</el-select>
</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>
......@@ -13,6 +13,7 @@ const StudentGroupDialog = defineAsyncComponent(() => import('../components/Stud
const StudentListDialog = defineAsyncComponent(() => import('../components/StudentListDialog.vue'))
const ViewGradeRules = defineAsyncComponent(() => import('../components/ViewGradeRules.vue'))
const ViewReportRules = defineAsyncComponent(() => import('../components/ViewReportRules.vue'))
const ViewExam = defineAsyncComponent(() => import('../components/ViewExam.vue'))
interface Props {
id: string
......@@ -122,6 +123,9 @@ const dmlURL = computed(() => {
</template>
</AppList>
</AppCard>
<AppCard title="理论考试">
<ViewExam :id="id"></ViewExam>
</AppCard>
<!-- 关联班级 -->
<SelectClassDialog v-model="selectClassVisible" @update="handleRefetch" v-if="selectClassVisible"></SelectClassDialog>
<!-- 学生分组 -->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论