提交 c7083fc6 authored 作者: matian's avatar matian

修改试卷添加

上级 1824e960
...@@ -16,7 +16,7 @@ const props = withDefaults( ...@@ -16,7 +16,7 @@ const props = withDefaults(
columns?: any[] columns?: any[]
data?: any[] data?: any[]
hasPagination?: boolean hasPagination?: boolean
limit?: number, limit?: number
}>(), }>(),
{ {
hasPagination: true, hasPagination: true,
......
/* eslint-disable vue/no-mutating-props */
<script setup lang="ts"> <script setup lang="ts">
import { ElMessage } from 'element-plus'
import AddExamDialog from './AddExamDialog.vue' import AddExamDialog from './AddExamDialog.vue'
const emit = defineEmits<Emits>()
interface Emits {
(e: 'change', examList: any): void
}
const props = defineProps({ const props = defineProps({
data: { data: {
type: Array type: Array,
required: true
} }
}) })
const emit = defineEmits(['change']) const examList: any = ref([])
console.log(props.data.length, 'length')
// if (props.data.length > 0) {
// examList.value = [...props.data]
// } else {
// examList.value = []
// }
watch(
() => props.data,
value => {
if (value?.length > 0) {
examList.value = [...props.data]
} else {
examList.value = []
}
},
{ immediate: true }
)
const isShowExamDialog = ref(false)
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
data: examList.value,
columns: [ columns: [
{ label: '试卷名称', prop: 'paper_title', align: 'center' }, {
label: '试卷名称',
prop: 'paper_title',
minWidth: 200
},
{ {
label: '组卷模式', label: '组卷模式',
prop: 'paper_type', prop: 'paper_type',
align: 'center', computed: (row: any) => {
computed({ row }: any) { return row.row.paper_type === 1 ? '选题组卷' : '自动组卷'
const json = { 1: '选题组卷', 2: '自动组卷' }
return json[parseInt(row.paper_type)]
} }
}, },
{ {
label: '试卷用途', label: '试卷用途',
prop: 'paper_uses', prop: 'paper_uses',
align: 'center', computed: (row: any) => {
computed({ row }: any) { if (row.row.paper_type === 1) {
const json = { 1: '考试', 2: '课后作业', 3: '课程测试' } return '考试'
return json[parseInt(row.paper_uses)] } else if (row.row.paper_type === 2) {
return '课后作业'
} else if (row.row.paper_type === 3) {
return '课程测试'
}
} }
}, },
{ label: '总分', prop: 'paper_total_score', align: 'center' }, { label: '总分', prop: 'paper_total_score', align: 'center' },
{ label: '及格分数', prop: 'pass_score', align: 'center' }, { label: '及格分数', prop: 'pass_score', align: 'center' },
{ label: '操作', slots: 'table-operate', align: 'center' } { label: '操作', slots: 'table-operate', align: 'center' }
], ]
data: props.data
} }
}) })
const addExam = ref([])
const isShowExamDialog = ref(false)
// // 删除考试 // // 删除考试
const removeLectuter = (id: string) => { const removeLectuter = (id: string) => {
const index = addExam.value.findIndex((ids: string) => ids === id) const index = examList.value.findIndex((ids: string) => ids === id)
addExam.value.splice(index, 1) examList.value.splice(index, 1)
handleAddExam('')
} }
const handleAddExam = (val: any) => { const handleAddExam = (val: any) => {
addExam.value = val console.log(props.data, 'pppp')
emit('change', val) let flag = false
examList.value.forEach((item: any) => {
val.value.forEach((it: any) => {
if (item.id === it.id) {
ElMessage.warning('不能重复添加同一张试卷')
flag = true
return false
}
})
})
if (!flag) {
examList.value = [...val.value, ...examList.value]
emit('change', examList.value)
}
} }
</script> </script>
......
<script setup lang="ts"> <script setup lang="ts">
import { searchExam } from '../../api' import { searchExam } from '../../api'
import { useQuestionList } from '@/composables/useQuestionList' import { useQuestionList } from '@/composables/useQuestionList'
const appList = ref() const appList = ref()
let { list: selectTree } = useQuestionList() let { list: selectTree } = useQuestionList()
const tabValue = ref('1') const tabValue = ref('1')
...@@ -28,17 +29,11 @@ const listOptions = { ...@@ -28,17 +29,11 @@ const listOptions = {
}, },
params: { params: {
project_tag: 'resourse_ci', project_tag: 'resourse_ci',
id: '', permission: tabValue
paper_title: '',
permission: tabValue,
paper_type: '',
paper_labels: '',
paper_category: '',
paper_categories: ''
} }
}, },
filters: [ filters: [
{ prop: 'classification', label: '类别:', slots: 'filter-type' }, { prop: 'paper_categories', label: '类别:', slots: 'filter-type' },
{ type: 'input', prop: 'paper_title', label: '标题:' } { type: 'input', prop: 'paper_title', label: '标题:' }
], ],
columns: [ columns: [
...@@ -92,12 +87,12 @@ const typeFilter = () => { ...@@ -92,12 +87,12 @@ const typeFilter = () => {
appList.value.refetch() appList.value.refetch()
} }
const handleSelectionChange = (val: any) => { const handleSelectionChange = (val: any) => {
multipleSelection.value = val multipleSelection.value = JSON.parse(JSON.stringify(val))
} }
</script> </script>
<template> <template>
<el-drawer :model-value="isShowExamDialog" draggable :before-close="handleCancel" size="60%" title="添加考试"> <el-drawer :model-value="isShowExamDialog" :before-close="handleCancel" size="60%" title="添加考试">
<div class="video-head"> <div class="video-head">
<el-tabs @tab-change="tabChange" v-model="tabValue"> <el-tabs @tab-change="tabChange" v-model="tabValue">
<el-tab-pane label="我的资源" name="1"></el-tab-pane> <el-tab-pane label="我的资源" name="1"></el-tab-pane>
......
...@@ -44,13 +44,7 @@ const listOptions = { ...@@ -44,13 +44,7 @@ const listOptions = {
}, },
params: { params: {
project_tag: 'resourse_ci', project_tag: 'resourse_ci',
id: '', permission: tabValue
paper_title: '',
permission: tabValue,
paper_type: '',
paper_labels: '',
paper_category: '',
paper_categories: ''
} }
}, },
filters: [ filters: [
......
...@@ -83,7 +83,14 @@ const changeLecturer = (data: any) => { ...@@ -83,7 +83,14 @@ const changeLecturer = (data: any) => {
// 选择考试 // 选择考试
const changeExam = (data: any) => { const changeExam = (data: any) => {
form.exam_id = data.toString() console.log(data, 'data')
form.exam_id = JSON.parse(JSON.stringify(data))
.map((item: any) => {
return item.id
})
.toString()
console.log(form.exam_id, 'data')
} }
// 选择直播 // 选择直播
...@@ -138,6 +145,7 @@ const createCourseForm = () => { ...@@ -138,6 +145,7 @@ const createCourseForm = () => {
} }
}) })
} else { } else {
console.log(form, 'form')
createCourse(form).then((res: any) => { createCourse(form).then((res: any) => {
if (res.code === 0) { if (res.code === 0) {
// 操作第二部 // 操作第二部
......
...@@ -185,6 +185,7 @@ const handleDrop = (startNode: any, endNode: any, position: any, event: any) => ...@@ -185,6 +185,7 @@ const handleDrop = (startNode: any, endNode: any, position: any, event: any) =>
:props="defaultProps" :props="defaultProps"
:allow-drop="allowDrop" :allow-drop="allowDrop"
@node-drop="handleDrop" @node-drop="handleDrop"
style="min-width: 100%"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<span class="custom-tree-node"> <span class="custom-tree-node">
...@@ -228,6 +229,9 @@ const handleDrop = (startNode: any, endNode: any, position: any, event: any) => ...@@ -228,6 +229,9 @@ const handleDrop = (startNode: any, endNode: any, position: any, event: any) =>
</el-tree> </el-tree>
<div class="btn-box" style="display: flex; justify-content: center"> <div class="btn-box" style="display: flex; justify-content: center">
<el-button type="primary" @click="router.push('/course/my')">保存</el-button> <el-button type="primary" @click="router.push('/course/my')">保存</el-button>
<el-button type="primary" @click="router.push({ path: '/course/update-course', query: { id: id } })"
>上一步</el-button
>
</div> </div>
</AppCard> </AppCard>
<!-- 添加章 --> <!-- 添加章 -->
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论