master
lion 3 months ago
parent 93e2493c19
commit 3d11e4fd3e

@ -8,11 +8,11 @@
<slot name="searchtype"></slot>
</div>
<div class="dialogConcent" :style="{height:wheight+'px'}">
<vue-office-docx v-if="urlType==='docx'" :src="url" @rendered="renderingCompleted"></vue-office-docx>
<vue-office-pdf v-if="urlType==='pdf'" :src="url" @rendered="renderingCompleted"></vue-office-pdf>
<vue-office-excel v-if="urlType==='excel'" :src="url" @rendered="renderingCompleted"></vue-office-excel>
<iframe v-else id="iframeWin" :src="baseUrl+url" frameborder="0" scrolling="auto" align="center" class="iframeWeb">
<div class="dialogConcent" :class="{'pdf-container': urlType==='pdf', 'excel-container': urlType==='excel'}" :style="{height:wheight+'px'}" v-loading="loading" element-loading-text="文件加载中...">
<vue-office-docx v-if="urlType==='docx' && url" :key="urlKey" :src="url" @rendered="renderingCompleted" @error="handleError"></vue-office-docx>
<vue-office-pdf v-if="urlType==='pdf' && url" :key="urlKey" :src="url" @rendered="renderingCompleted" @error="handleError"></vue-office-pdf>
<vue-office-excel v-if="urlType==='excel' && url" :key="urlKey" :src="url" @rendered="renderingCompleted" @error="handleError"></vue-office-excel>
<iframe v-if="urlType==='others' && url" :key="urlKey" id="iframeWin" :src="baseUrl+url" frameborder="0" scrolling="auto" align="center" class="iframeWeb" @load="iframeLoaded" @error="handleError">
</iframe>
</div>
@ -71,7 +71,10 @@
form:{
show:''
},
urlType:'others'
urlType:'others',
loading: false,
urlKey: 0, //
loadTimer: null //
}
},
watch: {
@ -81,6 +84,11 @@
url(val){
console.log("url",val)
if(val){
//
this.loading = true
//
this.urlKey = Date.now()
if(val.includes('docx')||val.includes('DOCX')){
this.urlType = 'docx'
}else if(val.includes('pdf')||val.includes('PDF')){
@ -91,15 +99,93 @@
this.urlType = 'others'
}
console.log('urltype',this.urlType)
// loading
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
}
this.loadTimer = setTimeout(() => {
if(this.loading) {
console.warn('文件加载超时')
this.loading = false
this.$message.warning('文件加载超时,请检查网络或文件是否存在')
}
}, 30000) // 30
} else {
// url
this.urlType = 'others'
this.loading = false
}
},
diaShow(val) {
// url
if(val && this.url) {
this.urlKey = Date.now()
this.loading = true
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
}
this.loadTimer = setTimeout(() => {
if(this.loading) {
console.warn('文件加载超时')
this.loading = false
this.$message.warning('文件加载超时,请检查网络或文件是否存在')
}
}, 30000)
}
//
if(!val) {
if(this.loadTimer) {
clearTimeout(this.loadTimer)
this.loadTimer = null
}
this.loading = false
}
}
},
methods: {
renderingCompleted(){
console.log("渲染完成")
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
this.loadTimer = null
}
// loading
this.loading = false
},
iframeLoaded(){
console.log("iframe加载完成")
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
this.loadTimer = null
}
// iframe loading
this.loading = false
},
handleError(error) {
console.error("文件加载失败:", error)
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
this.loadTimer = null
}
// loading
this.loading = false
this.$message.error('文件加载失败,请重试')
},
coloseDia() {
// this.url = ""
//
if(this.loadTimer) {
clearTimeout(this.loadTimer)
this.loadTimer = null
}
//
this.urlType = 'others'
this.loading = false
this.diaShow = false
this.$emit('update:isShow', false)
this.$emit('resetform')
@ -114,6 +200,27 @@
}
.dialogConcent {
overflow-y: hidden;
position: relative;
}
.dialogConcent.pdf-container {
overflow-y: auto;
overflow-x: hidden;
}
.dialogConcent.pdf-container /deep/ .vue-office-pdf {
width: 100%;
height: auto;
}
.dialogConcent.excel-container {
overflow-y: auto;
overflow-x: auto;
}
.dialogConcent.excel-container /deep/ .vue-office-excel {
width: 100%;
height: auto;
}
.iframeWeb {

@ -25,7 +25,7 @@ module.exports = {
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin',
outputDir: '/Users/mac/Documents/朗业/2024/h-河道处项目/a-安全生产/safety-manage-service/public/admin_test',
outputDir: '/Users/mac/Documents/朗业/2024/h-河道处项目/a-安全生产/safety-manage-service/public/admin',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,

Loading…
Cancel
Save