优化email新建邮件组件

This commit is contained in:
jingrow 2026-05-19 16:29:30 +08:00
parent 8696c8c913
commit 9939e6eca5
2 changed files with 6 additions and 10 deletions

View File

@ -201,7 +201,9 @@ const sending = ref(false)
const savingDraft = ref(false)
const props = defineProps<{
/** Reference document to link the email to */
/** Reference document for template rendering and subject auto-fill */
pg?: Record<string, any>
/** Reference document metadata */
referencePagetype?: string
referenceName?: string
/** Pre-fill recipients (e.g. from a Contact/Lead) */
@ -216,8 +218,6 @@ const props = defineProps<{
replyAll?: boolean
/** Last email data for reply logic */
lastEmail?: Record<string, any>
/** Document record (for subject auto-fill, attachments) */
doc?: Record<string, any>
/** Is this a forwarded email? */
isForward?: boolean
/** Is this editing an existing email? */
@ -686,16 +686,13 @@ function cleanupQuotedContent(html: string): string {
// Subject auto-fill from document
// -------------------------------------------------------
function autoFillSubject() {
const doc = propsRef.doc
if (!doc) {
// Use reference name as fallback
const pg = propsRef.pg
if (!pg) {
form.subject = propsRef.referenceName || ''
return
}
// Try title_field or subject_field from meta
const subject = doc.subject_field || doc.title_field || doc.name || ''
const subject = pg.subject_field || pg.title_field || pg.name || ''
form.subject = subject
// Add document identifier
if (propsRef.referenceName && !subject.includes(propsRef.referenceName)) {
form.subject = `${subject} (#${propsRef.referenceName})`
}

View File

@ -414,7 +414,6 @@ function getMailArgs() {
attachments: attachments.value,
referencePagetype: record.reference_pagetype,
referenceName: record.reference_name,
doc: record,
}
}