feat(oa): show attachment URLs in related-approval summaries
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
7b4e246100
commit
88982878b2
3 files changed
+111
-10
No files matched your search
@@ -63,7 +63,22 @@
|
||||
:class="{ 'oa-related-approval__field--full': f.fullWidth && expanded.has(item.id) }"
|
||||
>
|
||||
<span class="oa-related-approval__field-label">{{ f.label }}</span>
|
||||
<span class="oa-related-approval__field-value">{{ f.value }}</span>
|
||||
<span class="oa-related-approval__field-value">
|
||||
<template v-if="splitUrls(f.value).length">
|
||||
<a
|
||||
v-for="(u, ui) in splitUrls(f.value)"
|
||||
:key="`${item.id}-${idx}-${ui}`"
|
||||
class="oa-related-approval__link"
|
||||
:href="toFullUrl(u)"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
@click.stop
|
||||
>
|
||||
{{ displayUrlLabel(u, ui, splitUrls(f.value).length) }}
|
||||
</a>
|
||||
</template>
|
||||
<template v-else>{{ f.value }}</template>
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -153,6 +168,7 @@
|
||||
fetchOaRelatedSummaries,
|
||||
type OaRelatedSummary
|
||||
} from '@/api/oaApproval'
|
||||
import { attachmentFullUrl } from '@/composables/useAttachmentActions'
|
||||
|
||||
defineOptions({ name: 'relatedApproval' })
|
||||
|
||||
@@ -226,6 +242,31 @@
|
||||
return fields.slice(0, COLLAPSE_FIELD_COUNT)
|
||||
}
|
||||
|
||||
/** 顿号/逗号分隔的 URL 列表;非 URL 文本返回空数组走纯文本展示 */
|
||||
function splitUrls(value: string): string[] {
|
||||
const raw = String(value || '').trim()
|
||||
if (!raw) return []
|
||||
const parts = raw
|
||||
.split(/[、,,\s]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
if (!parts.length) return []
|
||||
const looksLikeUrl = parts.every(
|
||||
(p) => /^https?:\/\//i.test(p) || p.startsWith('/') || /\.[a-z0-9]{2,8}(\?|$)/i.test(p)
|
||||
)
|
||||
return looksLikeUrl ? parts : []
|
||||
}
|
||||
|
||||
function toFullUrl(u: string) {
|
||||
return attachmentFullUrl(u) || u
|
||||
}
|
||||
|
||||
function displayUrlLabel(u: string, index: number, total: number) {
|
||||
const name = u.split('?')[0].split('/').filter(Boolean).pop() || u
|
||||
const label = decodeURIComponent(name)
|
||||
return total > 1 ? `${index + 1}. ${label}` : label
|
||||
}
|
||||
|
||||
function toggleExpand(id: string) {
|
||||
const next = new Set(expanded.value)
|
||||
if (next.has(id)) next.delete(id)
|
||||
@@ -436,10 +477,22 @@
|
||||
}
|
||||
|
||||
.oa-related-approval__field-value {
|
||||
display: inline-flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 10px;
|
||||
color: var(--mint-text, #334155);
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.oa-related-approval__link {
|
||||
color: var(--primary, #10b981);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.oa-related-approval__link:hover {
|
||||
color: var(--primary-dark, #059669);
|
||||
}
|
||||
|
||||
.oa-related-approval--stack .oa-related-approval__fields {
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
|
||||
Reference in new issue
Block a user