import snippets from './snippets'; import { ActionBarButtonKey } from '@/constants'; import { actionBarButtonsProps, baseTableProps, columnsProps } from '../_props'; import { uuid } from '../_utils/utils'; import { checkParentWhitelist } from '../_utils/nestingRules'; import { IPublicModelSettingField } from '@alilc/lowcode-types'; import { FieldsSelectSetter, RsArraySetter, RsObjectSetter } from '../_setters'; import { version } from '../../package.json'; import { getHeadDetailSumProps } from '../_props/table/base-table-props'; const subFormTableProps = baseTableProps(true, true, false) .filter(({ name }) => name !== 'rowexpand' && name !== 'confirmButton' && name !== 'treeConfig') .map((item: Record) => { if (item.name === 'columns') { return { ...columnsProps(true, true), }; } else if (item.name === 'dataSourceSection') { return { ...item, items: [ ...item.items, { title: { label: '关联参数', tip: '选择与主表单的关联查询参数字段', }, }, { name: 'subForm_queryParams', title: { label: { type: 'i18n', zh_CN: '查询参数', en_US: 'query params', }, tip: { type: 'i18n', zh_CN: '属性: query params | 说明: 选择与主表单的关联查询参数字段', en_US: 'prop: query params | description: query params', }, }, extraProps: { display: 'plain', }, setter: { componentName: RsArraySetter, props: { itemSetter: { componentName: RsObjectSetter, props: { config: { items: [ { name: 'key', title: { label: '', }, setter: 'StringSetter', defaultValue: () => uuid(), condition: () => { return false; }, }, { name: 'subFormField', important: true, isRequired: true, title: { label: { type: 'i18n', zh_CN: '明细字段', en_US: 'fieldValue', }, tip: { type: 'i18n', zh_CN: '属性: fieldValue | 说明: 明细字段', en_US: 'prop: fieldValue | description: fieldValue', }, }, setter: { componentName: FieldsSelectSetter, initialValue: '', props: { componentType: 'Table', }, }, }, { name: 'mainFormField', important: true, isRequired: true, title: { label: { type: 'i18n', zh_CN: '主表字段', en_US: 'fieldValue', }, tip: { type: 'i18n', zh_CN: '属性: fieldValue | 说明: 主表字段', en_US: 'prop: fieldValue | description: fieldValue', }, }, setter: { componentName: FieldsSelectSetter, initialValue: '', props: { componentType: 'Form', }, }, }, ], }, }, }, }, }, }, ], }; } else if (item.name === 'actionBarButtons') { return { ...actionBarButtonsProps( [ { compId: ActionBarButtonKey.CREATE, key: ActionBarButtonKey.CREATE, name: '新增', type: 'primary', }, { compId: ActionBarButtonKey.COPY, key: ActionBarButtonKey.COPY, name: '复制', type: 'primary', }, { compId: ActionBarButtonKey.DELETE, key: ActionBarButtonKey.DELETE, name: '删除', type: 'primary', }, { compId: ActionBarButtonKey.REFRESH, key: ActionBarButtonKey.REFRESH, name: '刷新', type: 'primary', }, { compId: ActionBarButtonKey.IMPORT, key: ActionBarButtonKey.IMPORT, name: '导入', type: 'primary', }, { compId: ActionBarButtonKey.EXPORT, key: ActionBarButtonKey.EXPORT, name: '导出', type: 'primary', }, ], false, ), }; } else if (item.name === 'rowAction') { return { ...item, items: item.items .filter((x: Record) => ['selectionMode', 'newRowPosition', 'summaryColumns'].includes(x.name), ) .concat(...getHeadDetailSumProps()), }; } else if (item.name === 'paginationSection') { return { ...item, items: item.items.map((x: Record) => { if (x.name === 'showPagination') { return { ...x, setter: { componentName: 'BoolSetter', initialValue: false, }, }; } return x; }), }; } else { return { ...item }; } }); export default { snippets, // 表单页显示组件 group: '基础组件', category: '表单元素', componentName: 'RsSubForm', title: '子表单', priority: 36, npm: { package: 'components-page', version, exportName: 'RsSubForm', main: 'src\\index.tsx', destructuring: true, subName: '', }, configure: { props: subFormTableProps, component: { isContainer: false, nestingRule: { parentWhitelist: (testNode: IPublicModelSettingField) => { return checkParentWhitelist(testNode); }, }, }, supports: { style: true, events: [], }, }, };