From 5aa93f37c751a7f2c30b8a7c6da809b2d4fe3de8 Mon Sep 17 00:00:00 2001
From: lijiaqi <1205620597@qq.com>
Date: Wed, 7 Aug 2024 18:33:45 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AF=A6=E6=83=85?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env.development | 4 +-
src/api/user/chapter.js | 4 ++
.../course/components/course-chapters.vue | 50 ++++++++++++-------
src/views/course/ss.vue | 23 ---------
4 files changed, 37 insertions(+), 44 deletions(-)
delete mode 100644 src/views/course/ss.vue
diff --git a/.env.development b/.env.development
index c8c89d1..600aee7 100644
--- a/.env.development
+++ b/.env.development
@@ -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'
diff --git a/src/api/user/chapter.js b/src/api/user/chapter.js
index 76b9ef7..eb8aa9e 100644
--- a/src/api/user/chapter.js
+++ b/src/api/user/chapter.js
@@ -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}`)
+}
diff --git a/src/views/course/components/course-chapters.vue b/src/views/course/components/course-chapters.vue
index 3b656de..3b65b9d 100644
--- a/src/views/course/components/course-chapters.vue
+++ b/src/views/course/components/course-chapters.vue
@@ -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',
diff --git a/src/views/course/ss.vue b/src/views/course/ss.vue
deleted file mode 100644
index 9a7c1f7..0000000
--- a/src/views/course/ss.vue
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-