Explorar el Código

展示自动保存信息,调整保存逻辑

cxmo hace 1 año
padre
commit
1f5bd7ce28

+ 3 - 0
src/views/ppt_manage/mixins/pptEditorMixins.js

@@ -17,6 +17,9 @@ export default{
       copyPagesMap:{},//选中的ppt页Id
       savePagesArr:[],//存储上一次选中的ppt页
       CoverContent:'',//自定义封面页内容
+      showLastSaveTime:false,//是否展示自动保存时间
+      lastSaveTime:'',//自动保存时间
+      isSaved:false,//是否已点击了保存/发布
     }
   },
   directives: {

+ 22 - 20
src/views/ppt_manage/newVersion/pptEditor.vue

@@ -107,10 +107,13 @@
             </template>
         </div>
         <div class="ppt-tool flex-column">
+            <div class="save-hint" v-show="showLastSaveTime" 
+                style="color: #666; margin-bottom: 15px"
+            >最近保存时间:{{lastSaveTime}}</div>
             <div class="tool-btn">
                 <el-button v-permission="permissionBtn.pptPermission.ppt_publish"
-                 type="primary" @click="handlePublish">去发布</el-button>
-                <el-button @click="handleSave('save')">保存</el-button>
+                 type="primary" @click="handlePublish" :loading="isSaved">去发布</el-button>
+                <el-button @click="handleSave('save')" :loading="isSaved">保存</el-button>
                 <el-button type="text" @click="handleChangeEditModal"><i class="el-icon-sort" style="transform: rotate(90deg);margin-right:5px;"></i>{{isEditLayer?'ppt编辑':'图层编辑'}}</el-button>
             </div>
             <div class="richtext-tool"></div>
@@ -276,6 +279,7 @@
 <script>
 import {countComponentName,checkClipboardItems,createRandomCode,checkPPTpageElemant,getChartInfo} from './utils/untils';
 import {modelInfo,defaultPosition} from './utils/config'
+import http from '@/api/http.js';
 import { dataBaseInterface ,sandInterface } from "@/api/api.js";
 import futuresInterface from '@/api/modules/futuresBaseApi';
 import chartRelevanceApi from '@/api/modules/chartRelevanceApi';
@@ -972,7 +976,7 @@ export default {
         this.$refs[`pptPage_${this.currentIndex}`][0].initPositionInfo()
     },
     //手动保存PPT
-    handleSave(type){
+    async handleSave(type){
      /*  const {result,hintText} = this.checkPPT()
       if(!result){
         this.$message.warning(hintText)
@@ -998,19 +1002,21 @@ export default {
         ImgUrl:BackgroundImg,
         TemplateType:BackIndex+1
       }
+      this.isSaved = true
       if(this.$route.query.id||this.pptId){
-        this.editPPT(FirstPage,Content,type)
+        await this.editPPT(FirstPage,Content,type)
       }else{
-        this.addPPT(FirstPage,Content)
+        await this.addPPT(FirstPage,Content)
       }
     },
-    addPPT(FirstPage,Content){
-      pptInterface.addppt({
+    async addPPT(FirstPage,Content){
+      await pptInterface.addppt({
         FirstPage:FirstPage,
         Content:Content,
         GroupId:this.catalogId,
         CoverContent:this.CoverContent
       }).then(res=>{
+        this.isSaved = false
         if(res.Ret===200){
           this.$message.success('新增成功')
           //this.$router.push({path:'/pptlist'})
@@ -1022,15 +1028,16 @@ export default {
         }
       })
     },
-    editPPT(FirstPage,Content,type){
+    async editPPT(FirstPage,Content,type){
       //console.log(type)
       const ppt_id = this.$route.query.id||this.pptId
-      pptInterface.editppt({
+      await pptInterface.editppt({
         PptId:parseInt(ppt_id),
         FirstPage:FirstPage,
         Content:Content,
         CoverContent:this.CoverContent
       }).then(res=>{
+        this.isSaved = false
         if(res.Ret===200){
           if(type==='save'){
             this.$message.success('编辑成功')
@@ -1069,7 +1076,11 @@ export default {
           FirstPage:FirstPage,
           Content:Content,
           CoverContent:this.CoverContent
-        }).then((res)=>{})
+        }).then((res)=>{
+            if(res.Ret!==200) return 
+            this.showLastSaveTime = true
+            this.lastSaveTime = http.dateFormatter(new Date(), true);
+        })
       },10000)
     },
     //保存时的校验规则:封面信息,至少一页
@@ -1109,16 +1120,7 @@ export default {
       return {result:true,hintText:''}
     },
     async handlePublish(){
-      if(!this.isSave){
-        this.$message.warning("请先保存!")
-        return
-      }else{
-        const {result,hintText} = this.checkPPT()
-        if(!result){
-          this.$message.warning(hintText)
-          return
-        }
-      }
+      //ETA1.7.5更改发布逻辑,点击发布时,自动执行保存操作,若可保存,则跳转发布页
       await this.handleSave('pub')
       //ppt4.0后,合并后的PPT可能会超出页数or图表限制,在这里做个校验
       if(this.pageList.length>this.maxPageNum){

+ 22 - 20
src/views/ppt_manage/newVersion/pptEnEditor.vue

@@ -104,10 +104,13 @@
             </template>
         </div>
         <div class="ppt-tool flex-column">
+            <div class="save-hint" v-show="showLastSaveTime" 
+                style="color: #666; margin-bottom: 15px"
+            >最近保存时间:{{lastSaveTime}}</div>
             <div class="tool-btn">
                 <el-button v-permission="permissionBtn.enPPTPermission.pptEn_publish"
-                 type="primary" @click="handlePublish">去发布</el-button>
-                <el-button @click="handleSave('save')">保存</el-button>
+                 type="primary" @click="handlePublish" :loading="isSaved">去发布</el-button>
+                <el-button @click="handleSave('save')" :loading="isSaved">保存</el-button>
                 <el-button type="text" @click="handleChangeEditModal"><i class="el-icon-sort" style="transform: rotate(90deg);margin-right:5px;"></i>{{isEditLayer?'ppt编辑':'图层编辑'}}</el-button>
             </div>
             <div class="richtext-tool"></div>
@@ -288,6 +291,7 @@
 <script>
 import {countComponentName,checkClipboardItems,createRandomCode,checkPPTpageElemant,getChartInfo} from './utils/untils';
 import {modelInfo,defaultPosition} from './utils/config'
+import http from '@/api/http.js';
 import { dataBaseInterface ,sandInterface } from "@/api/api.js";
 import futuresInterface from '@/api/modules/futuresBaseApi';
 import chartRelevanceApi from '@/api/modules/chartRelevanceApi';
@@ -967,7 +971,7 @@ export default {
         this.$refs[`pptPage_${this.currentIndex}`][0].initPositionInfo()
     },
     //手动保存PPT
-    handleSave(type){
+    async handleSave(type){
       //保存走save_checkPPT,发布走checkPPT
       let checkResult = null
       if(type==='save'){
@@ -986,19 +990,21 @@ export default {
         ImgUrl:BackgroundImg,
         TemplateType:BackIndex+1
       }
+      this.isSaved = true
       if(this.$route.query.id||this.pptId){
-        this.editPPT(FirstPage,Content,type)
+        await this.editPPT(FirstPage,Content,type)
       }else{
-        this.addPPT(FirstPage,Content)
+        await this.addPPT(FirstPage,Content)
       }
     },
-    addPPT(FirstPage,Content){
-      pptEnInterface.addppt({
+    async addPPT(FirstPage,Content){
+      await pptEnInterface.addppt({
         FirstPage:FirstPage,
         Content:Content,
         GroupId:this.catalogId,
         CoverContent:this.CoverContent
       }).then(res=>{
+        this.isSaved = false
         if(res.Ret===200){
           this.$message.success('新增成功')
           this.isSave = true
@@ -1009,14 +1015,15 @@ export default {
         }
       })
     },
-    editPPT(FirstPage,Content,type){
+    async editPPT(FirstPage,Content,type){
       const ppt_id = this.$route.query.id||this.pptId
-      pptEnInterface.editppt({
+      await pptEnInterface.editppt({
         PptId:parseInt(ppt_id),
         FirstPage:FirstPage,
         Content:Content,
         CoverContent:this.CoverContent
       }).then(res=>{
+        this.isSaved = false
         if(res.Ret===200){
           if(type==='save'){
             this.$message.success('编辑成功')
@@ -1048,7 +1055,11 @@ export default {
           FirstPage:FirstPage,
           Content:Content,
           CoverContent:this.CoverContent
-        }).then((res)=>{})
+        }).then((res)=>{
+            if(res.Ret!==200) return 
+            this.showLastSaveTime = true
+            this.lastSaveTime = http.dateFormatter(new Date(), true);
+        })
       },10000)
     },
     //保存时的校验规则:封面信息,至少一页
@@ -1087,16 +1098,7 @@ export default {
       return {result:true,hintText:''}
     },
     async handlePublish(){
-      if(!this.isSave){
-        this.$message.warning("请先保存!")
-        return
-      }else{
-        const {result,hintText} = this.checkPPT()
-        if(!result){
-          this.$message.warning(hintText)
-          return
-        }
-      }
+      //ETA1.7.5更改发布逻辑,点击发布时,自动执行保存操作,若可保存,则跳转发布页
       await this.handleSave('pub')
       //ppt4.0后,合并后的PPT可能会超出页数or图表限制,在这里做个校验
       if(this.pageList.length>this.maxPageNum){