71 lines
1.8 KiB
TypeScript
71 lines
1.8 KiB
TypeScript
import { buildUUID } from '@vben/utils';
|
|
|
|
import {
|
|
localeProps,
|
|
makeRequiredRule,
|
|
} from '#/components/form-create/helpers';
|
|
|
|
export function useUploadImagesRule() {
|
|
const label = '多图上传';
|
|
const name = 'ImagesUpload';
|
|
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: {
|
|
multiple: true,
|
|
},
|
|
},
|
|
{
|
|
type: 'inputNumber',
|
|
field: 'maxSize',
|
|
title: '大小限制(MB)',
|
|
value: 5,
|
|
props: { min: 0 },
|
|
},
|
|
{
|
|
type: 'inputNumber',
|
|
field: 'maxNumber',
|
|
title: '数量限制',
|
|
value: 5,
|
|
props: { min: 1 },
|
|
},
|
|
{
|
|
type: 'switch',
|
|
field: 'disabled',
|
|
title: '是否禁用',
|
|
value: false,
|
|
},
|
|
]);
|
|
},
|
|
};
|
|
}
|