Pārlūkot izejas kodu

1、进一步优化选择模板显示 2、删除章节可直接删除有子节点的章节

dsy 1 nedēļu atpakaļ
vecāks
revīzija
ae1ac49cde

+ 12 - 0
src/api/book.js

@@ -445,3 +445,15 @@ export function SetProjectMemberResourcePopedom(data) {
     data,
   );
 }
+
+/**
+ * @description 检查章节是否存在子节点
+ * @param {object} data
+ * @param {string} data.id - 章节ID
+ */
+export function CheckChapterIsExistChildNode(data) {
+  return http.post(
+    `${process.env.VUE_APP_EepServer}?MethodName=book_chapter_manager-CheckChapterIsExistChildNode`,
+    data,
+  );
+}

+ 5 - 0
src/components/PaginationPage.vue

@@ -4,6 +4,7 @@
     :current-page="cur_page"
     :page-sizes="[10, 20, 30, 40, 50]"
     :page-size="page_capacity"
+    :pager-count="pagerCount"
     layout="total, prev, pager, next, sizes, jumper"
     :total="total"
     @prev-click="changePage"
@@ -25,6 +26,10 @@ export default {
       type: Number,
       required: true,
     },
+    pagerCount: {
+      type: Number,
+      default: 7,
+    },
   },
   data() {
     return {

+ 16 - 4
src/views/personal_workbench/edit_task/edit/UseTemplate.vue

@@ -17,7 +17,7 @@
     </header>
 
     <div class="main-container">
-      <div v-loading="loading" class="template-list">
+      <div v-loading="loading" class="template-list" :style="computedTemplateStyles()">
         <div class="search">
           <el-input v-model="name" placeholder="请输入模板名称" @keyup.enter.native="searchTemplateList">
             <el-select slot="prepend" v-model="storage_type" style="width: 100px" @change="searchTemplateList">
@@ -28,7 +28,7 @@
         <el-table
           ref="templateList"
           :data="template_list"
-          height="540"
+          height="525"
           highlight-current-row
           @current-change="selectCourseware"
         >
@@ -40,7 +40,7 @@
           <el-table-column prop="id" label="编号" />
           <el-table-column prop="name" label="名称" />
         </el-table>
-        <PaginationPage ref="pagination" :total="total" @getList="getTemplateList" />
+        <PaginationPage ref="pagination" :total="total" :pager-count="5" @getList="getTemplateList" />
       </div>
 
       <div class="courseware-preview">
@@ -407,6 +407,17 @@ export default {
       if (this.curSelectId === nodeId) return;
       this.curSelectId = nodeId;
     },
+    /**
+     * 计算模板列表样式,根据分页器的页码数量动态调整宽度
+     * 380px 是基础宽度,40px 是每个页码占用的宽度
+     */
+    computedTemplateStyles() {
+      let count = document.querySelectorAll('.template-list .el-pagination ul.el-pager li')?.length || 0;
+
+      return {
+        width: `${380 + count * 40}px`,
+      };
+    },
   },
 };
 </script>
@@ -438,7 +449,7 @@ export default {
     }
 
     .template-list {
-      width: 460px;
+      width: 500px;
     }
 
     .courseware-preview {
@@ -450,6 +461,7 @@ export default {
         top: 0;
         left: 0;
         z-index: 9;
+        background-color: #fff;
 
         .courseware-name {
           margin: 2px 0 0 4px;

+ 10 - 1
src/views/personal_workbench/project/ProductionEditorialManage.vue

@@ -190,6 +190,7 @@ import {
   ChapterUpdateChapter,
   ChapterUpdateCoursewareName,
   ChapterMoveTreeNode,
+  CheckChapterIsExistChildNode,
 } from '@/api/book';
 import { isEnable } from '@/views/book/courseware/data/common';
 
@@ -365,8 +366,16 @@ export default {
           cancelButtonText: '取消',
           type: 'warning',
         });
+        const { is_exist_child_node } = await CheckChapterIsExistChildNode({ id });
+        if (is_exist_child_node === 'true') {
+          await this.$confirm('要删除的章节下有子节点,是否强制删除?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning',
+          });
+        }
 
-        await ChapterDeleteChapter({ id });
+        await ChapterDeleteChapter({ id, is_force: is_exist_child_node });
         this.getBookChapterStructExpandList();
         this.$message.success('删除成功');
       } catch (err) {