招标解析

This commit is contained in:
cwchen 2025-11-27 17:39:50 +08:00
parent f591ac9298
commit 941a95ae56
4 changed files with 222 additions and 139 deletions

View File

@ -1,50 +1,22 @@
<!-- 文档预览面板 --> <!-- 文档预览面板 -->
<template> <template>
<div class="document-preview-panel"> <div class="document-preview-panel">
<div class="panel-header">
<div class="header-actions">
<el-button
type="text"
icon="el-icon-search"
class="search-btn"
@click="handleSearch"
></el-button>
</div>
<div class="document-switch">
<el-button
:type="activeDocType === 'tender' ? 'primary' : 'default'"
class="doc-btn"
@click="switchDocument('tender')"
>
招标文件
</el-button>
<el-button
:type="activeDocType === 'bid' ? 'primary' : 'default'"
class="doc-btn"
@click="switchDocument('bid')"
>
标段文件
</el-button>
</div>
</div>
<div class="panel-content"> <div class="panel-content">
<div v-if="documentUrl" class="document-viewer"> <div v-if="currentDocument" class="document-viewer">
<OnlyOfficeViewer <div v-if="currentDocument.type === 'pdf'" class="embedded-viewer">
v-if="showOnlyOffice" <DocumentSearch :file-url="currentDocument.url" />
:document-url="documentUrl" </div>
:document-title="documentTitle" <div v-else-if="currentDocument.type === 'word'" class="embedded-viewer">
:document-key="documentKey" <DocumentSearchWord :file-url="currentDocument.url" />
:mode="viewMode" </div>
:type="viewType" <div v-else-if="currentDocument.type === 'excel'" class="embedded-viewer">
@document-ready="handleDocumentReady" <DocumentExcel :file-url="currentDocument.url" />
@app-ready="handleAppReady" </div>
@error="handleError"
/>
<div v-else class="document-placeholder"> <div v-else class="document-placeholder">
<div class="placeholder-content"> <div class="placeholder-content">
<i class="el-icon-document placeholder-icon"></i> <i class="el-icon-document placeholder-icon"></i>
<p class="placeholder-text">文档预览</p> <p class="placeholder-text">暂不支持的文件类型</p>
<p class="placeholder-desc">{{ documentTitle || '暂无文档' }}</p> <p class="placeholder-desc">{{ currentDocument.title || currentDocument.url }}</p>
</div> </div>
</div> </div>
</div> </div>
@ -57,50 +29,71 @@
</template> </template>
<script> <script>
import OnlyOfficeViewer from '@/views/common/OnlyOfficeViewer.vue' import DocumentSearch from '@/views/common/DocumentSearch.vue'
import DocumentSearchWord from '@/views/common/DocumentSearchWord.vue'
import DocumentExcel from '@/views/common/DocumentExcel.vue'
const WORD_EXTS = ['.doc', '.docx']
const PDF_EXTS = ['.pdf']
const EXCEL_EXTS = ['.xls', '.xlsx', '.csv', '.xlsm']
const DEFAULT_DOCUMENTS = [
{
id: 'sample-pdf',
title: '示例 PDF 文档',
url: 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/10/30/fe5b46ea37554516a71e7c0c486d3715.pdf',
type: 'pdf'
},
{
id: 'sample-excel',
title: '示例 Excel 文档',
url: 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/12/928206a2fdc74c349781f441d9c010f8.xlsx',
type: 'excel'
},
{
id: 'sample-word',
title: '示例 Word 文档',
url: 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/11/11/887b35d28b2149b6a7555fb639be9411.docx',
type: 'word'
}
]
export default { export default {
name: 'DocumentPreviewPanel', name: 'DocumentPreviewPanel',
components: { components: {
OnlyOfficeViewer DocumentSearch,
DocumentSearchWord,
DocumentExcel
}, },
props: { props: {
// URL
tenderDocumentUrl: { tenderDocumentUrl: {
type: String, type: String,
default: '' default: ''
}, },
//
tenderDocumentTitle: { tenderDocumentTitle: {
type: String, type: String,
default: '' default: ''
}, },
// Key
tenderDocumentKey: { tenderDocumentKey: {
type: String, type: String,
default: '' default: ''
}, },
// URL
bidDocumentUrl: { bidDocumentUrl: {
type: String, type: String,
default: '' default: ''
}, },
//
bidDocumentTitle: { bidDocumentTitle: {
type: String, type: String,
default: '' default: ''
}, },
// Key
bidDocumentKey: { bidDocumentKey: {
type: String, type: String,
default: '' default: ''
}, },
//
viewMode: { viewMode: {
type: String, type: String,
default: 'view' default: 'view'
}, },
//
viewType: { viewType: {
type: String, type: String,
default: 'desktop' default: 'desktop'
@ -108,50 +101,74 @@ export default {
}, },
data() { data() {
return { return {
activeDocType: 'tender', // 'tender' 'bid' documents: [],
showOnlyOffice: false currentIndex: -1
} }
}, },
computed: { computed: {
documentUrl() { currentDocument() {
return this.activeDocType === 'tender' ? this.tenderDocumentUrl : this.bidDocumentUrl return this.documents[this.currentIndex] || null
},
documentTitle() {
return this.activeDocType === 'tender' ? this.tenderDocumentTitle : this.bidDocumentTitle
},
documentKey() {
return this.activeDocType === 'tender' ? this.tenderDocumentKey : this.bidDocumentKey
} }
}, },
created() {
this.buildDocuments()
},
watch: { watch: {
documentUrl(newVal) { tenderDocumentUrl() {
if (newVal) { this.buildDocuments()
this.showOnlyOffice = true },
} bidDocumentUrl() {
this.buildDocuments()
} }
}, },
methods: { methods: {
switchDocument(type) {
this.activeDocType = type
this.showOnlyOffice = false
this.$nextTick(() => {
if (this.documentUrl) {
this.showOnlyOffice = true
}
})
this.$emit('document-switch', type)
},
handleSearch() { handleSearch() {
this.$emit('search') this.$emit('search')
}, },
handleDocumentReady() {
this.$emit('document-ready')
},
handleAppReady() {
this.$emit('app-ready')
},
handleError(error) { handleError(error) {
this.$emit('error', error) this.$emit('error', error)
},
resolveViewerType(url, title) {
const value = (url || title || '').toLowerCase()
if (!value) {
return 'none'
}
if (PDF_EXTS.some(ext => value.includes(ext))) {
return 'pdf'
}
if (WORD_EXTS.some(ext => value.includes(ext))) {
return 'word'
}
if (EXCEL_EXTS.some(ext => value.includes(ext))) {
return 'excel'
}
return 'unsupported'
},
buildDocuments() {
const docs = []
if (this.tenderDocumentUrl) {
docs.push({
id: 'tender',
title: this.tenderDocumentTitle || '招标文件',
url: this.tenderDocumentUrl,
type: this.resolveViewerType(this.tenderDocumentUrl, this.tenderDocumentTitle)
})
}
if (this.bidDocumentUrl) {
docs.push({
id: 'bid',
title: this.bidDocumentTitle || '标段文件',
url: this.bidDocumentUrl,
type: this.resolveViewerType(this.bidDocumentUrl, this.bidDocumentTitle)
})
}
if (!docs.length) {
DEFAULT_DOCUMENTS.forEach(doc => docs.push({ ...doc }))
}
this.documents = docs
this.currentIndex = docs.length ? 0 : -1
const current = this.currentDocument
this.$emit('document-switch', current?.id || 'none')
} }
} }
} }
@ -168,7 +185,7 @@ export default {
.panel-header { .panel-header {
display: flex; display: flex;
justify-content: space-between; justify-content: flex-end;
align-items: center; align-items: center;
padding: 12px 20px; padding: 12px 20px;
border-bottom: 1px solid #EBEEF5; border-bottom: 1px solid #EBEEF5;
@ -185,35 +202,6 @@ export default {
} }
} }
} }
.document-switch {
display: flex;
gap: 8px;
.doc-btn {
padding: 8px 16px;
font-size: 14px;
border-radius: 4px;
transition: all 0.3s;
&.el-button--primary {
background: #409EFF;
border-color: #409EFF;
}
&.el-button--default {
background: #F5F7FA;
border-color: #DCDFE6;
color: #606266;
&:hover {
background: #ECF5FF;
border-color: #B3D8FF;
color: #409EFF;
}
}
}
}
} }
.panel-content { .panel-content {
@ -225,9 +213,25 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
::v-deep .onlyoffice-container { .embedded-viewer {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex;
flex-direction: column;
}
::v-deep .embedded-viewer .document-search,
::v-deep .embedded-viewer .document-search-word,
::v-deep .embedded-viewer .document-excel {
height: 100%;
padding: 0;
background: transparent;
box-sizing: border-box;
}
::v-deep .embedded-viewer .viewer-container {
min-height: auto;
border-radius: 0;
} }
} }

