form-tdesigner
Version:
好用的Vue低代码可视化表单设计器,可以通过拖拽的方式快速创建表单,提高开发者对表单的开发效率。
122 lines (119 loc) • 2.81 kB
JavaScript
import uniqueId from '@form-create/utils/lib/unique';
import { getInjectArg, localeOptions, localeProps } from '../../utils';
const label = '上传';
const name = 'upload';
export default {
menu: 'main',
icon: 'icon-upload',
label,
name,
event: ['change', 'remove', 'preview', 'error', 'progress', 'exceed'],
validate: ['array'],
rule({ t }) {
return {
type: name,
field: uniqueId(),
title: t('com.upload.name'),
info: '',
$required: false,
props: {
action: '/',
onSuccess: new Function('res', 'file', 'file.url = res.data.url;'),
},
};
},
props(_, { t }) {
return localeProps(t, name + '.props', [
{
type: 'switch',
field: 'disabled',
},
{
type: 'select',
field: 'theme',
options: localeOptions(t, [
{ label: 'file', value: 'file' },
{
label: 'image',
value: 'image',
},
{
label: 'file-input',
value: 'file-input',
},
]),
},
{ type: 'switch', field: 'multiple' },
{
type: 'input',
field: 'action',
},
{
type: 'FnInput',
field: 'beforeUpload',
props: {
args: ['file'],
name: 'beforeUpload',
},
},
{
type: 'FnInput',
field: 'beforeRemove',
props: {
body: true,
button: true,
fnx: true,
args: [getInjectArg(t)],
name: 'beforeRemove',
},
},
{
type: 'FnInput',
field: 'onSuccess',
info: t('com.upload.info'),
props: {
args: ['res', 'file'],
name: 'onSuccess',
},
},
{
type: 'TableOptions',
field: 'headers',
props: {
column: [
{ label: t('props.key'), key: 'label' },
{ label: t('props.value'), key: 'value' },
],
valueType: 'object',
},
},
{
type: 'TableOptions',
field: 'data',
props: {
column: [
{ label: t('props.key'), key: 'label' },
{ label: t('props.value'), key: 'value' },
],
valueType: 'object',
},
},
{ type: 'input', field: 'name' },
{
type: 'switch',
field: 'withCredentials',
},
{ type: 'input', field: 'accept' },
{
type: 'switch',
field: 'autoUpload',
value: true,
},
{
type: 'inputNumber',
field: 'limit',
props: { min: 0 },
},
]);
},
};