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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
| import type { VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
| import { DICT_TYPE } from '@vben/constants';
| import { getDictOptions } from '@vben/hooks';
| import { markRaw } from 'vue';
|
| import { AreaCascader } from '#/components/area';
|
| /** 表单类型 */
| export type FormType = 'create' | 'detail' | 'edit';
|
| /** 入会申请状态(对应字典 ums_application_status) */
| export const ApplicationStatus = {
| DRAFT: 0, // 草稿
| APPROVING: 15, // 审批中
| APPROVED: 20, // 已通过
| REJECTED: 35, // 已驳回
| } as const;
|
| /** 会员类型(对应字典 ums_member_type) */
| export const MemberType = {
| PERSONAL: 1, // 个人会员
| UNIT: 2, // 单位会员
| } as const;
|
| /** 根据会员类型获取等级字典选项 */
| export function getGradeDictOptions(memberType?: number) {
| return getDictOptions(
| memberType === MemberType.UNIT
| ? DICT_TYPE.UMS_UNIT_GRADE
| : DICT_TYPE.UMS_PERSONAL_GRADE,
| 'string',
| );
| }
|
| /** 表单配置 */
| export function useFormSchema(formType: FormType): VbenFormSchema[] {
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: {
| triggerFields: [''],
| show: () => false,
| },
| },
| {
| fieldName: 'no',
| label: '申请编号',
| component: 'Input',
| componentProps: {
| placeholder: '申请编号由系统自动生成',
| disabled: true,
| },
| },
| {
| fieldName: 'memberType',
| label: '会员类型',
| component: 'Select',
| componentProps: (_values, form) => ({
| options: getDictOptions(DICT_TYPE.UMS_MEMBER_TYPE, 'number'),
| placeholder: '请选择会员类型',
| allowClear: true,
| disabled: formType === 'detail',
| onChange: () => {
| // 切换会员类型后清空已选等级(个人与单位使用不同等级字典)
| form.setFieldValue('memberGrade', undefined);
| },
| }),
| rules: 'required',
| },
| {
| fieldName: 'applicantName',
| label: '申请人/单位名称',
| component: 'Input',
| componentProps: {
| placeholder: '个人填写姓名,单位填写单位名称',
| maxlength: 64,
| disabled: formType === 'detail',
| },
| rules: 'required',
| },
| {
| fieldName: 'memberGrade',
| label: '申请等级',
| component: 'Select',
| componentProps: (values) => ({
| options: getGradeDictOptions(values.memberType),
| placeholder: '请选择申请等级',
| allowClear: true,
| disabled: formType === 'detail',
| }),
| rules: 'required',
| },
| {
| fieldName: 'contactPhone',
| label: '联系电话(登录账号)',
| component: 'Input',
| componentProps: {
| placeholder: '请输入联系电话,将作为会员系统登录账号',
| maxlength: 20,
| disabled: formType === 'detail',
| },
| help: '审批通过后将自动创建系统登录账号:用户名与初始密码均为联系电话,请务必填写准确',
| },
| {
| fieldName: 'contactEmail',
| label: '邮箱',
| component: 'Input',
| componentProps: {
| placeholder: '请输入邮箱',
| maxlength: 128,
| disabled: formType === 'detail',
| },
| },
| {
| fieldName: 'workUnit',
| label: '工作单位',
| component: 'Input',
| componentProps: {
| placeholder: '请输入工作单位(个人会员填写)',
| maxlength: 128,
| disabled: formType === 'detail',
| },
| dependencies: {
| triggerFields: ['memberType'],
| show: (values) => values.memberType === MemberType.PERSONAL,
| },
| },
| {
| fieldName: 'title',
| label: '职称',
| component: 'Input',
| componentProps: {
| placeholder: '请输入职称(个人会员填写)',
| maxlength: 64,
| disabled: formType === 'detail',
| },
| dependencies: {
| triggerFields: ['memberType'],
| show: (values) => values.memberType === MemberType.PERSONAL,
| },
| },
| {
| fieldName: 'legalPerson',
| label: '法定代表人',
| component: 'Input',
| componentProps: {
| placeholder: '请输入法定代表人(单位会员填写)',
| maxlength: 64,
| disabled: formType === 'detail',
| },
| dependencies: {
| triggerFields: ['memberType'],
| show: (values) => values.memberType === MemberType.UNIT,
| },
| },
| {
| fieldName: 'organizationCode',
| label: '统一社会信用代码',
| component: 'Input',
| componentProps: {
| placeholder: '请输入统一社会信用代码(单位会员填写)',
| maxlength: 64,
| disabled: formType === 'detail',
| },
| dependencies: {
| triggerFields: ['memberType'],
| show: (values) => values.memberType === MemberType.UNIT,
| },
| },
| {
| fieldName: 'researchDirection',
| label: '研究方向',
| component: 'Textarea',
| componentProps: {
| placeholder: '请输入研究方向',
| autoSize: { minRows: 2, maxRows: 3 },
| disabled: formType === 'detail',
| },
| formItemClass: 'col-span-2',
| },
| {
| fieldName: 'regionCode',
| label: '地区',
| component: markRaw(AreaCascader),
| componentProps: {
| placeholder: '请选择地区',
| allowClear: true,
| class: '!w-full',
| disabled: formType === 'detail',
| },
| },
| {
| fieldName: 'industry',
| label: '行业',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.UMS_INDUSTRY, 'string'),
| placeholder: '请选择行业',
| allowClear: true,
| disabled: formType === 'detail',
| },
| },
| {
| fieldName: 'status',
| label: '状态',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.UMS_APPLICATION_STATUS, 'number'),
| disabled: true,
| },
| dependencies: {
| triggerFields: [''],
| show: () => formType !== 'create',
| },
| },
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: {
| placeholder: '请输入备注',
| autoSize: { minRows: 2, maxRows: 3 },
| disabled: formType === 'detail',
| },
| formItemClass: 'col-span-2',
| },
| {
| fieldName: 'blobIds',
| label: '附件',
| component: 'FileUpload',
| componentProps: {
| valueKey: 'id',
| maxNumber: 10,
| multiple: true,
| showDescription: formType !== 'detail',
| disabled: formType === 'detail',
| },
| formItemClass: 'col-span-2',
| },
| ];
| }
|
| /** 列表搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'no',
| label: '申请编号',
| component: 'Input',
| componentProps: {
| placeholder: '请输入申请编号',
| allowClear: true,
| },
| },
| {
| fieldName: 'status',
| label: '状态',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.UMS_APPLICATION_STATUS, 'number'),
| placeholder: '请选择状态',
| allowClear: true,
| },
| },
| {
| fieldName: 'memberType',
| label: '会员类型',
| component: 'Select',
| componentProps: {
| options: getDictOptions(DICT_TYPE.UMS_MEMBER_TYPE, 'number'),
| placeholder: '请选择会员类型',
| allowClear: true,
| },
| },
| ];
| }
|
| /** 列表列配置 */
| export function useGridColumns(): VxeTableGridOptions['columns'] {
| return [
| {
| type: 'checkbox',
| width: 50,
| fixed: 'left',
| },
| {
| field: 'no',
| title: '申请编号',
| width: 180,
| fixed: 'left',
| },
| {
| field: 'applicantName',
| title: '申请人/单位',
| minWidth: 140,
| },
| {
| field: 'memberType',
| title: '会员类型',
| minWidth: 100,
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.UMS_MEMBER_TYPE },
| },
| },
| {
| field: 'memberGrade',
| title: '申请等级',
| minWidth: 100,
| slots: { default: 'memberGrade' },
| },
| {
| field: 'status',
| title: '状态',
| minWidth: 95,
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.UMS_APPLICATION_STATUS },
| },
| },
| {
| field: 'hasAttachment',
| title: '附件',
| minWidth: 80,
| slots: { default: 'hasAttachment' },
| },
| {
| field: 'creatorName',
| title: '创建人',
| minWidth: 100,
| },
| {
| field: 'createTime',
| title: '创建时间',
| width: 165,
| formatter: 'formatDateTime',
| },
| {
| title: '操作',
| width: 290,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
|