|
|
@@ -14,9 +14,9 @@
|
|
|
</div>
|
|
|
<span class="link" @click="visibleAuditSteps = true">设置审校步骤</span>
|
|
|
<div class="operator flex">
|
|
|
- <span class="link" @click="openBookUnifiedAttrib">教材样式设置</span>
|
|
|
- <span class="link" @click="addChapterDialog">添加章节节点</span>
|
|
|
- <span class="link" @click="addCoursewareDialog">添加教材内容节点</span>
|
|
|
+ <span class="link" @click="openBookUnifiedAttrib()">教材样式设置</span>
|
|
|
+ <span class="link" @click="addChapterDialog()">添加章节节点</span>
|
|
|
+ <span class="link" @click="addCoursewareDialog()">添加教材内容节点</span>
|
|
|
<span class="link" @click="$router.push({ path: `/personal_workbench/project` })">返回项目列表</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -52,11 +52,22 @@
|
|
|
@click="selectActiveChapter(id, is_leaf_chapter === 'true')"
|
|
|
>
|
|
|
<div
|
|
|
- :class="['chapter-title', 'nowrap-ellipsis', { courseware: isEnable(is_leaf_chapter) }]"
|
|
|
+ :class="['chapter-title', { courseware: isEnable(is_leaf_chapter) }]"
|
|
|
:style="computedNameStyle(deep)"
|
|
|
:title="name"
|
|
|
>
|
|
|
- {{ name }}
|
|
|
+ <span class="nowrap-ellipsis">{{ name }}</span>
|
|
|
+ <el-dropdown v-if="!isEnable(is_leaf_chapter)" trigger="click">
|
|
|
+ <span class="el-dropdown-link" style="cursor: pointer"><i class="el-icon-plus"></i> </span>
|
|
|
+ <el-dropdown-menu slot="dropdown">
|
|
|
+ <el-dropdown-item>
|
|
|
+ <span @click="addCoursewareDialog(id)">添加教材内容</span>
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item>
|
|
|
+ <span @click="addChapterDialog(id)">添加章节</span>
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </el-dropdown>
|
|
|
</div>
|
|
|
<div
|
|
|
class="producer nowrap-ellipsis"
|
|
|
@@ -75,18 +86,13 @@
|
|
|
<div class="status">{{ status_name }}</div>
|
|
|
<div class="operator">
|
|
|
<template v-if="isEnable(is_leaf_chapter)">
|
|
|
- <span
|
|
|
- v-if="i > 0 && node_list[i - 1].is_leaf_chapter === 'true'"
|
|
|
- class="link"
|
|
|
- @click="moveChapterTreeNode(i, 0)"
|
|
|
- >
|
|
|
- 上移
|
|
|
- </span>
|
|
|
- <span
|
|
|
- v-if="i < node_list.length - 1 && node_list[i + 1].is_leaf_chapter === 'true'"
|
|
|
- class="link"
|
|
|
- @click="moveChapterTreeNode(i, 1)"
|
|
|
- >
|
|
|
+ <span v-if="i > 0 && computedIsFirst(i)" class="link" @click="moveChapterTreeNode(i, 0)">上移</span>
|
|
|
+ <span v-if="i < node_list.length - 1" class="link" @click="moveChapterTreeNode(i, 1)">下移</span>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-else>
|
|
|
+ <span v-if="i > 1" class="link" @click="moveChapterNode(i, deep, 0)">上移</span>
|
|
|
+ <span v-if="i > 0 && computedIsLast(id, deep)" class="link" @click="moveChapterNode(i, deep, 1)">
|
|
|
下移
|
|
|
</span>
|
|
|
</template>
|
|
|
@@ -287,11 +293,25 @@ export default {
|
|
|
openBookUnifiedAttrib() {
|
|
|
this.visibleAttr = true;
|
|
|
},
|
|
|
- addChapterDialog() {
|
|
|
+ /**
|
|
|
+ * 打开添加章节对话框
|
|
|
+ * @param {string} curId - 当前选中章节ID
|
|
|
+ */
|
|
|
+ addChapterDialog(curId) {
|
|
|
+ if (curId) {
|
|
|
+ this.curSelectId = curId;
|
|
|
+ }
|
|
|
this.visible = true;
|
|
|
this.addType = 'chapter';
|
|
|
},
|
|
|
- addCoursewareDialog() {
|
|
|
+ /**
|
|
|
+ * 打开添加课件对话框
|
|
|
+ * @param {string} curId - 当前选中章节ID
|
|
|
+ */
|
|
|
+ addCoursewareDialog(curId) {
|
|
|
+ if (curId) {
|
|
|
+ this.curSelectId = curId;
|
|
|
+ }
|
|
|
this.visible = true;
|
|
|
this.addType = 'courseware';
|
|
|
},
|
|
|
@@ -402,13 +422,74 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
|
+ * 计算是否为第一个教材内容节点
|
|
|
+ * @param {number} i - 当前节点索引
|
|
|
+ */
|
|
|
+ computedIsFirst(i) {
|
|
|
+ const index = this.node_list.findIndex((node) => node.is_leaf_chapter === 'true');
|
|
|
+ return i !== index;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 计算是否为同深度最后一个节点
|
|
|
+ * @param {string} id - 章节ID
|
|
|
+ * @param {number} deep - 节点深度
|
|
|
+ * @returns {boolean} - 是否为最后一个节点
|
|
|
+ */
|
|
|
+ computedIsLast(id, deep) {
|
|
|
+ const index = this.node_list.findIndex((node) => node.id === id);
|
|
|
+ for (let i = index + 1; i < this.node_list.length; i++) {
|
|
|
+ if (this.node_list[i].deep === deep) {
|
|
|
+ return true;
|
|
|
+ } else if (this.node_list[i].deep < deep) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 章节节点上移下移
|
|
|
* @param {number} i - 当前节点索引
|
|
|
* @param {number} dest_position - 目标位置 0上移 1下移
|
|
|
*/
|
|
|
moveChapterTreeNode(i, dest_position) {
|
|
|
const id = this.node_list[i].id;
|
|
|
- const dest_id = this.node_list[dest_position === 0 ? i - 1 : i + 1].id;
|
|
|
+ const is_leaf_chapter = this.node_list[dest_position === 0 ? i - 1 : i + 1].is_leaf_chapter === 'false';
|
|
|
+ const deep = is_leaf_chapter ? 2 : 1;
|
|
|
+ const num = dest_position === 0 ? i - deep : i + deep;
|
|
|
+ const dest_id = this.node_list[num].id;
|
|
|
+
|
|
|
+ ChapterMoveTreeNode({ id, dest_id, dest_position }).then(() => {
|
|
|
+ this.getBookChapterStructExpandList();
|
|
|
+ this.$message.success('章节移动成功');
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 同深度章节节点上移下移
|
|
|
+ * @param {number} i - 当前节点索引
|
|
|
+ * @param {number} deep - 节点深度
|
|
|
+ * @param {number} dest_position - 目标位置 0上移 1下移
|
|
|
+ */
|
|
|
+ moveChapterNode(i, deep, dest_position) {
|
|
|
+ const id = this.node_list[i].id;
|
|
|
+ let num = -1;
|
|
|
+ if (dest_position === 0) {
|
|
|
+ for (let j = i - 1; j >= 0; j--) {
|
|
|
+ if (this.node_list[j].deep === deep) {
|
|
|
+ num = j;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ for (let j = i + 1; j < this.node_list.length; j++) {
|
|
|
+ if (this.node_list[j].deep === deep) {
|
|
|
+ num = j;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (num === -1) return;
|
|
|
+ const dest_id = this.node_list[num].id;
|
|
|
+
|
|
|
ChapterMoveTreeNode({ id, dest_id, dest_position }).then(() => {
|
|
|
this.getBookChapterStructExpandList();
|
|
|
this.$message.success('章节移动成功');
|
|
|
@@ -514,6 +595,9 @@ export default {
|
|
|
}
|
|
|
|
|
|
.chapter-title {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
font-weight: bold;
|
|
|
color: #000;
|
|
|
}
|