Redeem 1 месяц назад
Родитель
Сommit
7962924ba1

+ 3 - 3
cors.js

@@ -207,7 +207,7 @@ module.exports = {
   },
   // devModules: ['index', 'entrustedManagement','sampleManager','screeningTests', 'resourceManager']
   //devModules: ['reportForm', 'screeningTests', 'index',  'entrustedManagement','measurementDataManagement', 'approveManagement', 'testAnalysis', 'resourceManager', 'taskManagement']
-  // devModules: ["index", "approveManagement"],
-  devModules: ["all"],
-  // devModules: ["index", "certificateManagement", "approveManagement"],
+  // devModules: ["index", "resourceManager"],
+  // devModules: ["all"],
+  devModules: ["index", "resourceManager", "standardManagement"],
 };

+ 2 - 2
src/views/standardManagement/components/systemAudit/systemAudit.vue

@@ -328,7 +328,7 @@ export default {
     },
     imgPreViewY(row, fileName) {
       let aaa = fileName.substr(fileName.indexOf(".") + 1);
-      this.axios.get('pass/baseManagement/v1/file/download/' + fileName, { responseType: 'blob' }, { headers: { 'content-type': 'application/x-www-form-urlencoded' } }).then(res => {
+      this.axios.get('pass/baseManagement/v1/file/download/' + encodeURIComponent(fileName), { responseType: 'blob' }, { headers: { 'content-type': 'application/x-www-form-urlencoded' } }).then(res => {
         if (aaa == "docx") {
           this.showFlag(true);
           docx.renderAsync(res, this.$refs.file)
@@ -350,7 +350,7 @@ export default {
       })
     },
     imgPreView(row, fileName) {
-      this.axios.get('pass/baseManagement/v1/file/download/' + fileName, { responseType: 'blob' }, { headers: { 'content-type': 'application/x-www-form-urlencoded' } }).then(res => {
+      this.axios.get('pass/baseManagement/v1/file/download/' + encodeURIComponent(fileName), { responseType: 'blob' }, { headers: { 'content-type': 'application/x-www-form-urlencoded' } }).then(res => {
         let blob = new Blob([res]);
         let elink = document.createElement('a');
         elink.download = fileName;

+ 0 - 149
src/views/standardManagement/components/systemFileManagement/OnlyofficeEditor.vue

@@ -1,149 +0,0 @@
-<template>
-  <div ref="officeEditor" class="office-editor"></div>
-</template>
-
-<script>
-export default {
-  name: 'OnlyofficeEditor',
-  props: {
-    documentUrl: { type: String, required: true },
-    title: { type: String, default: '文档.docx' },
-    fileType: { type: String, default: 'docx' },
-    isEdit: { type: Boolean, default: true },
-    callbackUrl: { type: String, default: '' },
-    documentKey: { type: String, default: '' },
-    data: { type: Object, default: () => ({}) }
-  },
-  data() {
-    return {
-      docEditor: null
-    }
-  },
-  mounted() {
-    console.log('[OnlyofficeEditor] mounted, documentUrl=', this.documentUrl)
-    this.$nextTick(() => {
-    if (this.documentUrl) {
-      this.initEditor();
-    }
-   });
-  this.$nextTick(() => {
-  console.log('editor height:', this.$refs.officeEditor.offsetHeight);
-  })
-  },
-  beforeDestroy() {
-    this.destroyEditor()
-  },
-  watch: {
-    documentUrl: {
-      handler(newVal, oldVal) {
-        console.log('[OnlyofficeEditor] documentUrl changed from', oldVal, 'to', newVal)
-        if (newVal && newVal !== oldVal) {
-          this.reinitEditor()
-        }
-      },
-      immediate: false
-    }
-  },
-  methods: {
-    getDocumentType(ext) {
-      const textTypes = ['doc', 'docm', 'docx', 'dot', 'dotm', 'dotx', 'odt', 'ott', 'rtf', 'txt']
-      const spreadTypes = ['xls', 'xlsm', 'xlsx', 'xlt', 'xltm', 'xltx', 'ods', 'ots', 'csv']
-      const presentTypes = ['ppt', 'pptm', 'pptx', 'pps', 'ppsm', 'ppsx', 'pot', 'potm', 'potx', 'odp', 'otp']
-      if (textTypes.includes(ext)) return 'text'
-      if (spreadTypes.includes(ext)) return 'spreadsheet'
-      if (presentTypes.includes(ext)) return 'presentation'
-      return 'text'
-    },
-    generateKey() {
-      return `${this.title}_${Date.now()}_${Math.random().toString(36).substring(2)}`
-    },
-    initEditor() {
-      console.log('[OnlyofficeEditor] initEditor called with url:', this.documentUrl)
-      console.log('[OnlyofficeEditor] Mount element:', this.$refs.officeEditor);
-      // 如果 DocsAPI 还未加载,等待100ms后重试
-      if (!window.DocsAPI) {
-        console.warn('DocsAPI not ready, retrying...');
-        setTimeout(() => this.initEditor(), 100);
-        return;
-      }
-      console.log('DocsAPI ready, initializing with url:', this.documentUrl);
-      if (!this.documentUrl) {
-        console.warn('[OnlyofficeEditor] documentUrl is empty, cannot init editor')
-        return
-      }
-      if (!this.$refs.officeEditor) {
-        console.error('[OnlyofficeEditor] officeEditor ref not found')
-        return
-      }
-
-      const config = {
-        document: {
-        url: 'http://192.168.254.22:9002/files/oss-volume-SA20260316152536737.docx', // 硬编码测试
-        title: 'test.docx',
-        fileType: 'docx',
-        key: 'test-key'
-      },
-      documentType: 'text',
-      height: '100%',
-      width: '100%',
-        editorConfig: {
-          mode: this.isEdit ? 'edit' : 'view',
-          lang: 'zh',
-          callbackUrl: this.callbackUrl,
-          customization: {
-            autosave: true,
-            chat: false,
-            comments: true,
-            help: false,
-            spellcheck: true
-          },
-          custom: this.data
-        },
-        events: {
-          onError: (error) => {
-            console.error('[OnlyofficeEditor] Error event:', error);
-          },
-          onAppReady: () => {
-            console.log('[OnlyofficeEditor] App ready');
-          },
-          onDocumentReady: () => {
-            console.log('[OnlyofficeEditor] Document ready');
-          },
-          onRequestClose: () => {
-            console.log('[OnlyofficeEditor] Request close');
-          }
-        },
-        height: '100%',
-        width: '100%'
-      }
-
-      try {
-        this.docEditor = new window.DocsAPI.DocEditor(this.$refs.officeEditor, config)
-        console.log('[OnlyofficeEditor] Editor instance created successfully')
-      } catch (error) {
-        console.error('[OnlyofficeEditor] Failed to create editor:', error)
-      }
-    },
-    destroyEditor() {
-      if (this.docEditor && typeof this.docEditor.destroyEditor === 'function') {
-        this.docEditor.destroyEditor()
-        this.docEditor = null
-        console.log('[OnlyofficeEditor] Editor destroyed')
-      }
-    },
-    reinitEditor() {
-      console.log('[OnlyofficeEditor] Reinitializing editor')
-      this.destroyEditor()
-      this.initEditor()
-    }
-  }
-}
-</script>
-
-<style scoped>
-.office-editor {
-  width: 100%;
-  height: 100%;
-  min-height: 600px;
-}
-</style>

+ 37 - 195
src/views/standardManagement/components/systemFileManagement/fourFileOnlineEdit.vue

@@ -1,219 +1,61 @@
 <template>
-  <el-container class="layout-container">
-    <!-- 主体左右分栏 -->
-    <el-container>
-      <!-- 左侧树区域 -->
-      <el-aside width="300px" class="aside-tree">
-        <div class="tree-header">
-          <el-input
-            v-model="filterText"
-            placeholder="搜索模板"
-            size="small"
-            prefix-icon="el-icon-search"
-            clearable
-          />
-          <el-button-group style="display: flex;">
-            <el-button size="mini" icon="el-icon-arrow-down" @click="expandAll">展开</el-button>
-            <el-button size="mini" icon="el-icon-arrow-up" @click="collapseAll">折叠</el-button>
-          </el-button-group>
-        </div>
-
-        <el-tree
-          ref="tree"
-          :data="treeData"
-          :props="defaultProps"
-          :filter-node-method="filterNode"
-          node-key="id"
-          highlight-current
-          @node-click="handleNodeClick"
-          class="tree-content"
-        >
-          <span slot-scope="{ node, data }" class="custom-tree-node">
-            <i :class="data.isFolder ? 'el-icon-menu' : 'el-icon-document'"></i>
-            <span>{{ node.label }}</span>
-          </span>
-        </el-tree>
-      </el-aside>
-
-      <!-- 右侧编辑器区域 -->
-      <el-main class="main-editor">
-        <div v-if="!currentFile" class="placeholder">
-          请从左侧选择一个模板文档
-        </div>
-        <div v-else class="editor-wrapper">
-          <OnlyofficeEditor
-            :key="editorKey"
-            :document-url="documentUrl"
-            :title="currentFile.name"
-            :file-type="currentFile.ext"
-            :callback-url="callbackUrl"
-            :data="{ templateId: currentFile.id }"
-            @document-ready="onDocumentReady"
-          />
-          <div class="editor-footer">
-            <span>当前编辑:{{ currentFile.name }}</span>
-            <el-button type="primary" size="small" @click="handleSave">保存</el-button>
-          </div>
-        </div>
-      </el-main>
-    </el-container>
-  </el-container>
+  <div class="onlyoffice-container">
+    <iframe
+      ref="editorIframe"
+      :src="editorUrl"
+      frameborder="0"
+      @load="handleIframeLoad"
+    />
+  </div>
 </template>
 
 <script>
-import OnlyofficeEditor from './OnlyofficeEditor.vue'
-
+import { getCookie } from '@/utils/util.js';
 export default {
-  name: 'TemplateEditor',
-  components: { OnlyofficeEditor },
+  name: 'OnlyofficeWrapper',
   data() {
     return {
-      filterText: '',            // 搜索关键字
-      treeData: [],              // 树数据
-      defaultProps: {
-        children: 'children',
-        label: 'label',
-        isFolder: 'isFolder' // 标识是否为文件夹
-      },
-      currentFile: null,         // 当前选中的文件节点
-      documentUrl: '',           // 传递给编辑器的签名URL
-      editorKey: 0,              // 用于强制刷新编辑器
-      callbackUrl: process.env.VUE_APP_API_BASE + '/api/onlyoffice/callback' // 保存回调地址
-    }
-  },
-  watch: {
-    filterText(val) {
-      this.$refs.tree.filter(val)
-    }
-  },
-  mounted() {
-    this.loadTreeData()
+      editorUrl: 'http://192.168.254.6:8888', // 替换为你的 Vue 3 项目地址
+      isIframeLoaded: false,
+    };
   },
   methods: {
-    // 加载左侧树
-    async loadTreeData() {
-      try {
-        const { data } = await this.getTemplateTree()
-        this.treeData = data
-      } catch (error) {
-        this.$message.error('加载模板树失败')
-      }
-    },
-    getTemplateTree() {
-      return this.axios.get('pass/baseManagement/v1/limsisofileds/getFiletree')
-    },
-    // 树节点过滤
-    filterNode(value, data) {
-      if (!value) return true
-      return data.label.toLowerCase().includes(value.toLowerCase())
-    },
-
-    // 展开所有节点
-    expandAll() {
-      const nodes = this.$refs.tree.store.nodesMap
-      Object.values(nodes).forEach(node => node.expand())
+    handleIframeLoad() {
+      this.isIframeLoaded = true;
+      console.log('编辑器 iframe 已加载');
+      this.sendAuthCookieToIframe();
     },
+    sendAuthCookieToIframe() {
+      if (!this.isIframeLoaded) return;
 
-    // 折叠所有节点
-    collapseAll() {
-      const nodes = this.$refs.tree.store.nodesMap
-      Object.values(nodes).forEach(node => node.collapse())
-    },
-
-    // 点击树节点
-    async handleNodeClick(data) {
-      if (data.isFolder) return // 文件夹不可编辑
-      this.currentFile = {
-        id: data.id,
-        name: data.label,
-        ext: this.getFileExt(data.label),
-        path: "http://192.168.254.22:9002/files/" + data.url // 假设后端返回了文件路径
-      }
+      const accessToken = getCookie('accessToken'); // 假设你有一个获取特定 cookie 的函数
+      const targetOrigin = 'http://192.168.254.6:8888'; // 必须与 editorUrl 的源保持一致
 
-      // 获取签名URL
       try {
-        this.documentUrl = this.currentFile.path
-        console.log('文件访问链接:', this.documentUrl)
+        this.$refs.editorIframe.contentWindow.postMessage(
+          {
+            type: 'AUTH_COOKIE',
+            data: accessToken,
+          },
+          targetOrigin
+        );
+        console.log('已向编辑器发送 accessToken');
       } catch (error) {
-        this.$message.error('获取文件访问链接失败')
+        console.error('向编辑器发送 accessToken 失败:', error);
       }
     },
-
-    // 获取文件扩展名
-    getFileExt(filename) {
-      return filename.split('.').pop().toLowerCase()
-    },
-
-    // 编辑器加载完成事件
-    onDocumentReady() {
-      console.log('编辑器已就绪')
-    },
-
-    // 手动触发保存(可选)
-    handleSave() {
-      // 由于ONLYOFFICE自带保存功能(通过回调),此按钮可保留用于提示
-      this.$message.info('编辑后请稍等,自动保存中...')
-      // 如果需要强制触发ONLYOFFICE的保存,可以调用编辑器实例的方法(如果有)
-      // 但通常自动保存已足够
-    }
-  }
-}
+  },
+};
 </script>
 
 <style scoped>
-.layout-container {
-  height: 100vh;
-}
-.header {
-  background-color: #409EFF;
-  color: white;
-  line-height: 60px;
-  padding-left: 20px;
-}
-.aside-tree {
-  background-color: #f5f7fa;
-  border-right: 1px solid #e6e9ed;
-  padding: 10px;
-  overflow-y: auto;
-}
-.tree-header {
-  display: flex;
-  align-items: center;
-  gap: 8px;
-  margin-bottom: 10px;
-}
-.tree-content {
-  background-color: transparent;
-}
-.custom-tree-node {
-  display: flex;
-  align-items: center;
-  gap: 6px;
-}
-.main-editor {
-  padding: 0;
-  display: flex;
-  flex-direction: column;
-}
-.placeholder {
+.onlyoffice-container {
+  width: 100%;
   height: 100%;
-  display: flex;
-  align-items: center;
-  justify-content: center;
-  color: #909399;
-  font-size: 16px;
 }
-.editor-wrapper {
+iframe {
+  width: 100%;
   height: 100%;
-  display: flex;
-  flex-direction: column;
-}
-.editor-footer {
-  padding: 8px 16px;
-  background-color: #f5f7fa;
-  border-top: 1px solid #e6e9ed;
-  display: flex;
-  justify-content: space-between;
-  align-items: center;
+  border: none;
 }
 </style>