持续开发习题管理模块,新增ckeditor5富文本组件

This commit is contained in:
2023-02-18 21:59:58 +08:00
parent cbe10214f5
commit 40f5e10da7
13 changed files with 10423 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
<script setup>
// 引入依赖
// import _ from 'lodash'
import api from '@/api/course'
import com_api from '@/api/common'
import custom from '@/utils/custom'
@@ -16,7 +17,7 @@ import chapterCom from '../components/chapter.vue'
const path = ref(import.meta.env.VITE_BASE_API)
const course_id = ref(0)
const active = ref(0)
const form = ref({status:1})
const form = ref({status:1,is_boutique:-1,is_audition:-1})
const subjectParams = ref({
pageIndex:1,
pageSize:100,
@@ -30,6 +31,7 @@ const rules = ref({
const ruleFormRef = ref(null)
const chapter_info = ref([])
const current_subject = ref('')
const isChange = ref(false)
// 生命周期
onMounted(() => {
course_id.value = route.params.course_id || 0
@@ -40,15 +42,14 @@ onMounted(() => {
})
provide('subjectList', subjectList)
provide('current_subject', current_subject)
// 方法
async function getCourseInfo() { // 获取课程信息
const res = await api.getCourse({id:course_id.value})
if(res.code === 0) {
chapter_info.value = res.data.course_ware_json
form.value = res.data.course
console.log(form.value)
}
}
// 方法
function stepChangeFunc(type) {
switch (type) {
case 1: // 上一步
@@ -56,7 +57,13 @@ function stepChangeFunc(type) {
break;
case 2: // 下一步
if(active.value == 0) { // 保存第一步的信息
submitForm(ruleFormRef.value)
console.log(isChange.value)
if(isChange.value){
submitForm(ruleFormRef.value)
}
else{
active.value += 1
}
}
else{
active.value +=1
@@ -144,6 +151,7 @@ async function uploadAction(file){//图片上传 非oss
}
function handleAvatarSuccess(res) {
form.value.cover = res.data.file.url
handlerChange()
}
function beforeAvatarUpload(file) {
const isLt05M = file.size / 1024 / 1024 < 20
@@ -159,6 +167,10 @@ function beforeAvatarUpload(file) {
function onSubmit() {
router.push({name:'courseManage'})
}
function handlerChange(e) {
// console.log(e)
isChange.value = true
}
</script>
<template>
<div>
@@ -174,10 +186,10 @@ function onSubmit() {
<!-- step1-->
<el-form ref="ruleFormRef" v-if="active == 0" :model="form" :rules="rules" label-width="120px" style="width: 50%">
<el-form-item label="课程名称" prop="name">
<el-input placeholder="请输入课程名称" v-model="form.name" />
<el-input placeholder="请输入课程名称" v-model="form.name" @change="handlerChange" />
</el-form-item>
<el-form-item label="课程分类" prop="subject">
<el-select v-model="form.subject" placeholder="请选择">
<el-select v-model="form.subject" placeholder="请选择" @change="handlerChange">
<el-option
v-for="item in subjectList"
:key="item.id"
@@ -200,19 +212,19 @@ function onSubmit() {
</el-upload>
</el-form-item>
<el-form-item label="价格" prop="price">
<el-input placeholder="请输入课程价格" type="number" v-model="form.price" />
<el-input @change="handlerChange" placeholder="请输入课程价格" type="number" v-model="form.price" />
</el-form-item>
<el-form-item label="课程简介">
<el-input v-model="form.intro" type="textarea" />
<el-input @change="handlerChange" v-model="form.intro" type="textarea" />
</el-form-item>
<el-form-item label="包含试听">
<el-switch v-model="form.is_audition" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
<el-switch @change="handlerChange" v-model="form.is_audition" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
</el-form-item>
<el-form-item label="设置精品">
<el-switch v-model="form.is_boutique" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
<el-switch @change="handlerChange" v-model="form.is_boutique" active-text="是" inactive-text="否" :active-value="1" :inactive-value="-1" />
</el-form-item>
<el-form-item label="课程状态">
<el-switch v-model="form.status" active-text="上架" inactive-text="下架" :active-value="1" :inactive-value="-1" />
<el-switch @change="handlerChange" v-model="form.status" active-text="上架" inactive-text="下架" :active-value="1" :inactive-value="-1" />
</el-form-item>
<el-form-item style="display: none">
<el-button type="primary" @click="submitForm(ruleFormRef)">