diff --git a/src/views/flow/create.vue b/src/views/flow/create.vue index 5607b6a..bb958d2 100644 --- a/src/views/flow/create.vue +++ b/src/views/flow/create.vue @@ -1260,7 +1260,7 @@ :href="getContractAttachmentUrl(contractDrawerDetail)" target="_blank" > - {{ (contractDrawerDetail.attachment && contractDrawerDetail.attachment.original_name) || (contractDrawerDetail.attachment && contractDrawerDetail.attachment.name) || '查看附件' }} + {{ getContractAttachmentName(contractDrawerDetail) }} - @@ -2100,9 +2100,28 @@ export default { } return String(rawValue); }, + getContractAttachment(detail) { + if (!detail) return null; + return detail.effective_attachment || detail.oa_inferred_attachment || detail.attachment || null; + }, + getContractAttachmentName(detail) { + const att = this.getContractAttachment(detail); + return att?.original_name || att?.name || '查看附件'; + }, getContractAttachmentUrl(detail) { - const att = detail?.attachment; - return att?.url || att?.path || att?.file_url || att?.download_url || att?.preview_url || ''; + const att = this.getContractAttachment(detail); + if (!att) return ''; + + const directUrl = att.url || att.path || att.file_url || att.download_url || att.preview_url; + if (directUrl) return directUrl; + + if (!att.folder || !att.name) return ''; + + const configuredBase = process.env.VUE_APP_BASE_API || window.location.origin; + const baseUrl = configuredBase.replace(/\/$/, '').replace(/\/api\/?$/, ''); + const folder = String(att.folder).replace(/^\/+|\/+$/g, ''); + const name = encodeURIComponent(String(att.name)); + return `${baseUrl}/${folder}/${name}`; }, // 格式化日期时间 formatDateTime(dateTime) {