|
|
@@ -8,20 +8,20 @@
|
|
|
<el-form-item label="考生类型" prop="examType">
|
|
|
<el-select v-model="queryParams.examType" clearable @change="handleQuery" style="width: 172px">
|
|
|
<el-option
|
|
|
- v-for="e in exam_type"
|
|
|
- :key="e.dictValue || e.value || e.dictCode"
|
|
|
- :label="e.dictLabel || e.label"
|
|
|
- :value="e.dictValue || e.value"
|
|
|
+ v-for="dict in exam_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="组卷类型" prop="buildType">
|
|
|
<el-select v-model="queryParams.buildType" clearable @change="handleQuery" style="width: 172px">
|
|
|
<el-option
|
|
|
- v-for="b in build_type"
|
|
|
- :key="b.dictValue || b.value || b.dictCode"
|
|
|
- :label="b.dictLabel || b.label"
|
|
|
- :value="b.dictValue || b.value"
|
|
|
+ v-for="dict in build_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
@@ -66,6 +66,7 @@
|
|
|
<template #download="{row}">
|
|
|
<el-button type="primary" link @click="handleDownload(row.paperId, row.paperName)" v-hasPermi="['learn:paper:download']">下载</el-button>
|
|
|
<el-button type="success" link @click="handleShowPaperQuestion(row.paperId)">题目</el-button>
|
|
|
+ <el-button type="info" link @click="handleEditPaper(row)">编辑</el-button>
|
|
|
<el-button type="warning" link @click="handleSendPaper(row)">发送</el-button>
|
|
|
</template>
|
|
|
</Table>
|
|
|
@@ -118,6 +119,79 @@
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
|
|
|
+ <!-- 编辑试卷弹窗 -->
|
|
|
+ <el-dialog v-model="editPaperDialogVisible" title="编辑试卷" width="600px" destroy-on-close>
|
|
|
+ <el-form ref="editPaperFormRef" :model="editPaperForm" :rules="editPaperRules" label-width="120px">
|
|
|
+ <el-form-item label="试卷名称" prop="paperName">
|
|
|
+ <el-input v-model="editPaperForm.paperName" placeholder="请输入试卷名称" maxlength="200" show-word-limit />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="试卷年份" prop="year">
|
|
|
+ <el-input-number v-model="editPaperForm.year" :min="2000" :max="2100" placeholder="请输入试卷年份" style="width: 100%" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="试卷类型" prop="buildType">
|
|
|
+ <el-select v-model="editPaperForm.buildType" clearable placeholder="请选择试卷类型" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in build_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="科目ID" prop="subjectId">
|
|
|
+ <el-select
|
|
|
+ v-model="editPaperForm.subjectId"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ placeholder="请选择科目"
|
|
|
+ style="width: 100%"
|
|
|
+ :loading="subjectListLoading"
|
|
|
+ >
|
|
|
+ <el-option-group v-for="g in groupedSubjects" :key="g.label" :label="g.label">
|
|
|
+ <el-option
|
|
|
+ v-for="s in g.items"
|
|
|
+ :key="s.subjectId"
|
|
|
+ :label="`${s.subjectName}(${s.subjectId})`"
|
|
|
+ :value="s.subjectId"
|
|
|
+ />
|
|
|
+ </el-option-group>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="考生类型" prop="examType">
|
|
|
+ <el-select v-model="editPaperForm.examType" clearable placeholder="请选择考生类型" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in exam_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="试卷ID" prop="paperId">
|
|
|
+ <el-input-number v-model="editPaperForm.paperId" :min="1" placeholder="请输入试卷ID" style="width: 100%" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="定向Key" prop="directKey">
|
|
|
+ <el-input v-model="editPaperForm.directKey" placeholder="请输入定向Key" maxlength="200" />
|
|
|
+ </el-form-item>
|
|
|
+ <!-- <el-form-item label="生成条件" prop="conditions">
|
|
|
+ <el-input
|
|
|
+ v-model="editPaperForm.conditions"
|
|
|
+ type="textarea"
|
|
|
+ :rows="3"
|
|
|
+ placeholder="请输入试卷生成条件"
|
|
|
+ maxlength="500"
|
|
|
+ show-word-limit
|
|
|
+ />
|
|
|
+ </el-form-item> -->
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="editPaperDialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="handleConfirmEdit" :loading="editing">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
<!-- 发送试卷弹窗 -->
|
|
|
<el-dialog v-model="sendPaperDialogVisible" title="发送试卷" width="60%" destroy-on-close>
|
|
|
<el-form :model="sendPaperForm" label-width="100px">
|
|
|
@@ -172,9 +246,9 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup name="ListPaperRecords">
|
|
|
-import { ref, computed, getCurrentInstance, onMounted, markRaw, nextTick } from 'vue'
|
|
|
+import { ref, computed, getCurrentInstance, onMounted, markRaw, nextTick, watch } from 'vue'
|
|
|
import { useInjectGlobalLoading } from "@/views/hooks/useGlobalLoading.js"
|
|
|
-import { getPapers, getFrontPaperDetail, sendPaper } from "@/api/dz/papers.js"
|
|
|
+import { getPapers, getFrontPaperDetail, sendPaper, updatePaper, getPaperSubjects, getPaperExamTypes } from "@/api/dz/papers.js"
|
|
|
import { listPaper_question } from "@/api/learn/paper_question.js"
|
|
|
import { listCards2 } from "@/api/dz/cards.js"
|
|
|
import SchoolClassSelect from '@/views/dz/components/SchoolClassSelect.vue'
|
|
|
@@ -235,6 +309,50 @@ const currentSubjectName = ref('')
|
|
|
const paperQuestionDialogVisible = ref(false)
|
|
|
const currentPaperId = ref(null)
|
|
|
|
|
|
+// 编辑试卷弹窗
|
|
|
+const editPaperDialogVisible = ref(false)
|
|
|
+const editPaperFormRef = ref(null)
|
|
|
+const editPaperForm = ref({
|
|
|
+ id: null,
|
|
|
+ paperName: '',
|
|
|
+ year: null,
|
|
|
+ buildType: '',
|
|
|
+ subjectId: null,
|
|
|
+ examType: '',
|
|
|
+ paperId: null,
|
|
|
+ directKey: '',
|
|
|
+ conditions: ''
|
|
|
+})
|
|
|
+const editPaperRules = {
|
|
|
+ paperName: [
|
|
|
+ { required: true, message: '请输入试卷名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ year: [
|
|
|
+ { required: true, message: '请输入试卷年份', trigger: 'blur' }
|
|
|
+ ]
|
|
|
+}
|
|
|
+const editing = ref(false)
|
|
|
+const currentEditPaperRow = ref(null)
|
|
|
+
|
|
|
+// 科目列表(用于编辑表单)
|
|
|
+const subjectList = ref([])
|
|
|
+const groupedSubjects = computed(() => {
|
|
|
+ const groups = []
|
|
|
+ subjectList.value.forEach(s => {
|
|
|
+ const match = groups.find(g => g.label == s.groupName)
|
|
|
+ if (!match) {
|
|
|
+ groups.push({
|
|
|
+ label: s.groupName,
|
|
|
+ items: [s]
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ match.items.push(s)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return groups
|
|
|
+})
|
|
|
+const subjectListLoading = ref(false)
|
|
|
+
|
|
|
// 发送试卷弹窗
|
|
|
const sendPaperDialogVisible = ref(false)
|
|
|
const sendPaperForm = ref({
|
|
|
@@ -359,6 +477,113 @@ const handleShowPaperQuestion = (paperId) => {
|
|
|
paperQuestionDialogVisible.value = true
|
|
|
}
|
|
|
|
|
|
+// 显示编辑试卷弹窗
|
|
|
+const handleEditPaper = async (row) => {
|
|
|
+ if (!row || !row.paperId) {
|
|
|
+ ElMessage.warning('试卷信息不存在')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ currentEditPaperRow.value = row
|
|
|
+ editPaperForm.value = {
|
|
|
+ id: row.paperId,
|
|
|
+ paperName: row.paperName || '',
|
|
|
+ year: row.year || null,
|
|
|
+ buildType: row.buildType || '',
|
|
|
+ subjectId: row.subjectId || null,
|
|
|
+ examType: row.examType || '',
|
|
|
+ paperId: row.paperId || null,
|
|
|
+ directKey: row.directKey || '',
|
|
|
+ conditions: row.conditions || ''
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载科目列表(如果有 examType 和 buildType)
|
|
|
+ if (row.examType && row.buildType) {
|
|
|
+ await loadSubjectList(row.buildType, row.examType)
|
|
|
+ }
|
|
|
+
|
|
|
+ editPaperDialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
+// 加载科目列表
|
|
|
+const loadSubjectList = async (buildType, examType) => {
|
|
|
+ if (!buildType || !examType) {
|
|
|
+ subjectList.value = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ subjectListLoading.value = true
|
|
|
+ try {
|
|
|
+ const response = await getPaperSubjects({
|
|
|
+ buildType,
|
|
|
+ examType
|
|
|
+ })
|
|
|
+ if (response && response.code === 200 && response.data) {
|
|
|
+ subjectList.value = response.data
|
|
|
+ } else {
|
|
|
+ subjectList.value = []
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载科目列表失败:', error)
|
|
|
+ subjectList.value = []
|
|
|
+ } finally {
|
|
|
+ subjectListLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 监听考生类型变化,重新加载科目列表
|
|
|
+watch(() => editPaperForm.value.examType, async (newExamType) => {
|
|
|
+ if (editPaperDialogVisible.value && newExamType && currentEditPaperRow.value?.buildType) {
|
|
|
+ editPaperForm.value.subjectId = null // 清空科目选择
|
|
|
+ await loadSubjectList(currentEditPaperRow.value.buildType, newExamType)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+// 确认编辑试卷
|
|
|
+const handleConfirmEdit = async () => {
|
|
|
+ if (!editPaperFormRef.value) return
|
|
|
+
|
|
|
+ try {
|
|
|
+ await editPaperFormRef.value.validate()
|
|
|
+ } catch (error) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!editPaperForm.value.id) {
|
|
|
+ ElMessage.warning('试卷ID不存在')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ editing.value = true
|
|
|
+ try {
|
|
|
+ const response = await updatePaper({
|
|
|
+ id: editPaperForm.value.id,
|
|
|
+ paperName: editPaperForm.value.paperName,
|
|
|
+ year: editPaperForm.value.year,
|
|
|
+ buildType: editPaperForm.value.buildType,
|
|
|
+ subjectId: editPaperForm.value.subjectId,
|
|
|
+ examType: editPaperForm.value.examType,
|
|
|
+ paperId: editPaperForm.value.paperId,
|
|
|
+ directKey: editPaperForm.value.directKey,
|
|
|
+ conditions: editPaperForm.value.conditions
|
|
|
+ })
|
|
|
+
|
|
|
+ if (response && response.code === 200) {
|
|
|
+ ElMessage.success('编辑成功')
|
|
|
+ editPaperDialogVisible.value = false
|
|
|
+ // 刷新列表
|
|
|
+ await getList()
|
|
|
+ } else {
|
|
|
+ ElMessage.error(response?.msg || '编辑失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('编辑试卷失败:', error)
|
|
|
+ ElMessage.error(error?.msg || error?.message || '编辑试卷失败')
|
|
|
+ } finally {
|
|
|
+ editing.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// 学校班级选择组件的引用
|
|
|
const schoolClassSelectRef = ref(null)
|
|
|
|
|
|
@@ -569,7 +794,7 @@ const columns = [
|
|
|
{ label: '题数/总分', prop: 'questionInfo', width: 100, type: 'slot', slotName: 'questionInfo' },
|
|
|
{ label: '时长(分钟)', prop: 'duration', width: 120, type: 'slot', slotName: 'duration' },
|
|
|
{ label: '创建时间', prop: 'createTime', width: 160, type: 'slot', slotName: 'createTime' },
|
|
|
- { label: '操作', prop: 'download', width: 220, type: 'slot', slotName: 'download' }
|
|
|
+ { label: '操作', prop: 'download', width: 280, type: 'slot', slotName: 'download' }
|
|
|
]
|
|
|
|
|
|
// 操作按钮
|