完成订单模块和教师管理模块

This commit is contained in:
2023-02-23 17:58:59 +08:00
parent db82d6ca21
commit 309eccc116
9 changed files with 957 additions and 77 deletions

View File

@@ -5,6 +5,7 @@ import api from '@/api/exercises'
import capi from '@/api/course'
import custom from '@/utils/custom'
import {formatDate} from '@/utils/format'
import _ from 'lodash'
// import { toSQLLine } from '@/utils/stringFun'
import WarningBar from '@/components/warningBar/warningBar.vue'
import ckEditor from '@/components/richText/ckEditor5.vue'
@@ -50,7 +51,6 @@ const question_form = ref({
onMounted(() => {
getExercisesList()
getSubject()
// console.log(options.value.size)
})
// 方法
async function getExercisesList() {
@@ -64,7 +64,6 @@ async function getSubject(){ // 获取课程分类
const res = await capi.getSubjectList(subjectParams.value)
if(res.code === 0) {
subjectList.value = custom.getStdSubject(res.data.records)
// console.log(subjectList.value)
}
}
function onSubmit() {
@@ -84,7 +83,7 @@ function openDialog(type) {
switch (type){
case 'add':
dialogTitle.value = '新增习题'
form.value = {}
form.value = {}
break;
case 'edit':
// params.question_id = question_id.value
@@ -95,7 +94,6 @@ function openDialog(type) {
// router.push({name:'addCourse',params})
}
async function onDelete() {
// console.log(question_ids.value)
const ids = question_ids.value.map(item => item.question_id)
const res = await api.delExercises({ question_ids:ids })
if (res.code === 0) {
@@ -111,26 +109,17 @@ async function onDelete() {
}
}
const handleSelectionChange = (val) => {
// console.log(val)
question_ids.value = val
}
function editCourseFunc(row) {
question_id.value = row.question_id
form.value = row
// console.log(JSON.parse(row.question))
content.value = JSON.parse(row.question).title
// if(JSON.parse(row.question).option) {
// question_form.value.options = JSON.parse(row.question).option
// }
// else{
// question_form.value.options = []
// }
question_form.value = JSON.parse(row.question)
form.value = _.cloneDeep(row)
question_id.value = form.value.question_id
content.value = JSON.parse(form.value.question).title
question_form.value = JSON.parse(form.value.question)
console.log(question_form.value)
openDialog('edit')
console.log(JSON.parse(row.question))
}
function deleteCourseFunc(row) {
// console.log(row); return
ElMessageBox.confirm('此操作将永久删除该数据, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
@@ -171,8 +160,11 @@ async function enterDialog() { // 提交
form.value.score = parseInt(form.value.score)
form.value.teacher_id = 0
form.value.question = JSON.stringify(question_form.value)
console.log(form.value)
const res = await api.addExercises(form.value)
let func_name = 'addExercises'
if(form.value.question_id) { // 编辑
func_name = 'editExercises'
}
const res = await api[func_name](form.value)
if(res.code === 0) {
ElMessage({
type: 'success',
@@ -190,7 +182,6 @@ function viewCourseFunc(row) { // 查看课程
router.push({name:'viewCourse',params:{question_id:row.question_id}})
}
function getExercisesName(row) {
// console.log(JSON.parse(row.question))
return JSON.parse(row.question).title
}
const std_options_title = ref(['A','B','C','D','E','F'])
@@ -202,7 +193,6 @@ function addOptionFunc() {
// }
// }
// console.log(options.value)
for(let i=0 ;i<std_options_title.value.length;i++) {
let has_flag = false
for(let item of question_form.value.options){
@@ -301,13 +291,6 @@ function delet_func(item) {
</el-table-column>
<el-table-column align="left" fixed="right" label="操作" width="200">
<template #default="scope">
<!-- <el-button-->
<!-- icon="view"-->
<!-- size="small"-->
<!-- type="primary"-->
<!-- link-->
<!-- @click="viewCourseFunc(scope.row)"-->
<!-- >查看</el-button>-->
<el-button
icon="edit"
size="small"
@@ -369,7 +352,7 @@ function delet_func(item) {
<el-form-item label="答案" >
<!-- <el-input v-model="form.score" placeholder="请输入分值" />-->
<view class="options-box">
<view class="option-item" v-if="question_form.options.length>0" v-for="(item,i) in question_form.options">
<view class="option-item" v-if="question_form" v-for="(item,i) in question_form.options">
<view>{{item.name}}</view>
<ckEditor v-model="item.value" :content="item.value" style="margin-left:5px" />
<el-icon style="margin-left: 5px;cursor: pointer" v-if="(i+1) == question_form.options.length" @click="delet_func(item)"><Delete /></el-icon>