Crunchy
2024-05-16 ea406e0b3aed9cd0b57a37e4ffa5b55892fa1434
2024-5-16 在线编辑完成
已修改4个文件
已添加1个文件
271 ■■■■ 文件已修改
index.html 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/tool/onlyoffice.vue 193 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/view/b1-report-preparation.vue 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/view/system-log.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.html
@@ -21,6 +21,7 @@
    </head>
    <body>
        <div id="app"></div>
        <script type='text/javascript' src='http://192.168.73.130:9001/web-apps/apps/api/documents/api.js'></script>
        <script src="<%= htmlWebpackPlugin.options.url %>/static/luckysheet/plugins/js/plugin.js"></script>
        <script src="<%= htmlWebpackPlugin.options.url %>/static/luckysheet/luckysheet.umd.js"></script>
    </body>
src/components/tool/onlyoffice.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,193 @@
<!--onlyoffice ç¼–辑器-->
<template>
  <div id="vabOnlyOffice"></div>
</template>
<script>
export default {
  name: "VabOnlyOffice",
  data() {
    return {
      doctype: "",
      docEditor: null,
      //参考vabOnlyOffice组件参数配置
      option: {
        url: "",
        isEdit: false,
        fileType: "",
        title: "",
        lang: "zh-CN",
        isPrint: true,
        user: {},
        editUrl: ""
      }
    };
  },
  created() {
    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) {
      console.log(`output->option`,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参数设置为edit,则填写表单仅对文档编辑器可用。 é»˜è®¤å€¼ä¸Žedit或review参数的值一致。
            // "review": true //跟踪变化
          },
          url: option.url
        },
        documentType: this.doctype,
        editorConfig: {
          callbackUrl: option.editUrl, //"编辑word后保存时回调的地址,这个api需要自己写了,将编辑后的文件通过这个api保存到自己想要的位置
          lang: option.lang, //语言设置
          //定制
          customization: {
            autosave: false, //是否自动保存
            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>
src/components/view/b1-report-preparation.vue
@@ -180,15 +180,15 @@
          showSelect: false,
          select: false,
          do: [
            //   {
            //   id: 'handleWeave',
            //   font: '在线编制',
            //   type: 'text',
            //   method: 'handleWeave',
            //   disabFun: (row, index) => {
            //     return row.isExamine != null
            //   }
            // },
              {
              id: 'handleWeave',
              font: '在线编制',
              type: 'text',
              method: 'handleWeave',
              disabFun: (row, index) => {
                return row.isExamine != null
              }
            },
            {
              id: 'download',
              font: '下载',
@@ -242,9 +242,9 @@
            }
          ],
          linkEvent: {
            // code: {
            //   method: 'selectAllByOne'
            // }
            code: {
              method: 'selectAllByOne'
            }
          },
          tagField: {
            isRatify: {
@@ -343,22 +343,22 @@
        this.upIndex++
      },
      async handleWeave(row) {
        // this.value = await file.convertFileToHtml(row.url)
        // this.claimVisible = true;
        this.$axios.post(this.$api.insReport.wordToHtml, {
          path: row.urlS ? row.urlS : row.url
        }).then(res => {
          if (res.code === 200) {
            // console.log(11111111,res.data)
            this.value = res.data
              .replace(/<a [^>]*>/g, "")
              .replace(/<\/a>/g, "")
              .replace(/&nbsp;/g, "&nbsp;&nbsp;");
            this.claimVisible = true;
        const userName = JSON.parse(localStorage.getItem("user")).name;
        //参考vabOnlyOffice组件参数配置
        const { href } = this.$router.resolve({
          path: `/wordEdit`,
          query: {
            url: this.javaApi + "/word/" + row.entrustCode + ".docx",
            isEdit: true,
            fileType: "docx",
            title: row.entrustCode + ".docx",
            lang: 'zh-CN',
            isPrint: true,
            user:  { id: 1, name: userName},
            editUrl: this.javaApi + "/insReport/onlyOffice/save?fileName=" + row.entrustCode + ".docx"
          }
        }).catch(error => {
          console.error(error)
        })
        window.open(href, '_blank');
      },
      // æƒé™åˆ†é…
      getPower(radio) {
@@ -406,7 +406,23 @@
        // console.log(this.$refs.Word.getValue())
      },
      async selectAllByOne(row) {
        console.log(row, await file.convertFileToHtml(row.url));
        const userName = JSON.parse(localStorage.getItem("user")).name;
        //参考vabOnlyOffice组件参数配置
        const { href } = this.$router.resolve({
          path: `/wordEdit`,
          query: {
            url: this.javaApi + "/word/" + row.entrustCode + ".docx",
            isEdit: "false",
            fileType: "docx",
            title: row.entrustCode + ".docx",
            lang: 'zh-CN',
            isPrint: true,
            user_id: 1,
            user_name: userName
          }
        })
        window.open(href, '_blank');
        console.log(`output->row`,row)
      },
      download(row) {
        let url = row.urlS ? row.urlS : row.url;
src/components/view/system-log.vue
@@ -106,4 +106,4 @@
            }
        }
    }
</script>
</script>
src/router/index.js
@@ -26,5 +26,8 @@
  },{
        path: "/test/excel",
        component: () => import("../components/tool/excel.vue")
    }]
    },{
    path: "/wordEdit",
    component: () => import("../components/tool/onlyoffice.vue")
  }]
})