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
| import { buildUUID } from '@vben/utils';
|
| import {
| localeProps,
| makeRequiredRule,
| } from '#/components/form-create/helpers';
|
| export function useUploadImageRule() {
| const label = '单图上传';
| const name = 'ImageUpload';
| return {
| icon: 'icon-image',
| label,
| name,
| rule() {
| return {
| type: name,
| field: buildUUID(),
| title: label,
| info: '',
| $required: false,
| };
| },
| props(_: any, { t }: any) {
| return localeProps(t, `${name}.props`, [
| makeRequiredRule(),
| {
| type: 'select',
| field: 'accept',
| title: '图片类型限制',
| value: ['image/jpeg', 'image/png', 'image/gif'],
| options: [
| { label: 'image/apng', value: 'image/apng' },
| { label: 'image/bmp', value: 'image/bmp' },
| { label: 'image/gif', value: 'image/gif' },
| { label: 'image/jpeg', value: 'image/jpeg' },
| { label: 'image/pjpeg', value: 'image/pjpeg' },
| { label: 'image/svg+xml', value: 'image/svg+xml' },
| { label: 'image/tiff', value: 'image/tiff' },
| { label: 'image/webp', value: 'image/webp' },
| { label: 'image/x-icon', value: 'image/x-icon' },
| ],
| props: {
| mode: 'multiple',
| },
| },
| {
| type: 'inputNumber',
| field: 'maxSize',
| title: '大小限制(MB)',
| value: 5,
| props: { min: 0 },
| },
| {
| type: 'switch',
| field: 'disabled',
| title: '是否禁用',
| value: false,
| },
| ]);
| },
| };
| }
|
|