Browse Source

Merge branch 'master' of http://gcls-git.helxsoft.cn/GCLS/eep_page

dusenyao 1 ngày trước cách đây
mục cha
commit
fe350cb160

+ 8 - 8
src/components/MindMap.vue

@@ -1,16 +1,16 @@
 <template>
   <div class="mind-map-container">
-    <div v-if="isEdit" class="toolbar">
-      <button @click="addParentNode">添加父节点</button>
-      <button @click="addNode">添加节点</button>
-      <button @click="addChildNode">添加子节点</button>
-      <button @click="removeNode">删除节点</button>
-      <button @click="forward">前进</button>
-      <button @click="back">回退</button>
+    <div class="toolbar">
+      <button v-if="isEdit" @click="addParentNode">添加父节点</button>
+      <button v-if="isEdit" @click="addNode">添加节点</button>
+      <button v-if="isEdit" @click="addChildNode">添加子节点</button>
+      <button v-if="isEdit" @click="removeNode">删除节点</button>
+      <button v-if="isEdit" @click="forward">前进</button>
+      <button v-if="isEdit" @click="back">回退</button>
       <button @click="zoomIn">放大</button>
       <button @click="zoomOut">缩小</button>
       <button @click="resetZoom">重置缩放</button>
-      <button @click="exportToPNG">导出PNG</button>
+      <button v-if="isEdit" @click="exportToPNG">导出PNG</button>
       <!-- <button @click="exportToSvg">导出SVG</button> -->
       <!-- <button @click="exportToJson">导出JSON</button> -->
       <!-- <button @click="importFromJson">导入JSON</button> -->

+ 1 - 2
src/utils/http.js

@@ -82,10 +82,9 @@ service.interceptors.response.use(
  * */
 function getRequestParams() {
   const token = getToken();
-
   return {
     AccessToken: token?.access_token ?? '',
-    UserCode: token?.gcls_sys_session_info?.user_code ?? '',
+    UserCode: token?.gcls_sys_session_info?.user_id ?? '',
     UserType: token?.gcls_sys_session_info?.user_type ?? '',
     SessionID: token?.gcls_sys_session_info?.session_id ?? '',
   };

+ 62 - 15
src/views/book/courseware/create/components/base/common/SelectResource.vue

@@ -25,10 +25,7 @@
         v-for="(item, index) in list"
         :key="index"
         class="sources-item"
-        :class="[
-          select_sources_id === item.id ? 'active' : '',
-          type_index === 5 ? 'sources-item-txt' : type_index === 3 ? 'sources-item-zip' : '',
-        ]"
+        :class="[select_sources_id === item.id ? 'active' : '', type_index === 5 ? 'sources-item-txt' : '']"
         @click="selectSourceNode(item)"
       >
         <template v-if="type_index === 0"> <el-image :src="item.file_url" fit="contain" /></template>
@@ -42,10 +39,17 @@
           />
         </template>
         <template v-else-if="type_index === 2">
-          <video controls :src="item.file_url" width="100%" height="140px"></video>
+          <video
+            class="sources-item-border"
+            :src="item.file_url"
+            width="100%"
+            height="140px"
+            :poster="item.video_preview_image_file_url"
+            preload="none"
+          ></video>
         </template>
         <template v-else-if="type_index === 3">
-          <iframe class="sources-item-border" :src="item.new_path" width="100%" height="300px" frameborder="0"></iframe>
+          <!-- <iframe class="sources-item-border" :src="item.new_path" width="100%" height="300px" frameborder="0"></iframe> -->
         </template>
         <template v-else-if="type_index === 4"> </template>
         <template v-else-if="type_index === 5">
@@ -62,7 +66,15 @@
           </div>
           <template #reference>
             <div class="sources-info">
-              <p class="name">{{ item.name }}</p>
+              <p class="name">
+                {{ item.name
+                }}<SvgIcon
+                  v-show="item.file_id && (type_index === 3 || type_index === 2)"
+                  icon-class="uploadPreview"
+                  size="16"
+                  @click="viewDialog(item)"
+                />
+              </p>
               <b class="label">{{ item.label }}</b>
             </div>
           </template>
@@ -75,21 +87,37 @@
       <el-button @click="dialogClose">取消</el-button>
       <el-button type="primary" @click="confirmSelect">选择</el-button>
     </div>
+    <el-dialog
+      v-if="visible_flag"
+      :visible.sync="visible_flag"
+      :show-close="true"
+      :close-on-click-modal="true"
+      :modal-append-to-body="true"
+      :append-to-body="true"
+      :lock-scroll="true"
+      width="80%"
+      top="0"
+    >
+      <iframe v-if="visible_flag" :src="newpath" width="100%" :height="iframeHeight" frameborder="0"></iframe>
+    </el-dialog>
   </el-dialog>
 </template>
 
 <script>
 import PaginationPage from '@/components/PaginationPage.vue';
+import AudioLine from '@/views/personal_workbench/project/components/AudioLine.vue';
 
 import { PageQueryProjectResourceList } from '@/api/list';
 import { H5StartupFile } from '@/api/app';
 
 const Base64 = require('js-base64').Base64;
+import { getConfig } from '@/utils/auth';
 
 export default {
   name: 'SelectResource',
   components: {
     PaginationPage,
+    AudioLine,
   },
   props: {
     visible: {
@@ -176,6 +204,10 @@ export default {
       isDesc: false, // 排序是否为倒序
       search_content: '',
       select_sources_id: '',
+      visible_flag: false,
+      newpath: '',
+      iframeHeight: `${window.innerHeight - 100}px`,
+      file_preview_url: getConfig() ? getConfig().doc_preview_service_address : '',
     };
   },
   created() {},
@@ -216,14 +248,16 @@ export default {
               item.new_path = `${this.file_preview_url}onlinePreview?url=${Base64.encode(item.file_url)}`;
             });
             this.loading = false;
-          } else if (this.type_index === 3) {
-            resource_list.forEach((item) => {
-              H5StartupFile({ file_id: item.file_id, index_file_name: 'index.html' }).then((res) => {
-                item.new_path = res.file_url;
-                this.loading = false;
-              });
-            });
-          } else {
+          }
+          // else if (this.type_index === 3) {
+          //   resource_list.forEach((item) => {
+          //     H5StartupFile({ file_id: item.file_id, index_file_name: 'index.html' }).then((res) => {
+          //       item.new_path = res.file_url;
+          //       this.loading = false;
+          //     });
+          //   });
+          // }
+          else {
             this.loading = false;
           }
           this.list = resource_list;
@@ -255,6 +289,19 @@ export default {
         intro: selectedResource.intro,
       });
     },
