From 952a20f1c005d80e9bf881287c40e6f4e4266a0b Mon Sep 17 00:00:00 2001
From: lxp <1928192722@qq.com>
Date: 星期三, 12 三月 2025 15:34:52 +0800
Subject: [PATCH] Merge branch 'dev' of http://114.132.189.42:9002/r/center-lims-before-ruoyi into dev

---
 src/views/business/reportPreparation/onlyoffice.vue |  207 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 207 insertions(+), 0 deletions(-)

diff --git a/src/views/business/reportPreparation/onlyoffice.vue b/src/views/business/reportPreparation/onlyoffice.vue
new file mode 100644
index 0000000..c9a6e33
--- /dev/null
+++ b/src/views/business/reportPreparation/onlyoffice.vue
@@ -0,0 +1,207 @@
+<!--onlyoffice 缂栬緫鍣�-->
+<template>
+    <div id="vabOnlyOffice"></div>
+  </template>
+  
+  <script>
+  export default {
+    name: "VabOnlyOffice",
+    props: ['options'],
+    data() {
+      return {
+        doctype: "",
+        docEditor: null,
+        //鍙傝�僾abOnlyOffice缁勪欢鍙傛暟閰嶇疆
+        option: {
+          url: "",
+          isEdit: false,
+          fileType: "",
+          title: "",
+          lang: "zh-CN",
+          isPrint: true,
+          user: {},
+          editUrl: ""
+        }
+      };
+    },
+    created() {
+      if(this.options){
+        const option = this.options
+        this.option.url = option.url
+        this.option.isEdit = option.isEdit === "true" ? true : false
+        this.option.fileType = option.fileType
+        this.option.title = option.title
+        this.option.lang = option.lang
+        this.option.isPrint = option.isPrint
+        this.option.user.id = option.user_id
+        this.option.user.name = option.user_name
+        this.option.editUrl = option.editUrl
+      }else{
+        const option = this.$route.query
+        this.option.url = option.url
+        this.option.isEdit = option.isEdit === "true" ? true : false
+        this.option.fileType = option.fileType
+        this.option.title = option.title
+        this.option.lang = option.lang
+        this.option.isPrint = option.isPrint
+        this.option.user.id = option.user_id
+        this.option.user.name = option.user_name
+        this.option.editUrl = option.editUrl
+      }
+    },
+    beforeDestroy() {
+      if (this.docEditor !== null) {
+        this.docEditor.destroyEditor();
+        this.docEditor = null;
+      }
+    },
+    watch: {
+      option: {
+        handler: function(n) {
+          this.setEditor(n);
+          this.doctype = this.getFileType(n.fileType);
+        },
+        deep: true
+      }
+    },
+    mounted() {
+      if (this.option.url) {
+        this.setEditor(this.option);
+      }
+    },
+    methods: {
+      async setEditor(option) {
+        if (this.docEditor !== null) {
+          this.docEditor.destroyEditor();
+          this.docEditor = null;
+        }
+        this.doctype = this.getFileType(option.fileType);
+        let config = {
+          document: {
+            //鍚庣紑
+            fileType: option.fileType,
+            key: option.key || "",
+            title: option.title,
+            permissions: {
+              edit: option.isEdit, //鏄惁鍙互缂栬緫: 鍙兘鏌ョ湅锛屼紶false
+              print: option.isPrint,
+              download: false
+              // "fillForms": true,//鏄惁鍙互濉啓琛ㄦ牸锛屽鏋滃皢mode鍙傛暟璁剧疆涓篹dit锛屽垯濉啓琛ㄥ崟浠呭鏂囨。缂栬緫鍣ㄥ彲鐢ㄣ�� 榛樿鍊间笌edit鎴杛eview鍙傛暟鐨勫�间竴鑷淬��
+              // "review": true //璺熻釜鍙樺寲
+            },
+            url: option.url
+          },
+          documentType: this.doctype,
+          editorConfig: {
+            callbackUrl: option.editUrl, //"缂栬緫word鍚庝繚瀛樻椂鍥炶皟鐨勫湴鍧�锛岃繖涓猘pi闇�瑕佽嚜宸卞啓浜嗭紝灏嗙紪杈戝悗鐨勬枃浠堕�氳繃杩欎釜api淇濆瓨鍒拌嚜宸辨兂瑕佺殑浣嶇疆
+            lang: option.lang, //璇█璁剧疆
+            //瀹氬埗
+            customization: {
+              autosave: true, //鏄惁鑷姩淇濆瓨
+              chat: true,
+              comments: false,
+              help: false,
+              "hideRightMenu": false,//瀹氫箟鍦ㄧ涓�娆″姞杞芥椂鏄樉绀鸿繕鏄殣钘忓彸渚ц彍鍗曘�� 榛樿鍊间负false
+              //鏄惁鏄剧ず鎻掍欢
+              plugins: false
+            },
+            user: {
+              id: option.user.id,
+              name: option.user.name
+            },
+            mode: option.model ? option.model : "edit"
+          },
+          width: "100%",
+          height: "100%",
+          token: option.token || ""
+        };
+  
+        // eslint-disable-next-line no-undef,no-unused-vars
+        this.docEditor = new DocsAPI.DocEditor("vabOnlyOffice", config);
+      },
+      getFileType(fileType) {
+        let docType = "";
+        let fileTypesDoc = [
+          "doc",
+          "docm",
+          "docx",
+          "dot",
+          "dotm",
+          "dotx",
+          "epub",
+          "fodt",
+          "htm",
+          "html",
+          "mht",
+          "odt",
+          "ott",
+          "pdf",
+          "rtf",
+          "txt",
+          "djvu",
+          "xps"
+        ];
+        let fileTypesCsv = [
+          "csv",
+          "fods",
+          "ods",
+          "ots",
+          "xls",
+          "xlsm",
+          "xlsx",
+          "xlt",
+          "xltm",
+          "xltx"
+        ];
+        let fileTypesPPt = [
+          "fodp",
+          "odp",
+          "otp",
+          "pot",
+          "potm",
+          "potx",
+          "pps",
+          "ppsm",
+          "ppsx",
+          "ppt",
+          "pptm",
+          "pptx"
+        ];
+        if (fileTypesDoc.includes(fileType)) {
+          docType = "text";
+        }
+        if (fileTypesCsv.includes(fileType)) {
+          docType = "spreadsheet";
+        }
+        if (fileTypesPPt.includes(fileType)) {
+          docType = "presentation";
+        }
+        return docType;
+      }
+    }
+  };
+  </script>
+  
+  <style>
+  html,
+  body {
+    height: 100%;
+  }
+  #app {
+    font-family: Avenir, Helvetica, Arial, sans-serif;
+    -webkit-font-smoothing: antialiased;
+    -moz-osx-font-smoothing: grayscale;
+    text-align: center;
+    color: #2c3e50;
+    height: 100%;
+  }
+  .qualityManual-container {
+    padding: 0 !important;
+    height: 100%;
+  }
+  .qualityManual-container-office {
+    width: 100%;
+    height: calc(100% - 55px);
+  }
+  </style>
+  
\ No newline at end of file

--
Gitblit v1.9.3