Commit 4de2993b by Sweet Zhang

联系人管理、发件人管理对接

parent d86fbaed
...@@ -34,19 +34,7 @@ ...@@ -34,19 +34,7 @@
</header> </header>
<!-- 使用router-view显示当前路由组件 --> <!-- 使用router-view显示当前路由组件 -->
<router-view <router-view />
:senders="senders"
:contacts="contacts"
:variables="variables"
:variable-templates="variableTemplates"
:emails="emails"
@save-email="saveEmail"
@update-contacts="updateContacts"
@update-senders="updateSenders"
@update-variables="updateVariables"
@update-variable-templates="updateVariableTemplates"
@reuse-email="reuseEmail"
/>
</main> </main>
</div> </div>
</div> </div>
...@@ -59,7 +47,6 @@ import { useRoute, useRouter } from 'vue-router' ...@@ -59,7 +47,6 @@ import { useRoute, useRouter } from 'vue-router'
import LoginPage from './views/LoginPage.vue' import LoginPage from './views/LoginPage.vue'
import Sidebar from './views/Sidebar.vue' import Sidebar from './views/Sidebar.vue'
import MobileSidebar from './views/MobileSidebar.vue' import MobileSidebar from './views/MobileSidebar.vue'
import type { Contact, Sender, Variable, VariableTemplate, Email } from './types'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
...@@ -80,13 +67,6 @@ watch( ...@@ -80,13 +67,6 @@ watch(
}, },
) )
// 数据存储(保持不变)
const contacts = ref<Contact[]>([])
const senders = ref<Sender[]>([])
const variables = ref<Variable[]>([])
const variableTemplates = ref<VariableTemplate[]>([])
const emails = ref<Email[]>([])
// 页面标题映射(保持不变) // 页面标题映射(保持不变)
const pageTitles = { const pageTitles = {
compose: '写邮件', compose: '写邮件',
...@@ -100,7 +80,6 @@ const pageTitles = { ...@@ -100,7 +80,6 @@ const pageTitles = {
const handleLogin = () => { const handleLogin = () => {
isAuthenticated.value = true isAuthenticated.value = true
isLoginPage.value = false isLoginPage.value = false
loadInitialData()
router.push('/compose') // 登录后跳转到写邮件页面 router.push('/compose') // 登录后跳转到写邮件页面
} }
...@@ -110,64 +89,10 @@ const handleLogout = () => { ...@@ -110,64 +89,10 @@ const handleLogout = () => {
router.push('/login') // 退出后跳转到登录页面 router.push('/login') // 退出后跳转到登录页面
} }
const handlePageChange = (page: string) => {
currentPage.value = page as 'compose' | 'contacts' | 'senders' | 'variables' | 'emails'
}
const handleMobilePageChange = (page: string) => {
currentPage.value = page as 'compose' | 'contacts' | 'senders' | 'variables' | 'emails'
showMobileMenu.value = false
}
const updateContacts = (newContacts: Contact[]) => {
contacts.value = newContacts
}
const updateSenders = (newSenders: Sender[]) => {
senders.value = newSenders
}
const updateVariables = (newVariables: Variable[]) => {
variables.value = newVariables
}
const updateVariableTemplates = (newTemplates: VariableTemplate[]) => {
variableTemplates.value = newTemplates
}
const saveEmail = (email: Email) => {
emails.value.push(email)
}
const reuseEmail = (emailData: Email) => {
currentPage.value = 'compose'
// 这里可以传递需要复用的邮件数据到ComposeEmail组件
// 实际实现中可以使用状态管理或props
}
const loadInitialData = () => {
// 模拟加载初始数据
// 联系人
contacts.value = []
// 发件人
senders.value = []
// 变量
variables.value = []
// 变量模板
variableTemplates.value = []
// 邮件记录
emails.value = []
}
// 初始化 // 初始化
onMounted(() => { onMounted(() => {
// 检查是否已登录(实际项目中应该检查本地存储或令牌) // 检查是否已登录(实际项目中应该检查本地存储或令牌)
if (isAuthenticated.value) { if (isAuthenticated.value) {
loadInitialData()
} }
}) })
</script> </script>
...@@ -35,7 +35,7 @@ export const editContact = (data) => { ...@@ -35,7 +35,7 @@ export const editContact = (data) => {
* @returns * @returns
*/ */
export const deleteContact = (id: number) => { export const deleteContact = (id: number) => {
return request.delete('/emailContact/del?contactBizId=' + id, { params: { contactBizId: id } }) return request.delete('/emailContact/del?contactBizId=' + id)
} }
// 获取联系人详情 // 获取联系人详情
...@@ -74,6 +74,28 @@ export const getContactList = (params: { ...@@ -74,6 +74,28 @@ export const getContactList = (params: {
return request.post('/emailContact/page', params) return request.post('/emailContact/page', params)
} }
/**服务商列表 */
/**
*
* @param params {
"providerName": "", //邮箱服务商名称
"pageNo": 1,
"pageSize": 1,
"sortField": "",
"sortOrder": ""
}
* @returns
*/
export const getEmailProviderList = (params: {
providerName?: string
pageNo?: number
pageSize?: number
sortField?: string
sortOrder?: string
}) => {
return request.post('/emailProviderConfig/page', params)
}
// 新增发送配置 // 新增发送配置
/** /**
* *
...@@ -81,13 +103,11 @@ export const getContactList = (params: { ...@@ -81,13 +103,11 @@ export const getContactList = (params: {
* @returns * @returns
*/ */
export const addEmailSenderConfig = (data: { export const addEmailSenderConfig = (data: {
emailSenderConfigBizId?: number email?: number
emailSenderConfigName?: string password?: string
emailSenderConfigEmail?: string providerBizId?: string
emailSenderConfigType?: string displayName?: string
emailSenderConfigAppellation?: string active?: boolean
emailSenderConfigOther?: string
emailSenderConfigCcEmailList?: string[]
}) => { }) => {
return request.post('/emailSenderConfig/add', data) return request.post('/emailSenderConfig/add', data)
} }
...@@ -99,13 +119,12 @@ export const addEmailSenderConfig = (data: { ...@@ -99,13 +119,12 @@ export const addEmailSenderConfig = (data: {
* @returns * @returns
*/ */
export const editEmailSenderConfig = (data: { export const editEmailSenderConfig = (data: {
emailSenderConfigBizId?: number senderBizId?: number
emailSenderConfigName?: string email?: string
emailSenderConfigEmail?: string password?: string
emailSenderConfigType?: string providerBizId?: string
emailSenderConfigAppellation?: string displayName?: string
emailSenderConfigOther?: string active?: number
emailSenderConfigCcEmailList?: string[]
}) => { }) => {
return request.put('/emailSenderConfig/edit', data) return request.put('/emailSenderConfig/edit', data)
} }
...@@ -116,8 +135,8 @@ export const editEmailSenderConfig = (data: { ...@@ -116,8 +135,8 @@ export const editEmailSenderConfig = (data: {
* @param id 发送配置id * @param id 发送配置id
* @returns * @returns
*/ */
export const deleteEmailSenderConfig = (id: number) => { export const deleteEmailSenderConfig = (id: string) => {
return request.delete('/emailSenderConfig/delete', { params: { emailSenderConfigBizId: id } }) return request.delete('/emailSenderConfig/del?senderBizId=' + id)
} }
// 获取发送配置详情 // 获取发送配置详情
...@@ -126,8 +145,8 @@ export const deleteEmailSenderConfig = (id: number) => { ...@@ -126,8 +145,8 @@ export const deleteEmailSenderConfig = (id: number) => {
* @param id 发送配置id * @param id 发送配置id
* @returns * @returns
*/ */
export const getEmailSenderConfigDetail = (id: number) => { export const getEmailSenderConfigDetail = (id: string) => {
return request.get('/emailSenderConfig/detail', { params: { emailSenderConfigBizId: id } }) return request.get('/emailSenderConfig/detail', { params: { senderBizId: id } })
} }
// 获取发送配置列表 // 获取发送配置列表
......
...@@ -6,7 +6,7 @@ const router = createRouter({ ...@@ -6,7 +6,7 @@ const router = createRouter({
routes: [ routes: [
{ {
path: '/', path: '/',
redirect: '/compose', redirect: '/login',
}, },
{ {
path: '/compose', path: '/compose',
......
// 联系人类型 // 联系人类型
export interface Contact { export interface Contact {
id: string contactBizId?: string
name: string name?: string
type: string type?: string
companyName: string companyName?: string
email: string email?: string
ccEmailList: string[] ccEmailList?: string[]
other: string other?: string
appellation: string appellation?: string
} }
// 发件人类型 // 发件人类型
export interface Sender { export interface Sender {
id: string senderBizId?: string
email: string email?: string
password: string password?: string
smtpServer: string displayName?: string
smtpPort: string providerBizId?: string
active?: number
} }
// 变量类型 // 变量类型
......
...@@ -8,7 +8,7 @@ const request = axios.create({ ...@@ -8,7 +8,7 @@ const request = axios.create({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
// Authorization: 'Bearer ' + localStorage.getItem('authToken'), // Authorization: 'Bearer ' + localStorage.getItem('authToken'),
Authorization: Authorization:
'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyXzEwMDEiLCJyb2xlcyI6W10sImlhdCI6MTc1ODY5OTA3NywiZXhwIjoxNzU4Nzg1NDc3fQ.LR2fGy0aO6EHsHe9Que8rzCaJ0TSAB9KtJndYMSYvvKOSeNvGawCmjE8kgDeRmyFFOFJ2kt0sk-fGaExgzQHSw', 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ1c2VyXzEwMDEiLCJyb2xlcyI6W10sImlhdCI6MTc1ODc4NTY3NCwiZXhwIjoxNzU4ODcyMDc0fQ.tjTO6vdpwLpNjVa1DhxRBdpjZsdhbx6g1TdtpAm7BZBRMwanM_ci7dsnbc8FNXpyfSb-ifXW7ccxwyQbtCaKiQ',
}, },
}) })
......
...@@ -250,33 +250,14 @@ import { ...@@ -250,33 +250,14 @@ import {
ImportRecord, ImportRecord,
} from '../types' } from '../types'
const props = defineProps({ const senders = ref<Sender[]>([])
senders: { const contacts = ref<Contact[]>([])
type: Array as () => Sender[], const variables = ref<Variable[]>([])
required: true, const variableTemplates = ref<VariableTemplate[]>([])
}, const emails = ref<Email[]>([])
contacts: {
type: Array as () => Contact[],
required: true,
},
variables: {
type: Array as () => Variable[],
required: true,
},
variableTemplates: {
type: Array as () => VariableTemplate[],
required: true,
},
emails: {
type: Array as () => Email[],
required: true,
},
})
const emits = defineEmits(['save-email', 'save-import-record'])
// 状态 // 状态
const currentSender = ref<Sender | null>(props.senders.length > 0 ? props.senders[0] : null) const currentSender = ref<Sender | null>(senders.value.length > 0 ? senders.value[0] : null)
const emailForm = ref<EmailForm>({ const emailForm = ref<EmailForm>({
to: '', to: '',
cc: '', cc: '',
...@@ -307,8 +288,8 @@ watch( ...@@ -307,8 +288,8 @@ watch(
}, },
) )
// 计算属性
const variablePrefix = '{{' const variablePrefix = '{{'
const variableNextfix = '}}'
// 方法 // 方法
const handleFileUpload = (e: Event) => { const handleFileUpload = (e: Event) => {
...@@ -325,16 +306,19 @@ const removeAttachment = (index: number) => { ...@@ -325,16 +306,19 @@ const removeAttachment = (index: number) => {
const applyVariableTemplate = () => { const applyVariableTemplate = () => {
if (!selectedVariableTemplate.value) return if (!selectedVariableTemplate.value) return
const variableKeys = selectedVariableTemplate.value.variableIds.map((id) => { const variableKeys =
const variable = props.variables.find((v) => v.id === id) selectedVariableTemplate.value.variableBizIdList.map((id) => {
return variable ? variable.key : '' const variable = variables.value.find((v) => v.variableBizId === id)
}) return variable ? variable.variableNameEn : ''
const variablesText = variableKeys.map((key) => `${variablePrefix}${key}}`).join(', ') }) || []
const variablesText = variableKeys
.map((key) => `${variablePrefix}${key}${variableNextfix}`)
.join(', ')
emailForm.value.content = `【使用了模板变量:${variablesText}】\n\n${emailForm.value.content}` emailForm.value.content = `【使用了模板变量:${variablesText}】\n\n${emailForm.value.content}`
} }
const insertVariable = (variable: Variable) => { const insertVariable = (variable: Variable) => {
emailForm.value.content += `${variablePrefix}${variable.key}}` emailForm.value.content += `${variablePrefix}${variable.variableNameEn}${variableNextfix}`
showVariableSelector.value = false showVariableSelector.value = false
} }
...@@ -366,8 +350,6 @@ const saveImportRecord = (to: string, cc: string) => { ...@@ -366,8 +350,6 @@ const saveImportRecord = (to: string, cc: string) => {
} }
importRecords.value.push(newRecord) importRecords.value.push(newRecord)
} }
emits('save-import-record', importRecords.value)
} }
// 更新导入记录 // 更新导入记录
...@@ -375,14 +357,12 @@ const updateImportRecord = (updatedRecord: ImportRecord) => { ...@@ -375,14 +357,12 @@ const updateImportRecord = (updatedRecord: ImportRecord) => {
const index = importRecords.value.findIndex((record) => record.id === updatedRecord.id) const index = importRecords.value.findIndex((record) => record.id === updatedRecord.id)
if (index !== -1) { if (index !== -1) {
importRecords.value[index] = { ...updatedRecord } importRecords.value[index] = { ...updatedRecord }
emits('save-import-record', importRecords.value)
} }
} }
// 删除导入记录 // 删除导入记录
const deleteImportRecord = (id: string) => { const deleteImportRecord = (id: string) => {
importRecords.value = importRecords.value.filter((record) => record.id !== id) importRecords.value = importRecords.value.filter((record) => record.id !== id)
emits('save-import-record', importRecords.value)
} }
// 修改handleImportContacts方法 // 修改handleImportContacts方法
...@@ -413,7 +393,6 @@ const saveAsDraft = () => { ...@@ -413,7 +393,6 @@ const saveAsDraft = () => {
status: 'draft', status: 'draft',
attachments: attachments.value.map((file) => ({ name: file.name })), attachments: attachments.value.map((file) => ({ name: file.name })),
} }
emits('save-email', draft)
alert('草稿已保存') alert('草稿已保存')
} }
...@@ -447,7 +426,6 @@ const confirmSendEmail = () => { ...@@ -447,7 +426,6 @@ const confirmSendEmail = () => {
status: emailForm.value.scheduleSend ? 'scheduled' : 'sent', status: emailForm.value.scheduleSend ? 'scheduled' : 'sent',
attachments: attachments.value.map((file) => ({ name: file.name })), attachments: attachments.value.map((file) => ({ name: file.name })),
} }
emits('save-email', email)
emailForm.value = { to: '', cc: '', subject: '', content: '', scheduleSend: false, sendTime: '' } emailForm.value = { to: '', cc: '', subject: '', content: '', scheduleSend: false, sendTime: '' }
attachments.value = [] attachments.value = []
selectedVariableTemplate.value = null selectedVariableTemplate.value = null
......
...@@ -122,22 +122,14 @@ ...@@ -122,22 +122,14 @@
import { ref, computed, defineProps, defineEmits } from 'vue' import { ref, computed, defineProps, defineEmits } from 'vue'
import { Email } from '../types' import { Email } from '../types'
const props = defineProps({
emails: {
type: Array as () => Email[],
required: true,
},
})
const emits = defineEmits(['reuse-email'])
// 状态 // 状态
const emails = ref<Email[]>([])
const searchTerm = ref('') const searchTerm = ref('')
const filterStatus = ref('') const filterStatus = ref('')
// 计算属性 // 计算属性
const filteredEmails = computed(() => { const filteredEmails = computed(() => {
return props.emails return emails.value
.filter((email) => { .filter((email) => {
const matchesSearch = const matchesSearch =
email.subject.toLowerCase().includes(searchTerm.value.toLowerCase()) || email.subject.toLowerCase().includes(searchTerm.value.toLowerCase()) ||
...@@ -164,9 +156,5 @@ const viewEmailDetail = (email: Email) => { ...@@ -164,9 +156,5 @@ const viewEmailDetail = (email: Email) => {
const reuseEmailContent = (email: Email) => { const reuseEmailContent = (email: Email) => {
// 触发复用邮件内容事件 // 触发复用邮件内容事件
emits('reuse-email', {
subject: email.subject,
content: email.content,
})
} }
</script> </script>
...@@ -340,22 +340,10 @@ const handleCancel = (triggerKey: string) => { ...@@ -340,22 +340,10 @@ const handleCancel = (triggerKey: string) => {
console.log('用户取消操作', triggerKey) console.log('用户取消操作', triggerKey)
} }
const props = defineProps({ const variables = ref<Variable[]>([])
variables: { const variableTemplates = ref<VariableTemplate[]>([])
type: Array as () => Variable[],
required: true,
},
variableTemplates: {
type: Array as () => VariableTemplate[],
required: true,
},
})
const emits = defineEmits(['update-variables', 'update-variable-templates'])
// 状态 // 状态
const variables = ref<Variable[]>([...props.variables])
const variableTemplates = ref<VariableTemplate[]>([...props.variableTemplates])
const variablePrefix = '{{' const variablePrefix = '{{'
const variableNextfix = '}}' const variableNextfix = '}}'
...@@ -405,13 +393,6 @@ const saveVariable = () => { ...@@ -405,13 +393,6 @@ const saveVariable = () => {
description: variableForm.value.description, description: variableForm.value.description,
}).then(() => { }).then(() => {
// 更新本地变量列表 // 更新本地变量列表
const index = variables.value.findIndex((v) => v.id === editingVariableId.value)
if (index > -1) {
variables.value[index] = {
...variables.value[index],
...variableForm.value,
}
}
fetchVariables() fetchVariables()
openModal({ openModal({
title: '成功', title: '成功',
...@@ -638,7 +619,6 @@ const saveVariableTemplate = () => { ...@@ -638,7 +619,6 @@ const saveVariableTemplate = () => {
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
emits('update-variable-templates', [...variableTemplates.value])
}) })
.catch((error) => { .catch((error) => {
console.error('更新变量模版失败:', error) console.error('更新变量模版失败:', error)
...@@ -664,7 +644,6 @@ const saveVariableTemplate = () => { ...@@ -664,7 +644,6 @@ const saveVariableTemplate = () => {
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
emits('update-variable-templates', [...variableTemplates.value])
}) })
.catch((error) => { .catch((error) => {
console.error('创建变量模版失败:', error) console.error('创建变量模版失败:', error)
...@@ -692,7 +671,6 @@ const deleteVariableTemplate = (id: string, type?: string) => { ...@@ -692,7 +671,6 @@ const deleteVariableTemplate = (id: string, type?: string) => {
.then(() => { .then(() => {
// 刷新变量模版列表 // 刷新变量模版列表
fetchVariableTemplates() fetchVariableTemplates()
emits('update-variable-templates', [...variableTemplates.value])
}) })
.catch((error) => { .catch((error) => {
console.error('删除变量模版失败:', error) console.error('删除变量模版失败:', error)
...@@ -710,7 +688,7 @@ const deleteVariableTemplate = (id: string, type?: string) => { ...@@ -710,7 +688,7 @@ const deleteVariableTemplate = (id: string, type?: string) => {
}) })
} else { } else {
openModal({ openModal({
showClose: true, showCancel: true,
title: '确认删除', title: '确认删除',
message: '确定删除此变量模版吗?', message: '确定删除此变量模版吗?',
triggerKey: 'templeteDelete', triggerKey: 'templeteDelete',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment