全面优化

This commit is contained in:
2023-04-03 12:43:27 +08:00
parent a2087efdc9
commit a3c4468ee9
27 changed files with 24827 additions and 542 deletions

View File

@@ -10,9 +10,6 @@ export default {
// 引入依赖
import _ from 'lodash'
import api from '@/api/course'
// import com_api from '@/api/common'
// import custom from '@/utils/custom'
// import WarningBar from '@/components/warningBar/warningBar.vue'
import {ref,onMounted,watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
@@ -23,31 +20,13 @@ const userStore = useUserStore()
import mediaCom from '../components/mediaPool.vue'
import exercisesCom from '../components/exercisesPool.vue'
import examCom from '../components/examinationPool.vue'
import viewExamCom from '../components/viewExamination.vue'
const props = defineProps(['course_id','chapter_info'])
const emit = defineEmits(['reload'])
import UploadCommon from '@/components/upload/common.vue'
// 变量
const is_sub = ref(-1)
const dialogChapterVisible = ref(false)
// const dialogChapterTitle = ref('')
const chapterForm = ref({pid:0,sort:0})
const chapterRules = ref({
name: [{ required: true, message: '请输入章节名称', trigger: 'blur' }]
})
const chapter_data = ref([])
const dialogChapterChildVisible = ref(false)
const chapterChildForm = ref({sort:0})
const chapterChildRules = ref({
name: [{ required: true, message: '请输入章节名称', trigger: 'blur' }],
price: [{ required: true, message: '请输入章节价格', trigger: 'blur' }]
})
const dialogChapterTitle = ref('')
const dialogChapterChildTitle = ref('')
// const path = ref(import.meta.env.VITE_BASE_API)
const imageCommon = ref('')
// const current_chapter = ref({}) // 当前操作的大章节
// const current_chapter_child = ref({}) // 当前操作的子章节
// const chapter_index = ref(0)
// 生命周期
onMounted(() => {
chapter_data.value = props.chapter_info
@@ -55,130 +34,31 @@ onMounted(() => {
watch(props,(old, newProps) => {
chapter_data.value = props.chapter_info
})
// 方法
function addChapterFunc() { // 添加大章节
chapterForm.value = {pid:0,sort:0}
dialogChapterVisible.value = true
dialogChapterTitle.value = '添加大章节'
}
async function deleteChapterFunc(item) { //删除大章节
is_sub.value = -1
delFunc(item.course_chapter_id)
}
function delFunc(id) {
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(async() => {
const res = await api.delChapter({
ids:[id],
course_id:parseInt(props.course_id),
sub:parseInt(is_sub.value)
})
if (res.code === 0) {
ElMessage({
type: 'success',
message: '删除成功!'
})
emit('reload')
}
},() => {
})
}
function editChapterFunc(item) { //编辑大章节
chapterForm.value = item
dialogChapterVisible.value = true
dialogChapterTitle.value = '编辑大章节'
}
function closeChapterDialog() {
dialogChapterVisible.value = false
}
function closeChapterChildDialog() {
dialogChapterChildVisible.value = false
chapterChildForm.value = {sort:0}
}
async function enterChapterDialog() { // 提交大章节
// return
chapterForm.value.sort = parseInt(chapterForm.value.sort)
const params = {
...chapterForm.value
// 方法
function indexMethod(index) {
return index +=1
}
// 视频预览相关
const videoDialogTitle = ref('')
const dialogVideoVisible = ref(false)
const video_url = ref(null)
function viewFunc(row,type) { // 查看课件/试卷
if(type ===1) { // 课件
videoDialogTitle.value = '章节:'+row.name
// console.log(row)
dialogVideoVisible.value = true
video_url.value = row.url
}
let func_name = ''
if(chapterForm.value.course_chapter_id) { // 编辑
func_name = 'editChapter'
params.course_id = parseInt(props.course_id)
}
else{ // 新增
func_name = 'addChapter'
params.course_id = parseInt(props.course_id)
}
const res = await api[func_name](params)
if(res.code === 0) {
ElMessage({
type: 'success',
message: '操作成功!'
})
closeChapterDialog()
emit('reload')
else{ // 试卷
// dialogFormVisible.value = true
}
}
function addChapterchildFunc(item) { // 打开新增子章节窗口
dialogChapterChildTitle.value = '新增子章节'
// current_chapter.value = item
chapterChildForm.value = {pid:item.course_chapter_id,sort:0}
dialogChapterChildVisible.value = true
}
function editChapterChildFunc(item,main_index) { // 打开编辑子章节窗口
dialogChapterChildTitle.value = '编辑子章节'
// current_chapter.value = chapter_data.value[main_index]
// item.exam_ids =item.exam_id?[item.exam_id]: []
item.examination_id = item.exam_id
chapterChildForm.value = _.cloneDeep(item)
chapterChildForm.value.price /= 100
dialogChapterChildVisible.value = true
}
function deleteChapterChildFunc(item) { // 删除子章节
is_sub.value = 1
delFunc(item.course_subsection_id)
}
async function enterChapterChildDialog() { // 提交小章节
chapterChildForm.value.sort = parseInt(chapterChildForm.value.sort)
// chapterChildForm.value.price = parseInt(chapterChildForm.value.price*100)
chapterChildForm.value.price = chapterChildForm.value.price*100
const params = {
...chapterChildForm.value
}
let func_name = ''
// return
if(chapterChildForm.value.course_subsection_id){ // 编辑
func_name = 'editChapter'
params.course_id = parseInt(props.course_id)
}
else{ // 新增
func_name = 'addChapter'
params.course_id = parseInt(props.course_id)
}
const res = await api[func_name](params)
if(res.code === 0) {
ElMessage({
type: 'success',
message: '操作成功!'
})
closeChapterChildDialog()
emit('reload')
}
}
function getFilePath(file) { // 获取上传文件之后的地址
chapterChildForm.value.url = file.url
chapterChildForm.value.url_name = file.url_name
}
function addExamFunc(data) {
chapterChildForm.value.examination_id = data
chapterChildForm.value.exam_id = data
function closeVideoDialog() {
dialogVideoVisible.value = false
}
</script>
<template>
<div>
@@ -189,146 +69,46 @@ function addExamFunc(data) {
<div class="lb-card" v-for="(item,i) in chapter_data">
<!--大章节标题-->
<div class="lb-title-part">
<div class="lbt-title">{{item.name}}</div>
<!-- <div class="lbt-btn-box">-->
<!-- <el-button-->
<!-- icon="edit"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="editChapterFunc(item)"-->
<!-- />-->
<!-- <el-button-->
<!-- icon="plus"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="addChapterchildFunc(item)"-->
<!-- />-->
<!-- <el-button-->
<!-- icon="delete"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="deleteChapterFunc(item)"-->
<!-- />-->
<!-- </div>-->
<div class="lbt-title" style="margin-bottom: 10px">{{item.name}}</div>
</div>
<!--表格数据-->
<div class="lb-table-part" style="margin-bottom: 20px">
<el-table :data="item.course_sub" >
<div class="lb-table-part" style="margin-bottom: 20px">
<el-table border :data="item.course_sub" >
<el-table-column align="left" type="index" :index="indexMethod" label="序号" width="60" />
<el-table-column align="left" label="ID" width="60" prop="course_subsection_id" />
<el-table-column align="left" label="子章节名称" min-width="60" prop="name" />
<el-table-column align="left" label="课件名称" min-width="60" prop="url">
<template #default="scope">{{scope.row.url?scope.row.url:'未上传课件'}}</template>
<template #default="scope">
<div class="view-css" v-if="scope.row.url" @click="viewFunc(scope.row,1)">点击查看</div>
<div v-else>未上传课件</div>
</template>
</el-table-column>
<el-table-column align="left" label="章节试卷" min-width="60" prop="exam_id">
<template #default="scope">
{{scope.row.exam_id === 0?'未添加习题':scope.row.exam_id}}
<viewExamCom v-if="scope.row.exam_id" :exam_id = 'scope.row.exam_id' :chaper_name="scope.row.name" ></viewExamCom>
<div v-else>未绑定试卷</div>
</template>
</el-table-column>
<el-table-column align="left" label="章节价格" min-width="60" prop="price">
<template #default="scope">{{scope.row.price/100}}</template>
</el-table-column>
<!-- <el-table-column align="left" label="是否免费" min-width="60">-->
<!-- <template #default="scope">-->
<!-- {{scope.row.is_free === 1? '是':'否'}}-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column align="left" label="是否展示" min-width="60">
<el-table-column align="left" label="是否免费" min-width="60">
<template #default="scope">
{{scope.row.is_show === 1? '是':'否'}}
{{scope.row.is_free === 1? '是':'否'}}
</template>
</el-table-column>
<!-- <el-table-column align="left" label="操作" min-width="60">-->
<!-- <template #default="scope">-->
<!-- <el-button-->
<!-- icon="edit"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="editChapterChildFunc(scope.row)"-->
<!-- >编辑</el-button>-->
<!-- <el-button-->
<!-- icon="delete"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="deleteChapterChildFunc(scope.row)"-->
<!-- >删除</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
</el-table>
</div>
</div>
</div>
<!-- 添加/编辑 大章节窗口-->
<el-dialog v-model="dialogChapterVisible" :before-close="closeChapterDialog" :title="dialogChapterTitle">
<el-form ref="apiForm" :model="chapterForm" :rules="chapterRules" label-width="80px">
<el-form-item label="章节名称" prop="name">
<el-input v-model="chapterForm.name" autocomplete="off" />
</el-form-item>
<el-form-item label="章节排序" prop="sort">
<el-input v-model="chapterForm.sort" placeholder="输入整数,排序越小越靠前展示" autocomplete="off" />
</el-form-item>
<el-form-item label="是否免费" prop="is_free">
<el-switch v-model="chapterForm.is_free" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
</el-form-item>
<!-- <el-form-item label="是否展示" prop="is_show">-->
<!-- <el-switch v-model="chapterForm.is_show" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />-->
<!-- </el-form-item>-->
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeChapterDialog"> </el-button>
<el-button size="small" type="primary" @click="enterChapterDialog"> </el-button>
</div>
</template>
</el-dialog>
<!-- 添加小章节窗口-->
<el-dialog v-model="dialogChapterChildVisible" :before-close="closeChapterChildDialog" :title="dialogChapterChildTitle">
<el-form ref="apiForm" :model="chapterChildForm" :rules="chapterChildRules" label-width="80px">
<el-form-item label="章节名称" prop="name">
<el-input v-model="chapterChildForm.name" autocomplete="off" />
</el-form-item>
<el-form-item label="上传课件">
<!-- <upload-common-->
<!-- v-model:imageCommon="imageCommon"-->
<!-- class="upload-btn"-->
<!-- @on-success="getFilePath"-->
<!-- />-->
<media-com @on-success="getFilePath" :url_name="chapterChildForm.url_name" />
<!-- <el-button size="small" type="primary" @click="openExercisesWinFunc">点击上传</el-button>-->
</el-form-item>
<el-form-item label="试卷管理">
<!-- <el-button size="small" @click="chooseChapterChildExercises">添加习题</el-button>-->
<exam-com @addFunc="addExamFunc" :seleted_id="chapterChildForm.exam_id" />
</el-form-item>
<el-form-item label="章节价格" prop="price">
<el-input type="number" v-model="chapterChildForm.price" placeholder="输入章节价格" autocomplete="off" />
</el-form-item>
<el-form-item label="章节排序" prop="sort">
<el-input v-model="chapterChildForm.sort" placeholder="输入整数,排序越小越靠前展示" autocomplete="off" />
</el-form-item>
<el-form-item label="是否免费" prop="is_free">
<el-switch v-model="chapterChildForm.is_free" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
</el-form-item>
<!-- <el-form-item label="是否展示" prop="is_show">-->
<!-- <el-switch v-model="chapterChildForm.is_show" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />-->
<!-- </el-form-item>-->
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeChapterChildDialog"> </el-button>
<el-button size="small" type="primary" @click="enterChapterChildDialog"> </el-button>
</div>
</template>
<el-dialog v-model="dialogVideoVisible" :before-close="closeVideoDialog" :title="videoDialogTitle">
<video style="width: 100%" :src="video_url" controls></video>
</el-dialog>
</div>
</template>
<style scoped>
.view-css{
cursor: pointer;
}
.lbt-title{
margin-right: 20px;
font-size: 18px;

View File

@@ -162,16 +162,6 @@ function handleChooseChange(row) {
<el-form-item label="试卷名称">
<el-input v-model="queryParams.name" placeholder="根据试卷名称进行查询" />
</el-form-item>
<!-- <el-form-item label="试卷分类">-->
<!-- <el-select v-model="queryParams.subject" clearable placeholder="请选择">-->
<!-- <el-option-->
<!-- v-for="item in subjectList"-->
<!-- :key="item.id"-->
<!-- :label="item.name"-->
<!-- :value="item.name"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item>
<el-button size="small" type="primary" icon="search" @click="onSubmit">查询</el-button>
<el-button size="small" icon="refresh" @click="onReset">重置</el-button>
@@ -181,11 +171,7 @@ function handleChooseChange(row) {
<!-- 数据列表-->
<div class="list-box">
<el-table ref="multipleTableRef" row-key="exam.exam_id" :data="tableData" highlight-current-row @current-change="handleChooseChange">
<!-- <el-table-column-->
<!-- type="selection"-->
<!-- width="55"-->
<!-- reserve-selection="true"-->
<!-- />-->
<el-table-column align="center" label="ID" min-width="60" prop="exam.exam_id" sortable="custom" />
<el-table-column align="center" label="试卷名称" min-width="150" prop="exam.name" />
<el-table-column align="center" label="科目" min-width="150" prop="exam.subject" />

View File

@@ -1,6 +1,6 @@
<script setup>
// 引入依赖
// import api from '@/api/course'
import capi from '@/api/course'
// import com_api from '@/api/common'
// import WarningBar from '@/components/warningBar/warningBar.vue'
import api from '@/api/exercises'
@@ -12,15 +12,16 @@ const route = useRoute()
import { useUserStore } from '@/pinia/modules/user'
const userStore = useUserStore()
// import chapterCom from '../components/chapter.vue'
const props = defineProps(['url_name','seleted_arr'])
const props = defineProps(['seleted_arr'])
const emit = defineEmits(['addFunc'])
// import { clients, getNowDate } from '@/utils'
import custom from '@/utils/custom'
// import { getToken } from '@/utils/auth'
// 监听
watch(props,(val1,val2) => {
selected_question_ids.value = val2.seleted_arr || []
selected_question_ids.value = val2.seleted_arr?JSON.parse(val2.seleted_arr):[]
})
// console.log(props)
// 变量
const selected_question_ids = ref(props.seleted_arr || [])
@@ -39,14 +40,27 @@ const tableData =ref([])
const total = ref(0)
const question_ids = ref([])
// 生命周期
const subjectList = inject('subjectList')
// const subjectList = inject('subjectList')
const subjectList = ref([])
const current_subject = inject('current_subject')
queryParams.value.subject = current_subject
const subjectParams = ref({
page:1,
pageSize:100,
})
onMounted(() => {
// console.log(headers.value)
// getExercisesList()
getSubject()
})
// 方法
async function getSubject(){ // 获取课程分类
const res = await capi.getSubjectList(subjectParams.value)
if(res.code === 0) {
// subjectList.value = custom.getStdSubject(res.data.records)
subjectList.value = custom.addTreeFormatSubject(res.data.records,'name')
}
}
async function getExercisesList() {
const res = await api.getExercisesList(queryParams.value)
if(res.code === 0) {
@@ -114,12 +128,15 @@ const toggleSelection = (rows) => { // 判断是否被选中
multipleTableRef.value.clearSelection()
}
}
function selectFunc(row, index) {
return false
}
</script>
<template>
<div>
<el-button v-if="selected_question_ids.length==0" size="small" @click="chooseChapterChildExercises">添加习题</el-button>
<el-button v-else size="small" @click="chooseChapterChildExercises" type="plain">点击查看已选{{selected_question_ids.length}}道题</el-button>
<div v-if="url_name">{{url_name}}</div>
<!-- <div v-if="url_name">{{url_name}}</div>-->
<el-drawer v-model="drawer" title="习题库" size="60%">
<div class="drawer-section">
<!-- 搜索框-->
@@ -129,14 +146,15 @@ const toggleSelection = (rows) => { // 判断是否被选中
<el-input v-model="queryParams.content" placeholder="请输入" />
</el-form-item>
<el-form-item label="课程分类">
<el-select v-model="queryParams.subject" clearable placeholder="请选择">
<el-option
v-for="item in subjectList"
:key="item.id"
:label="item.name"
:value="item.name"
/>
</el-select>
<!-- <el-select v-model="queryParams.subject" clearable placeholder="请选择">-->
<!-- <el-option-->
<!-- v-for="item in subjectList"-->
<!-- :key="item.id"-->
<!-- :label="item.name"-->
<!-- :value="item.name"-->
<!-- />-->
<!-- </el-select>-->
<el-tree-select v-model="queryParams.subject" :data="subjectList" :render-after-expand="false" />
</el-form-item>
<el-form-item label="题目类型">
<el-select v-model="queryParams.type" clearable placeholder="请选择">
@@ -156,7 +174,7 @@ const toggleSelection = (rows) => { // 判断是否被选中
</div>
<!-- 数据列表-->
<div class="list-box">
<el-table ref="multipleTableRef" row-key="question_id" :data="tableData" @selection-change="handleSelectionChange">
<el-table border ref="multipleTableRef" row-key="question_id" :data="tableData" @selection-change="handleSelectionChange">
<el-table-column
type="selection"
width="55"
@@ -190,7 +208,7 @@ const toggleSelection = (rows) => { // 判断是否被选中
</div>
<!-- 按钮-->
<div class="btn-box" style="text-align: right">
<el-button size="small" type="primary" icon="plus" @click="addFunc">添加</el-button>
<!-- <el-button size="small" type="primary" icon="plus" @click="addFunc">添加</el-button>-->
</div>
</div>
</el-drawer>

View File

@@ -0,0 +1,357 @@
<script setup>
// 引入依赖
import api from '@/api/examination'
import capi from '@/api/course'
import custom from '@/utils/custom'
import {formatDate} from '@/utils/format'
import _ from 'lodash'
import WarningBar from '@/components/warningBar/warningBar.vue'
import exercisesPool from '@/view/course/components/exercisesPool.vue'
import groupPool from '@/view/examinationManage/components/groupPool.vue'
import {ref,onMounted,provide } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()
// store
import { useUserStore } from '@/pinia/modules/user'
const userStore = useUserStore()
// 组件通信
const props = defineProps(['exam_id','chaper_name'])
// const emit = defineEmits(['reload'])
// 变量
const path = ref(import.meta.env.VITE_BASE_API)
// const typeList = custom.getExercisesTypeList()
// const queryParams = ref({
// teacherId:0,
// page:1,
// pageSize:10,
// name:'',
// status:'',
// subject:''
// })
const subjectParams = ref({
page:1,
pageSize:100,
})
const tableData = ref([])
const subjectList = ref([])
const current_subject = ref('')
const deleteVisible = ref(false)
const question_ids = ref([])
const total = ref(0)
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const form =ref({price:4.9})
const rules = ref({
// name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }]
})
const question_id = ref(0)
const content = ref(null)
// const options = ref([]) // 答案选项数组
const exam_types = ref([])
const exam_ids = ref([])
const price_props = ['first','second','third','price']
const exam_type_ids = ref([])
// 生命周期
onMounted(() => {
// getExaminationList()
// getExaminationDetail()
// getSubject()
})
// provide('subjectList', subjectList)
// provide('current_subject', current_subject)
const std_group = ref({
persons:'',
expiry_date:'',
public_date:'',
first:'',
second:'',
third:''
})
const exam_info =ref(null)
// 方法
async function viewFunc() {
dialogFormVisible.value = true
if(subjectList.value.length === 0) {
await getSubject()
}
// await getSubject()
getExaminationDetail()
}
async function getExaminationDetail() {
const res = await api.getExaminationDetail({
id:props.exam_id
})
if(res.code === 0) {
exam_info.value = res.data
form.value = res.data.exam
exam_types.value = res.data.exam_types.map((item) => {
for(let prop in item) {
if(price_props.includes(prop)) {
item[prop] /= 100
}
}
return item
})
console.log(exam_info.value,exam_types.value)
}
}
// async function getExaminationList() {
// const res = await api.getExaminationList(queryParams.value)
// if(res.code === 0) {
// tableData.value = res.data.records
// total.value = res.data.total
// }
// }
async function getSubject(){ // 获取课程分类
const res = await capi.getSubjectList(subjectParams.value)
if(res.code === 0) {
subjectList.value = custom.getStdSubject(res.data.records)
}
}
// function onSubmit() {
// getExaminationList()
// }
// const onReset = () => {
// queryParams.value = {
// page:1,
// pageSize:10,
// name:'',
// status:'',
// subject:''
// }
// }
function openDialog(type) {
// let params = {}
switch (type){
case 'add':
dialogTitle.value = '新增试卷'
form.value = {price:4.9}
break;
case 'edit':
// params.question_id = question_id.value
dialogTitle.value = '编辑试卷'
break;
}
dialogFormVisible.value = true
// router.push({name:'addCourse',params})
}
// async function onDelete() {
// const ids = exam_ids.value
// const res = await api.delExamination({ exam_ids:ids })
// if (res.code === 0) {
// ElMessage({
// type: 'success',
// message: res.msg
// })
// // if (tableData.value.length === ids.length && page.value > 1) {
// // page.value--
// // }
// deleteVisible.value = false
// getExaminationList()
// }
// }
// const handleSelectionChange = (val) => {
// exam_ids.value = val.map((item) => {
// return item.exam.exam_id
// })
// }
// const exam_id = ref(null)
// function handleCurrentChange(val) {
// queryParams.value.page = val
// getExaminationList()
// }
// function handleSizeChange(val) {
// queryParams.value.pageSize = val
// getExaminationList()
// }
function closeDialog(){
dialogFormVisible.value = false
exam_types.value = []
form.value = {}
}
async function enterDialog() { // 提交
// form.value.teacher_id = 0
// form.value.exam_type = exam_types.value.map((item) => {
// for(let prop in item) {
// if(Object.keys(std_group.value).includes(prop)) {
// item[prop] = Number(item[prop])
// if(price_props.includes(prop)) {
// item[prop] *= 100
// }
// }
// }
// return item
// })
// form.value.price = parseInt(Number(form.value.price )*100)
// form.value.duration = parseInt(form.value.duration)
// const params = {
// ...form.value
// }
// params.question_ids = JSON.stringify(form.value.question_ids)
// params.course_ids = JSON.stringify(form.value.course_ids)
// let func_name = 'addExamination'
// if(form.value.exam_id) { // 编辑
// func_name = 'editExamination'
// }
// const res = await api[func_name](params)
// if(res.code === 0) {
// ElMessage({
// type: 'success',
// message: res.msg
// })
// closeDialog()
// getExaminationList()
// }
}
// function viewCourseFunc(row) { // 查看课程
// router.push({name:'viewCourse',params:{question_id:row.question_id}})
// }
// function getExercisesName(row) {
// return JSON.parse(row.question).title
// }
// const std_options_title = ref(['A','B','C','D','E','F'])
// function addOptionFunc() {
// exam_types.value.push(_.cloneDeep(std_group.value))
// }
// function delet_func(i) {
// exam_types.value.splice(i,1)
// }
// function handleAvatarSuccess(res) {
// form.value.cover = res.data.file.url
// }
// function beforeAvatarUpload(file) {
// const isLt05M = file.size / 1024 / 1024 < 20
// const isJPG = file.type.indexOf('image/') === -1
// if (isJPG) {
// ElMessage.error('文件格式错误,请上传图片类型,如JPGPNG后缀的文件')
// }
// if (!isLt05M) {
// ElMessage.error('上传头像图片大小不能超过 2M!')
// }
// return !isJPG && isLt05M
// }
// function changeSubjectFunc(e) {
// current_subject.value = e
// }
function addExercisesFunc(data) {
form.value.question_ids = data
}
function addGroupFunc(data) {
console.log("父组件行为")
exam_types.value = _.clone(data)
}
</script>
<template>
<div>
<el-button size="small" @click="viewFunc" type="plain">点击查看</el-button>
<!-- 编辑窗口 -->
<el-dialog v-model="dialogFormVisible" :before-close="closeDialog" :title="'章节:'+chaper_name">
<el-form ref="apiForm" :model="form" :rules="rules" label-width="80px">
<el-form-item label="试卷名称" >
<el-input disabled v-model="form.name" placeholder="请输入试卷名称" />
</el-form-item>
<el-form-item label="科目" prop="subject">
<el-select disabled v-model="form.subject" @change="changeSubjectFunc" clearable placeholder="请选择">
<el-option
v-for="item in subjectList"
:key="item.id"
:label="item.name"
:value="item.name"
/>
</el-select>
</el-form-item>
<el-form-item label="封面">
<el-upload
disabled
class="avatar-uploader"
:action="`${path}/fileUploadAndDownload/upload`"
:headers="{ 'x-token': userStore.token }"
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload"
>
<img v-if="form.cover" :src="form.cover" class="avatar avatar-uploader-img" />
<el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
</el-upload>
</el-form-item>
<el-form-item label="测试时长" >
<el-input disabled type="number" v-model="form.duration" placeholder="请输入测试时长(分钟)" />
</el-form-item>
<el-form-item label="测试价格" >
<el-input type="number" v-model="form.price" disabled placeholder="请输入测试价格(元)" />
</el-form-item>
<el-form-item label="测试组别" >
<groupPool @addFunc="addGroupFunc" :exam_types="exam_types" :exam_id="exam_id" />
</el-form-item>
<el-form-item label="添加习题" >
<exercisesPool @addFunc="addExercisesFunc" :seleted_arr="form.question_ids" />
</el-form-item>
<el-form-item label="是否上架" >
<el-switch
disabled
v-model="form.status"
active-text="上架"
inactive-text="下架"
:active-value="1"
:inactive-value="-1"
/>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button size="small" @click="closeDialog"> </el-button>
<el-button size="small" type="primary" @click="closeDialog"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<style>
.el-table .el-table__cell{
z-index: unset;
}
</style>
<style scoped lang="scss">
.avatar-uploader-img{
width: 178px;
height: 178px;
}
.avatar-uploader{
}
.rb-item{
margin-bottom: 10px;
}
.e-img{
width: 150px;
height: 100px;
}
.option-item{
border-bottom: 1px solid #ebebeb;
margin-bottom: 10px;
.oi-row{
display: flex;
align-items: center;
margin-bottom: 10px;
.oi-item{
//color: red;
}
}
}
.button-box {
padding: 10px 20px;
.el-button {
float: right;
}
}
.warning {
color: #dc143c;
}
</style>