zhuliu преди 10 месеца
родител
ревизия
00a066ca4c

+ 4 - 0
src/api/newApi/file.js

@@ -28,5 +28,9 @@ export default {
   //获取当前版本显示的数据
   getCurrentVersionData(data){
     return axios.post('/myOnlyOffice/onlyOffice/getCurrentVersionData', data)
+  },
+  //强制保存
+  onlyOffice_forceSave(data){
+    return axios.post('/myOnlyOffice/onlyOffice/forceSave', data)
   }
 };

+ 50 - 0
src/components/VabOnlyOffice/addNewFile.vue

@@ -0,0 +1,50 @@
+<template>
+  <div>
+    <el-dialog title="保存新文件" :visible.sync="visible" width="500px" append-to-body destroy-on-close
+      :close-on-click-modal="false" :before-close="handleClose">
+      <el-form :model="form" ref="form" label-width="80px" label-position="left">
+        <el-form-item label="新文件名称" prop="referencesName">
+          <el-input v-model="form.referencesName" placeholder="请输入新文件名称"></el-input>
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" placeholder="请输入备注" type="textarea"></el-input>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="handleClose">取 消</el-button>
+        <el-button type="primary" @click="submit">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+export default {
+  components: {},
+  props: {},
+  data() {
+    return {
+        visible:false,
+        form:{},
+    };
+  },
+  watch: {},
+  computed: {},
+  created() {},
+  mounted() {},
+  methods: {
+    open(form = {}){
+        this.form = form
+        this.visible = true
+    },
+    handleClose(){
+        this.visible = false
+    },
+    submit(){
+
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 27 - 2
src/components/VabOnlyOffice/index.js

@@ -1,6 +1,5 @@
 
 import CryptoJS from "crypto-js";
-
 const SECRET_KEY = 'VI71S3cGtXg96HgFWzQhblz1KwMc1Jzk';
 
 
@@ -29,7 +28,33 @@ export default{
             var reg = new RegExp('/','g')
             encodedSource = encodedSource.replace(/=+$/,'').replace(/\+/g,'-').replace(reg,'_')
             return encodedSource
-        }
+        },
+
+
+        //调用强制保存
+        async forceSave(){
+            var params = {
+                c:'forcesave',
+                key:this.option.key,
+            }
+            var data = null
+            await this.$api.onlyOffice_forceSave(params).then(response=>{
+                if(response.code == 200){
+                    data = response.data
+                }
+            })
+            return data
+        },
+        //保存新文件
+        async saveNewFile(){
+            var data = await this.forceSave()
+            if(data==1){
+                var form = {
+                    referencesName:this.option.title + '(1)'
+                }
+                this.$refs.addNewFile.open(form)
+            }
+        },
     },
 }
 

+ 22 - 8
src/components/VabOnlyOffice/index.vue

@@ -1,15 +1,24 @@
 <!--onlyoffice 编辑器-->
 <template>
   <div style="height:100%;width:100%" v-loading="loading">
+    <div class="menu_btn">
+      <el-button size="small" type="primary" @click="saveNewFile">保存新文件</el-button>
+    </div>
+    
     <div id='vabOnlyOffice' v-if="show"></div>
+    <addNewFile ref="addNewFile"></addNewFile>
   </div>
  
 </template>
 
 <script>
+import addNewFile from './addNewFile.vue'
 import mixins from './index.js'
   export default {
     name: 'VabOnlyOffice',
+    components:{
+      addNewFile
+    },
     mixins:[mixins],
     props: {
       option: {
@@ -202,7 +211,6 @@ import mixins from './index.js'
             onRequestHistoryData:this.onRequestHistoryData,//获取历史文件
             onRequestRestore:this.onRequestRestore,//恢复
             onRequestHistoryClose:this.onRequestHistoryClose,//关闭历史
-            onDocumentStateChange:this.onDocumentStateChange,
           },
           width: '100%',
           height: '100%',
@@ -220,6 +228,7 @@ import mixins from './index.js'
           await this.$api.GetJWT(data).then(response=>{
             if(response.code == 200){
               config.token = response.data
+              this.option.token = response.data
               this.loading = false
             }
           }).catch(error=>{
@@ -308,12 +317,13 @@ import mixins from './index.js'
           await this.$api.GetJWT(params).then(response=>{
             if(response.code == 200){
               obj2.token = response.data
+              this.option.token = response.data
               this.loading = false
             }
           }).catch(error=>{
             this.loading  = false
           })
-            this.docEditor.setHistoryData(obj2)
+          this.docEditor.setHistoryData(obj2)
           }
       },
       //恢复
@@ -335,12 +345,6 @@ import mixins from './index.js'
       onRequestHistoryClose(event){
         this.setEditor(this.option)
       },
-      onDocumentStateChange(event){
-        if(this.option.isSave){
-          this.option.isSave = false
-          this.$emit('reLoadQuery',this.option)
-        }
-      },
       getFileType(fileType) {
         let docType = ''
         let fileTypesDoc = [
@@ -371,3 +375,13 @@ import mixins from './index.js'
   background-image: url('../../assets/logo.png') !important;
 }
 </style>
+
+<style lang="scss" scoped>
+  .menu_btn{
+    height: 45px;
+    padding: 0 20px;
+    display: flex;
+    align-items: center;
+    flex-direction: row-reverse;
+  }
+</style>

+ 12 - 22
src/views/components/onlyOffice/index.vue

@@ -1,7 +1,7 @@
 <template>
     <div class='qualityManual-container'>
         <div v-if='show' class='qualityManual-container-office'>
-            <vab-only-office :option='option' @reLoadQuery="reLoadQuery"/>
+            <vab-only-office :option='option'/>
         </div>
     </div>
 </template>
@@ -68,7 +68,6 @@ export default {
                     if(response && response.length>0){
                         var data = response[0]
                         this.file.fileType = data.type
-                        this.reLoadQuery()
                         this.getOption()
                     }
                 })
@@ -84,25 +83,15 @@ export default {
             // this.show = true
         },
         //刷新网页参数
-        reLoadQuery(data){
-            if(data){
-                this.$router.replace({
-                    path: '/onlyOffice',
-                    query: {
-                        ...data,
-                    
-                    }
-                })
-            }else{
-                this.$router.replace({
-                    path: '/onlyOffice',
-                    query: {
-                        ...this.file,
-                    
-                    }
-                })
-            }
-            
+        reLoadQuery(data={}){
+            this.$router.replace({
+                path: '/onlyOffice',
+                query: {
+                    ...this.file,
+                    ...data
+                
+                }
+            })
         },
         getOption(){
             this.option.name = this.file.title
@@ -112,6 +101,7 @@ export default {
             this.option.fileType = this.file.fileType
             this.option.key = this.file.guid
             this.option.created = this.file.createTime || formatDate(new Date(),'YYYY-MM-DD HH:mm:ss')
+            this.option.isSave = this.file.isSave
             this.$nextTick(()=>{
                 this.show = true
             })
@@ -138,6 +128,6 @@ export default {
 
   .qualityManual-container-office {
     width: 100%;
-    height: calc(100% - 20px);
+    height: calc(100% - 50px);
   }
 </style>