Files
income_payments_enterprise_…/src/views/MessagePage/modules/UnderStudyFilesModal.vue
T
2023-10-11 16:05:04 +08:00

127 lines
3.5 KiB
Vue

<template>
<j-modal
:title="title"
:width="width"
:visible="visible"
:confirmLoading="confirmLoading"
switchFullscreen
@cancel="handleCancel"
cancelText="关闭">
<!-- table表格区域-->
<div>
<a-table
ref="table"
size="middle"
:rowKey="record => record.FILE_ID"
bordered
:columns="columns"
:dataSource="dataSource"
:pagination="false"
:loading="confirmLoading"
class="j-table-force-nowrap">
<template slot="text" slot-scope="text">
<j-ellipsis :value="text" :length="18"></j-ellipsis>
</template>
<!-- 时间戳转时间-->
<template slot="time" slot-scope="text">
<j-ellipsis :value="text.toString().indexOf('-') === -1 ? processingTimestamp(text) : text" :length="20"></j-ellipsis>
</template>
<!-- 操作-->
<span slot="action" class="action-span-cell" slot-scope="text, record">
<a @click="handleDownload(record)">下载</a>
<a @click="handlePreview(record)">查看</a>
</span>
</a-table>
</div>
<template slot="footer">
<a-button key="back" @click="handleCancel">关闭</a-button>
</template>
</j-modal>
</template>
<script>
import { downloadFile } from '@api/manage'
import Vue from 'vue'
import { ACCESS_TOKEN } from '@/store/mutation-types'
import { processingTimestamp } from '@/utils/util'
// eslint-disable-next-line
const Base64 = require('js-base64').Base64
export default {
name: 'UnderStudyFilesModal',
props: {
columns: {
type: Array,
default: () => {
return []
}
},
// 是否为在分标委在研项目,默认是
isCommittee: {
type: Boolean,
default: true
}
},
data() {
return {
title: '操作',
width: 800,
visible: false,
confirmLoading: false,
dataSource: []
}
},
methods: {
processingTimestamp,
/**
* 下载
* @param record
*/
handleDownload(record) {
if (this.isCommittee) {
let param = {
fileId: record.FILE_ID,
fullfilename: record.FILE_NAME
}
downloadFile(`/payResearchProject/payResearchProject/download`, record.FILE_NAME, param)
} else {
downloadFile(`sys/common/download/${record.fileId}`, record.fileName)
}
},
/**
* 预览
* @param record
*/
handlePreview(record) {
if (this.isCommittee) {
if (record && record.FILE_ID) {
const fileFullUrl = `${window._CONFIG['domianWebSocketURL']}/payResearchProject/payResearchProject/download/?fileId=${record.FILE_ID}&token=${Vue.ls.get(ACCESS_TOKEN)}&fullfilename=${record.FILE_NAME}`
let url = `${ window._CONFIG['onlinePreviewDomainURL'] }?url=${ encodeURIComponent(Base64.encode(fileFullUrl)) }`
window.open(url)
}
} else {
if (record && record.fileId) {
const fileFullUrl = `${ window._CONFIG['domianWebSocketURL'] }/sys/common/download/${ record.fileId }?token=${ Vue.ls.get(ACCESS_TOKEN) }&fullfilename=${ record.fileName }`
let url = `${ window._CONFIG['onlinePreviewDomainURL'] }?url=${ encodeURIComponent(Base64.encode(fileFullUrl)) }`
window.open(url)
}
}
},
handleCancel() {
this.dataSource = []
this.visible = false
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
</style>