diff --git a/.env.development b/.env.development index 64c763e..bb86534 100644 --- a/.env.development +++ b/.env.development @@ -8,7 +8,7 @@ VUE_APP_ENV = 'development' # 智能投标系统/开发环境 VUE_APP_BASE_API = '/dev-api' -VUE_APP_ONLYOFFICE_URL = 'http://192.168.0.14:19840/' +VUE_APP_ONLYOFFICE_URL = 'http://192.168.0.14:19840' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/src/views/analysis/components/AnalysisForm.vue b/src/views/analysis/components/AnalysisForm.vue new file mode 100644 index 0000000..47ea3d4 --- /dev/null +++ b/src/views/analysis/components/AnalysisForm.vue @@ -0,0 +1,292 @@ + + + \ No newline at end of file diff --git a/src/views/analysis/index.vue b/src/views/analysis/index.vue index 14ce8ee..9a49b15 100644 --- a/src/views/analysis/index.vue +++ b/src/views/analysis/index.vue @@ -34,6 +34,9 @@ :allow-download="true" @close="showViewer = false" @loaded="onViewerLoaded" @error="onViewerError" @download-success="onDownloadSuccess" /> + + @@ -42,11 +45,13 @@ import TableModel from '@/components/TableModel2' import { columnsList, formLabel } from './config' import { listAPI, delDataAPI } from '@/api/analysis/analysis' import OnlyOfficeViewer from '@/views/common/OnlyOfficeViewer.vue' +import AnalysisForm from './components/AnalysisForm.vue' export default { name: 'Tool', components: { TableModel, OnlyOfficeViewer, + AnalysisForm }, data() { return { @@ -55,7 +60,11 @@ export default { listAPI, showViewer: false, documentId: '716d9f3d89434c56bc49296dbbccc226', - documentName: 'technicalSolutionDatabase/2025/11/03/716d9f3d89434c56bc49296dbbccc226.docx' + documentName: 'technicalSolutionDatabase/2025/11/03/716d9f3d89434c56bc49296dbbccc226.docx', + showAnalysisForm: false, + title: '', + isAdd: '', + row: {}, } }, @@ -75,15 +84,14 @@ export default { }, /** 新增按钮操作 */ handleAdd() { - this.title = "新增工器具"; + this.title = "新建项目"; this.isAdd = 'add'; - this.row = { enterpriseId: this.enterpriseId }; - this.isflag = true; + this.showAnalysisForm = true; }, /** 修改操作 */ handleUpdate(row) { - this.title = "修改工器具"; + this.title = "修改项目"; this.isAdd = 'edit'; this.row = row; this.isflag = true; diff --git a/src/views/common/OnlyOfficeViewer.vue b/src/views/common/OnlyOfficeViewer.vue index 72f0388..2d79eb5 100644 --- a/src/views/common/OnlyOfficeViewer.vue +++ b/src/views/common/OnlyOfficeViewer.vue @@ -39,8 +39,8 @@ -
+
@@ -124,11 +124,16 @@ export default { return '100vh'; } // 工具栏高度约48px,减去后计算容器高度 + if (this.height.includes('vh')) { + // 如果是vh单位,直接计算 + const vhValue = parseFloat(this.height); + return `calc(${vhValue}vh - 48px)`; + } const heightValue = parseInt(this.height); if (isNaN(heightValue)) { return 'calc(100% - 48px)'; } - return `${heightValue - 48}px`; + return `${Math.max(heightValue - 48, 200)}px`; // 最小高度200px } }, @@ -165,6 +170,21 @@ export default { // 获取编辑器配置 this.loadingText = '正在获取文档配置...'; const config = await this.getEditorConfig(); + console.log('OnlyOffice 配置:', config); + + // 验证配置格式 + if (!config || typeof config !== 'object') { + throw new Error('获取的配置格式不正确'); + } + + // 验证必要的配置项 + if (!config.document || !config.document.url) { + throw new Error('配置中缺少文档URL'); + } + + if (!config.documentType) { + console.warn('配置中缺少 documentType,将尝试自动检测'); + } // 创建编辑器实例 if (!window.DocsAPI) { @@ -172,13 +192,72 @@ export default { } this.loadingText = '正在初始化编辑器...'; - this.editor = new window.DocsAPI.DocEditor( - this.$refs.editorContainer, - config - ); - this.loading = false; - this.$emit('loaded', this.editor); + // 确保容器有正确的尺寸 + const container = this.$refs.editorContainer; + if (container) { + // 确保容器可见 + container.style.display = 'block'; + container.style.width = '100%'; + + // 等待下一个tick确保DOM已更新 + await this.$nextTick(); + + // 验证容器尺寸 + const rect = container.getBoundingClientRect(); + if (rect.width === 0 || rect.height === 0) { + console.warn('容器尺寸为0,等待尺寸调整...', rect); + // 等待一段时间再初始化 + await new Promise(resolve => setTimeout(resolve, 500)); + } + } + + // 创建编辑器实例 + try { + this.editor = new window.DocsAPI.DocEditor( + this.$refs.editorContainer, + config + ); + + // 监听编辑器事件(如果存在) + if (this.editor && this.editor.events) { + // 等待编辑器准备就绪 + this.editor.events.on('onDocumentReady', () => { + console.log('OnlyOffice 文档已准备就绪'); + this.loading = false; + }); + + this.editor.events.on('onAppReady', () => { + console.log('OnlyOffice 应用已准备就绪'); + // 应用准备就绪后,可以隐藏加载状态 + setTimeout(() => { + if (this.loading) { + this.loading = false; + } + }, 1000); + }); + + this.editor.events.on('onError', (error) => { + console.error('OnlyOffice 错误:', error); + this.handleError(`编辑器错误: ${error?.data || error?.message || '未知错误'}`); + }); + } + + // 设置超时,防止一直加载 + setTimeout(() => { + if (this.loading) { + this.loading = false; + console.warn('编辑器初始化超时,但可能仍在加载中'); + } + }, 30000); // 30秒超时 + + // 默认设置加载完成 + this.loading = false; + this.$emit('loaded', this.editor); + } catch (editorError) { + console.error('创建编辑器实例失败:', editorError); + throw new Error(`创建编辑器失败: ${editorError.message}`); + } } catch (error) { console.error('初始化文档查看器失败:', error); const errorMsg = error?.message || error?.response?.data?.msg || '加载文档失败,请重试'; @@ -608,6 +687,17 @@ export default { position: relative; transition: all 0.3s ease; background: #f5f5f5; + min-height: 200px; + display: block !important; + /* 确保容器始终显示 */ + + /* 确保 OnlyOffice iframe 正确显示 */ + ::v-deep iframe { + width: 100% !important; + height: 100% !important; + border: none; + display: block; + } } .editor-container.fullscreen { diff --git a/src/views/enterpriseLibrary/tool/components/ToolForm.vue b/src/views/enterpriseLibrary/tool/components/ToolForm.vue index 7901dc8..eb99f98 100644 --- a/src/views/enterpriseLibrary/tool/components/ToolForm.vue +++ b/src/views/enterpriseLibrary/tool/components/ToolForm.vue @@ -72,9 +72,9 @@ export default { dialogVisible: true, defaultParams, form: { - id: null, + toolId: null, enterpriseId: this.rowData.enterpriseId, - technicalSolutionName: '', + toolName: '', model: '', unit: '', technicalParameters: '', @@ -188,10 +188,14 @@ export default { /**重置表单*/ reset() { this.form = { - id: null, - pid: null, - dataTypeName: '', + toolName: '', + model: '', + unit: '', + technicalParameters: '', + mainFunction: '', remark: '', + fileList: [], + delFileList: [] }; this.resetForm("ruleForm"); },