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
113
114
115
116
117
118
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { WxCpNoticeApi } from '#/api/wxcp/notice';
|
| import { NOTICE_STATUS_OPTIONS, PUSH_STATUS_OPTIONS } from '../data';
|
| /** 表单类型 */
| export type NoticeFormType = 'create' | 'update' | 'detail';
|
| /** 通知表单 */
| export function useNoticeFormSchema(formType: NoticeFormType): VbenFormSchema[] {
| const readonly = formType === 'detail';
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: { triggerFields: [''], show: () => false },
| },
| {
| fieldName: 'title',
| label: '通知标题',
| component: 'Input',
| componentProps: { placeholder: '请输入通知标题', disabled: readonly },
| rules: 'required',
| formItemClass: 'col-span-2',
| },
| {
| fieldName: 'content',
| label: '通知正文',
| component: 'Textarea',
| componentProps: {
| rows: 8,
| placeholder: '请输入通知正文',
| disabled: readonly,
| },
| rules: 'required',
| help: '推送时超过 600 字会自动截断,建议把关键信息放前面',
| formItemClass: 'col-span-2',
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: { rows: 2, placeholder: '内部备注,不推送', disabled: readonly },
| formItemClass: 'col-span-2',
| },
| ];
| }
|
| /** 通知搜索表单 */
| export function useNoticeSearchFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'title',
| label: '通知标题',
| component: 'Input',
| componentProps: { allowClear: true, placeholder: '请输入通知标题' },
| },
| {
| fieldName: 'status',
| label: '状态',
| component: 'Select',
| componentProps: {
| allowClear: true,
| options: NOTICE_STATUS_OPTIONS,
| placeholder: '请选择状态',
| },
| },
| {
| fieldName: 'pushStatus',
| label: '推送状态',
| component: 'Select',
| componentProps: {
| allowClear: true,
| options: PUSH_STATUS_OPTIONS,
| placeholder: '请选择推送状态',
| },
| },
| ];
| }
|
| /** 通知列表字段 */
| export function useNoticeGridColumns(): VxeTableGridOptions<WxCpNoticeApi.Notice>['columns'] {
| return [
| {
| field: 'title',
| title: '通知标题',
| minWidth: 220,
| slots: { default: 'title' },
| },
| {
| field: 'content',
| title: '正文摘要',
| minWidth: 260,
| slots: { default: 'content' },
| },
| {
| field: 'status',
| title: '状态',
| width: 90,
| slots: { default: 'status' },
| },
| {
| field: 'pushScopeName',
| title: '推送范围',
| width: 110,
| },
| {
| field: 'pushStatus',
| title: '推送',
| width: 90,
| slots: { default: 'pushStatus' },
| },
| { field: 'pushTime', title: '推送时间', width: 170 },
| { field: 'createTime', title: '创建时间', width: 170 },
| { title: '操作', width: 220, fixed: 'right', slots: { default: 'actions' } },
| ];
| }
|
|