From 0e6e54bd8177a0bf3f0e966e112d0597dea2ac8d Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 18 Dec 2024 15:47:31 +0800 Subject: [PATCH] fix --- src/assets/img/drag.svg | 1 + src/views/course/content/index.vue | 172 +++++++++++++++------------- src/views/course/content/source.vue | 46 +++++--- src/views/course/detail.vue | 39 +------ src/views/course/list.vue | 4 +- 5 files changed, 134 insertions(+), 128 deletions(-) create mode 100644 src/assets/img/drag.svg diff --git a/src/assets/img/drag.svg b/src/assets/img/drag.svg new file mode 100644 index 0000000..3fba973 --- /dev/null +++ b/src/assets/img/drag.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/course/content/index.vue b/src/views/course/content/index.vue index 9c18a0d..461f027 100644 --- a/src/views/course/content/index.vue +++ b/src/views/course/content/index.vue @@ -13,11 +13,17 @@ 新增章节
@@ -33,30 +39,36 @@
@@ -198,14 +210,12 @@ import Upload from '@/components/upload'; import Oss from '@/components/upload/upload.js' import Util from '@/libs/util' import Source from './source' - +import Draggable from 'vuedraggable' export default { + components: { Pdf, Upload, Source, Draggable }, data () { return { name: this.$route.query.name, - headers: { - token: sessionStorage.getItem('token') - }, id: this.$route.query.cid, originChapters: [], chapters: [], @@ -242,7 +252,7 @@ export default { player: null, previewImg: "", iframeSrc: "", - curFile: {}, + curSection: {}, isAddSection: false, isWord: false, isPPT: false, @@ -273,10 +283,9 @@ export default { sort: 'bottom' }, sourceVisible: false, - sections: [] + sections: [], }; }, - components: { Pdf, Upload, Source }, mounted () { this.insertScript(); this.id && this.getData(); @@ -449,6 +458,23 @@ export default { this.getData() }).catch(() => { }) }, + // 拖拽后回调 + async updateSort (e) { + e.preventDefault() + const { chapters, sections, chapterId } = this + chapters.forEach((n, k) => { + n.sort = k + 1 + if (n.id === chapterId) n.subsectionList = sections + n.subsectionList && n.subsectionList.forEach((j, i) => { + j.sort = i + 1 + j.chapterId = n.id + }) + }) + await this.$post(this.api.reorder, { + chapterVOList: chapters + }) + this.getData() + }, // 目标章节选择回调 chapterChange (id) { const list = [] @@ -536,6 +562,7 @@ export default { // 添加系统资源 showSource () { + this.curSection = {} this.sourceVisible = true }, addSection (id) { @@ -551,30 +578,26 @@ export default { let data = { cid: this.id, name: this.chapterName - }; + } if (this.chapterId) { data.id = this.chapterId; this.$put(this.api.editChapter, data).then(res => { - this.$message.success("修改成功"); - this.chapterVisible = false; - this.getData(); - }) - .catch(err => { - }); + this.$message.success("修改成功") + this.chapterVisible = false + this.getData() + }).catch(err => { }) } else { this.$post(this.api.addChapter, data).then(res => { - this.$message.success("添加成功"); - this.chapterVisible = false; - this.getData(); - }) - .catch(err => { - }); + this.$message.success("添加成功") + this.chapterVisible = false + this.getData() + }).catch(err => { }) } }, sectionSubmit (e) { - if (!this.sectionForm.sectionName) return this.$message.warning("请填写小节名称"); - if (this.uploading) return this.$message.warning("资源正在上传中,请稍候"); - if (!this.fileUrl && !this.fileId) return this.$message.warning("请上传资源"); + if (!this.sectionForm.sectionName) return this.$message.warning("请填写小节名称") + if (this.uploading) return this.$message.warning("资源正在上传中,请稍候") + if (!this.fileUrl && !this.fileId) return this.$message.warning("请上传资源") let data = { id: this.sectionId, cid: this.id, @@ -585,21 +608,19 @@ export default { fileName: this.fileName, fileType: this.fileType, originalFileName: this.originalFileName - }; + } this.$post(this.api.addSubsection, data).then(res => { - this.$message.success("添加成功"); - this.sectionVisible = false; - this.getData(); - }) - .catch(err => { - }) + this.$message.success("添加成功") + this.sectionVisible = false + this.getData() + }).catch(err => { }) }, closeSwitch () { - this.fileId = ""; - this.fileName = ""; - this.fileType = ""; - this.fileUrl = ""; - this.sectionId = ""; + this.fileId = '' + this.fileName = '' + this.fileType = '' + this.fileUrl = '' + this.sectionId = '' this.progressPercent = 0 }, // 下载资源 @@ -685,22 +706,14 @@ export default { } }, editSectionName (row) { - this.sectionId = row.id; - this.sectionForm.sectionName = row.name; - this.sectionNameVisible = true; + this.sectionId = row.id + this.sectionForm.sectionName = row.name + this.sectionNameVisible = true }, switchFile (row) { - this.uploadList = [] - this.curFile = { - fileId: row.fileId, - fileName: row.fileName, - fileType: row.fileType, - fileUrl: row.fileUrl - } + this.curSection = row this.sectionId = row.id - this.sectionForm.sectionName = row.sectionName - - this.switchVisible = true; + this.sourceVisible = true }, switchSubmitFile () { let data = { @@ -977,6 +990,11 @@ export default { background-color: #f9f9f9; } + .drag { + margin-right: 10px; + cursor: move; + } + .section-left, .section-right { display: inline-flex; diff --git a/src/views/course/content/source.vue b/src/views/course/content/source.vue index ab33339..b130410 100644 --- a/src/views/course/content/source.vue +++ b/src/views/course/content/source.vue @@ -54,6 +54,10 @@
+
+

原资源(共1个)

+
+