فهرست منبع

公共上传文件,根据权限可以提交到资源库和下载

zq 1 ماه پیش
والد
کامیت
c1fdeb9a6b

+ 26 - 0
src/api/book.js

@@ -162,6 +162,15 @@ export function MangerAddResource(data) {
 }
 
 /**
+ * @description 编辑时把文件提交到资源库
+ * @param {object} data
+ */
+export function SubmitFileToResourceStore(data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=project_resource_manager-SubmitFileToResourceStore`, data);
+}
+
+
+/**
  * @description 删除项目资源
  * @param {object} data
  */
@@ -412,3 +421,20 @@ export function GetTitleStyle(data) {
 export function SetBookResourceHide(data) {
   return http.post(`${process.env.VUE_APP_EepServer}?MethodName=book_content_manager-SetBookResourceHide`, data);
 }
+
+
+/**
+ * @description 得到项目成员资源权限列表
+ * @param {Object} data
+ */
+export function GetProjectMemberResourcePopedomList(data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=project_resource_manager-GetProjectMemberResourcePopedomList`, data);
+}
+
+/**
+ * @description 设置项目成员资源权限
+ * @param {Object} data
+ */
+export function SetProjectMemberResourcePopedom(data) {
+  return http.post(`${process.env.VUE_APP_EepServer}?MethodName=project_resource_manager-SetProjectMemberResourcePopedom`, data);
+}

+ 1 - 0
src/icons/svg/download.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1772266509970" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="8116" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M892.3 695.8c-19.9 0-36 16.1-36 36v155.6l-686 1.2V731.8c0-19.9-16.1-36-36-36s-36 16.1-36 36v192.9c0 9.6 3.8 18.7 10.6 25.5 6.8 6.7 15.9 10.5 25.4 10.5h0.1l758-1.3c19.9 0 35.9-16.1 35.9-36V731.8c0-19.9-16.1-36-36-36z" fill="#333333" p-id="8117"></path><path d="M480.6 716.9c3.8 6.2 9.5 11.3 16.5 14.3 4.8 2.1 10 3 15 2.9h0.9c4.8 0 9.6-1 14.1-2.9 7-3 12.7-8 16.5-14.3l186.1-177.8c14.4-13.7 14.9-36.5 1.2-50.9-13.7-14.4-36.5-14.9-50.9-1.2L549 612.2v-511c0-19.9-16.1-36-36-36h-1.7c-19.9 0-36 16.1-36 36v511.1L344.2 487c-14.4-13.7-37.2-13.2-50.9 1.2-13.7 14.4-13.2 37.2 1.2 50.9l186.1 177.8z" fill="#333333" p-id="8118"></path></svg>

+ 1 - 0
src/views/book/courseware/create/components/base/common/SelectResource.vue

@@ -230,6 +230,7 @@ export default {
         cur_page: this.cur_page,
         project_id: this.projectId,
         book_chapter_node_id: this.coursewareId,
+        is_search_parent_node_resource: 'true',
         type: this.type_list[this.type_index].value,
         name_or_label: this.search_content,
         order_column_list,

+ 52 - 13
src/views/book/courseware/create/components/base/common/UploadFile.vue

@@ -18,14 +18,7 @@
         >
           <el-button>{{ type === 'h5_games' ? '选择Zip压缩包或单个html文件' : '选取' + labelText + '文件' }}</el-button>
         </el-upload>
-        <el-button
-          v-if="isEnable(projectResourcePopedom.is_can_upload)"
-          size="small"
-          type="primary"
-          @click="uploadFiles"
-        >
-          上传
-        </el-button>
+        <el-button size="small" type="primary" @click="uploadFiles"> 上传 </el-button>
         <el-button v-if="isEnable(projectResourcePopedom.is_can_use)" size="small" type="primary" @click="useResource">
           使用资源
         </el-button>
@@ -47,7 +40,7 @@
             <span v-else>{{
               canEditName && file.file_id
                 ? content.file_info[file.file_id].xuhao + content.file_info[file.file_id].file_name
-                : (file.file_name ?? file.name)
+                : file.file_name ?? file.name
             }}</span>
             <!-- <span>({{ file.size }})</span> -->
           </span>
@@ -60,7 +53,7 @@
             stroke-linecap="butt"
             :show-text="false"
           />
-          <span v-else-if="file.file_id"> 完成 </span>
+          <span v-else-if="file.file_id"> 完成</span>
         </div>
         <SvgIcon icon-class="delete-black" size="12" @click="removeFile(file, i)" />
         <SvgIcon
@@ -79,6 +72,20 @@
           />
           <SvgIcon v-else icon-class="icon-edit" size="12" @click="changeIsEdit(content.file_info[file.file_id])" />
         </template>
+
+        <el-tooltip effect="dark" placement="top" content="提交到资源库">
+          <SvgIcon
+            v-if="isEnable(projectResourcePopedom.is_can_upload) && canEditName && file.file_id"
+            icon-class="upload"
+            @click="addResource(file)"
+          />
+        </el-tooltip>
+
+        <SvgIcon
+          v-if="isEnable(projectResourcePopedom.is_can_download) && canEditName && file.file_id"
+          icon-class="download"
+          @click="downLoad(file)"
+        />
       </li>
     </ul>
 
@@ -98,10 +105,11 @@
 import { fileUpload } from '@/api/app';
 import { conversionSize } from '@/utils/common';
 import { isEnable } from '@/views/book/courseware/data/common';
+import { getConfig, getToken } from '@/utils/auth';
 
 import FillDescribe from '../../common/FillDescribe.vue';
 import SelectResource from './SelectResource.vue';
-
+import { SubmitFileToResourceStore } from '@/api/book';
 export default {
   name: 'UploadFile',
   components: {
@@ -264,7 +272,9 @@ export default {
       });
       if (this.limit !== null && this.content.file_list.length + files.length > this.limit) {
         this.$message.warning(
-          `当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + this.content.file_list.length} 个文件`,
+          `当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
+            files.length + this.content.file_list.length
+          } 个文件`
         );
         return;
       }
@@ -273,7 +283,9 @@ export default {
 
     handleExceed(files, fileList) {
       this.$message.warning(
-        `当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`,
+        `当前限制选择 ${this.limit} 个文件,本次选择了 ${files.length} 个文件,共选择了 ${
+          files.length + fileList.length
+        } 个文件`
       );
     },
 
@@ -462,6 +474,33 @@ export default {
     changeIsEdit(file) {
       file.isEdit = !file.isEdit;
     },
+
+    //提交到资源库
+    addResource(file) {
+      let data = {
+        project_id: this.project_id,
+        file_id: file.file_id,
+      };
+      SubmitFileToResourceStore(data)
+        .then((res) => {})
+        .catch(() => {
+          this.loading = false;
+        });
+    },
+    // 下载文件
+    downLoad(file) {
+      let userInfor = getToken();
+      let AccessToken = '';
+      if (userInfor) {
+        AccessToken = userInfor.access_token;
+      }
+      let FileID = file.file_id;
+      let data = {
+        AccessToken,
+        FileID,
+      };
+      location.href = `${process.env.VUE_APP_EEP}/FileServer/WebFileDownload?AccessToken=${data.AccessToken}&FileID=${data.FileID}`;
+    },
   },
 };
 </script>