1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| import type { CrudSchema } from '@/hooks/web/useCrudSchemas'
| import { dateFormatter } from '@/utils/formatTime'
| import { TableColumn } from '@/types/table'
| import * as MailAccountApi from '@/api/system/mail/account'
|
| // 邮箱账号的列表
| const accountList = await MailAccountApi.getSimpleMailAccountList()
|
| // 表单校验
| export const rules = reactive({
| name: [required],
| code: [required],
| accountId: [required],
| label: [required],
| content: [required],
| params: [required],
| status: [required]
| })
|
| const crudSchemas = reactive<CrudSchema[]>([
| {
| label: '模板编码',
| field: 'code',
| isSearch: true
| },
| {
| label: '模板名称',
| field: 'name',
| isSearch: true
| },
| {
| label: '模板标题',
| field: 'title'
| },
| {
| label: '模板内容',
| field: 'content',
| form: {
| component: 'Editor',
| componentProps: {
| valueHtml: '',
| height: 200
| }
| }
| },
| {
| label: '邮箱账号',
| field: 'accountId',
| width: '200px',
| formatter: (_: Recordable, __: TableColumn, cellValue: number) => {
| return accountList.find((account) => account.id === cellValue)?.mail
| },
| search: {
| show: true,
| component: 'Select',
| api: () => accountList,
| componentProps: {
| optionsAlias: {
| labelField: 'mail',
| valueField: 'id'
| }
| }
| },
| form: {
| component: 'Select',
| api: () => accountList,
| componentProps: {
| optionsAlias: {
| labelField: 'mail',
| valueField: 'id'
| }
| }
| }
| },
| {
| label: '发送人名称',
| field: 'nickname'
| },
| {
| label: '开启状态',
| field: 'status',
| isSearch: true,
| dictType: DICT_TYPE.COMMON_STATUS,
| dictClass: 'number'
| },
| {
| label: '备注',
| field: 'remark',
| isTable: false
| },
| {
| label: '创建时间',
| field: 'createTime',
| isForm: false,
| formatter: dateFormatter,
| search: {
| show: true,
| component: 'DatePicker',
| componentProps: {
| valueFormat: 'YYYY-MM-DD HH:mm:ss',
| type: 'daterange',
| defaultTime: [new Date('1 00:00:00'), new Date('1 23:59:59')]
| }
| }
| },
| {
| label: '操作',
| field: 'action',
| isForm: false
| }
| ])
| export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|