Browse Source

预览下载

natasha 9 months ago
parent
commit
ace26e649a

BIN
src/assets/download.png


+ 7 - 2
src/views/book/courseware/create/components/base/upload_preview/UploadPreview.vue

@@ -17,7 +17,7 @@
         :limit="1"
         @updateFileList="updateFileList"
       />
-      <!-- <el-form :model="data" label-width="72px" label-position="left">
+      <el-form :model="data" label-width="72px" label-position="left">
         <el-form-item label="下载">
           <el-radio-group v-model="data.is_enable_download">
             <el-radio v-for="{ value, label } in switchOption" :key="value" :label="value">
@@ -25,7 +25,7 @@
             </el-radio>
           </el-radio-group>
         </el-form-item>
-      </el-form> -->
+      </el-form>
     </template>
   </ModuleBase>
 </template>
@@ -59,3 +59,8 @@ export default {
   },
 };
 </script>
+<style lang="scss" scoped>
+:deep .file-list {
+  margin-bottom: 16px;
+}
+</style>

+ 49 - 0
src/views/book/courseware/preview/components/upload_preview/UploadPreviewPreview.vue

@@ -22,6 +22,10 @@
         <template v-else-if="data.file_list[0].file_name.indexOf('pdf') !== -1">
           <iframe :src="data.file_list[0].newpath" id="ifm" width="100%" height="260px" frameborder="0"></iframe>
         </template>
+        <div class="uploadBtn" @click="downLoad" v-if="isEnable(data.is_enable_download)">
+          <img style="width: 24px; height: 24px" src="@/assets/download.png" alt="" />
+          下载
+        </div>
       </template>
     </div>
   </div>
@@ -32,6 +36,7 @@ import PreviewMixin from '../common/PreviewMixin';
 import { getConfig } from '@/utils/auth';
 import { GetFileURLMap } from '@/api/app';
 const Base64 = require('js-base64').Base64;
+import { getToken } from '@/utils/auth';
 
 import { getUploadPreviewData } from '@/views/book/courseware/data/uploadPreview';
 
@@ -68,6 +73,28 @@ export default {
         });
       });
     },
+    //   下载表格
+    downLoad() {
+      let userInfor = getToken();
+      let UserCode = '',
+        UserType = '',
+        SessionID = '';
+      if (userInfor) {
+        UserCode = userInfor.user_code;
+        UserType = userInfor.user_type;
+        SessionID = userInfor.session_id;
+      }
+      let FileID = this.data.file_list[0].file_id;
+      let data = {
+        SessionID,
+        UserCode,
+        UserType,
+        FileID,
+      };
+      location.href =
+        process.env.VUE_APP_BASE_API +
+        `/GCLSFileServer/WebFileDownload?UserCode=${data.UserCode}&UserType=${data.UserType}&SessionID=${data.SessionID}&FileID=${data.FileID}`;
+    },
   },
 };
 </script>
@@ -78,4 +105,26 @@ export default {
 .upload-preview {
   @include preview-base;
 }
+
+.uploadBtn {
+  box-sizing: border-box;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  width: 96px;
+  height: 39px;
+  margin-top: 8px;
+  font-size: 16px;
+  line-height: 150%;
+  color: #000;
+  cursor: pointer;
+  background: #fff;
+  border: 1px solid rgba(0, 0, 0, 10%);
+  border-radius: 4px;
+  box-shadow: 0 2px 6px rgba(0, 0, 0, 10%);
+
+  img {
+    margin-right: 13px;
+  }
+}
 </style>