mirror of
https://gitee.com/qqtt-ah/ai-crm.git
synced 2026-11-25 05:09:20 +08:00
feat: 落地邮件方案A,支持模板手发与发送记录
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import type { CrmMailAccountDTO, CrmMailAccountVO } from './types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function getCrmMailAccountListApi() {
|
||||
return requestClient.get<CrmMailAccountVO.Info[]>('/crm/mail-account/list');
|
||||
}
|
||||
|
||||
export async function getCrmMailAccountOptionsApi() {
|
||||
return requestClient.get<CrmMailAccountVO.Info[]>(
|
||||
'/crm/mail-account/options',
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCrmMailAccountApi(id: number) {
|
||||
return requestClient.get<CrmMailAccountVO.Info>(`/crm/mail-account/${id}`);
|
||||
}
|
||||
|
||||
export async function createCrmMailAccountApi(data: CrmMailAccountDTO.Create) {
|
||||
return requestClient.post<CrmMailAccountVO.Info>(
|
||||
'/crm/mail-account/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateCrmMailAccountApi(
|
||||
id: number,
|
||||
data: CrmMailAccountDTO.Update,
|
||||
) {
|
||||
return requestClient.put<CrmMailAccountVO.Info>(
|
||||
`/crm/mail-account/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteCrmMailAccountApi(id: number) {
|
||||
return requestClient.delete(`/crm/mail-account/delete/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,44 @@
|
||||
/** 发件账户 */
|
||||
export namespace CrmMailAccountVO {
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
name: string;
|
||||
fromEmail: string;
|
||||
smtpHost: string;
|
||||
smtpPort: number;
|
||||
smtpSsl?: number;
|
||||
username: string;
|
||||
enabled?: number;
|
||||
isDefault?: number;
|
||||
passwordSet?: boolean;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace CrmMailAccountDTO {
|
||||
export interface Create {
|
||||
name: string;
|
||||
fromEmail: string;
|
||||
smtpHost: string;
|
||||
smtpPort: number;
|
||||
smtpSsl?: number;
|
||||
username: string;
|
||||
password: string;
|
||||
enabled?: number;
|
||||
isDefault?: number;
|
||||
}
|
||||
|
||||
export interface Update {
|
||||
name: string;
|
||||
fromEmail: string;
|
||||
smtpHost: string;
|
||||
smtpPort: number;
|
||||
smtpSsl?: number;
|
||||
username: string;
|
||||
password?: string;
|
||||
enabled?: number;
|
||||
isDefault?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { CrmMailLogDTO, CrmMailLogVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function getCrmMailLogPageApi(
|
||||
params: PageQueryDTO<CrmMailLogDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<CrmMailLogVO.Info>>(
|
||||
'/crm/mail-log/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCrmMailLogApi(id: number) {
|
||||
return requestClient.get<CrmMailLogVO.Info>(`/crm/mail-log/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,34 @@
|
||||
/** 发送记录 */
|
||||
export namespace CrmMailLogVO {
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
accountId?: number;
|
||||
accountName?: string;
|
||||
templateId?: number;
|
||||
templateName?: string;
|
||||
customerId?: number;
|
||||
customerName?: string;
|
||||
refType?: string;
|
||||
refId?: number;
|
||||
toEmail: string;
|
||||
ccEmail?: string;
|
||||
subject: string;
|
||||
bodyHtml?: string;
|
||||
status: string;
|
||||
errorMessage?: string;
|
||||
sentAt?: string;
|
||||
createTime?: string;
|
||||
createBy?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace CrmMailLogDTO {
|
||||
export interface Filters {
|
||||
keyword?: string;
|
||||
status?: string;
|
||||
customerId?: number;
|
||||
refType?: string;
|
||||
refId?: number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { CrmMailLogVO } from '../log';
|
||||
import type { CrmMailSendDTO, CrmMailSendVO } from './types';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function previewCrmMailApi(data: CrmMailSendDTO.Preview) {
|
||||
return requestClient.post<CrmMailSendVO.Preview>('/crm/mail/preview', data);
|
||||
}
|
||||
|
||||
export async function sendCrmMailApi(data: CrmMailSendDTO.Send) {
|
||||
return requestClient.post<CrmMailLogVO.Info>('/crm/mail/send', data);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,34 @@
|
||||
/** 手发邮件 */
|
||||
export namespace CrmMailSendVO {
|
||||
export interface Preview {
|
||||
templateId: number;
|
||||
templateName?: string;
|
||||
scene?: string;
|
||||
customerId: number;
|
||||
toEmail?: string;
|
||||
subject: string;
|
||||
bodyHtml: string;
|
||||
variables?: Record<string, string>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace CrmMailSendDTO {
|
||||
export interface Preview {
|
||||
templateId: number;
|
||||
customerId: number;
|
||||
refType?: string;
|
||||
refId?: number;
|
||||
}
|
||||
|
||||
export interface Send {
|
||||
accountId?: number;
|
||||
templateId?: number;
|
||||
customerId: number;
|
||||
refType?: string;
|
||||
refId?: number;
|
||||
toEmail: string;
|
||||
ccEmail?: string;
|
||||
subject: string;
|
||||
bodyHtml: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { CrmMailTemplateDTO, CrmMailTemplateVO } from './types';
|
||||
|
||||
import type { PageQueryDTO, PageResultVO } from '#/types/common';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export async function getCrmMailTemplatePageApi(
|
||||
params: PageQueryDTO<CrmMailTemplateDTO.Filters>,
|
||||
) {
|
||||
return requestClient.post<PageResultVO<CrmMailTemplateVO.Info>>(
|
||||
'/crm/mail-template/list',
|
||||
params,
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCrmMailTemplateOptionsApi(scene?: string) {
|
||||
return requestClient.get<CrmMailTemplateVO.Info[]>(
|
||||
'/crm/mail-template/options',
|
||||
{ params: { scene } },
|
||||
);
|
||||
}
|
||||
|
||||
export async function getCrmMailTemplateApi(id: number) {
|
||||
return requestClient.get<CrmMailTemplateVO.Info>(`/crm/mail-template/${id}`);
|
||||
}
|
||||
|
||||
export async function createCrmMailTemplateApi(
|
||||
data: CrmMailTemplateDTO.Create,
|
||||
) {
|
||||
return requestClient.post<CrmMailTemplateVO.Info>(
|
||||
'/crm/mail-template/create',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateCrmMailTemplateApi(
|
||||
id: number,
|
||||
data: CrmMailTemplateDTO.Update,
|
||||
) {
|
||||
return requestClient.put<CrmMailTemplateVO.Info>(
|
||||
`/crm/mail-template/update/${id}`,
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export async function deleteCrmMailTemplateApi(id: number) {
|
||||
return requestClient.delete(`/crm/mail-template/delete/${id}`);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export * from './apis';
|
||||
export * from './types';
|
||||
@@ -0,0 +1,34 @@
|
||||
/** 邮件模板 */
|
||||
export namespace CrmMailTemplateVO {
|
||||
export interface Info {
|
||||
id: number;
|
||||
companyId?: number;
|
||||
name: string;
|
||||
scene: string;
|
||||
subject: string;
|
||||
bodyHtml: string;
|
||||
enabled?: number;
|
||||
remark?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace CrmMailTemplateDTO {
|
||||
export interface Create {
|
||||
name: string;
|
||||
scene: string;
|
||||
subject: string;
|
||||
bodyHtml: string;
|
||||
enabled?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export type Update = Create;
|
||||
|
||||
export interface Filters {
|
||||
keyword?: string;
|
||||
scene?: string;
|
||||
enabled?: number;
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
import { exportByGet } from '#/utils/export';
|
||||
|
||||
import SendMailModal from '../mail/components/SendMailModal.vue';
|
||||
import CustomerModal from './components/CustomerModal.vue';
|
||||
|
||||
defineOptions({ name: 'CrmCustomer' });
|
||||
@@ -33,6 +34,7 @@ const UploadIcon = createIconifyIcon('lucide:upload');
|
||||
|
||||
const loading = ref(false);
|
||||
const modalRef = ref<InstanceType<typeof CustomerModal>>();
|
||||
const mailModalRef = ref<InstanceType<typeof SendMailModal>>();
|
||||
const searchForm = ref({ keyword: '', status: undefined as string | undefined });
|
||||
|
||||
const statusMap: Record<string, { color: string; label: string }> = {
|
||||
@@ -47,6 +49,7 @@ const actionCodes = [
|
||||
'crm:customer:update',
|
||||
'crm:customer:delete',
|
||||
'crm:customer:import',
|
||||
'crm:mail:send',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
@@ -71,7 +74,7 @@ const actionColumn: NonNullable<
|
||||
VxeGridProps<CrmCustomerVO.Info>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
width: 160,
|
||||
width: 200,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
@@ -220,6 +223,22 @@ async function handleImport(file: File) {
|
||||
编辑
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:mail:send">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
:disabled="!row.email"
|
||||
@click="
|
||||
mailModalRef?.open({
|
||||
customerId: row.id,
|
||||
toEmail: row.email,
|
||||
scene: 'outreach',
|
||||
})
|
||||
"
|
||||
>
|
||||
发邮件
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:customer:delete">
|
||||
<Popconfirm title="确认删除该客户?" @confirm="handleDelete(row)">
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
@@ -229,5 +248,6 @@ async function handleImport(file: File) {
|
||||
</template>
|
||||
</Grid>
|
||||
<CustomerModal ref="modalRef" @success="gridApi.reload()" />
|
||||
<SendMailModal ref="mailModalRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CrmMailAccountDTO, CrmMailAccountVO } from '#/api/crm/mail/account';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, InputNumber, Switch, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createCrmMailAccountApi,
|
||||
updateCrmMailAccountApi,
|
||||
} from '#/api/crm/mail/account';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[560px]',
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
const editingId = ref<number>();
|
||||
const form = ref({
|
||||
name: '',
|
||||
fromEmail: '',
|
||||
smtpHost: '',
|
||||
smtpPort: 465,
|
||||
smtpSsl: true,
|
||||
username: '',
|
||||
password: '',
|
||||
enabled: true,
|
||||
isDefault: false,
|
||||
});
|
||||
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
fromEmail: [{ required: true, message: '请输入发件邮箱', trigger: 'blur' }],
|
||||
smtpHost: [{ required: true, message: '请输入 SMTP 主机', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
async function open(edit = false, row?: CrmMailAccountVO.Info) {
|
||||
isEdit.value = edit;
|
||||
editingId.value = row?.id;
|
||||
if (edit && row) {
|
||||
form.value = {
|
||||
name: row.name,
|
||||
fromEmail: row.fromEmail,
|
||||
smtpHost: row.smtpHost,
|
||||
smtpPort: row.smtpPort ?? 465,
|
||||
smtpSsl: row.smtpSsl !== 0,
|
||||
username: row.username,
|
||||
password: '',
|
||||
enabled: row.enabled !== 0,
|
||||
isDefault: row.isDefault === 1,
|
||||
};
|
||||
modalApi.setState({ title: `编辑发件账户 ${row.name}` });
|
||||
} else {
|
||||
form.value = {
|
||||
name: '',
|
||||
fromEmail: '',
|
||||
smtpHost: '',
|
||||
smtpPort: 465,
|
||||
smtpSsl: true,
|
||||
username: '',
|
||||
password: '',
|
||||
enabled: true,
|
||||
isDefault: false,
|
||||
};
|
||||
modalApi.setState({ title: '新建发件账户' });
|
||||
}
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!isEdit.value && !form.value.password) {
|
||||
message.error('请填写 SMTP 密码');
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
try {
|
||||
const payload: CrmMailAccountDTO.Create = {
|
||||
name: form.value.name,
|
||||
fromEmail: form.value.fromEmail,
|
||||
smtpHost: form.value.smtpHost,
|
||||
smtpPort: form.value.smtpPort,
|
||||
smtpSsl: form.value.smtpSsl ? 1 : 0,
|
||||
username: form.value.username,
|
||||
password: form.value.password,
|
||||
enabled: form.value.enabled ? 1 : 0,
|
||||
isDefault: form.value.isDefault ? 1 : 0,
|
||||
};
|
||||
if (isEdit.value && editingId.value) {
|
||||
await updateCrmMailAccountApi(editingId.value, {
|
||||
...payload,
|
||||
password: form.value.password || undefined,
|
||||
});
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createCrmMailAccountApi(payload);
|
||||
message.success('创建成功');
|
||||
}
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 16 }"
|
||||
>
|
||||
<Form.Item label="显示名" name="name">
|
||||
<Input v-model:value="form.name" placeholder="如 业务邮箱" />
|
||||
</Form.Item>
|
||||
<Form.Item label="发件邮箱" name="fromEmail">
|
||||
<Input v-model:value="form.fromEmail" />
|
||||
</Form.Item>
|
||||
<Form.Item label="SMTP 主机" name="smtpHost">
|
||||
<Input v-model:value="form.smtpHost" placeholder="smtp.example.com" />
|
||||
</Form.Item>
|
||||
<Form.Item label="端口">
|
||||
<InputNumber v-model:value="form.smtpPort" :min="1" class="w-full" />
|
||||
</Form.Item>
|
||||
<Form.Item label="SSL/TLS">
|
||||
<Switch v-model:checked="form.smtpSsl" />
|
||||
</Form.Item>
|
||||
<Form.Item label="用户名" name="username">
|
||||
<Input v-model:value="form.username" />
|
||||
</Form.Item>
|
||||
<Form.Item :label="isEdit ? '密码(留空不改)' : '密码'">
|
||||
<Input.Password
|
||||
v-model:value="form.password"
|
||||
:placeholder="isEdit ? '不修改请留空' : 'SMTP 密码'"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="启用">
|
||||
<Switch v-model:checked="form.enabled" />
|
||||
</Form.Item>
|
||||
<Form.Item label="默认发件">
|
||||
<Switch v-model:checked="form.isDefault" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,145 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CrmMailAccountVO } from '#/api/crm/mail/account';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteCrmMailAccountApi,
|
||||
getCrmMailAccountListApi,
|
||||
} from '#/api/crm/mail/account';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import MailAccountModal from './components/MailAccountModal.vue';
|
||||
|
||||
defineOptions({ name: 'CrmMailAccount' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const modalRef = ref<InstanceType<typeof MailAccountModal>>();
|
||||
const rows = ref<CrmMailAccountVO.Info[]>([]);
|
||||
|
||||
const actionCodes = [
|
||||
'crm:mail-account:create',
|
||||
'crm:mail-account:update',
|
||||
'crm:mail-account:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
const baseColumns: VxeGridProps<CrmMailAccountVO.Info>['columns'] = [
|
||||
{ type: 'seq', title: '序号', minWidth: 60 },
|
||||
{ field: 'name', title: '名称', minWidth: 140 },
|
||||
{ field: 'fromEmail', title: '发件邮箱', minWidth: 180 },
|
||||
{ field: 'smtpHost', title: 'SMTP', minWidth: 160 },
|
||||
{ field: 'smtpPort', title: '端口', minWidth: 70 },
|
||||
{
|
||||
field: 'enabled',
|
||||
title: '启用',
|
||||
minWidth: 80,
|
||||
slots: { default: 'enabled' },
|
||||
},
|
||||
{
|
||||
field: 'isDefault',
|
||||
title: '默认',
|
||||
minWidth: 80,
|
||||
slots: { default: 'isDefault' },
|
||||
},
|
||||
];
|
||||
|
||||
const actionColumn: NonNullable<
|
||||
VxeGridProps<CrmMailAccountVO.Info>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const tableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(baseColumns ?? []), actionColumn]
|
||||
: (baseColumns ?? []),
|
||||
);
|
||||
|
||||
const gridOptions: VxeGridProps<CrmMailAccountVO.Info> = {
|
||||
columns: tableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
pagerConfig: { enabled: false },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async () => {
|
||||
rows.value = (await getCrmMailAccountListApi()) ?? [];
|
||||
return { items: rows.value, total: rows.value.length };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({ gridOptions });
|
||||
syncVxeGridColumns(gridApi, tableColumns);
|
||||
|
||||
async function handleDelete(row: CrmMailAccountVO.Info) {
|
||||
await deleteCrmMailAccountApi(row.id);
|
||||
message.success('已删除');
|
||||
gridApi.reload();
|
||||
}
|
||||
|
||||
onMounted(() => gridApi.reload());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page
|
||||
auto-content-height
|
||||
title="发件账户"
|
||||
description="公司级 SMTP,密码加密存储,不回显明文"
|
||||
>
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
<PermissionGate code="crm:mail-account:create">
|
||||
<Button type="primary" @click="modalRef?.open(false)">
|
||||
<PlusIcon class="size-4" />
|
||||
新建
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
<template #enabled="{ row }">
|
||||
<Tag :color="row.enabled === 1 ? 'success' : 'default'">
|
||||
{{ row.enabled === 1 ? '是' : '否' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #isDefault="{ row }">
|
||||
<Tag v-if="row.isDefault === 1" color="processing">默认</Tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="crm:mail-account:update">
|
||||
<Button type="link" size="small" @click="modalRef?.open(true, row)">
|
||||
编辑
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:mail-account:delete">
|
||||
<Popconfirm title="确认删除?" @confirm="handleDelete(row)">
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
<MailAccountModal ref="modalRef" @success="gridApi.reload()" />
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,147 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { CrmMailLogDTO, CrmMailLogVO } from '#/api/crm/mail/log';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { h, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
|
||||
import { Button, Modal, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getCrmMailLogApi, getCrmMailLogPageApi } from '#/api/crm/mail/log';
|
||||
|
||||
defineOptions({ name: 'CrmMailLog' });
|
||||
|
||||
const searchForm = ref({
|
||||
keyword: '',
|
||||
status: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const statusMap: Record<string, { color: string; label: string }> = {
|
||||
pending: { color: 'default', label: '待发' },
|
||||
success: { color: 'success', label: '成功' },
|
||||
failed: { color: 'error', label: '失败' },
|
||||
};
|
||||
|
||||
const columns: VxeGridProps<CrmMailLogVO.Info>['columns'] = [
|
||||
{ type: 'seq', title: '序号', minWidth: 60 },
|
||||
{ field: 'createTime', title: '时间', minWidth: 160 },
|
||||
{ field: 'toEmail', title: '收件人', minWidth: 180 },
|
||||
{ field: 'subject', title: '主题', minWidth: 200 },
|
||||
{ field: 'customerName', title: '客户', minWidth: 140 },
|
||||
{ field: 'templateName', title: '模板', minWidth: 120 },
|
||||
{ field: 'accountName', title: '发件账户', minWidth: 120 },
|
||||
{
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
minWidth: 90,
|
||||
slots: { default: 'status' },
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
];
|
||||
|
||||
const gridOptions: VxeGridProps<CrmMailLogVO.Info> = {
|
||||
columns,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50, 100] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<CrmMailLogDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
keyword: searchForm.value.keyword || undefined,
|
||||
status: searchForm.value.status,
|
||||
},
|
||||
};
|
||||
const data = await getCrmMailLogPageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'keyword',
|
||||
label: '关键词',
|
||||
componentProps: { placeholder: '收件人/主题' },
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
fieldName: 'status',
|
||||
label: '状态',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: Object.entries(statusMap).map(([value, v]) => ({
|
||||
value,
|
||||
label: v.label,
|
||||
})),
|
||||
},
|
||||
},
|
||||
],
|
||||
handleSubmit: async (values: Record<string, any>) => {
|
||||
searchForm.value.keyword = values.keyword ?? '';
|
||||
searchForm.value.status = values.status;
|
||||
gridApi.reload();
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
async function showDetail(row: CrmMailLogVO.Info) {
|
||||
const detail = await getCrmMailLogApi(row.id);
|
||||
Modal.info({
|
||||
title: detail.subject,
|
||||
width: 720,
|
||||
content: h('div', { class: 'space-y-2 text-sm' }, [
|
||||
h('div', `收件:${detail.toEmail}`),
|
||||
detail.ccEmail ? h('div', `抄送:${detail.ccEmail}`) : null,
|
||||
detail.errorMessage
|
||||
? h(
|
||||
'div',
|
||||
{ style: 'color:#cf1322' },
|
||||
`失败:${detail.errorMessage}`,
|
||||
)
|
||||
: null,
|
||||
h('div', {
|
||||
style:
|
||||
'border:1px solid #eee;padding:12px;max-height:360px;overflow:auto',
|
||||
innerHTML: detail.bodyHtml || '',
|
||||
}),
|
||||
]),
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #status="{ row }">
|
||||
<Tag :color="statusMap[row.status]?.color ?? 'default'">
|
||||
{{ statusMap[row.status]?.label ?? row.status }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Button type="link" size="small" @click="showDetail(row)">详情</Button>
|
||||
</template>
|
||||
</Grid>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,153 @@
|
||||
<script lang="ts" setup>
|
||||
import type {
|
||||
CrmMailTemplateDTO,
|
||||
CrmMailTemplateVO,
|
||||
} from '#/api/crm/mail/template';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, Select, Switch, message } from 'ant-design-vue';
|
||||
|
||||
import {
|
||||
createCrmMailTemplateApi,
|
||||
getCrmMailTemplateApi,
|
||||
updateCrmMailTemplateApi,
|
||||
} from '#/api/crm/mail/template';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const sceneOptions = [
|
||||
{ value: 'outreach', label: '开发信' },
|
||||
{ value: 'quote_followup', label: '报价跟进' },
|
||||
{ value: 'shipment_notice', label: '出货通知' },
|
||||
];
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[720px]',
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSubmit();
|
||||
},
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
const editingId = ref<number>();
|
||||
const form = ref({
|
||||
name: '',
|
||||
scene: 'outreach',
|
||||
subject: '',
|
||||
bodyHtml: '',
|
||||
enabled: true,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
const rules = {
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
scene: [{ required: true, message: '请选择场景', trigger: 'change' }],
|
||||
subject: [{ required: true, message: '请输入主题', trigger: 'blur' }],
|
||||
bodyHtml: [{ required: true, message: '请输入正文', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
async function open(edit = false, id?: number) {
|
||||
isEdit.value = edit;
|
||||
editingId.value = id;
|
||||
if (edit && id) {
|
||||
const detail = await getCrmMailTemplateApi(id);
|
||||
form.value = {
|
||||
name: detail.name,
|
||||
scene: detail.scene,
|
||||
subject: detail.subject,
|
||||
bodyHtml: detail.bodyHtml,
|
||||
enabled: detail.enabled !== 0,
|
||||
remark: detail.remark ?? '',
|
||||
};
|
||||
modalApi.setState({ title: `编辑模板 ${detail.name}` });
|
||||
} else {
|
||||
form.value = {
|
||||
name: '',
|
||||
scene: 'outreach',
|
||||
subject: 'Hello {{contactName}}',
|
||||
bodyHtml:
|
||||
'<p>Dear {{contactName}},</p><p>We are {{companyName}}.</p><p>Best regards</p>',
|
||||
enabled: true,
|
||||
remark: '',
|
||||
};
|
||||
modalApi.setState({ title: '新建邮件模板' });
|
||||
}
|
||||
modalApi.open();
|
||||
}
|
||||
|
||||
async function handleSubmit() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
try {
|
||||
const payload: CrmMailTemplateDTO.Create = {
|
||||
name: form.value.name,
|
||||
scene: form.value.scene,
|
||||
subject: form.value.subject,
|
||||
bodyHtml: form.value.bodyHtml,
|
||||
enabled: form.value.enabled ? 1 : 0,
|
||||
remark: form.value.remark || undefined,
|
||||
};
|
||||
if (isEdit.value && editingId.value) {
|
||||
await updateCrmMailTemplateApi(editingId.value, payload);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
await createCrmMailTemplateApi(payload);
|
||||
message.success('创建成功');
|
||||
}
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 4 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="名称" name="name">
|
||||
<Input v-model:value="form.name" />
|
||||
</Form.Item>
|
||||
<Form.Item label="场景" name="scene">
|
||||
<Select v-model:value="form.scene" :options="sceneOptions" />
|
||||
</Form.Item>
|
||||
<Form.Item label="主题" name="subject">
|
||||
<Input v-model:value="form.subject" />
|
||||
</Form.Item>
|
||||
<Form.Item label="正文 HTML" name="bodyHtml">
|
||||
<Input.TextArea v-model:value="form.bodyHtml" :rows="10" />
|
||||
</Form.Item>
|
||||
<Form.Item label="启用">
|
||||
<Switch v-model:checked="form.enabled" />
|
||||
</Form.Item>
|
||||
<Form.Item label="备注">
|
||||
<Input v-model:value="form.remark" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div class="text-muted-foreground px-2 text-xs">
|
||||
变量示例:{{customerName}} {{contactName}}
|
||||
{{quoteNo}} {{companyName}}
|
||||
{{shipmentNo}}
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,192 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type {
|
||||
CrmMailTemplateDTO,
|
||||
CrmMailTemplateVO,
|
||||
} from '#/api/crm/mail/template';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, Popconfirm, Space, Tag, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteCrmMailTemplateApi,
|
||||
getCrmMailTemplatePageApi,
|
||||
} from '#/api/crm/mail/template';
|
||||
import { PermissionGate } from '#/components/permission';
|
||||
import {
|
||||
syncVxeGridColumns,
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import MailTemplateModal from './components/MailTemplateModal.vue';
|
||||
|
||||
defineOptions({ name: 'CrmMailTemplate' });
|
||||
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const modalRef = ref<InstanceType<typeof MailTemplateModal>>();
|
||||
const searchForm = ref({
|
||||
keyword: '',
|
||||
scene: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const sceneMap: Record<string, string> = {
|
||||
outreach: '开发信',
|
||||
quote_followup: '报价跟进',
|
||||
shipment_notice: '出货通知',
|
||||
};
|
||||
|
||||
const actionCodes = [
|
||||
'crm:mail-template:create',
|
||||
'crm:mail-template:update',
|
||||
'crm:mail-template:delete',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
const baseColumns: VxeGridProps<CrmMailTemplateVO.Info>['columns'] = [
|
||||
{ type: 'seq', title: '序号', minWidth: 60 },
|
||||
{ field: 'name', title: '名称', minWidth: 160 },
|
||||
{
|
||||
field: 'scene',
|
||||
title: '场景',
|
||||
minWidth: 110,
|
||||
slots: { default: 'scene' },
|
||||
},
|
||||
{ field: 'subject', title: '主题', minWidth: 220 },
|
||||
{
|
||||
field: 'enabled',
|
||||
title: '启用',
|
||||
minWidth: 80,
|
||||
slots: { default: 'enabled' },
|
||||
},
|
||||
{ field: 'updateTime', title: '更新时间', minWidth: 160 },
|
||||
];
|
||||
|
||||
const actionColumn: NonNullable<
|
||||
VxeGridProps<CrmMailTemplateVO.Info>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
width: 140,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
|
||||
const tableColumns = computed(() =>
|
||||
showActionColumn.value
|
||||
? [...(baseColumns ?? []), actionColumn]
|
||||
: (baseColumns ?? []),
|
||||
);
|
||||
|
||||
const gridOptions: VxeGridProps<CrmMailTemplateVO.Info> = {
|
||||
columns: tableColumns.value,
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
rowConfig: { isHover: true },
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: { custom: true, refresh: true, zoom: true },
|
||||
pagerConfig: { enabled: true, pageSizes: [10, 20, 50] },
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
const params: PageQueryDTO<CrmMailTemplateDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
keyword: searchForm.value.keyword || undefined,
|
||||
scene: searchForm.value.scene,
|
||||
},
|
||||
};
|
||||
const data = await getCrmMailTemplatePageApi(params);
|
||||
return { items: data.records, total: data.total };
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: {
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'keyword',
|
||||
label: '关键词',
|
||||
componentProps: { placeholder: '名称/主题' },
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
fieldName: 'scene',
|
||||
label: '场景',
|
||||
componentProps: {
|
||||
allowClear: true,
|
||||
options: Object.entries(sceneMap).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
})),
|
||||
},
|
||||
},
|
||||
],
|
||||
handleSubmit: async (values: Record<string, any>) => {
|
||||
searchForm.value.keyword = values.keyword ?? '';
|
||||
searchForm.value.scene = values.scene;
|
||||
gridApi.reload();
|
||||
},
|
||||
},
|
||||
});
|
||||
syncVxeGridColumns(gridApi, tableColumns);
|
||||
|
||||
async function handleDelete(row: CrmMailTemplateVO.Info) {
|
||||
await deleteCrmMailTemplateApi(row.id);
|
||||
message.success('已删除');
|
||||
gridApi.reload();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-tools>
|
||||
<PermissionGate code="crm:mail-template:create">
|
||||
<Button type="primary" @click="modalRef?.open(false)">
|
||||
<PlusIcon class="size-4" />
|
||||
新建模板
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
</template>
|
||||
<template #scene="{ row }">
|
||||
{{ sceneMap[row.scene] ?? row.scene }}
|
||||
</template>
|
||||
<template #enabled="{ row }">
|
||||
<Tag :color="row.enabled === 1 ? 'success' : 'default'">
|
||||
{{ row.enabled === 1 ? '是' : '否' }}
|
||||
</Tag>
|
||||
</template>
|
||||
<template #action="{ row }">
|
||||
<Space>
|
||||
<PermissionGate code="crm:mail-template:update">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
@click="modalRef?.open(true, row.id)"
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:mail-template:delete">
|
||||
<Popconfirm title="确认删除?" @confirm="handleDelete(row)">
|
||||
<Button type="link" size="small" danger>删除</Button>
|
||||
</Popconfirm>
|
||||
</PermissionGate>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
<MailTemplateModal ref="modalRef" @success="gridApi.reload()" />
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts" setup>
|
||||
import type { CrmMailAccountVO } from '#/api/crm/mail/account';
|
||||
import type { CrmMailTemplateVO } from '#/api/crm/mail/template';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Form, Input, Select, message } from 'ant-design-vue';
|
||||
|
||||
import { getCrmMailAccountOptionsApi } from '#/api/crm/mail/account';
|
||||
import { previewCrmMailApi, sendCrmMailApi } from '#/api/crm/mail/send';
|
||||
import { getCrmMailTemplateOptionsApi } from '#/api/crm/mail/template';
|
||||
|
||||
const emit = defineEmits<{ success: [] }>();
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[760px]',
|
||||
onCancel() {
|
||||
modalApi.close();
|
||||
},
|
||||
onConfirm() {
|
||||
handleSend();
|
||||
},
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const accounts = ref<CrmMailAccountVO.Info[]>([]);
|
||||
const templates = ref<CrmMailTemplateVO.Info[]>([]);
|
||||
const ctx = ref({
|
||||
customerId: 0,
|
||||
refType: undefined as string | undefined,
|
||||
refId: undefined as number | undefined,
|
||||
defaultTo: '',
|
||||
scene: undefined as string | undefined,
|
||||
});
|
||||
|
||||
const form = ref({
|
||||
accountId: undefined as number | undefined,
|
||||
templateId: undefined as number | undefined,
|
||||
toEmail: '',
|
||||
ccEmail: '',
|
||||
subject: '',
|
||||
bodyHtml: '',
|
||||
});
|
||||
|
||||
const rules = {
|
||||
templateId: [{ required: true, message: '请选择模板', trigger: 'change' }],
|
||||
toEmail: [{ required: true, message: '请填写收件人', trigger: 'blur' }],
|
||||
subject: [{ required: true, message: '请填写主题', trigger: 'blur' }],
|
||||
bodyHtml: [{ required: true, message: '请填写正文', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
async function open(opts: {
|
||||
customerId: number;
|
||||
toEmail?: string;
|
||||
refType?: string;
|
||||
refId?: number;
|
||||
scene?: string;
|
||||
}) {
|
||||
ctx.value = {
|
||||
customerId: opts.customerId,
|
||||
refType: opts.refType,
|
||||
refId: opts.refId,
|
||||
defaultTo: opts.toEmail ?? '',
|
||||
scene: opts.scene,
|
||||
};
|
||||
const [acc, tpl] = await Promise.all([
|
||||
getCrmMailAccountOptionsApi(),
|
||||
getCrmMailTemplateOptionsApi(opts.scene),
|
||||
]);
|
||||
accounts.value = acc ?? [];
|
||||
templates.value = tpl ?? [];
|
||||
const defaultAcc = accounts.value.find((a) => a.isDefault === 1);
|
||||
form.value = {
|
||||
accountId: defaultAcc?.id ?? accounts.value[0]?.id,
|
||||
templateId: templates.value[0]?.id,
|
||||
toEmail: opts.toEmail ?? '',
|
||||
ccEmail: '',
|
||||
subject: '',
|
||||
bodyHtml: '',
|
||||
};
|
||||
modalApi.setState({ title: '发送邮件' });
|
||||
modalApi.open();
|
||||
if (form.value.templateId) {
|
||||
await handlePreview();
|
||||
}
|
||||
}
|
||||
|
||||
async function handlePreview() {
|
||||
if (!form.value.templateId || !ctx.value.customerId) {
|
||||
return;
|
||||
}
|
||||
const preview = await previewCrmMailApi({
|
||||
templateId: form.value.templateId,
|
||||
customerId: ctx.value.customerId,
|
||||
refType: ctx.value.refType,
|
||||
refId: ctx.value.refId,
|
||||
});
|
||||
form.value.subject = preview.subject;
|
||||
form.value.bodyHtml = preview.bodyHtml;
|
||||
if (!form.value.toEmail) {
|
||||
form.value.toEmail = preview.toEmail || ctx.value.defaultTo || '';
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSend() {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
modalApi.setState({ confirmLoading: true });
|
||||
try {
|
||||
await sendCrmMailApi({
|
||||
accountId: form.value.accountId,
|
||||
templateId: form.value.templateId,
|
||||
customerId: ctx.value.customerId,
|
||||
refType: ctx.value.refType,
|
||||
refId: ctx.value.refId,
|
||||
toEmail: form.value.toEmail,
|
||||
ccEmail: form.value.ccEmail || undefined,
|
||||
subject: form.value.subject,
|
||||
bodyHtml: form.value.bodyHtml,
|
||||
});
|
||||
message.success('发送成功');
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} finally {
|
||||
modalApi.setState({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal>
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 4 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="发件账户">
|
||||
<Select
|
||||
v-model:value="form.accountId"
|
||||
allow-clear
|
||||
:options="
|
||||
accounts.map((a) => ({
|
||||
value: a.id,
|
||||
label: `${a.name} <${a.fromEmail}>`,
|
||||
}))
|
||||
"
|
||||
placeholder="默认账户"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="模板" name="templateId">
|
||||
<Select
|
||||
v-model:value="form.templateId"
|
||||
:options="
|
||||
templates.map((t) => ({
|
||||
value: t.id,
|
||||
label: `${t.name} (${t.scene})`,
|
||||
}))
|
||||
"
|
||||
@change="handlePreview"
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item label="收件人" name="toEmail">
|
||||
<Input v-model:value="form.toEmail" />
|
||||
</Form.Item>
|
||||
<Form.Item label="抄送">
|
||||
<Input v-model:value="form.ccEmail" placeholder="可选,逗号分隔" />
|
||||
</Form.Item>
|
||||
<Form.Item label="主题" name="subject">
|
||||
<Input v-model:value="form.subject" />
|
||||
</Form.Item>
|
||||
<Form.Item label="正文" name="bodyHtml">
|
||||
<Input.TextArea v-model:value="form.bodyHtml" :rows="10" />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
useActionColumnVisible,
|
||||
} from '#/composables/use-vxe-action-column';
|
||||
|
||||
import SendMailModal from '../mail/components/SendMailModal.vue';
|
||||
import QuoteModal from './components/QuoteModal.vue';
|
||||
|
||||
defineOptions({ name: 'CrmQuote' });
|
||||
@@ -39,6 +40,7 @@ defineOptions({ name: 'CrmQuote' });
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
const loading = ref(false);
|
||||
const modalRef = ref<InstanceType<typeof QuoteModal>>();
|
||||
const mailModalRef = ref<InstanceType<typeof SendMailModal>>();
|
||||
const searchForm = ref({
|
||||
keyword: '',
|
||||
status: undefined as string | undefined,
|
||||
@@ -59,6 +61,7 @@ const actionCodes = [
|
||||
'crm:quote:status',
|
||||
'crm:quote:export',
|
||||
'crm:shipment:create',
|
||||
'crm:mail:send',
|
||||
];
|
||||
const showActionColumn = useActionColumnVisible(actionCodes);
|
||||
|
||||
@@ -82,7 +85,7 @@ const actionColumn: NonNullable<
|
||||
VxeGridProps<CrmQuoteVO.Info>['columns']
|
||||
>[number] = {
|
||||
title: '操作',
|
||||
width: 340,
|
||||
width: 380,
|
||||
fixed: 'right',
|
||||
slots: { default: 'action' },
|
||||
};
|
||||
@@ -236,6 +239,22 @@ function statusActions(row: CrmQuoteVO.Info) {
|
||||
导出PI
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:mail:send">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
@click="
|
||||
mailModalRef?.open({
|
||||
customerId: row.customerId,
|
||||
refType: 'quote',
|
||||
refId: row.id,
|
||||
scene: 'quote_followup',
|
||||
})
|
||||
"
|
||||
>
|
||||
发邮件
|
||||
</Button>
|
||||
</PermissionGate>
|
||||
<PermissionGate code="crm:shipment:create">
|
||||
<Button
|
||||
v-if="row.status === 'accepted'"
|
||||
@@ -279,5 +298,6 @@ function statusActions(row: CrmQuoteVO.Info) {
|
||||
</template>
|
||||
</Grid>
|
||||
<QuoteModal ref="modalRef" @success="gridApi.reload()" />
|
||||
<SendMailModal ref="mailModalRef" />
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user