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

修改试卷添加

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