Files
iot-device-management-frontend/apps/web-antd/src/views/system/mail/account/data.ts

177 lines
3.8 KiB
TypeScript
Raw Normal View History

2025-04-03 23:39:31 +08:00
import type { VbenFormSchema } from '#/adapter/form';
2025-05-19 17:58:06 +08:00
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
2025-04-22 11:25:11 +08:00
2025-09-05 12:00:24 +08:00
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
2025-04-03 23:39:31 +08:00
import { z } from '#/adapter/form';
2025-04-03 23:39:31 +08:00
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'id',
component: 'Input',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'mail',
label: '邮箱',
component: 'Input',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入邮箱',
},
2025-04-03 23:39:31 +08:00
rules: 'required',
},
{
fieldName: 'username',
label: '用户名',
component: 'Input',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入用户名',
},
2025-04-03 23:39:31 +08:00
rules: 'required',
},
{
fieldName: 'password',
label: '密码',
component: 'InputPassword',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入密码',
},
2025-04-03 23:39:31 +08:00
rules: 'required',
},
{
fieldName: 'host',
label: 'SMTP 服务器域名',
component: 'Input',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入 SMTP 服务器域名',
},
2025-04-03 23:39:31 +08:00
rules: 'required',
},
{
fieldName: 'port',
label: 'SMTP 服务器端口',
component: 'InputNumber',
componentProps: {
2025-04-04 17:45:56 +08:00
placeholder: '请输入 SMTP 服务器端口',
2025-04-03 23:39:31 +08:00
min: 0,
max: 65_535,
},
rules: 'required',
},
{
fieldName: 'sslEnable',
label: '是否开启 SSL',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
rules: z.boolean().default(true),
},
{
fieldName: 'starttlsEnable',
label: '是否开启 STARTTLS',
component: 'RadioGroup',
componentProps: {
options: getDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING, 'boolean'),
buttonStyle: 'solid',
optionType: 'button',
},
rules: z.boolean().default(false),
},
{
fieldName: 'remark',
label: '备注',
component: 'Textarea',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入备注',
2025-04-22 11:25:11 +08:00
},
2025-04-03 23:39:31 +08:00
},
];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
return [
{
fieldName: 'mail',
label: '邮箱',
component: 'Input',
2025-04-04 17:45:56 +08:00
componentProps: {
placeholder: '请输入邮箱',
allowClear: true,
2025-04-22 11:25:11 +08:00
},
2025-04-03 23:39:31 +08:00
},
{
fieldName: 'username',
label: '用户名',
component: 'Input',
componentProps: {
2025-04-04 17:45:56 +08:00
placeholder: '请输入用户名',
allowClear: true,
2025-04-22 11:25:11 +08:00
},
},
2025-04-03 23:39:31 +08:00
];
}
/** 列表的字段 */
2025-05-19 17:58:06 +08:00
export function useGridColumns(): VxeTableGridOptions['columns'] {
2025-04-03 23:39:31 +08:00
return [
{ type: 'checkbox', width: 40 },
2025-04-03 23:39:31 +08:00
{
field: 'id',
title: '编号',
},
{
field: 'mail',
title: '邮箱',
},
{
field: 'username',
title: '用户名',
},
{
field: 'host',
title: 'SMTP 服务器域名',
},
{
field: 'port',
title: 'SMTP 服务器端口',
},
{
field: 'sslEnable',
title: '是否开启 SSL',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'starttlsEnable',
title: '是否开启 STARTTLS',
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.INFRA_BOOLEAN_STRING },
},
},
{
field: 'createTime',
title: '创建时间',
formatter: 'formatDateTime',
},
{
title: '操作',
2025-05-19 17:58:06 +08:00
width: 130,
2025-04-03 23:39:31 +08:00
fixed: 'right',
2025-05-19 17:58:06 +08:00
slots: { default: 'actions' },
2025-04-03 23:39:31 +08:00
},
];
}