Files
laws-sinotruk-client/src/views/documentManage/modules/LibraryDetailFileModal.vue
T

143 lines
4.7 KiB
Vue

<template>
<a-modal
:title="$t('docLibrary.viewFileOne')"
:width="600"
:visible="visible"
:maskClosable="false"
@cancel="visible = false"
>
<template slot="footer">
<a-button key="back" @click="visible = false">
{{$t('cancel')}}
</a-button>
</template>
<a-table
class="table"
:columns="columns"
:pagination="false"
:scroll="{x:500,y: 400}"
:data-source="dataSource"
: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('view')}}
</a>
<a class="text" @click="download(record)">
{{$t('download')}}
</a>
<a class="text" @click="breakdown(record)" v-if="record.splitFlag === 1">
{{$t('docLibrary.standardBreakdown')}}
</a>
</span>
</a-table>
</a-modal>
</template>
<script>
import { getAction, downloadFile } from '@/api/manage'
import { Base64 } from 'js-base64'
export default {
name: 'LibraryDetailFileModal',
data () {
return {
visible: false,
ipagination: {
current: 1,
pageSize: 50,
pageSizeOptions: ['10', '50', '100', '150', '200'],
showTotal: (total, range) => {
return range[0] + '-' + range[1] + ' ' + this.$t('total') + ' ' + total + ' ' + this.$t('strip')
},
showQuickJumper: true,
showSizeChanger: true,
total: 0
},
columns: [
{
title: this.$t('fileName'),
dataIndex: 'fileName',
align: 'left',
width: 260,
ellipsis: true
},
{
title: this.$t('operation'),
align: 'left',
width: 130,
scopedSlots: { customRender: 'fileOperation' }
}
],
dataSource: [],
loading: false
}
},
methods: {
open (item) {
this.visible = true
this.getFileList(item)
},
getFileList (item) {
this.loading = true
this.visibleFile = true
getAction('document/bussDocumentLibraryEO/getFileInfos', { id: item.join(',') }).then((res) => {
if (res.success) {
this.dataSource = res.result
this.dataSource.forEach((val) => {
const fileName = val.fileName
const index1 = fileName.lastIndexOf('.')
const index2 = fileName.length
const fileSuffix = fileName.substring(index1, index2)
val.fileSuffix = fileSuffix
})
} else {
this.dataSource = []
}
}).finally(() => {
this.loading = false
})
},
pdfPreview (fileQuery) {
const fileName = fileQuery.fileName
const index1 = fileName.lastIndexOf('.')
const index2 = fileName.length
const fileSuffix = fileName.substring(index1, index2)
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') {
const url = window._CONFIG.onlinePreviewDomainURL + '?url=' + Base64.encode(this.downLoadFileUrl + '/' + fileQuery.id + fileSuffix)
window.open(url, '_blank')
} else if (fileSuffix === '.xlsx' || fileSuffix === '.xls') {
const 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') {
const 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 })
},
breakdown (item) {
const newUrl = this.$router.resolve({
path: '/docManage/splitting/splitDetail',
query: {
infoId: item.splitInfoId
}
})
window.open(newUrl.href, '_blank')
}
}
}
</script>
<style scoped>
</style>