|
@@ -70,8 +70,8 @@
|
|
|
<div class="catalogue-edit-top">
|
|
|
<span class="title">编辑目录</span>
|
|
|
<div class="operation">
|
|
|
- <el-button class="cancel" @click="isEdit = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="isEdit = false">完成</el-button>
|
|
|
+ <el-button class="cancel" @click="cancel">取消</el-button>
|
|
|
+ <el-button type="primary" @click="complete">完成</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
@@ -80,7 +80,9 @@
|
|
|
<!-- 一级目录 -->
|
|
|
<div v-if="item.id === curEditNodeId" :key="item.id" class="nodes-edit">
|
|
|
<el-input v-model="item.name" placeholder="请输入标题" />
|
|
|
- <el-button type="primary" @click="confirmEditNode(item.id, '', 'false')">确定</el-button>
|
|
|
+ <el-button type="primary" class="confirm-edit" @click="confirmEditNode(item.id, '', 'false')">
|
|
|
+ 确定
|
|
|
+ </el-button>
|
|
|
<el-button @click="cancelEditNode(item.id)">取消</el-button>
|
|
|
</div>
|
|
|
<div v-else :key="item.id" class="nodes-item">
|
|
@@ -105,7 +107,11 @@
|
|
|
<template v-for="li in item.nodes">
|
|
|
<div v-if="li.id === curEditNodeId" :key="li.id" class="nodes-edit">
|
|
|
<el-input v-model="li.name" placeholder="请输入标题" />
|
|
|
- <el-button type="primary" @click="confirmEditNode(li.id, item.id, li.is_leaf_chapter)">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="confirm-edit"
|
|
|
+ @click="confirmEditNode(li.id, item.id, li.is_leaf_chapter)"
|
|
|
+ >
|
|
|
确定
|
|
|
</el-button>
|
|
|
<el-button @click="cancelEditNode(li.id)">取消</el-button>
|
|
@@ -144,7 +150,11 @@
|
|
|
<template v-for="child in li.nodes">
|
|
|
<div v-if="child.id === curEditNodeId" :key="child.id" class="nodes-edit">
|
|
|
<el-input v-model="child.name" placeholder="请输入标题" />
|
|
|
- <el-button type="primary" @click="confirmEditNode(child.id, li.id, child.is_leaf_chapter)">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ class="confirm-edit"
|
|
|
+ @click="confirmEditNode(child.id, li.id, child.is_leaf_chapter)"
|
|
|
+ >
|
|
|
确定
|
|
|
</el-button>
|
|
|
<el-button @click="cancelEditNode(child.id)">取消</el-button>
|
|
@@ -205,6 +215,7 @@ export default {
|
|
|
description: '',
|
|
|
},
|
|
|
nodes: [],
|
|
|
+ loading: false,
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -236,6 +247,7 @@ export default {
|
|
|
getBookChapterStruct() {
|
|
|
GetBookChapterStruct({ book_id: this.book_id, node_deep_mode: 0 }).then(({ nodes }) => {
|
|
|
this.nodes = nodes ?? [];
|
|
|
+ this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
/**
|
|
@@ -253,6 +265,10 @@ export default {
|
|
|
const name = nodes[position[position.length - 1]].name;
|
|
|
if (name.length <= 0) {
|
|
|
this.$message.error('请输入名称');
|
|
|
+ // 非编辑状态下删除临时节点
|
|
|
+ if (!this.isEdit) {
|
|
|
+ this.cancelEditNode(id);
|
|
|
+ }
|
|
|
return;
|
|
|
}
|
|
|
if (nodes[position[position.length - 1]]?.temporary) {
|
|
@@ -262,11 +278,15 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
addChapterToBook(name, parent_id, is_leaf) {
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
AddChapterToBook({ name, book_id: this.book_id, parent_id, is_leaf }).then(() => {
|
|
|
this.getBookChapterStruct();
|
|
|
});
|
|
|
},
|
|
|
updateChapter(id, name) {
|
|
|
+ if (this.loading) return;
|
|
|
+ this.loading = true;
|
|
|
UpdateChapter({ id, name }).then(() => {
|
|
|
this.getBookChapterStruct();
|
|
|
this.curEditNodeId = '';
|
|
@@ -386,6 +406,22 @@ export default {
|
|
|
}
|
|
|
this.curEditNodeId = '';
|
|
|
},
|
|
|
+ // 取消编辑
|
|
|
+ cancel() {
|
|
|
+ this.isEdit = false;
|
|
|
+ if (this.curEditNodeId) {
|
|
|
+ this.cancelEditNode(this.curEditNodeId);
|
|
|
+ this.getBookChapterStruct();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 完成编辑
|
|
|
+ complete() {
|
|
|
+ this.isEdit = false;
|
|
|
+ // 如果有正在编辑的节点,先保存
|
|
|
+ if (this.curEditNodeId) {
|
|
|
+ document.querySelector('.confirm-edit').click();
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -402,10 +438,13 @@ export default {
|
|
|
}
|
|
|
|
|
|
.setting {
|
|
|
- height: 100%;
|
|
|
+ min-height: 100%;
|
|
|
padding: 8px 24px;
|
|
|
|
|
|
.breadcrumb {
|
|
|
+ position: sticky;
|
|
|
+ top: 8px;
|
|
|
+ z-index: 1;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
font-size: 14px;
|
|
@@ -434,7 +473,7 @@ export default {
|
|
|
display: flex;
|
|
|
column-gap: 24px;
|
|
|
justify-content: center;
|
|
|
- height: calc(100% - 40px);
|
|
|
+ min-height: calc(100vh - 118px);
|
|
|
margin-top: 16px;
|
|
|
|
|
|
.basic-info {
|