reactor:【system 系统管理】mail/log 进一步统一代码风格
parent
9565de2b5c
commit
5f77cde53f
|
|
@ -4,13 +4,12 @@ import type { DescriptionItemSchema } from '#/components/description';
|
||||||
|
|
||||||
import { h } from 'vue';
|
import { h } from 'vue';
|
||||||
|
|
||||||
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
import { getDictOptions } from '@vben/hooks';
|
||||||
import { formatDateTime } from '@vben/utils';
|
import { formatDateTime } from '@vben/utils';
|
||||||
|
|
||||||
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
|
||||||
import { getDictOptions } from '@vben/hooks';
|
|
||||||
|
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
|
|
@ -84,22 +83,24 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
title: '编号',
|
title: '编号',
|
||||||
|
minWidth: 100,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'sendTime',
|
field: 'sendTime',
|
||||||
title: '发送时间',
|
title: '发送时间',
|
||||||
|
minWidth: 180,
|
||||||
formatter: 'formatDateTime',
|
formatter: 'formatDateTime',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'userType',
|
field: 'userType',
|
||||||
title: '接收用户',
|
title: '接收用户',
|
||||||
width: 150,
|
minWidth: 150,
|
||||||
slots: { default: 'userInfo' },
|
slots: { default: 'userInfo' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'toMails',
|
field: 'toMails',
|
||||||
title: '接收信息',
|
title: '接收信息',
|
||||||
width: 300,
|
minWidth: 300,
|
||||||
formatter: ({ row }) => {
|
formatter: ({ row }) => {
|
||||||
const lines: string[] = [];
|
const lines: string[] = [];
|
||||||
if (row.toMails && row.toMails.length > 0) {
|
if (row.toMails && row.toMails.length > 0) {
|
||||||
|
|
@ -117,18 +118,22 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'templateTitle',
|
field: 'templateTitle',
|
||||||
title: '邮件标题',
|
title: '邮件标题',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'templateContent',
|
field: 'templateContent',
|
||||||
title: '邮件内容',
|
title: '邮件内容',
|
||||||
|
minWidth: 300,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'fromMail',
|
field: 'fromMail',
|
||||||
title: '发送邮箱',
|
title: '发送邮箱',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'sendStatus',
|
field: 'sendStatus',
|
||||||
title: '发送状态',
|
title: '发送状态',
|
||||||
|
minWidth: 120,
|
||||||
cellRender: {
|
cellRender: {
|
||||||
name: 'CellDict',
|
name: 'CellDict',
|
||||||
props: { type: DICT_TYPE.SYSTEM_MAIL_SEND_STATUS },
|
props: { type: DICT_TYPE.SYSTEM_MAIL_SEND_STATUS },
|
||||||
|
|
@ -137,6 +142,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
{
|
{
|
||||||
field: 'templateCode',
|
field: 'templateCode',
|
||||||
title: '模板编码',
|
title: '模板编码',
|
||||||
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '操作',
|
title: '操作',
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { DICT_TYPE } from '@vben/constants';
|
||||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getMailLogPage } from '#/api/system/mail/log';
|
import { getMailLogPage } from '#/api/system/mail/log';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import Detail from './modules/detail.vue';
|
import Detail from './modules/detail.vue';
|
||||||
|
|
@ -18,7 +19,7 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,6 +49,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
|
@ -62,7 +64,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="邮件日志列表">
|
<Grid table-title="邮件日志列表">
|
||||||
<template #userInfo="{ row }">
|
<template #userInfo="{ row }">
|
||||||
<div v-if="row.userType && row.userId" class="flex items-center gap-1">
|
<div v-if="row.userType && row.userId" class="flex items-center gap-1">
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemMailLogApi } from '#/api/system/mail/log';
|
|
||||||
|
|
||||||
import { useAccess } from '@vben/access';
|
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
import { getDictOptions } from '@vben/hooks';
|
import { getDictOptions } from '@vben/hooks';
|
||||||
|
|
||||||
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
import { getSimpleMailAccountList } from '#/api/system/mail/account';
|
||||||
import { getRangePickerDefaultProps } from '#/utils';
|
import { getRangePickerDefaultProps } from '#/utils';
|
||||||
|
|
||||||
const { hasAccessByCodes } = useAccess();
|
|
||||||
|
|
||||||
/** 列表的搜索表单 */
|
/** 列表的搜索表单 */
|
||||||
export function useGridFormSchema(): VbenFormSchema[] {
|
export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
return [
|
return [
|
||||||
|
|
@ -77,9 +73,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 列表的字段 */
|
/** 列表的字段 */
|
||||||
export function useGridColumns<T = SystemMailLogApi.MailLog>(
|
export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||||
onActionClick: OnActionClickFn<T>,
|
|
||||||
): VxeTableGridOptions['columns'] {
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
field: 'id',
|
field: 'id',
|
||||||
|
|
@ -146,26 +140,10 @@ export function useGridColumns<T = SystemMailLogApi.MailLog>(
|
||||||
minWidth: 120,
|
minWidth: 120,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'operation',
|
|
||||||
title: '操作',
|
title: '操作',
|
||||||
minWidth: 80,
|
width: 80,
|
||||||
align: 'center',
|
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
cellRender: {
|
slots: { default: 'actions' },
|
||||||
attrs: {
|
|
||||||
nameField: 'toMail',
|
|
||||||
nameTitle: '邮件日志',
|
|
||||||
onClick: onActionClick,
|
|
||||||
},
|
|
||||||
name: 'CellOperation',
|
|
||||||
options: [
|
|
||||||
{
|
|
||||||
code: 'detail',
|
|
||||||
text: '查看',
|
|
||||||
show: hasAccessByCodes(['system:mail-log:query']),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type {
|
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
OnActionClickParams,
|
|
||||||
VxeTableGridOptions,
|
|
||||||
} from '#/adapter/vxe-table';
|
|
||||||
import type { SystemMailLogApi } from '#/api/system/mail/log';
|
import type { SystemMailLogApi } from '#/api/system/mail/log';
|
||||||
|
|
||||||
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { DICT_TYPE } from '@vben/constants';
|
import { DICT_TYPE } from '@vben/constants';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import { getMailLogPage } from '#/api/system/mail/log';
|
import { getMailLogPage } from '#/api/system/mail/log';
|
||||||
import { DictTag } from '#/components/dict-tag';
|
import { DictTag } from '#/components/dict-tag';
|
||||||
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import Detail from './modules/detail.vue';
|
import Detail from './modules/detail.vue';
|
||||||
|
|
@ -21,34 +19,21 @@ const [DetailModal, detailModalApi] = useVbenModal({
|
||||||
});
|
});
|
||||||
|
|
||||||
/** 刷新表格 */
|
/** 刷新表格 */
|
||||||
function onRefresh() {
|
function handleRefresh() {
|
||||||
gridApi.query();
|
gridApi.query();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查看邮件日志 */
|
/** 查看邮件日志 */
|
||||||
function onDetail(row: SystemMailLogApi.MailLog) {
|
function handleDetail(row: SystemMailLogApi.MailLog) {
|
||||||
detailModalApi.setData(row).open();
|
detailModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 表格操作按钮的回调函数 */
|
|
||||||
function onActionClick({
|
|
||||||
code,
|
|
||||||
row,
|
|
||||||
}: OnActionClickParams<SystemMailLogApi.MailLog>) {
|
|
||||||
switch (code) {
|
|
||||||
case 'detail': {
|
|
||||||
onDetail(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const [Grid, gridApi] = useVbenVxeGrid({
|
const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
formOptions: {
|
formOptions: {
|
||||||
schema: useGridFormSchema(),
|
schema: useGridFormSchema(),
|
||||||
},
|
},
|
||||||
gridOptions: {
|
gridOptions: {
|
||||||
columns: useGridColumns(onActionClick),
|
columns: useGridColumns(),
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
|
|
@ -64,6 +49,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
},
|
},
|
||||||
rowConfig: {
|
rowConfig: {
|
||||||
keyField: 'id',
|
keyField: 'id',
|
||||||
|
isHover: true,
|
||||||
},
|
},
|
||||||
toolbarConfig: {
|
toolbarConfig: {
|
||||||
refresh: true,
|
refresh: true,
|
||||||
|
|
@ -78,7 +64,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
<DocAlert title="邮件配置" url="https://doc.iocoder.cn/mail" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<DetailModal @success="onRefresh" />
|
<DetailModal @success="handleRefresh" />
|
||||||
<Grid table-title="邮件日志列表">
|
<Grid table-title="邮件日志列表">
|
||||||
<template #userInfo="{ row }">
|
<template #userInfo="{ row }">
|
||||||
<div v-if="row.userType && row.userId" class="flex items-center gap-1">
|
<div v-if="row.userType && row.userId" class="flex items-center gap-1">
|
||||||
|
|
@ -87,7 +73,20 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
</div>
|
</div>
|
||||||
<div v-else>-</div>
|
<div v-else>-</div>
|
||||||
</template>
|
</template>
|
||||||
<template #toolbar-tools> </template>
|
<template #actions="{ row }">
|
||||||
|
<TableAction
|
||||||
|
:actions="[
|
||||||
|
{
|
||||||
|
label: $t('common.detail'),
|
||||||
|
type: 'primary',
|
||||||
|
link: true,
|
||||||
|
icon: ACTION_ICON.VIEW,
|
||||||
|
auth: ['system:mail-log:query'],
|
||||||
|
onClick: handleDetail.bind(null, row),
|
||||||
|
},
|
||||||
|
]"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue