提交 | 用户 | 时间
|
820397
|
1 |
import { generateUUID } from '@/utils' |
H |
2 |
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils' |
|
3 |
|
|
4 |
export const useUploadImgRule = () => { |
|
5 |
const label = '单图上传' |
|
6 |
const name = 'UploadImg' |
|
7 |
return { |
|
8 |
icon: 'icon-upload', |
|
9 |
label, |
|
10 |
name, |
|
11 |
rule() { |
|
12 |
return { |
|
13 |
type: name, |
|
14 |
field: generateUUID(), |
|
15 |
title: label, |
|
16 |
info: '', |
|
17 |
$required: false |
|
18 |
} |
|
19 |
}, |
|
20 |
props(_, { t }) { |
|
21 |
return localeProps(t, name + '.props', [ |
|
22 |
makeRequiredRule(), |
|
23 |
{ |
|
24 |
type: 'switch', |
|
25 |
field: 'drag', |
|
26 |
title: '拖拽上传', |
|
27 |
value: false |
|
28 |
}, |
|
29 |
{ |
|
30 |
type: 'select', |
|
31 |
field: 'fileType', |
|
32 |
title: '图片类型限制', |
|
33 |
value: ['image/jpeg', 'image/png', 'image/gif'], |
|
34 |
options: [ |
|
35 |
{ label: 'image/apng', value: 'image/apng' }, |
|
36 |
{ label: 'image/bmp', value: 'image/bmp' }, |
|
37 |
{ label: 'image/gif', value: 'image/gif' }, |
|
38 |
{ label: 'image/jpeg', value: 'image/jpeg' }, |
|
39 |
{ label: 'image/pjpeg', value: 'image/pjpeg' }, |
|
40 |
{ label: 'image/svg+xml', value: 'image/svg+xml' }, |
|
41 |
{ label: 'image/tiff', value: 'image/tiff' }, |
|
42 |
{ label: 'image/webp', value: 'image/webp' }, |
|
43 |
{ label: 'image/x-icon', value: 'image/x-icon' } |
|
44 |
], |
|
45 |
props: { |
|
46 |
multiple: true |
|
47 |
} |
|
48 |
}, |
|
49 |
{ |
|
50 |
type: 'inputNumber', |
|
51 |
field: 'fileSize', |
|
52 |
title: '大小限制(MB)', |
|
53 |
value: 5, |
|
54 |
props: { min: 0 } |
|
55 |
}, |
|
56 |
{ |
|
57 |
type: 'input', |
|
58 |
field: 'height', |
|
59 |
title: '组件高度', |
|
60 |
value: '150px' |
|
61 |
}, |
|
62 |
{ |
|
63 |
type: 'input', |
|
64 |
field: 'width', |
|
65 |
title: '组件宽度', |
|
66 |
value: '150px' |
|
67 |
}, |
|
68 |
{ |
|
69 |
type: 'input', |
|
70 |
field: 'borderradius', |
|
71 |
title: '组件边框圆角', |
|
72 |
value: '8px' |
|
73 |
}, |
|
74 |
{ |
|
75 |
type: 'switch', |
|
76 |
field: 'disabled', |
|
77 |
title: '是否显示删除按钮', |
|
78 |
value: true |
|
79 |
}, |
|
80 |
{ |
|
81 |
type: 'switch', |
|
82 |
field: 'showBtnText', |
|
83 |
title: '是否显示按钮文字', |
|
84 |
value: true |
|
85 |
} |
|
86 |
]) |
|
87 |
} |
|
88 |
} |
|
89 |
} |