form-tdesigner
Version:
好用的Vue低代码可视化表单设计器,可以通过拖拽的方式快速创建表单,提高开发者对表单的开发效率。
77 lines (74 loc) • 2.42 kB
JavaScript
import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeTreeOptions, makeTreeOptionsRule} from '../../utils/index';
const label = '树形选择';
const name = 'elTreeSelect';
export default {
menu: 'main',
icon: 'icon-tree-select',
label,
name,
event: ['change', 'visibleChange', 'removeTag', 'clear', 'blur', 'focus'],
validate: ['string', 'number', 'array'],
rule({t}) {
return {
type: name,
field: uniqueId(),
title: t('com.elTreeSelect.name'),
info: '',
effect: {
fetch: ''
},
$required: false,
props: {
nodeKey: 'value',
showCheckbox: true,
data: makeTreeOptions(t('props.option'), {label: 'label', value: 'value'}, 3),
},
};
},
watch: {
multiple({rule}) {
rule.key = uniqueId();
}
},
props(_, {t}) {
return localeProps(t, name + '.props', [
makeTreeOptionsRule(t, 'props.data', 'label', 'value'),
{type: 'switch', field: 'multiple'}, {
type: 'switch',
field: 'disabled'
}, {type: 'switch', field: 'clearable'}, {
type: 'switch',
field: 'collapseTags'
}, {
type: 'inputNumber',
field: 'multipleLimit',
props: {min: 0}
}, {type: 'input', field: 'placeholder'},
{
type: 'TableOptions',
field: 'props',
props: {
column: [{label: t('props.key'), key: 'label'}, {label: t('props.value'), key: 'value'}],
valueType: 'object'
}
}, {
type: 'switch',
field: 'renderAfterExpand',
value: true
}, {
type: 'switch',
field: 'defaultExpandAll',
}, {
type: 'switch',
field: 'expandOnClickNode',
value: true
}, {
type: 'switch',
field: 'checkOnClickNode'
}, {
type: 'input',
field: 'nodeKey'
}]);
}
};