课程详情

develoop
lijiaqi 4 months ago
parent c3c6e5e3de
commit 5aa93f37c7
  1. 4
      .env.development
  2. 4
      src/api/user/chapter.js
  3. 50
      src/views/course/components/course-chapters.vue
  4. 23
      src/views/course/ss.vue

@ -1,5 +1,5 @@
# 变量必须以 VITE_ 为前缀才能暴露给外部读取
NODE_ENV = 'development'
VITE_APP_TITLE = '无糖运营平台'
# VITE_APP_BASE_API = 'http://127.0.0.1:8080'
VITE_APP_BASE_API = 'http://39.106.16.162:8080'
VITE_APP_BASE_API = 'http://127.0.0.1:8080'
# VITE_APP_BASE_API = 'http://39.106.16.162:8080'

@ -5,3 +5,7 @@ export const getChaptersListApi = (params) => {
}
// 添加课程章节
export const addChaptersApi = (params) => request.post('/chapter2/add', params)
// 删除课程章节
export const delChapterstApi = (id) => {
return request.delete(`/chapter2/delete/${id}`)
}

@ -3,7 +3,11 @@ import { ref } from 'vue'
import type Node from 'element-plus/es/components/tree/src/model/node'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRoute } from 'vue-router'
import { getChaptersListApi, addChaptersApi } from '@/api/user/chapter'
import {
getChaptersListApi,
addChaptersApi,
delchaptersApi,
} from '@/api/user/chapter'
import { onMounted } from 'vue'
const route = useRoute()
// const router = useRouter()
@ -49,32 +53,40 @@ const append = async (data: Tree) => {
confirmButtonText: '确定',
cancelButtonText: '取消',
}).then(async ({ value }) => {
const newChild = { id: id++, name: `${value}`, pid: data.id, children: [] }
// const res = await addChaptersApi({ name: value, pid: })
const res = await addChaptersApi(newChild)
// getChaptersList()
console.log(res)
const newChild = {
id: id++,
name: `${value}`,
pid: data.id,
courseId: courseId.value,
}
if (!data.children) {
data.children = []
}
data.children.push(newChild)
dataSource.value = [...dataSource.value]
// getChaptersList()
// if (res.code === 200) {
// //
// // dataSource.value = [...dataSource.value]
// } else {
// ElMessage({
// type: 'error',
// message: '',
// })
// }
const res = await addChaptersApi(newChild)
console.log(res)
if (res.code === 200) {
//
dataSource.value = [...dataSource.value]
ElMessage({
type: 'success',
message: '添加成功',
})
} else {
ElMessage({
type: 'error',
message: '添加失败,请稍后再试',
})
}
// dataSource.value = [...dataSource.value]
})
}
//
const remove = async (node: Node, data: Tree) => {
await ElMessageBox.confirm('确定删除本章节吗?', '提示', {
const res = await getChaptersListApi(data.id)
console.log(res, 'delres')
ElMessageBox.confirm('确定删除本章节吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',

@ -1,23 +0,0 @@
<template>
<div>
<button @click="toggle">点击折叠/展开</button>
<div v-if="isExpanded">
<!-- 折叠内容 -->
</div>
</div>
</template>
<script setup>
export default {
data() {
return {
isExpanded: false,
}
},
methods: {
toggle() {
this.isExpanded = !this.isExpanded
},
},
}
</script>
Loading…
Cancel
Save