瀏覽代碼

PPT发布页增加下载按钮

cxmo 10 月之前
父節點
當前提交
2b94ede3bc
共有 1 個文件被更改,包括 13 次插入2 次删除
  1. 13 2
      src/views/ppt_manage/newVersion/pptPublish.vue

+ 13 - 2
src/views/ppt_manage/newVersion/pptPublish.vue

@@ -14,7 +14,8 @@
             <el-dropdown-item :command="3">4:3</el-dropdown-item>
           </el-dropdown-menu>
         </el-dropdown>
-				<el-button  type="primary" plain style="width:120px;height:40px;" @click="$router.push({path:'/pptlist'})">返回列表</el-button>
+        <el-button  type="primary" style="width:120px;height:40px;" @click="downloadPPT" :disabled="isPublish">下载</el-button>
+        <el-button  type="primary" plain style="width:120px;height:40px;" @click="$router.push({path:'/pptlist'})">返回列表</el-button>
       </div>
       <!--全加载-->
       <template v-if="loadingAll">
@@ -139,6 +140,11 @@ export default {
       }
       this.isPublish = false
     },
+    async downloadPPT(){
+        this.isPublish = true
+        await this.pageToPptx('dowload') 
+        this.isPublish = false
+    },
     //计算ppt的版式名称
     getComponentName(modelId){
         return countComponentName(modelId);
@@ -238,7 +244,7 @@ export default {
       this.checkImg(base64Url,'svg')
     },
     //生成pptx
-    async pageToPptx(){
+    async pageToPptx(type){
       //开始计时
       const start = Date.now()
       const SlideMaster = _.cloneDeep(pptSlideMaster) 
@@ -456,6 +462,11 @@ export default {
       const end = Date.now()
       console.log("转换ppt用时:",Math.floor((end-start)/1000),' s')
       //pptx2.writeFile({ fileName: "test.pptx" });//本地测试用
+      //直接下载
+      if(type==='dowload'){
+        pptx2.writeFile({ fileName: `${this.coverInfo.page.Title||'unname'}.pptx` });
+        return
+      }
       this.publishLoading = this.$loading({
         fullscreen:true,
         text:"发布中..."