UNPKG

@ywfe/materials-design

Version:
215 lines (211 loc) 5.72 kB
import { IPublicTypeComponentMetadata } from '@alilc/lowcode-types'; import { FormItemsProps, IPublicTypeSnippetMore, YwButtonBaseProps, layoutConfig } from '../_base'; import { uuid, getRefConfig } from '../_utils'; const refConfig = getRefConfig('data_edit_dialog'); const DataEditDialogMeta: IPublicTypeComponentMetadata = { componentName: 'DataEditDialog', title: '编辑数据', docUrl: '', screenshot: '', group: '基础组件', category: '弹窗', devMode: 'proCode', npm: { package: '@ywfe/materials-design', version: '0.0.1-beta.6', exportName: 'YwFormDialog', main: 'src/index.tsx', destructuring: true, subName: '', }, configure: { props: [ refConfig, { name: 'title', title: { label: '弹窗标题', tip: 'title | 标题' }, setter: 'StringSetter', display: 'block', }, ...YwButtonBaseProps, { title: { label: '布局配置', tip: 'props | 布局配置' }, type: 'group', display: 'accordion', extraProps: { defaultCollapsed: true, }, supportVariable: false, items: layoutConfig, }, FormItemsProps, { title: { label: '表单默认值', tip: 'initialValues | 表单默认值', }, display: 'inline', name: 'initialValues', description: '表单默认值', supportVariable: false, setter: { componentName: 'JsonSetter', isRequired: false, initialValue: {}, }, }, { title: { label: '表单初始化', tip: 'onFormInit | 表单初始化', }, name: 'onFormInit', setter: { componentName: 'SchemaFunctionSetter', props: { title: 'getDataSource', async: true, properties: { input: { type: 'object', properties: { form: { type: 'object', }, }, required: ['form'], }, body: { type: 'array', items: [ { type: 'Function', properties: { template: 'RequestFunction', variable: 'requestRes', extraProps: { _params: false, _paramsArr: [ { name: 'id', value: '{{this.initialValues?.id}}', }, ], params: { id: '{{this.initialValues?.id}}', }, }, }, }, { type: 'JSExpression', run: 'console.log(1,this.record,this.initialValues);form.setInitialValues(requestRes || this.initialValues)', }, ], }, }, }, }, }, { title: { label: '确定操作', tip: 'onConfirm | 确定操作', }, name: 'onConfirm', setter: { componentName: 'SchemaFunctionSetter', props: { title: 'getDataSource', async: true, properties: { input: { type: 'object', properties: { values: { type: 'object', }, }, required: ['values'], }, body: { type: 'array', items: [ { type: 'Function', properties: { template: 'RequestFunction', variable: 'requestRes', extraProps: { params: '{{values}}', }, }, }, { type: 'JSExpression', run: 'if (requestRes) this.reload && this.reload()', }, ], }, output: 'requestRes', }, }, }, }, ], supports: { events: [ { name: 'onCancel', description: '取消事件', template: 'function onCancel() {\n this.setState({\n isShowDialog: false\n });\n}', }, { name: 'onOpen', description: '弹窗打开事件(开发中)', }, ], style: true, className: true, loop: false, }, component: { isContainer: false, }, }, }; const snippets: IPublicTypeSnippetMore[] = [ { title: '编辑数据', svgId: 'icon-bianjishuju', screenshot: 'https://yw-fed-static.oss-cn-hangzhou.aliyuncs.com/lowcode/dialog', schema: { componentName: 'DataEditDialog', props: { btnText: '编辑', btnType: 'link', title: '编辑数据', initialValues: { type: 'JSExpression', value: 'this.record', }, reload: { type: 'JSExpression', value: 'this.reload', }, items: [ { component: 'Input', title: '表单项', name: `input_${uuid()}`, }, ], visible: undefined, }, }, }, ]; export default { ...DataEditDialogMeta, snippets, };