+    // 预览
+    viewDialog(file) {
+      this.newpath = '';
+      if (this.type_index === 3) {
+        H5StartupFile({ file_id: file.file_id, index_file_name: 'index.html' }).then((res) => {
+          this.newpath = res.file_url;
+          this.visible_flag = true;
+        });
+      } else {
+        this.newpath = `${this.file_preview_url}onlinePreview?url=${Base64.encode(file.file_url)}`;
+        this.visible_flag = true;
+      }
+    },
   },
 };
 </script>

+ 40 - 16
src/views/book/courseware/create/components/common/SelectUpload.vue

@@ -1,28 +1,43 @@
 <template>
-  <div class="select-upload" :style="{ width: width }">
-    <span v-if="label" class="label-text">{{ label }}</span>
-    <el-upload
-      ref="upload"
-      class="file-uploader"
-      action="no"
-      :accept="curTypeObj.accept"
-      :multiple="multiple"
-      :show-file-list="false"
-      :auto-upload="false"
-      :limit="limit"
-      :on-change="onFileChange"
-    >
-      <el-button>{{ showText }}</el-button>
-    </el-upload>
-    <el-button size="small" class="upload-button" type="primary" @click="uploadFiles">上传</el-button>
+  <div>
+    <div class="select-upload" :style="{ width: width }">
+      <span v-if="label" class="label-text">{{ label }}</span>
+      <el-upload
+        ref="upload"
+        class="file-uploader"
+        action="no"
+        :accept="curTypeObj.accept"
+        :multiple="multiple"
+        :show-file-list="false"
+        :auto-upload="false"
+        :limit="limit"
+        :on-change="onFileChange"
+      >
+        <el-button>{{ showText }}</el-button>
+      </el-upload>
+      <el-button size="small" class="upload-button" type="primary" @click="uploadFiles">上传</el-button>
+      <el-button size="small" type="primary" @click="useResource">使用资源</el-button>
+    </div>
+    <SelectResource
+      :visible.sync="visibleResource"
+      :project-id="project_id"
+      :accept="type"
+      :courseware-id="courseware_id"
+      @selectResource="selectResource"
+    />
   </div>
 </template>
 
 <script>
 import { fileUpload } from '@/api/app';
+import SelectResource from '../base/common/SelectResource.vue';
 
 export default {
   name: 'SelectUpload',
+  inject: ['courseware_id', 'project_id'],
+  components: {
+    SelectResource,
+  },
   props: {
     type: {
       type: String,
@@ -66,6 +81,7 @@ export default {
         },
       },
       fileList: [],
+      visibleResource: false,
     };
   },
   computed: {
@@ -105,6 +121,14 @@ export default {
           });
       });
     },
+    // 使用资源
+    useResource() {
+      this.visibleResource = true;
+    },
+    selectResource({ file_id, file_name, file_url, intro }) {
+      this.$emit('uploadSuccess', [{ file_id, file_name, file_url }]);
+      this.visibleResource = false;
+    },
   },
 };
 </script>

+ 11 - 5
src/views/personal_workbench/project/ProductionResourceManage.vue

@@ -67,11 +67,12 @@
             </template>
             <template v-else-if="type_index === 2">
               <video
-                controls
+                class="sources-item-border"
                 :src="item.file_url"
                 width="100%"
                 height="140px"
                 :poster="item.video_preview_image_file_url"
+                preload="none"
               ></video>
             </template>
             <template v-else-if="type_index === 3">
@@ -107,7 +108,7 @@
                   <p class="name">
                     {{ item.name }}
                     <SvgIcon
-                      v-show="item.file_id && type_index === 3"
+                      v-show="item.file_id && (type_index === 3 || type_index === 2)"
                       icon-class="uploadPreview"
                       size="16"
                       @click="viewDialog(item)"
@@ -618,10 +619,15 @@ export default {
     // 预览
     viewDialog(file) {
       this.newpath = '';
-      H5StartupFile({ file_id: file.file_id, index_file_name: 'index.html' }).then((res) => {
-        this.newpath = res.file_url;
+      if (this.type_index === 3) {
+        H5StartupFile({ file_id: file.file_id, index_file_name: 'index.html' }).then((res) => {
+          this.newpath = res.file_url;
+          this.visible = true;
+        });
+      } else {
+        this.newpath = `${this.file_preview_url}onlinePreview?url=${Base64.encode(file.file_url)}`;
         this.visible = true;
-      });
+      }
     },
   },
 };