|
@@ -17,7 +17,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">产品/服务</label>
|
|
<label class="form-label">产品/服务</label>
|
|
|
- <el-select v-model="aiGenerator.inputs.products">
|
|
|
|
|
|
|
+ <el-select v-model="aiGenerator.inputs.products" :disabled="isSopLoading">
|
|
|
<el-option value="固态硬盘 SSD" label="固态硬盘 SSD"></el-option>
|
|
<el-option value="固态硬盘 SSD" label="固态硬盘 SSD"></el-option>
|
|
|
<el-option value="机械硬盘 HDD" label="机械硬盘 HDD"></el-option>
|
|
<el-option value="机械硬盘 HDD" label="机械硬盘 HDD"></el-option>
|
|
|
<el-option value="内存条" label="内存条"></el-option>
|
|
<el-option value="内存条" label="内存条"></el-option>
|
|
@@ -27,7 +27,7 @@
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">核心卖点</label>
|
|
<label class="form-label">核心卖点</label>
|
|
|
<div>
|
|
<div>
|
|
|
- <el-checkbox-group v-model="aiGenerator.inputs.core_selling_points">
|
|
|
|
|
|
|
+ <el-checkbox-group v-model="aiGenerator.inputs.core_selling_points" :disabled="isSopLoading">
|
|
|
<el-checkbox :label="point.label" :value="point.label" v-for="point in sellingPoints" />
|
|
<el-checkbox :label="point.label" :value="point.label" v-for="point in sellingPoints" />
|
|
|
</el-checkbox-group>
|
|
</el-checkbox-group>
|
|
|
</div>
|
|
</div>
|
|
@@ -36,21 +36,21 @@
|
|
|
<label class="form-label">语气风格</label>
|
|
<label class="form-label">语气风格</label>
|
|
|
<div class="tone-options">
|
|
<div class="tone-options">
|
|
|
<span v-for="tone in toneOptions" :key="tone.value"
|
|
<span v-for="tone in toneOptions" :key="tone.value"
|
|
|
- class="tone-option" :class="{ active: aiGenerator.inputs.style === tone.label }"
|
|
|
|
|
- @click="aiGenerator.inputs.style = tone.label">{{ tone.label }}</span>
|
|
|
|
|
|
|
+ class="tone-option" :class="{ active: aiGenerator.inputs.style === tone.label, disabled: isSopLoading }"
|
|
|
|
|
+ @click="!isSopLoading && (aiGenerator.inputs.style = tone.label)">{{ tone.label }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">语言</label>
|
|
<label class="form-label">语言</label>
|
|
|
<div class="language-options">
|
|
<div class="language-options">
|
|
|
<span v-for="lang in languageOptions" :key="lang.value"
|
|
<span v-for="lang in languageOptions" :key="lang.value"
|
|
|
- class="language-option" :class="{ active: aiGenerator.inputs.language === lang.label }"
|
|
|
|
|
- @click="aiGenerator.inputs.language = lang.label">{{ lang.label }}</span>
|
|
|
|
|
|
|
+ class="language-option" :class="{ active: aiGenerator.inputs.language === lang.label, disabled: isSopLoading }"
|
|
|
|
|
+ @click="!isSopLoading && (aiGenerator.inputs.language = lang.label)">{{ lang.label }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="form-group">
|
|
<div class="form-group">
|
|
|
<label class="form-label">额外要求</label>
|
|
<label class="form-label">额外要求</label>
|
|
|
- <el-input type="textarea" v-model="aiGenerator.inputs.extra" :rows="3" resize="none" placeholder="例如:强调价格优势、提及促销信息"></el-input>
|
|
|
|
|
|
|
+ <el-input type="textarea" v-model="aiGenerator.inputs.extra" :rows="3" resize="none" placeholder="例如:强调价格优势、提及促销信息" :disabled="isSopLoading"></el-input>
|
|
|
</div>
|
|
</div>
|
|
|
<el-button style="height: 38px;" class="btn btn-primary btn-block" @click="generateEmail" :disabled="!selectedSopId || isSopLoading || isGenerating">生成邮件</el-button>
|
|
<el-button style="height: 38px;" class="btn btn-primary btn-block" @click="generateEmail" :disabled="!selectedSopId || isSopLoading || isGenerating">生成邮件</el-button>
|
|
|
</div>
|
|
</div>
|
|
@@ -218,12 +218,48 @@
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ const normalizeProductHighlights = (value) => {
|
|
|
|
|
+ if (Array.isArray(value)) return [...value]
|
|
|
|
|
+ if (typeof value !== 'string' || !value) return []
|
|
|
|
|
+ return value.split(',').filter(Boolean)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const normalizeSingleSelection = (listValue, value) => {
|
|
|
|
|
+ const values = normalizeProductHighlights(listValue ?? value)
|
|
|
|
|
+ return values[0] || ''
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const getCurrentSettings = () => ({
|
|
|
|
|
+ productName: aiGenerator.value.inputs.products,
|
|
|
|
|
+ productHighlights: [...aiGenerator.value.inputs.core_selling_points],
|
|
|
|
|
+ toneStyle: aiGenerator.value.inputs.style,
|
|
|
|
|
+ language: aiGenerator.value.inputs.language,
|
|
|
|
|
+ additionalRequirements: aiGenerator.value.inputs.extra
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const emptySettings = () => ({
|
|
|
|
|
+ productName: '',
|
|
|
|
|
+ productHighlights: [],
|
|
|
|
|
+ toneStyle: '',
|
|
|
|
|
+ language: '',
|
|
|
|
|
+ additionalRequirements: ''
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ const applySettings = (settings) => {
|
|
|
|
|
+ aiGenerator.value.inputs.products = settings.productName
|
|
|
|
|
+ aiGenerator.value.inputs.core_selling_points = [...settings.productHighlights]
|
|
|
|
|
+ aiGenerator.value.inputs.style = settings.toneStyle
|
|
|
|
|
+ aiGenerator.value.inputs.language = settings.language
|
|
|
|
|
+ aiGenerator.value.inputs.extra = settings.additionalRequirements
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const syncActiveEmailDraft = () => {
|
|
const syncActiveEmailDraft = () => {
|
|
|
if (activeSopId.value === undefined || activeSopId.value === null) return
|
|
if (activeSopId.value === undefined || activeSopId.value === null) return
|
|
|
const draft = emailDrafts.value[String(activeSopId.value)]
|
|
const draft = emailDrafts.value[String(activeSopId.value)]
|
|
|
if (!draft) return
|
|
if (!draft) return
|
|
|
draft.emailContent = emailContent.value
|
|
draft.emailContent = emailContent.value
|
|
|
draft.emailSubject = emailSubject.value
|
|
draft.emailSubject = emailSubject.value
|
|
|
|
|
+ draft.settings = getCurrentSettings()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const changeType = async () => {
|
|
const changeType = async () => {
|
|
@@ -235,6 +271,7 @@
|
|
|
if (id === undefined || id === null) {
|
|
if (id === undefined || id === null) {
|
|
|
emailContent.value = ''
|
|
emailContent.value = ''
|
|
|
emailSubject.value = ''
|
|
emailSubject.value = ''
|
|
|
|
|
+ applySettings(emptySettings())
|
|
|
isSopLoading.value = false
|
|
isSopLoading.value = false
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
@@ -244,28 +281,43 @@
|
|
|
if (draft) {
|
|
if (draft) {
|
|
|
emailContent.value = draft.emailContent
|
|
emailContent.value = draft.emailContent
|
|
|
emailSubject.value = draft.emailSubject
|
|
emailSubject.value = draft.emailSubject
|
|
|
|
|
+ applySettings(draft.settings)
|
|
|
isSopLoading.value = false
|
|
isSopLoading.value = false
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
emailContent.value = ''
|
|
emailContent.value = ''
|
|
|
emailSubject.value = ''
|
|
emailSubject.value = ''
|
|
|
|
|
+ applySettings(emptySettings())
|
|
|
isSopLoading.value = true
|
|
isSopLoading.value = true
|
|
|
try {
|
|
try {
|
|
|
const res = await getSopDetail(id)
|
|
const res = await getSopDetail(id)
|
|
|
const detail = res.result || {}
|
|
const detail = res.result || {}
|
|
|
const originalContent = detail.emailContent || ''
|
|
const originalContent = detail.emailContent || ''
|
|
|
const originalSubject = detail.emailSubject || ''
|
|
const originalSubject = detail.emailSubject || ''
|
|
|
|
|
+ const originalSettings = {
|
|
|
|
|
+ productName: normalizeSingleSelection(detail.productNameList, detail.productName),
|
|
|
|
|
+ productHighlights: normalizeProductHighlights(detail.productHighlightsList ?? detail.productHighlights),
|
|
|
|
|
+ toneStyle: normalizeSingleSelection(detail.toneStyleList, detail.toneStyle),
|
|
|
|
|
+ language: normalizeSingleSelection(detail.languageList, detail.language),
|
|
|
|
|
+ additionalRequirements: detail.additionalRequirements || ''
|
|
|
|
|
+ }
|
|
|
emailDrafts.value[key] = {
|
|
emailDrafts.value[key] = {
|
|
|
id,
|
|
id,
|
|
|
originalContent,
|
|
originalContent,
|
|
|
originalSubject,
|
|
originalSubject,
|
|
|
emailContent: originalContent,
|
|
emailContent: originalContent,
|
|
|
- emailSubject: originalSubject
|
|
|
|
|
|
|
+ emailSubject: originalSubject,
|
|
|
|
|
+ originalSettings,
|
|
|
|
|
+ settings: {
|
|
|
|
|
+ ...originalSettings,
|
|
|
|
|
+ productHighlights: [...originalSettings.productHighlights]
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (String(selectedSopId.value) === String(id)) {
|
|
if (String(selectedSopId.value) === String(id)) {
|
|
|
emailContent.value = originalContent
|
|
emailContent.value = originalContent
|
|
|
emailSubject.value = originalSubject
|
|
emailSubject.value = originalSubject
|
|
|
|
|
+ applySettings(originalSettings)
|
|
|
}
|
|
}
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
ElMessage.error(err.message || '营销序列邮件加载失败')
|
|
ElMessage.error(err.message || '营销序列邮件加载失败')
|
|
@@ -479,24 +531,32 @@
|
|
|
})
|
|
})
|
|
|
window.open(href, '_blank')
|
|
window.open(href, '_blank')
|
|
|
}
|
|
}
|
|
|
|
|
+ const hasSettingsChanged = (settings, originalSettings) =>
|
|
|
|
|
+ settings.productName !== originalSettings.productName ||
|
|
|
|
|
+ JSON.stringify(settings.productHighlights) !== JSON.stringify(originalSettings.productHighlights) ||
|
|
|
|
|
+ settings.toneStyle !== originalSettings.toneStyle ||
|
|
|
|
|
+ settings.language !== originalSettings.language ||
|
|
|
|
|
+ settings.additionalRequirements !== originalSettings.additionalRequirements
|
|
|
|
|
+
|
|
|
|
|
+ const hasDraftChanged = (draft) =>
|
|
|
|
|
+ draft.emailContent !== draft.originalContent ||
|
|
|
|
|
+ draft.emailSubject !== draft.originalSubject ||
|
|
|
|
|
+ hasSettingsChanged(draft.settings, draft.originalSettings)
|
|
|
|
|
+
|
|
|
const hasEmailChanges = computed(() => {
|
|
const hasEmailChanges = computed(() => {
|
|
|
- const changedDraft = Object.values(emailDrafts.value).some(draft =>
|
|
|
|
|
- draft.emailContent !== draft.originalContent ||
|
|
|
|
|
- draft.emailSubject !== draft.originalSubject
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const changedDraft = Object.values(emailDrafts.value).some(hasDraftChanged)
|
|
|
const activeDraft = emailDrafts.value[String(activeSopId.value)]
|
|
const activeDraft = emailDrafts.value[String(activeSopId.value)]
|
|
|
- return changedDraft || Boolean(activeDraft && (
|
|
|
|
|
- emailContent.value !== activeDraft.originalContent ||
|
|
|
|
|
- emailSubject.value !== activeDraft.originalSubject
|
|
|
|
|
- ))
|
|
|
|
|
|
|
+ return changedDraft || Boolean(activeDraft && hasDraftChanged({
|
|
|
|
|
+ ...activeDraft,
|
|
|
|
|
+ emailContent: emailContent.value,
|
|
|
|
|
+ emailSubject: emailSubject.value,
|
|
|
|
|
+ settings: getCurrentSettings()
|
|
|
|
|
+ }))
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const useEmail = async () => {
|
|
const useEmail = async () => {
|
|
|
syncActiveEmailDraft()
|
|
syncActiveEmailDraft()
|
|
|
- const changedDrafts = Object.entries(emailDrafts.value).filter(([, draft]) =>
|
|
|
|
|
- draft.emailContent !== draft.originalContent ||
|
|
|
|
|
- draft.emailSubject !== draft.originalSubject
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ const changedDrafts = Object.entries(emailDrafts.value).filter(([, draft]) => hasDraftChanged(draft))
|
|
|
if (changedDrafts.length === 0) return
|
|
if (changedDrafts.length === 0) return
|
|
|
|
|
|
|
|
isSaving.value = true
|
|
isSaving.value = true
|
|
@@ -506,6 +566,11 @@
|
|
|
id: draft.id,
|
|
id: draft.id,
|
|
|
emailContent: draft.emailContent,
|
|
emailContent: draft.emailContent,
|
|
|
emailSubject: draft.emailSubject,
|
|
emailSubject: draft.emailSubject,
|
|
|
|
|
+ productName: draft.settings.productName ? [draft.settings.productName] : [],
|
|
|
|
|
+ productHighlights: [...draft.settings.productHighlights],
|
|
|
|
|
+ toneStyle: draft.settings.toneStyle ? [draft.settings.toneStyle] : [],
|
|
|
|
|
+ language: draft.settings.language ? [draft.settings.language] : [],
|
|
|
|
|
+ additionalRequirements: draft.settings.additionalRequirements,
|
|
|
marketingCampaignId: marketingData.value.id
|
|
marketingCampaignId: marketingData.value.id
|
|
|
})
|
|
})
|
|
|
))
|
|
))
|
|
@@ -514,6 +579,10 @@
|
|
|
const draft = changedDrafts[index][1]
|
|
const draft = changedDrafts[index][1]
|
|
|
draft.originalContent = draft.emailContent
|
|
draft.originalContent = draft.emailContent
|
|
|
draft.originalSubject = draft.emailSubject
|
|
draft.originalSubject = draft.emailSubject
|
|
|
|
|
+ draft.originalSettings = {
|
|
|
|
|
+ ...draft.settings,
|
|
|
|
|
+ productHighlights: [...draft.settings.productHighlights]
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|