邮件附件预览
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 PreviewConstructor = Vue.extend(Preview);
const preview = options => { const preview = options => {
const { path, type, title } = options; const { path, type, title, isLocal = false } = options;
if (!path) throw `path is requred.but ${path}` if (!path) throw `path is requred.but ${path}`
const id = `Preview_${new Date().getTime()}`; const id = `Preview_${new Date().getTime()}`;
const instance = new PreviewConstructor(); const instance = new PreviewConstructor();
@ -12,7 +12,7 @@ const preview = options => {
instance.vm = instance.$mount(); instance.vm = instance.$mount();
if (instance.vm.visible) return; if (instance.vm.visible) return;
document.body.appendChild(instance.vm.$el); document.body.appendChild(instance.vm.$el);
instance.vm.open(path, type, title); instance.vm.open(path, type, title, isLocal);
instance.vm.$on("closed", () => { instance.vm.$on("closed", () => {
document.body.removeChild(instance.vm.$el); document.body.removeChild(instance.vm.$el);
instance.vm.$destroy(); instance.vm.$destroy();

View File

@ -1,15 +1,8 @@
<template> <template>
<el-dialog <el-dialog v-if="visible" :visible.sync="visible" :title="title" :fullscreen="true" append-to-body
v-if="visible" custom-class="base-dialog-wrapper" @close="handleClose">
: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"> <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> </div>
</el-dialog> </el-dialog>
</template> </template>
@ -24,13 +17,15 @@ export default {
path: null, path: null,
type: null, type: null,
title: null, title: null,
isLocal: false
}; };
}, },
methods: { methods: {
open(path, type, title) { open(path, type, title, isLocal) {
this.path = path; this.path = path;
this.type = type; this.type = type;
this.title = title; this.title = title;
this.isLocal = isLocal;
this.visible = true; this.visible = true;
}, },
handleClose() { handleClose() {

View File

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

View File

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