From c16aa923e265b8d705e0db819999a47be3c3454e Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Mon, 10 Nov 2025 09:46:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E9=9B=86=E6=88=90onlyoffice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 3 +- src/api/common/onlyOfficeViewer.js | 9 ++ src/assets/styles/element-variables.scss | 2 +- src/components/ThemePicker/index.vue | 4 +- src/layout/components/Navbar.vue | 4 +- src/layout/components/Sidebar/Logo.vue | 2 +- src/router/index.js | 16 +- src/utils/request.js | 4 +- .../analysis/components/TestOnlyOffice.vue | 37 +++-- src/views/analysis/index.vue | 146 +++++++++--------- src/views/common/OnlyOfficeViewer.vue | 48 +++--- .../enterprise/components/EnterpriseForm.vue | 4 + .../child/AccountOpeningCertificate.vue | 70 +++++---- .../enterprise/components/child/BasicInfo.vue | 117 ++++++++------ .../components/child/LegalPerson.vue | 99 +++++++----- 16 files changed, 341 insertions(+), 226 deletions(-) diff --git a/.env.development b/.env.development index bb86534..596aa34 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://36.33.26.201:19840' # 路由懒加载 VUE_CLI_BABEL_TRANSPILE_MODULES = true diff --git a/.env.production b/.env.production index e9352a0..d6e6a05 100644 --- a/.env.production +++ b/.env.production @@ -4,6 +4,7 @@ VUE_APP_TITLE = 智能投标系统 # 生产环境配置 ENV = 'production' VUE_APP_ENV = 'production' +VUE_APP_ONLYOFFICE_URL = 'http://36.33.26.201:19840' # 智能投标系统/生产环境 -VUE_APP_BASE_API = '/smart-archiving-api' +VUE_APP_BASE_API = '/smart-bid-api' diff --git a/src/api/common/onlyOfficeViewer.js b/src/api/common/onlyOfficeViewer.js index 7513a80..5b338f1 100644 --- a/src/api/common/onlyOfficeViewer.js +++ b/src/api/common/onlyOfficeViewer.js @@ -7,4 +7,13 @@ export function getConfigAPI(params) { method: 'get', params }) +} + +// 调用后端生成专用 token +export function generateCallbackTokenAPI(params) { + return request({ + url: '/smartBid/documents/handleCallbackToken', + method: 'get', + params + }) } \ No newline at end of file diff --git a/src/assets/styles/element-variables.scss b/src/assets/styles/element-variables.scss index 318c6d0..5596f85 100644 --- a/src/assets/styles/element-variables.scss +++ b/src/assets/styles/element-variables.scss @@ -4,7 +4,7 @@ **/ /* theme color */ -$--color-primary: #006E6B; +$--color-primary: #1E6BFF; $--color-success: #13ce66; $--color-warning: #ffba00; $--color-danger: #ff4949; diff --git a/src/components/ThemePicker/index.vue b/src/components/ThemePicker/index.vue index 7e85ab9..b26091e 100644 --- a/src/components/ThemePicker/index.vue +++ b/src/components/ThemePicker/index.vue @@ -1,14 +1,14 @@ \ No newline at end of file + diff --git a/src/views/analysis/index.vue b/src/views/analysis/index.vue index 17098e5..36b29bb 100644 --- a/src/views/analysis/index.vue +++ b/src/views/analysis/index.vue @@ -2,23 +2,15 @@
- +
- - - + @@ -64,7 +55,7 @@ export default { components: { TableModel, OnlyOfficeViewer, - AnalysisForm + AnalysisForm, }, data() { return { @@ -72,11 +63,14 @@ export default { columnsList, listAPI, sendParams: { - enterpriseId: 2 + enterpriseId: 2, }, showViewer: false, - documentId: '716d9f3d89434c56bc49296dbbccc226', - documentName: 'technicalSolutionDatabase/2025/11/03/716d9f3d89434c56bc49296dbbccc226.docx', + documentUrl: 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/03/716d9f3d89434c56bc49296dbbccc226.docx', + documentTitle: '716d9f3d89434c56bc49296dbbccc226.docx', + documentKey: '716d9f3d89434c56bc49296dbbccc226', + mode: 'edit', + type: 'desktop', // desktop, mobile embedded showAnalysisForm: false, title: '', row: {}, @@ -84,32 +78,40 @@ export default { } }, - created() { - }, + created() { }, methods: { - onViewerLoaded(editor) { - console.log('文档查看器已加载', editor); + handleDocumentReady() { + console.log('文档已准备就绪'); }, - onViewerError(error) { - console.error('文档查看器错误', error); - this.$message.error('加载文档失败'); + handleAppReady() { + console.log('应用已准备就绪'); }, - onDownloadSuccess() { - this.$message.success('文档下载成功'); + handleError(error) { + console.error('发生错误:', error); + this.$message.error('文档加载失败'); }, + handleInitialized(editor) { + console.log('编辑器已初始化', editor); + }, + handleOnlyOffice() { + this.$router.push({ + name: 'TestOnlyOffice', + }) + }, + /** 新增按钮操作 */ handleAdd() { - this.title = "新建项目"; - this.showAnalysisForm = true; + this.title = '新建项目' + this.showAnalysisForm = true }, /** 修改操作 */ handleUpdate(row) { - this.title = "修改项目"; - this.isAdd = 'edit'; - this.row = row; - this.isflag = true; + this.title = '修改项目' + this.isAdd = 'edit' + this.row = row + this.isflag = true }, /* 查看操作 */ @@ -117,8 +119,8 @@ export default { this.$router.push({ name: 'AnalysisDetail', query: { - proId: encryptWithSM4('2') - } + proId: encryptWithSM4('2'), + }, }) }, /** 标段解析操作 */ @@ -126,8 +128,8 @@ export default { this.$router.push({ name: 'AnalysisBidDetail', query: { - proId: encryptWithSM4('2') - } + proId: encryptWithSM4('2'), + }, }) }, /** 查看标段操作 */ @@ -135,8 +137,8 @@ export default { this.$router.push({ name: 'AnalysisBidIndex', query: { - proId: encryptWithSM4('2') - } + proId: encryptWithSM4('2'), + }, }) }, @@ -144,31 +146,35 @@ export default { handleQuery() { this.$refs.analysisTableRef.getTableList() }, - + /** 删除操作 */ handleDelete(row) { - this.$confirm(`确定要删除"${row.toolName}"吗?删除后将无法恢复!`, '操作提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning', - dangerouslyUseHTMLString: true, - customClass: 'delete-confirm-dialog' - }).then(() => { - delDataAPI( - { - toolId: row.toolId, - enterpriseId: this.enterpriseId - } - ).then(res => { - if (res.code === 200) { - this.$message.success('删除成功'); - this.handleQuery(); - } else { - this.$message.error(res.msg || '删除失败'); - } - }).catch(error => { - console.error('删除失败:', error); - }); + this.$confirm( + `确定要删除"${row.toolName}"吗?删除后将无法恢复!`, + '操作提示', + { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', + dangerouslyUseHTMLString: true, + customClass: 'delete-confirm-dialog', + }, + ).then(() => { + delDataAPI({ + toolId: row.toolId, + enterpriseId: this.enterpriseId, + }) + .then((res) => { + if (res.code === 200) { + this.$message.success('删除成功') + this.handleQuery() + } else { + this.$message.error(res.msg || '删除失败') + } + }) + .catch((error) => { + console.error('删除失败:', error) + }) }) }, }, @@ -178,19 +184,17 @@ export default { .analysis-container { height: calc(100vh - 84px); overflow: hidden; - background: linear-gradient(180deg, #F1F6FF 20%, #E5EFFF 100%); + background: linear-gradient(180deg, #f1f6ff 20%, #e5efff 100%); } ::v-deep .table-card { height: calc(100vh - 230px) !important; } - - .add-btn { width: 121px; height: 36px; - background: #1F72EA; + background: #1f72ea; box-shadow: 0px 4px 8px 0px rgba(51, 135, 255, 0.5); border-radius: 4px 4px 4px 4px; color: #fff; @@ -199,7 +203,7 @@ export default { transition: all 0.3s; &:hover { - background: #4A8BFF; + background: #4a8bff; box-shadow: 0px 6px 12px 0px rgba(51, 135, 255, 0.6); } } diff --git a/src/views/common/OnlyOfficeViewer.vue b/src/views/common/OnlyOfficeViewer.vue index 3c02e63..189aa00 100644 --- a/src/views/common/OnlyOfficeViewer.vue +++ b/src/views/common/OnlyOfficeViewer.vue @@ -5,7 +5,7 @@

正在加载文档...

- +
@@ -13,7 +13,7 @@

{{ error }}

- +
@@ -68,6 +68,9 @@ export default { try { this.loading = true; this.error = null; + if(this.docEditor){ + this.destroyEditor(); + } // 先加载配置 await this.getConfig(); // 再初始化 OnlyOffice(成功后会自动设置 loading = false) @@ -90,18 +93,16 @@ export default { try { console.log('开始获取编辑器配置...', { fileId: this.documentKey, - fileName: this.fileName, mode: this.mode, type: this.type }); const res = await getConfigAPI({ fileId: this.documentKey, - fileName: this.fileName, mode: this.mode, type: this.type }); - + console.log('获取配置响应:', res); if (res.code !== 200) { @@ -122,10 +123,10 @@ export default { events: { onDocumentReady: () => this.onDocumentReady(), onError: (error) => this.onEditorError(error), - onAppReady: () => this.onAppReady() + onAppReady: () => this.onAppReady(), } }; - + this.configReady = true; console.log('编辑器配置准备完成:', this.editorConfig); @@ -153,7 +154,7 @@ export default { // 等待 DOM 准备好 await this.$nextTick(); - + // 初始化编辑器 await this.initDocEditor(); } catch (error) { @@ -191,12 +192,12 @@ export default { const script = document.createElement('script'); // onlyOfficeUrl 是 OnlyOffice 服务地址 const onlyOfficeUrl = process.env.VUE_APP_ONLYOFFICE_URL || process.env.VUE_APP_BASE_API || ''; - + if (!onlyOfficeUrl) { reject(new Error('OnlyOffice 服务地址未配置,请检查环境变量 VUE_APP_ONLYOFFICE_URL')); return; } - + const scriptUrl = `${onlyOfficeUrl}/web-apps/apps/api/documents/api.js`; console.log('加载 OnlyOffice 脚本,URL:', scriptUrl); script.src = scriptUrl; @@ -239,7 +240,7 @@ export default { // 验证容器元素(容器可能被 v-show 隐藏,但 DOM 中应该存在) await this.$nextTick(); let container = document.getElementById('placeholder'); - + // 如果容器不存在,等待一下再试 if (!container) { console.warn('容器元素不存在,等待 DOM 渲染...'); @@ -247,7 +248,7 @@ export default { await this.$nextTick(); container = document.getElementById('placeholder'); } - + if (!container) { throw new Error('找不到编辑器容器元素 #placeholder,请确保容器已正确渲染'); } @@ -269,7 +270,7 @@ export default { if (container.offsetWidth === 0 || container.offsetHeight === 0) { console.warn('容器尺寸为0,等待尺寸调整...'); await new Promise(resolve => setTimeout(resolve, 300)); - + if (container.offsetWidth === 0 || container.offsetHeight === 0) { console.warn('容器尺寸仍为0,但继续尝试创建编辑器'); } @@ -277,15 +278,15 @@ export default { try { console.log('创建 OnlyOffice 编辑器,配置:', this.editorConfig); - + // 清空容器 container.innerHTML = ''; - + // 创建编辑器实例 this.docEditor = new window.DocsAPI.DocEditor('placeholder', this.editorConfig); - + console.log('编辑器实例创建成功:', this.docEditor); - + // 编辑器创建成功,隐藏加载状态 this.loading = false; this.$emit('initialized', this.docEditor); @@ -331,9 +332,9 @@ export default { * 销毁编辑器 */ destroyEditor() { - if (this.docEditor && typeof this.docEditor.destroy === 'function') { + if (this.docEditor) { try { - this.docEditor.destroy(); + this.docEditor.destroyEditor() } catch (error) { console.warn('销毁编辑器时出错:', error); } @@ -431,8 +432,13 @@ export default { } @keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } + 0% { + transform: rotate(0deg); + } + + 100% { + transform: rotate(360deg); + } } .error-icon { diff --git a/src/views/enterpriseLibrary/enterprise/components/EnterpriseForm.vue b/src/views/enterpriseLibrary/enterprise/components/EnterpriseForm.vue index 5a11f3c..64bcb8c 100644 --- a/src/views/enterpriseLibrary/enterprise/components/EnterpriseForm.vue +++ b/src/views/enterpriseLibrary/enterprise/components/EnterpriseForm.vue @@ -16,10 +16,14 @@ + + + + diff --git a/src/views/enterpriseLibrary/enterprise/components/child/AccountOpeningCertificate.vue b/src/views/enterpriseLibrary/enterprise/components/child/AccountOpeningCertificate.vue index 95fec78..fbe192e 100644 --- a/src/views/enterpriseLibrary/enterprise/components/child/AccountOpeningCertificate.vue +++ b/src/views/enterpriseLibrary/enterprise/components/child/AccountOpeningCertificate.vue @@ -4,18 +4,33 @@ 开户证明 开户证明 - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + @@ -24,18 +39,18 @@ import UploadFile from '@/views/common/UploadFile.vue' export default { name: 'AccountOpeningCertificate', - components:{UploadFile}, + components: { UploadFile }, dicts: ['identification_tag'], - props:{ + props: { detailData: { type: Object, - default: () => {} + default: () => { } } }, data() { return { form: { - fileList:[], + fileList: [], openingBank: '', openingAccount: '', delFileList: [] @@ -50,7 +65,7 @@ export default { "开户账号": "openingAccount", }, rules: { - fileList:[ + fileList: [ { required: true, message: '请上传开户许可证', trigger: 'change' } ], openingBank: [ @@ -59,7 +74,7 @@ export default { openingAccount: [ { required: true, message: '请输入开户账号', trigger: 'blur' } ], - + } } @@ -120,11 +135,11 @@ export default { handleDelFile(file) { console.log(file); const delPath = file?.response?.fileRes?.filePath || file?.filePath || null; - if(delPath){ + if (delPath) { this.form.delFileList.push(delPath); } }, - setFormData(){ + setFormData() { const fileList = this.getFileList('account_opening_license'); this.form = { fileList: fileList, @@ -133,13 +148,13 @@ export default { delFileList: [] } }, - getFileList(businessType){ + getFileList(businessType) { return this.detailData.fileList.filter(item => item.businessType === businessType).map(item => { return { name: item.fileName, filePath: item.filePath, - lsFilePath:item.lsFilePath, - fileType:item.fileType + lsFilePath: item.lsFilePath, + fileType: item.fileType }; }); } @@ -159,17 +174,17 @@ export default { }, immediate: true // 立即执行一次 }, - detailData:{ + detailData: { handler(newVal) { if (Object.keys(newVal).length > 0) { this.setFormData(); } }, immediate: true, // 立即执行一次 - deep:true + deep: true } }, - + } @@ -178,7 +193,8 @@ export default { display: flex; align-items: center; margin: 10px 0; - span{ + + span { margin: 0 5px; font-size: 20px; } diff --git a/src/views/enterpriseLibrary/enterprise/components/child/BasicInfo.vue b/src/views/enterpriseLibrary/enterprise/components/child/BasicInfo.vue index b79f25c..cc223da 100644 --- a/src/views/enterpriseLibrary/enterprise/components/child/BasicInfo.vue +++ b/src/views/enterpriseLibrary/enterprise/components/child/BasicInfo.vue @@ -5,39 +5,62 @@ 基本信息 - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -50,10 +73,10 @@ export default { components: { UploadFile }, - props:{ + props: { detailData: { type: Object, - default: () => {} + default: () => { } } }, dicts: ['identification_tag'], @@ -146,7 +169,7 @@ export default { // 文件变化 handleFileChange(file) { console.log(file); - + this.form.fileList = file; if (file instanceof Array && file.length > 0 && file[0].response) { const response = file[0].response; @@ -175,14 +198,14 @@ export default { handleDelFile(file) { console.log(file); const delPath = file?.response?.fileRes?.filePath || file?.filePath || null; - if(delPath){ + if (delPath) { this.form.delFileList.push(delPath); } }, - setFormData(){ - const fileList = this.getFileList('business_license'); - - this.form = { + setFormData() { + const fileList = this.getFileList('business_license'); + + this.form = { enterpriseName: this.detailData.enterpriseName || '', enterpriseCode: this.detailData.enterpriseCode || '', registeredCapital: this.detailData.registeredCapital || '', @@ -194,17 +217,17 @@ export default { delFileList: [] } }, - getFileList(businessType){ + getFileList(businessType) { return this.detailData.fileList.filter(item => item.businessType === businessType).map(item => { return { name: item.fileName, filePath: item.filePath, - lsFilePath:item.lsFilePath, - fileType:item.fileType + lsFilePath: item.lsFilePath, + fileType: item.fileType }; }); } - + }, computed: { fileUploadRule() { @@ -221,14 +244,14 @@ export default { }, immediate: true // 立即执行一次 }, - detailData:{ + detailData: { handler(newVal) { if (Object.keys(newVal).length > 0) { this.setFormData(); } }, immediate: true, // 立即执行一次 - deep:true + deep: true } }, } diff --git a/src/views/enterpriseLibrary/enterprise/components/child/LegalPerson.vue b/src/views/enterpriseLibrary/enterprise/components/child/LegalPerson.vue index 3c67f2a..87d9d10 100644 --- a/src/views/enterpriseLibrary/enterprise/components/child/LegalPerson.vue +++ b/src/views/enterpriseLibrary/enterprise/components/child/LegalPerson.vue @@ -5,46 +5,73 @@ 法人信息 - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +