|
@@ -75,9 +75,10 @@
|
|
|
>
|
|
>
|
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
<el-button
|
|
|
- v-if="scope.row.attachments && scope.row.attachments.length > 0"
|
|
|
|
|
|
|
+ v-if="scope.row.attachmentUrl"
|
|
|
type="text"
|
|
type="text"
|
|
|
size="small"
|
|
size="small"
|
|
|
|
|
+ icon="iconfont-5039297 icon-wenjian"
|
|
|
@click="handlePreviewWorkingPaperAttachment(scope.row)"
|
|
@click="handlePreviewWorkingPaperAttachment(scope.row)"
|
|
|
>
|
|
>
|
|
|
查看
|
|
查看
|
|
@@ -567,18 +568,44 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handlePreviewWorkingPaperAttachment(row) {
|
|
handlePreviewWorkingPaperAttachment(row) {
|
|
|
- const attachments =
|
|
|
|
|
- row.attachments && Array.isArray(row.attachments)
|
|
|
|
|
- ? row.attachments
|
|
|
|
|
- : []
|
|
|
|
|
- if (attachments.length === 0) {
|
|
|
|
|
- this.$message.info('暂无附件')
|
|
|
|
|
|
|
+ if (!row || !row.attachmentUrl) {
|
|
|
|
|
+ this.$message.warning('该记录没有附件')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- this.$message({
|
|
|
|
|
- type: 'info',
|
|
|
|
|
- message: `预览附件:${attachments.join(', ')}`,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 获取附件URL,如果是逗号分隔的字符串,取第一个
|
|
|
|
|
+ let attachmentUrl = ''
|
|
|
|
|
+ if (typeof row.attachmentUrl === 'string') {
|
|
|
|
|
+ attachmentUrl = row.attachmentUrl.split(',')[0].trim()
|
|
|
|
|
+ } else if (Array.isArray(row.attachmentUrl)) {
|
|
|
|
|
+ attachmentUrl = row.attachmentUrl[0]
|
|
|
|
|
+ } else {
|
|
|
|
|
+ attachmentUrl = row.attachmentUrl
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!attachmentUrl) {
|
|
|
|
|
+ this.$message.warning('该记录没有附件')
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 处理文件URL
|
|
|
|
|
+ let _fileUrl = ''
|
|
|
|
|
+ if (attachmentUrl.startsWith('http')) {
|
|
|
|
|
+ _fileUrl = attachmentUrl
|
|
|
|
|
+ } else {
|
|
|
|
|
+ _fileUrl = (window.context && window.context.form) + attachmentUrl
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 对文件URL进行Base64编码
|
|
|
|
|
+ const encodedUrl = encodeURIComponent(Base64.encode(_fileUrl))
|
|
|
|
|
+
|
|
|
|
|
+ // 构建 kkFileView 预览URL
|
|
|
|
|
+ window.open(`${host}:8012/onlinePreview?url=${encodedUrl}`)
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('文件预览失败: ', e)
|
|
|
|
|
+ this.$message.error('文件预览失败')
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 文件上传前验证
|
|
// 文件上传前验证
|