View File

@ -32,6 +32,12 @@ const DEFAULT_EXCEL_URL = 'http://192.168.0.14:9090/smart-bid/technicalSolutionD
export default { export default {
name: 'DocumentExcel', name: 'DocumentExcel',
props: {
fileUrl: {
type: String,
default: ''
}
},
data() { data() {
return { return {
loading: false, loading: false,
@ -43,20 +49,27 @@ export default {
}, },
computed: { computed: {
routeExcelUrl() { routeExcelUrl() {
return this.$route.query.url || this.$route.params.url; return this.$route?.query?.url || this.$route?.params?.url || ''
} }
}, },
watch: { watch: {
fileUrl: {
immediate: true,
handler(newVal) {
if (newVal) {
this.applyExcelUrl(newVal)
} else if (!this.excelUrl && !this.routeExcelUrl) {
this.applyExcelUrl(DEFAULT_EXCEL_URL)
}
}
},
routeExcelUrl: { routeExcelUrl: {
immediate: true, immediate: true,
handler(newUrl) { handler(newVal) {
if (newUrl) { if (this.fileUrl) return
this.excelUrl = newUrl; const target = newVal || DEFAULT_EXCEL_URL
this.loadExcel(); if (target && target !== this.excelUrl) {
} else { this.applyExcelUrl(target)
// URL使URL
this.excelUrl = DEFAULT_EXCEL_URL;
this.loadExcel();
} }
} }
} }
@ -69,6 +82,17 @@ export default {
this.destroyLuckySheet(); this.destroyLuckySheet();
}, },
methods: { methods: {
applyExcelUrl(url) {
if (!url || url === this.excelUrl) {
this.excelUrl = url
if (url) {
this.loadExcel()
}
return
}
this.excelUrl = url
this.loadExcel()
},
// Excel // Excel
async loadExcel() { async loadExcel() {
if (!this.excelUrl) { if (!this.excelUrl) {
@ -329,7 +353,7 @@ export default {
<style scoped> <style scoped>
.document-excel { .document-excel {
height: 90vh; height: 100%;
background: #f5f5f5; background: #f5f5f5;
} }

View File

@ -66,9 +66,16 @@ if (resolvedWorkerSrc) {
} }
const DEFAULT_SCALE = 1 const DEFAULT_SCALE = 1
const DEFAULT_PDF_URL = 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/10/30/fe5b46ea37554516a71e7c0c486d3715.pdf'
export default { export default {
name: 'DocumentSearch', name: 'DocumentSearch',
props: {
fileUrl: {
type: String,
default: ''
}
},
computed: { computed: {
overlayType() { overlayType() {
if (this.loading) { if (this.loading) {
@ -135,9 +142,9 @@ export default {
} }
} }
this.pdfUrl = this.$route.query.url || 'http://192.168.0.14:9090/smart-bid/technicalSolutionDatabase/2025/10/30/fe5b46ea37554516a71e7c0c486d3715.pdf' if (!this.pdfUrl) {
if (this.pdfUrl) { const initialUrl = this.fileUrl || this.$route?.query?.url || DEFAULT_PDF_URL
this.loadDocument() this.applyPdfUrl(initialUrl)
} }
}, },
beforeDestroy() { beforeDestroy() {
@ -145,17 +152,38 @@ export default {
this.cancelScrollAnimation() this.cancelScrollAnimation()
}, },
watch: { watch: {
'$route.query.url'(newUrl, oldUrl) { fileUrl: {
if (newUrl !== oldUrl) { immediate: true,
this.pdfUrl = newUrl || '' handler(newVal) {
this.resetViewerState() if (newVal) {
if (this.pdfUrl) { this.applyPdfUrl(newVal)
this.loadDocument()
} }
} }
}, },
'$route.query.url'(newUrl, oldUrl) {
if (this.fileUrl) return
if (newUrl !== oldUrl) {
const target = newUrl || DEFAULT_PDF_URL
this.applyPdfUrl(target)
}
},
}, },
methods: { methods: {
applyPdfUrl(url) {
const resolved = url || ''
if (resolved === this.pdfUrl) {
if (resolved) {
this.loadDocument()
}
return
}
this.pdfUrl = resolved
if (this.pdfUrl) {
this.loadDocument()
} else {
this.resetViewerState()
}
},
async loadDocument() { async loadDocument() {
if (!this.pdfUrl) return if (!this.pdfUrl) return
this.loading = true this.loading = true

View File

@ -53,6 +53,12 @@ const DEFAULT_DOC_URL = 'http://192.168.0.14:9090/smart-bid/technicalSolutionDat
export default { export default {
name: 'DocumentSearchWord', name: 'DocumentSearchWord',
props: {
fileUrl: {
type: String,
default: ''
}
},
data() { data() {
return { return {
docUrl: '', docUrl: '',
@ -69,9 +75,9 @@ export default {
} }
}, },
mounted() { mounted() {
this.docUrl = this.$route.query.url || DEFAULT_DOC_URL if (!this.docUrl) {
if (this.docUrl) { const initialUrl = this.fileUrl || this.$route?.query?.url || DEFAULT_DOC_URL
this.loadDocument() this.applyDocUrl(initialUrl)
} }
}, },
beforeDestroy() { beforeDestroy() {
@ -79,17 +85,38 @@ export default {
this.cancelScrollAnimation() this.cancelScrollAnimation()
}, },
watch: { watch: {
'$route.query.url'(newUrl, oldUrl) { fileUrl: {
if (newUrl !== oldUrl) { immediate: true,
this.docUrl = newUrl || DEFAULT_DOC_URL handler(newVal) {
this.resetViewerState() if (newVal) {
if (this.docUrl) { this.applyDocUrl(newVal)
this.loadDocument()
} }
} }
}, },
'$route.query.url'(newUrl, oldUrl) {
if (this.fileUrl) return
if (newUrl !== oldUrl) {
const target = newUrl || DEFAULT_DOC_URL
this.applyDocUrl(target)
}
},
}, },
methods: { methods: {
applyDocUrl(url) {
const resolved = url || ''
if (resolved === this.docUrl) {
if (resolved) {
this.loadDocument()
}
return
}
this.docUrl = resolved
if (this.docUrl) {
this.loadDocument()
} else {
this.resetViewerState()
}
},
cancelFetch() { cancelFetch() {
if (this.abortController) { if (this.abortController) {
this.abortController.abort() this.abortController.abort()