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