124 lines
4.5 KiB
Java
124 lines
4.5 KiB
Java
<template>
|
|
<a-modal
|
|
:title="$t('viewFile')"
|
|
:width="600"
|
|
style="z-index: 1007"
|
|
:visible="visibleFile"
|
|
:maskClosable="false"
|
|
@cancel="visibleFile = false;$emit('visible')"
|
|
>
|
|
<template slot="footer">
|
|
<a-button key="back" @click="visibleFile = false;$emit('visible')">
|
|
{{$t('cancel')}}
|
|
</a-button>
|
|
</template>
|
|
<a-table
|
|
class="table"
|
|
:components="drag(columnsFile,'columnsFile')"
|
|
:columns="columnsFile"
|
|
:pagination="false"
|
|
:scroll="{x:500,y: 400}"
|
|
:data-source="dataSourceFile"
|
|
:loading="loading"
|
|
>
|
|
<span slot="fileOperation" slot-scope="record">
|
|
<a class="text" @click="pdfPreview(record)"
|
|
:disabled="record.fileSuffix == '.pdf' || record.fileSuffix == '.docx' || record.fileSuffix == '.doc'
|
|
|| record.fileSuffix == '.jpg' || record.fileSuffix == '.png' || record.fileSuffix == '.gif'
|
|
|| record.fileSuffix == '.jpeg' || record.fileSuffix == '.xlsx' || record.fileSuffix == '.xls' ? false : true">
|
|
{{$t('See')}}
|
|
</a>
|
|
<a class="text" @click="download(record)">
|
|
{{ $t('download') }}
|
|
</a>
|
|
</span>
|
|
</a-table>
|
|
</a-modal>
|
|
</template>
|
|
|
|
<script>
|
|
import { Base64 } from 'js-base64'
|
|
import { getAction, postAction, downloadFile, putAction } from '@/api/manage'
|
|
import { mapGetters } from 'vuex'
|
|
import { ResizeHeader, ResizeColumnProvide } from '@/mixins/header'
|
|
|
|
export default {
|
|
name: 'viewFileModel',
|
|
mixins:[ResizeHeader, ResizeColumnProvide],
|
|
data() {
|
|
return {
|
|
dataSourceFile: [],
|
|
loading: false,
|
|
visibleFile:false,
|
|
downLoadFileUrl: window._CONFIG['domianPreviewURL'] + '/sys/common/download',
|
|
downLoadImgUrl: window._CONFIG['domianWebImgURL'] + '/sys/common/download',
|
|
columnsFile: [
|
|
{
|
|
title: this.$t('fileName'),
|
|
dataIndex: 'fileName',
|
|
align: 'left',
|
|
width: 260,
|
|
ellipsis: true
|
|
},
|
|
{
|
|
title: this.$t('operation'),
|
|
align: 'left',
|
|
width: 130,
|
|
scopedSlots: { customRender: 'fileOperation' }
|
|
}
|
|
]
|
|
}
|
|
},
|
|
methods: {
|
|
...mapGetters(['userInfo']),
|
|
pdfPreview(fileQuery) {
|
|
let fileName = fileQuery.fileName
|
|
let index1 = fileName.lastIndexOf('.')
|
|
let index2 = fileName.length
|
|
let fileSuffix = fileName.substring(index1, index2)
|
|
fileSuffix = fileSuffix.toLowerCase()
|
|
if (fileSuffix == '.pdf') {
|
|
window.open('/pdf/web/viewer.html?file=' + encodeURIComponent('/jero-boot/sys/common/pdf/viewFile?id=' + fileQuery.id+'&userName='+this.userInfo().username))
|
|
} else if (fileSuffix == '.docx' || fileSuffix == '.doc') {
|
|
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
|
|
window.open(url, '_blank')
|
|
} else if (fileSuffix == '.xlsx' || fileSuffix == '.xls') {
|
|
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
|
|
window.open(url, '_blank')
|
|
} else if(fileSuffix == '.png' || fileSuffix == '.jpeg' || fileSuffix == '.gif' || fileSuffix == '.jpg'){
|
|
let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + Base64.encode(this.downLoadImgUrl + '/' + fileQuery.id + fileSuffix)
|
|
window.open(url, '_blank')
|
|
} else {
|
|
downloadFile('/sys/common/downLoadFile', fileQuery.fileName, { id: fileQuery.id })
|
|
}
|
|
},
|
|
download(item) {
|
|
downloadFile('/sys/common/downLoadFile', item.fileName, { id: item.id ,userName:this.userInfo().username})
|
|
},
|
|
clickButtonToUpload(item) {
|
|
this.loading = true
|
|
this.visibleFile = true
|
|
getAction('sys/common/getFileInfos', { id: item }).then((res) => {
|
|
if (res.success) {
|
|
this.dataSourceFile = res.result
|
|
this.dataSourceFile.forEach((val) => {
|
|
let fileName = val.fileName
|
|
let index1 = fileName.lastIndexOf('.')
|
|
let index2 = fileName.length
|
|
let fileSuffix = fileName.substring(index1, index2)
|
|
val.fileSuffix = fileSuffix.toLowerCase()
|
|
})
|
|
this.loading = false
|
|
} else {
|
|
this.dataSourceFile = []
|
|
this.loading = false
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
|
|
</style> |