邮件附件预览
continuous-integration/drone/push Build encountered an error Details

uat
wangxiaoshuang 2025-12-16 09:40:36 +08:00
parent 9da598862a
commit 903faf405e
4 changed files with 43 additions and 23 deletions

View File

@ -4,7 +4,7 @@ import Preview from "./index.vue";
const PreviewConstructor = Vue.extend(Preview);
const preview = options => {
const { path, type, title } = options;
const { path, type, title, isLocal = false } = options;
if (!path) throw `path is requred.but ${path}`
const id = `Preview_${new Date().getTime()}`;
const instance = new PreviewConstructor();
@ -12,7 +12,7 @@ const preview = options => {
instance.vm = instance.$mount();
if (instance.vm.visible) return;
document.body.appendChild(instance.vm.$el);
instance.vm.open(path, type, title);
instance.vm.open(path, type, title, isLocal);
instance.vm.$on("closed", () => {
document.body.removeChild(instance.vm.$el);
instance.vm.$destroy();

View File

@ -1,15 +1,8 @@
<template>
<el-dialog
v-if="visible"
:visible.sync="visible"
:title="title"
:fullscreen="true"
append-to-body
custom-class="base-dialog-wrapper"
@close="handleClose"
>
<el-dialog v-if="visible" :visible.sync="visible" :title="title" :fullscreen="true" append-to-body
custom-class="base-dialog-wrapper" @close="handleClose">
<div class="base-modal-body" style="border: 2px solid #ccc; padding: 10px">
<PreviewFile v-if="visible" :file-path="path" :file-type="type" />
<PreviewFile v-if="visible" :file-path="path" :file-type="type" :is-local="isLocal" />
</div>
</el-dialog>
</template>
@ -24,13 +17,15 @@ export default {
path: null,
type: null,
title: null,
isLocal: false
};
},
methods: {
open(path, type, title) {
open(path, type, title, isLocal) {
this.path = path;
this.type = type;
this.title = title;
this.isLocal = isLocal;
this.visible = true;
},
handleClose() {

View File

@ -5,16 +5,17 @@
<!-- <embed v-else-if="fileType.indexOf('pdf') !== -1" :src="filePath+'#toolbar=0'" style="width: 100%; height: 100%"> -->
<!-- <iframe v-else-if="fileType.indexOf('pdf') !== -1" :src="filePath+'#toolbar=0'" width="100%" height="100%" frameborder="0" /> -->
<iframe v-else-if="fileType.indexOf('pdf') !== -1"
:src="`/static/pdfjs/web/viewer.html?file=${OSSclientConfig.basePath}${filePath}?userName=${currentUser}&COMPANY=${COMPANY}`"
:src="`/static/pdfjs/web/viewer.html?file=${isLocal ? window.location.origin : OSSclientConfig.basePath}${filePath}?userName=${currentUser}&COMPANY=${COMPANY}`"
width="100%" height="100%" frameborder="0" crossorigin="anonymous" />
<!-- <pdf-->
<!-- v-else-if="fileType.indexOf('pdf') !== -1"-->
<!-- :src="`/static/pdfjs/web/viewer.html?file=${filePath}`">-->
<!-- </pdf>-->
<video :src="`${OSSclientConfig.basePath}${filePath}`" style="width: 100%;height: 99%;" autoplay controls
controlsList="nodownload" v-else-if="fileType.indexOf('mp4') !== -1"></video>
<video :src="`${isLocal ? window.location.origin : OSSclientConfig.basePath}${filePath}`"
style="width: 100%;height: 99%;" autoplay controls controlsList="nodownload"
v-else-if="fileType.indexOf('mp4') !== -1"></video>
<iframe v-else
:src="`/static/onlyOffice/viewer.html?url=${OSSclientConfig.basePath}${filePath}?onlyOffice_url=${onlyOffice_url}&type=${fileType}&title=${title}&documentType=${documentType}&userName=${currentUser}`"
:src="`/static/onlyOffice/viewer.html?url=${isLocal ? window.location.origin : OSSclientConfig.basePath}${filePath}?onlyOffice_url=${onlyOffice_url}&type=${fileType}&title=${title}&documentType=${documentType}&userName=${currentUser}`"
width="100%" height="100%" frameborder="0" crossorigin="anonymous" />
<!-- <div v-else>
{{ $t('common:message:downloadFile') }}
@ -43,12 +44,17 @@ export default {
type: String,
default: ''
},
isLocal: {
type: Boolean,
default: false
}
},
data() {
return {
currentUser: zzSessionStorage.getItem('userName'),
COMPANY: process.env.VUE_APP_COMPANY_NAME,
onlyOffice_url: process.env.VUE_APP_ONLYOFFICE_URL
onlyOffice_url: process.env.VUE_APP_ONLYOFFICE_URL,
window
}
},
computed: {

View File

@ -125,14 +125,14 @@
<el-table-column v-if="$i18n.locale === 'zh' && isDistinguishCriteria" prop="AttachNameCN"
:label="$t('trials:emailManageCfg:title:fileName')" show-overflow-tooltip min-width="140">
<template slot-scope="scope">
<span v-if="scope.row.AttachCNPath" @click="handlePreview(scope.row.AttachCNPath)"
<span v-if="scope.row.AttachCNPath" @click="handlePreview(scope.row)"
style="cursor: pointer; color: #428bca">{{ scope.row.AttachNameCN }}</span>
</template>
</el-table-column>
<el-table-column v-if="$i18n.locale === 'en' && isDistinguishCriteria" prop="AttachName"
:label="$t('trials:emailManageCfg:title:fileName')" show-overflow-tooltip min-width="140">
<template slot-scope="scope">
<span v-if="scope.row.AttachPath" @click="handlePreview(scope.row.AttachPath)"
<span v-if="scope.row.AttachPath" @click="handlePreview(scope.row)"
style="cursor: pointer; color: #428bca">{{ scope.row.AttachName }}</span>
</template>
</el-table-column>
@ -276,6 +276,9 @@ export default {
(item) => ![4, 7, 8, 31, 32, 21, 26, 27].includes(item.value)
)
},
isEN() {
return this.$i18n.locale !== 'zh'
},
},
mounted() {
this.trialId = this.$route.query.trialId
@ -362,10 +365,26 @@ export default {
this.currentRow = { ...row }
this.editDialog.visible = true
},
handlePreview(filePath) {
if (filePath) {
window.open(this.OSSclientConfig.basePath + filePath, '_blank')
handlePreview(row) {
let name = null, FilePath = null
if (this.isEN) {
name = row.AttachName;
FilePath = row.AttachPath;
} else {
name = row.AttachNameCN;
FilePath = row.AttachCNPath;
}
this.$preview({
path: FilePath,
type: 'docx',
title: name,
isLocal: true
})
// if (filePath) {
// let path = row.Path || row.FullPath || row.FilePath
// window.open(this.OSSclientConfig.basePath + filePath, '_blank')
// }
},
handleSearch() {
this.searchData.PageIndex = 1