提交 | 用户 | 时间
|
820397
|
1 |
import { generateUUID } from '@/utils' |
H |
2 |
import { localeProps, makeRequiredRule } from '@/components/FormCreate/src/utils' |
|
3 |
|
|
4 |
export const useUploadFileRule = () => { |
|
5 |
const label = '文件上传' |
|
6 |
const name = 'UploadFile' |
|
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: 'select', |
|
25 |
field: 'fileType', |
|
26 |
title: '文件类型', |
|
27 |
value: ['doc', 'xls', 'ppt', 'txt', 'pdf'], |
|
28 |
options: [ |
|
29 |
{ label: 'doc', value: 'doc' }, |
|
30 |
{ label: 'xls', value: 'xls' }, |
|
31 |
{ label: 'ppt', value: 'ppt' }, |
|
32 |
{ label: 'txt', value: 'txt' }, |
|
33 |
{ label: 'pdf', value: 'pdf' } |
|
34 |
], |
|
35 |
props: { |
|
36 |
multiple: true |
|
37 |
} |
|
38 |
}, |
|
39 |
{ |
|
40 |
type: 'switch', |
|
41 |
field: 'autoUpload', |
|
42 |
title: '是否在选取文件后立即进行上传', |
|
43 |
value: true |
|
44 |
}, |
|
45 |
{ |
|
46 |
type: 'switch', |
|
47 |
field: 'drag', |
|
48 |
title: '拖拽上传', |
|
49 |
value: false |
|
50 |
}, |
|
51 |
{ |
|
52 |
type: 'switch', |
|
53 |
field: 'isShowTip', |
|
54 |
title: '是否显示提示', |
|
55 |
value: true |
|
56 |
}, |
|
57 |
{ |
|
58 |
type: 'inputNumber', |
|
59 |
field: 'fileSize', |
|
60 |
title: '大小限制(MB)', |
|
61 |
value: 5, |
|
62 |
props: { min: 0 } |
|
63 |
}, |
|
64 |
{ |
|
65 |
type: 'inputNumber', |
|
66 |
field: 'limit', |
|
67 |
title: '数量限制', |
|
68 |
value: 5, |
|
69 |
props: { min: 0 } |
|
70 |
}, |
|
71 |
{ |
|
72 |
type: 'switch', |
|
73 |
field: 'disabled', |
|
74 |
title: '是否禁用', |
|
75 |
value: false |
|
76 |
} |
|
77 |
]) |
|
78 |
} |
|
79 |
} |
|
80 |
} |