@lljj/vue2-form-core
Version:
基于 Vue 、JsonSchema快速构建一个带完整校验的form表单,vue2版本基础框架
48 lines (40 loc) • 1.26 kB
JavaScript
/**
* Created by Liu.Jun on 2020/4/23 10:50.
*/
import { getWidgetConfig, optionsList } from '@lljj/vjsf-utils/formUtils';
import Widget from '../../components/Widget';
import vueProps from '../props';
export default {
name: 'BooleanField',
props: vueProps,
functional: true,
render(h, context) {
const {
schema, uiSchema, curNodePath, rootFormData, globalOptions
} = context.props;
// Bool 会默认传入枚举类型选项 true false
const enumOptions = optionsList({
enumNames: schema.enumNames || ['true', 'false'],
enum: schema.enum || [true, false]
}, uiSchema, curNodePath, rootFormData);
const widgetConfig = getWidgetConfig({
schema,
uiSchema,
curNodePath,
rootFormData
}, () => ({
widget: globalOptions.WIDGET_MAP.types.boolean
}));
widgetConfig.uiProps.enumOptions = widgetConfig.uiProps.enumOptions || enumOptions;
return h(
Widget,
{
...context.data,
props: {
...context.props,
...widgetConfig
}
}
);
}
};