Browse Source

模板预览

natasha 2 months ago
parent
commit
80a2e5db99

+ 5 - 0
src/api/template.js

@@ -40,4 +40,9 @@ export function UpdateTemplateUseScope (data) {
 // 更改模板状态
 export function UpdateTemplateStatus (data) {
   return http.post(`${process.env.VUE_APP_EepServer}?MethodName=template_manager-UpdateTemplateStatus`, data);
+}
+
+// 得到模板信息
+export function GetTemplateInfo (data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=template_manager-GetTemplateInfo`, data);
 }

+ 9 - 0
src/router/modules/project.js

@@ -117,6 +117,15 @@ const personalWorkPage = {
       },
       component: () => import('@/views/personal_workbench/template_list_manager/index.vue'),
     },
+    // 模板预览
+    {
+      path: 'personal_workbench/template_list/preview/:id',
+      name: 'PersonalWorkbenchTemplatePreview',
+      meta: {
+        title: '模板预览',
+      },
+      component: () => import('@/views/personal_workbench/template_list/preview/index.vue'),
+    },
   ],
 };
 

+ 8 - 2
src/views/personal_workbench/template_list/index.vue

@@ -85,7 +85,7 @@ import MenuPage from '../common/menu.vue';
 import PaginationPage from '@/components/PaginationPage.vue';
 
 import { PageQueryTemplateListPersonal } from '@/api/list.js';
-import { CreateTemplatePersonal, UpdateTemplateShareStatus, DeleteTemplate } from '@/api/template';
+import { CreateTemplatePersonal, UpdateTemplateShareStatus, DeleteTemplate, GetTemplateInfo } from '@/api/template';
 
 export default {
   name: 'PersonalWorkbenchTemplate',
@@ -188,7 +188,13 @@ export default {
         });
     },
     // 预览模板
-    previewTemplate(row) {},
+    previewTemplate(row) {
+      if (!row.id) return;
+      this.$router.push({
+        path: `/personal_workbench/template_list/preview/${row.id}`,
+        query: { type: 'personal' },
+      });
+    },
     //共享/取消共享模板
     shareTemplate(row) {
       UpdateTemplateShareStatus({ share_status: row.share_status === 0 ? 1 : 0, id: row.id }).then((res) => {

+ 705 - 0
src/views/personal_workbench/template_list/preview/CommonPreview.vue

@@ -0,0 +1,705 @@
+<template>
+  <div class="common-preview">
+    <div class="common-preview__header">
+      <div class="menu-container">
+        {{ courseware_info.book_name }}
+      </div>
+      <div class="courseware">
+        <span class="name-path">{{ courseware_info.name_path }}</span>
+        <span class="flow-nodename">{{ courseware_info.cur_audit_flow_node_name }}</span>
+        <slot name="middle" :courseware="courseware_info"></slot>
+
+        <div class="operator">
+          <span class="link" @click="editTask">开始编辑</span>
+
+          <span class="link" @click="goBackTemplateList">返回模板列表</span>
+        </div>
+      </div>
+    </div>
+    <div class="audit-content">
+      <div ref="previewMain" class="main-container" :style="{ paddingLeft: '0', paddingRight: '0' }">
+        <main :class="['preview-main', { 'no-audit': !isShowAudit }]">
+          <div class="preview-left"></div>
+          <CoursewarePreview
+            v-if="courseware_info.book_name"
+            ref="courserware"
+            :is-show-group="false"
+            :group-show-all="true"
+            :group-row-list="content_group_row_list"
+            :data="data"
+            :courseware-id="curSelectId"
+            :component-list="component_list"
+            :background="background"
+            :can-remark="isTrue(courseware_info.is_my_audit_task) && isTrue(courseware_info.is_can_add_audit_remark)"
+            :show-remark="isShowAudit"
+            :component-remark-obj="{}"
+            :project="project"
+          />
+          <div class="preview-right"></div>
+        </main>
+      </div>
+      <div v-if="!sidebarShow" class="back-top" @click="backTop">
+        <img :src="require(`@/assets/icon/back-top.png`)" alt="返回顶部" />
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import CoursewarePreview from '@/views/book/courseware/preview/CoursewarePreview.vue';
+import { isTrue } from '@/utils/validate';
+
+import { GetBookCoursewareInfo } from '@/api/project';
+import { ContentGetCoursewareContent_View } from '@/api/book';
+
+export default {
+  name: 'CommonPreview',
+  components: {
+    CoursewarePreview,
+  },
+  provide() {
+    return {
+      getLang: () => this.lang,
+      getChinese: () => this.chinese,
+      getLangList: () => this.langList,
+      convertText: this.convertText,
+    };
+  },
+  props: {
+    id: {
+      type: String,
+      default: '',
+    },
+
+    isShowAudit: {
+      type: Boolean,
+      default: true,
+    },
+    isBook: {
+      type: Boolean,
+      default: false,
+    },
+  },
+  data() {
+    return {
+      select_node: this.id,
+      courseware_info: {
+        book_name: '',
+        is_can_start_edit: 'false',
+        is_can_submit_audit: 'false',
+        is_can_audit_pass: 'false',
+        is_can_audit_reject: 'false',
+        is_can_add_audit_remark: 'false',
+        is_can_finish_audit: 'false',
+        is_can_request_shangjia_book: 'false',
+        is_can_request_rollback_project: 'false',
+        is_can_shangjia_book: 'false',
+        is_can_rollback_project: 'false',
+      },
+      background: {
+        background_image_url: '',
+        background_position: {
+          left: 0,
+          top: 0,
+        },
+      },
+      node_list: [],
+      data: { row_list: [] },
+      component_list: [],
+      content_group_row_list: [],
+      type: this.$route.query.type,
+      curSelectId: this.id,
+      isTrue,
+      sidebarShow: true,
+      project: {
+        editor: '', // 作者
+        cover_image_file_id: null, // 封面图片ID
+        cover_image_file_url: '', // 封面图片URL
+      },
+    };
+  },
+  computed: {},
+  watch: {},
+  created() {
+    if (this.id) {
+      this.getBookCoursewareInfo(this.id);
+      this.getCoursewareComponentContent_View(this.id);
+    } else {
+      this.isBook ? this.getBookBaseInfo() : this.getProjectBaseInfo();
+    }
+    if (!this.isBook) {
+      this.getProjectInfo();
+    }
+  },
+  mounted() {},
+  methods: {
+    getProjectBaseInfo() {},
+
+    getBookBaseInfo() {},
+
+    getProjectInfo() {},
+
+    /**
+     * 得到教材课件信息
+     * @param {string} id - 课件ID
+     */
+    getBookCoursewareInfo(id) {
+      GetBookCoursewareInfo({ id, is_contain_producer: 'true', is_contain_auditor: 'true' }).then(
+        ({ courseware_info }) => {
+          this.courseware_info = { ...this.courseware_info, ...courseware_info };
+        },
+      );
+    },
+    /**
+     * 得到课件内容(展示内容)
+     * @param {string} id - 课件ID
+     */
+    getCoursewareComponentContent_View(id) {
+      ContentGetCoursewareContent_View({ id }).then(({ content, component_list, content_group_row_list }) => {
+        if (content) {
+          const _content = JSON.parse(content);
+          this.data = _content;
+          this.background = {
+            background_image_url: _content.background_image_url,
+            background_position: _content.background_position,
+          };
+        } else {
+          this.data = { row_list: [] };
+        }
+
+        if (component_list) this.component_list = component_list;
+        if (content_group_row_list) this.content_group_row_list = JSON.parse(content_group_row_list) || [];
+      });
+    },
+
+    backTop() {
+      this.$refs.previewMain.scrollTo({
+        top: 0,
+        left: 0,
+        behavior: 'smooth',
+      });
+    },
+
+    goBackTemplateList() {
+      if (this.type === 'personal') {
+        this.$router.push({ path: '/personal_workbench/template_list' });
+      } else if (this.type === 'org') {
+        this.$router.push({ path: '/personal_workbench/template_list_org' });
+      } else {
+        this.$router.push({ path: '/personal_workbench/template_list_manager' });
+      }
+    },
+    editTask() {
+      this.$router.push({
+        path: `/personal_workbench/edit_task/edit/${this.id}`,
+        query: { type: this.type },
+      });
+    },
+    convertText(text) {
+      return text;
+    },
+  },
+};
+</script>
+
+<style lang="scss" scoped>
+@use '@/styles/mixin.scss' as *;
+
+$total-width: $courseware-width + $courseware-left-margin + $courseware-right-margin;
+
+.common-preview {
+  &__header {
+    position: sticky;
+    top: 56px;
+    left: 0;
+    z-index: 9;
+    display: flex;
+    align-items: center;
+    height: 40px;
+    padding: 6px 4px;
+    margin-bottom: 5px;
+    background-color: #fff;
+    border-top: $border;
+    border-bottom: $border;
+
+    > .menu-container {
+      display: flex;
+      justify-content: space-between;
+      width: 360px;
+      padding: 4px 8px;
+      border-right: $border;
+    }
+
+    > .courseware {
+      display: flex;
+      flex-grow: 1;
+      column-gap: 16px;
+      align-items: center;
+      justify-content: space-between;
+      height: 40px;
+
+      .name-path {
+        min-width: 200px;
+        height: 40px;
+        padding: 4px 8px;
+        font-size: 14px;
+        line-height: 32px;
+        border-right: $border;
+      }
+
+      .lang-select {
+        :deep .el-input {
+          width: 100px;
+        }
+
+        :deep .el-input__inner {
+          height: 24px;
+          line-height: 24px;
+          background-color: #fff;
+        }
+
+        :deep .el-input__icon {
+          line-height: 24px;
+        }
+      }
+
+      .flow-nodename {
+        flex: 1;
+      }
+
+      .group {
+        display: flex;
+        align-items: center;
+      }
+
+      .operator {
+        display: flex;
+        column-gap: 8px;
+        align-items: center;
+
+        .link {
+          + .link {
+            margin-left: 0;
+
+            &::before {
+              margin-right: 8px;
+              color: #999;
+              content: '|';
+            }
+          }
+        }
+      }
+    }
+  }
+
+  .main-container {
+    position: relative;
+    flex: 1;
+    min-width: 1110px;
+    padding: 15px 0;
+    overflow: auto;
+    background-color: #ececec;
+
+    .catalogue-bar {
+      position: absolute;
+      top: 15px;
+      left: 0;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      width: 54px;
+      height: 54px;
+      margin: -9px 6px 0 240px;
+      cursor: pointer;
+      background-color: #fff;
+      border-radius: 2px;
+      box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
+    }
+
+    .sidebar-bar {
+      position: absolute;
+      top: 0;
+      right: 240px;
+      display: flex;
+      width: 60px;
+      height: calc(100vh - 166px);
+
+      .toolbar {
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+        width: 60px;
+        height: 100%;
+
+        img {
+          cursor: pointer;
+        }
+
+        &-special {
+          display: flex;
+          flex-direction: column;
+          row-gap: 16px;
+          align-items: center;
+          width: 100%;
+          margin-bottom: 24px;
+          background-color: #fff;
+
+          img {
+            width: 36px;
+            height: 36px;
+          }
+        }
+      }
+    }
+  }
+
+  .back-top {
+    position: absolute;
+    right: 240px;
+    bottom: 0;
+    display: flex;
+    place-content: center center;
+    align-items: center;
+    width: 60px;
+    height: 60px;
+    cursor: pointer;
+    background-color: #fff;
+  }
+
+  main.preview-main {
+    display: flex;
+    flex: 1;
+    width: calc($total-width);
+    min-width: calc($total-width);
+    max-width: calc($total-width);
+    min-height: 100%;
+    margin: 0 auto;
+    background-color: #fff;
+    border-radius: 4px;
+    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 40%);
+
+    .preview-left {
+      width: $courseware-left-margin;
+      min-width: $courseware-left-margin;
+      max-width: $courseware-left-margin;
+      background-color: $courseware-bgColor;
+    }
+
+    .preview-right {
+      width: $courseware-right-margin;
+      min-width: $courseware-right-margin;
+      max-width: $courseware-right-margin;
+      background-color: $courseware-bgColor;
+    }
+
+    &.no-audit {
+      margin: 0 auto;
+    }
+  }
+
+  .audit-content {
+    display: flex;
+    min-width: 1810px;
+    height: calc(100vh - 166px);
+
+    .left-menu {
+      display: flex;
+      flex-direction: column;
+      width: $catalogue-width;
+      font-family: 'Microsoft YaHei', 'Arial', sans-serif;
+      background-color: #fff;
+
+      .courseware-info {
+        display: flex;
+        column-gap: 18px;
+        width: 100%;
+        height: 186px;
+        padding: 6px 6px 24px;
+        border-bottom: $border;
+
+        .cover-image {
+          display: flex;
+          align-items: center;
+          justify-content: center;
+          width: 111px;
+          height: 157px;
+          background-color: rgba(229, 229, 229, 100%);
+
+          img {
+            max-width: 111px;
+            max-height: 157px;
+          }
+        }
+
+        .info-content {
+          display: flex;
+          flex-direction: column;
+          justify-content: space-between;
+
+          .catalogue-icon {
+            text-align: right;
+
+            .svg-icon {
+              cursor: pointer;
+            }
+          }
+
+          .courseware {
+            width: 159px;
+            height: 64px;
+            font-size: 16px;
+
+            .name {
+              font-weight: bold;
+            }
+
+            .editor {
+              display: -webkit-box;
+              overflow: hidden;
+              text-overflow: ellipsis;
+              word-break: break-word;
+              white-space: normal;
+              -webkit-line-clamp: 2; /* 多行省略行数,按需调整 */
+              -webkit-box-orient: vertical;
+            }
+          }
+        }
+      }
+
+      .courseware-tree {
+        display: flex;
+        flex: 1;
+        flex-direction: column;
+        row-gap: 8px;
+        padding: 12px;
+        margin-top: 12px;
+        overflow: auto;
+
+        .menu-item {
+          display: flex;
+          align-items: center;
+
+          &:not(.courseware) {
+            font-weight: bold;
+          }
+
+          &.courseware {
+            &:hover {
+              .name {
+                background-color: #f3f3f3;
+              }
+            }
+          }
+
+          .svg-icon {
+            margin-left: 4px;
+
+            &.my-edit-task {
+              color: $right-color;
+            }
+          }
+
+          .name {
+            flex: 1;
+            padding: 4px 8px 4px 4px;
+            border-radius: 4px;
+          }
+
+          &.active {
+            .name {
+              font-weight: bold;
+              color: #4095e5;
+            }
+          }
+        }
+      }
+    }
+
+    .sidebar {
+      position: relative;
+      display: flex;
+      width: $sidebar-width;
+
+      .toolbar {
+        display: flex;
+        flex-direction: column;
+        align-items: center;
+        width: 60px;
+        height: 100%;
+        background-color: rgba(247, 248, 250, 100%);
+
+        img {
+          cursor: pointer;
+        }
+
+        &-special {
+          display: flex;
+          flex-direction: column;
+          row-gap: 16px;
+          margin-bottom: 24px;
+        }
+
+        &-list {
+          display: flex;
+          flex-direction: column;
+          row-gap: 16px;
+          align-items: center;
+          width: 100%;
+
+          .sidebar-item {
+            width: 100%;
+            text-align: center;
+
+            .sidebar-icon {
+              width: 36px;
+              height: 36px;
+              cursor: pointer;
+            }
+
+            &.active {
+              background-color: #4095e5;
+            }
+          }
+        }
+      }
+
+      .content {
+        flex: 1;
+        background-color: #fff;
+
+        .resource_box {
+          height: 100%;
+          overflow-y: auto;
+          border: 1px solid #e5e5e5;
+
+          h5 {
+            position: fixed;
+            z-index: 999;
+            width: 240px;
+            padding: 0 5px;
+            margin: 0;
+            font-size: 18px;
+            line-height: 40px;
+            background: #f2f3f5;
+          }
+
+          .scroll-container {
+            display: flex;
+            flex-direction: column;
+            row-gap: 8px;
+            margin: 6px;
+
+            .list-item {
+              display: flex;
+              align-items: center;
+              cursor: pointer;
+              border: 1px solid #ccc;
+              border-radius: 8px;
+
+              :deep .el-slider {
+                .el-slider__runway {
+                  background-color: #eee;
+                }
+              }
+
+              .el-image {
+                display: flex;
+                width: 100%;
+                min-width: 100%;
+                height: 90px;
+                background-color: #ccc;
+                border-radius: 8px;
+              }
+
+              .video-play {
+                width: 100%;
+                min-width: 100%;
+              }
+
+              .text-box {
+                word-break: break-word;
+              }
+            }
+          }
+
+          p {
+            color: #999;
+            text-align: center;
+          }
+
+          .card-box li {
+            padding: 10px;
+            border-bottom: 1px solid #ccc;
+
+            .el-icon-notebook-2 {
+              display: block;
+              margin-bottom: 4px;
+              font-size: 12px;
+              color: grey;
+            }
+          }
+        }
+      }
+
+      .back-top {
+        position: absolute;
+        bottom: 0;
+        left: 0;
+        display: flex;
+        place-content: center center;
+        align-items: center;
+        width: 60px;
+        height: 60px;
+        cursor: pointer;
+      }
+    }
+  }
+}
+
+:deep .scroll-container .audio-wrapper {
+  width: 100% !important;
+
+  .audio-middle {
+    width: 100% !important;
+    padding: 6px 8px !important;
+    border: none;
+    border-radius: 8px;
+
+    .audio-name {
+      text-align: left;
+    }
+
+    .slider-area {
+      column-gap: 8px !important;
+    }
+
+    :deep .remark-dialog {
+      .el-dialog__body {
+        padding: 5px 20px;
+      }
+    }
+
+    :deep .audit-dialog {
+      .el-dialog__body {
+        height: calc(100vh - 260px);
+        padding: 5px 20px;
+      }
+
+      .mind-map-container .mind-map {
+        height: calc(100vh - 310px);
+      }
+    }
+  }
+}
+
+.mt10 {
+  margin: 10px 0 0 !important;
+  background-color: #eee;
+}
+</style>
+
+<style lang="scss">
+.tox-tinymce-aux {
+  z-index: 9999 !important;
+}
+</style>

+ 34 - 0
src/views/personal_workbench/template_list/preview/index.vue

@@ -0,0 +1,34 @@
+<template>
+  <div class="task-preview">
+    <MenuPage only-key="/personal_workbench/template_list" />
+
+    <CommonPreview :id="id" ref="preview"> </CommonPreview>
+  </div>
+</template>
+
+<script>
+import MenuPage from '@/views/personal_workbench/common/menu.vue';
+import CommonPreview from './CommonPreview.vue';
+
+export default {
+  name: 'PersonalWorkbenchTemplatePreview',
+  components: {
+    MenuPage,
+    CommonPreview,
+  },
+  data() {
+    return {
+      id: this.$route.params.id,
+    };
+  },
+  methods: {},
+};
+</script>
+
+<style lang="scss" scoped>
+@use '@/styles/mixin.scss' as *;
+
+.task-preview {
+  @include page-content(true);
+}
+</style>

+ 8 - 4
src/views/personal_workbench/template_list_manager/index.vue

@@ -53,9 +53,7 @@
             <span class="link" @click="changeStatusTemplate(row, 1)" v-if="row.status === 0 || row.status === 3">{{
               '申请发布'
             }}</span>
-            <span class="link" @click="changeStatusTemplate(row, 2)" v-if="row.status === 1 || row.status === 3">{{
-              '发布'
-            }}</span>
+            <span class="link" @click="changeStatusTemplate(row, 2)" v-if="row.status === 1">{{ '发布' }}</span>
             <span class="link" @click="changeStatusTemplate(row, 4)" v-if="row.status === 1">{{ '驳回' }}</span>
             <span class="link" @click="changeStatusTemplate(row, 3)" v-if="row.status === 2">{{ '取消发布' }}</span>
             <span class="link" @click="changeStatusTemplate(row, 1)" v-if="row.status === 4">{{ '撤销驳回' }}</span>
@@ -142,7 +140,13 @@ export default {
       this.queryTemplateList({ cur_page: 1, page_capacity: this.form.page_capacity });
     },
     // 预览模板
-    previewTemplate(row) {},
+    previewTemplate(row) {
+      if (!row.id) return;
+      this.$router.push({
+        path: `/personal_workbench/template_list/preview/${row.id}`,
+        query: { type: 'manager' },
+      });
+    },
     // 更改模板状态
     changeStatusTemplate(row, status) {
       UpdateTemplateStatus({ status: status, id: row.id }).then((res) => {

+ 7 - 1
src/views/personal_workbench/template_list_org/index.vue

@@ -179,7 +179,13 @@ export default {
         });
     },
     // 预览模板
-    previewTemplate(row) {},
+    previewTemplate(row) {
+      if (!row.id) return;
+      this.$router.push({
+        path: `/personal_workbench/template_list/preview/${row.id}`,
+        query: { type: 'org' },
+      });
+    },
     //更改模板状态
     changeStatusTemplate(row) {
       let status = null;