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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
| import type { VxeGridProps } from '#/adapter/vxe-table';
|
| import { h } from 'vue';
|
| import { DictEnum } from '@vben/constants';
| import { FolderIcon, MenuIcon, VbenIcon } from '@vben/icons';
| import { getPopupContainer } from '@vben/utils';
|
| import { type FormSchemaGetter } from '#/adapter/form';
| import { getDictOptions } from '#/utils/dict';
| import { renderDict } from '#/utils/render';
|
| export const querySchema: FormSchemaGetter = () => [
| {
| component: 'Input',
| fieldName: 'typeName',
| label: '类型名称 '
| },
| {
| component: 'Select',
| componentProps: {
| getPopupContainer,
| options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE)
| },
| fieldName: 'status',
| label: '类型状态 '
| }
| ];
|
| // 菜单类型(M目录 C菜单 F按钮)
| export const fixtureTypeOptions = [
| { label: '目录', value: 'M' },
| { label: '类型', value: 'C' }
| ];
|
| export const yesNoOptions = [
| { label: '是', value: '0' },
| { label: '否', value: '1' }
| ];
|
| // (M目录 C菜单)
| const menuTypes = {
| M: { icon: FolderIcon, value: '目录' },
| C: { icon: MenuIcon, value: '类型' }
| };
| export const columns: VxeGridProps['columns'] = [
| {
| title: '类型名称',
| field: 'typeName',
| treeNode: true,
| width: 200
| },
| {
| title: '类型编码',
| field: 'typeCode',
| width: 200
| },
| {
| title: '图标',
| field: 'icon',
| width: 80,
| slots: {
| default: ({ row }) => {
| if (row?.icon === '#') {
| return '';
| }
| return (
| <span class={'flex justify-center'}>
| <VbenIcon icon={row.icon} />
| </span>
| );
| }
| }
| },
| {
| title: '排序',
| field: 'orderNum',
| width: 120
| },
| {
| title: '节点类型',
| field: 'menuType',
| width: 150,
| slots: {
| default: ({ row }) => {
| const current = menuTypes[row.menuType as 'C' | 'M'];
| if (!current) {
| return '未知';
| }
| return (
| <span class="flex items-center justify-center gap-1">
| {h(current.icon, { class: 'size-[18px]' })}
| <span>{current.value}</span>
| </span>
| );
| }
| }
| },
| {
| title: '状态',
| field: 'status',
| width: 100,
| slots: {
| default: ({ row }) => {
| return renderDict(row.status, DictEnum.SYS_NORMAL_DISABLE);
| }
| }
| },
| {
| title: '创建时间',
| field: 'createTime'
| },
| {
| field: 'action',
| fixed: 'right',
| slots: { default: 'action' },
| title: '操作',
| width: 200
| }
| ];
|
| export const drawerSchema: FormSchemaGetter = () => [
| {
| component: 'Input',
| dependencies: {
| show: () => false,
| triggerFields: ['']
| },
| fieldName: 'id'
| },
| {
| component: 'TreeSelect',
| defaultValue: 0,
| fieldName: 'parentId',
| label: '上级菜单',
| rules: 'selectRequired'
| },
| {
| component: 'RadioGroup',
| componentProps: {
| buttonStyle: 'solid',
| options: fixtureTypeOptions,
| optionType: 'button'
| },
| defaultValue: 'M',
| dependencies: {
| componentProps: (_, api) => {
| // 切换时清空校验
| // 直接抄的源码 没有清空校验的方法
| Object.keys(api.errors.value).forEach((key) => {
| api.setFieldError(key, undefined);
| });
| return {};
| },
| triggerFields: ['menuType']
| },
| fieldName: 'menuType',
| label: '节点类型'
| },
| {
| component: 'Input',
| fieldName: 'typeName',
| label: '类型名称',
| rules: 'required'
| },
| {
| component: 'Input',
| fieldName: 'typeCode',
| label: '类型编码',
| rules: 'required'
| },
| {
| component: 'InputNumber',
| fieldName: 'orderNum',
| help: '排序, 数字越小越靠前',
| label: '显示排序',
| rules: 'required'
| },
| {
| component: 'RadioGroup',
| componentProps: {
| buttonStyle: 'solid',
| options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
| optionType: 'button'
| },
| defaultValue: '0',
| dependencies: {
| // 类型不为按钮时显示
| show: (values) => values.menuType !== 'F',
| triggerFields: ['menuType']
| },
| fieldName: 'status',
| help: '停用后不会出现在列表',
| label: '类型状态'
| }
| ];
|
|