chore: avoid error
This commit is contained in:
parent
2e4636a8ca
commit
fbbd90ca3c
@ -1,15 +1,15 @@
|
|||||||
import { observer, useField, useFieldSchema, useForm } from '@formily/react';
|
import { observer, useField, useFieldSchema, useForm } from '@formily/react';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React from 'react';
|
||||||
|
import { SchemaComponentOptions } from '../../';
|
||||||
|
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
|
||||||
import { AssociationFieldProvider } from './AssociationFieldProvider';
|
import { AssociationFieldProvider } from './AssociationFieldProvider';
|
||||||
|
import { AssociationSelect } from './AssociationSelect';
|
||||||
|
import { InternalFileManager } from './FileManager';
|
||||||
import { InternalNester } from './InternalNester';
|
import { InternalNester } from './InternalNester';
|
||||||
import { InternalPicker } from './InternalPicker';
|
import { InternalPicker } from './InternalPicker';
|
||||||
import { AssociationSelect } from './AssociationSelect';
|
|
||||||
import { useAssociationCreateActionProps as useCAP } from '../../../block-provider/hooks';
|
|
||||||
import { SchemaComponentOptions } from '../../';
|
|
||||||
import { InternalSubTable } from './InternalSubTable';
|
import { InternalSubTable } from './InternalSubTable';
|
||||||
import { InternalFileManager } from './FileManager';
|
import { CreateRecordAction } from './components/CreateRecordAction';
|
||||||
import { useAssociationFieldContext } from './hooks';
|
import { useAssociationFieldContext } from './hooks';
|
||||||
import {CreateRecordAction} from './components/CreateRecordAction'
|
|
||||||
|
|
||||||
const EditableAssociationField = observer((props: any) => {
|
const EditableAssociationField = observer((props: any) => {
|
||||||
const { multiple } = props;
|
const { multiple } = props;
|
||||||
@ -25,7 +25,7 @@ const EditableAssociationField = observer((props: any) => {
|
|||||||
async onClick() {
|
async onClick() {
|
||||||
await onClick();
|
await onClick();
|
||||||
const { data } = actionField.data?.data?.data || {};
|
const { data } = actionField.data?.data?.data || {};
|
||||||
if (['m2m', 'o2m'].includes(collectionField.interface) && multiple !== false) {
|
if (['m2m', 'o2m'].includes(collectionField?.interface) && multiple !== false) {
|
||||||
const values = JSON.parse(JSON.stringify(form.values[fieldSchema.name] || []));
|
const values = JSON.parse(JSON.stringify(form.values[fieldSchema.name] || []));
|
||||||
values.push({
|
values.push({
|
||||||
...data,
|
...data,
|
||||||
@ -45,7 +45,7 @@ const EditableAssociationField = observer((props: any) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions scope={{ useCreateActionProps }} components={{CreateRecordAction}}>
|
<SchemaComponentOptions scope={{ useCreateActionProps }} components={{ CreateRecordAction }}>
|
||||||
{currentMode === 'Picker' && <InternalPicker {...props} />}
|
{currentMode === 'Picker' && <InternalPicker {...props} />}
|
||||||
{currentMode === 'Nester' && <InternalNester {...props} />}
|
{currentMode === 'Nester' && <InternalNester {...props} />}
|
||||||
{currentMode === 'Select' && <AssociationSelect {...props} />}
|
{currentMode === 'Select' && <AssociationSelect {...props} />}
|
||||||
|
@ -2,12 +2,12 @@ import { GeneralField } from '@formily/core';
|
|||||||
import { useFieldSchema } from '@formily/react';
|
import { useFieldSchema } from '@formily/react';
|
||||||
import cloneDeep from 'lodash/cloneDeep';
|
import cloneDeep from 'lodash/cloneDeep';
|
||||||
import { useCallback, useContext, useMemo } from 'react';
|
import { useCallback, useContext, useMemo } from 'react';
|
||||||
import { useDesignable } from '../../hooks';
|
|
||||||
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
import { mergeFilter } from '../../../block-provider/SharedFilterProvider';
|
||||||
import { AssociationFieldContext } from './context';
|
|
||||||
import { useRecord } from '../../../record-provider';
|
|
||||||
import { isInFilterFormBlock } from '../../../filter-provider';
|
|
||||||
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
import { useCollection, useCollectionManager } from '../../../collection-manager';
|
||||||
|
import { isInFilterFormBlock } from '../../../filter-provider';
|
||||||
|
import { useRecord } from '../../../record-provider';
|
||||||
|
import { useDesignable } from '../../hooks';
|
||||||
|
import { AssociationFieldContext } from './context';
|
||||||
|
|
||||||
export const useInsertSchema = (component) => {
|
export const useInsertSchema = (component) => {
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
@ -72,7 +72,7 @@ export default function useServiceOptions(props) {
|
|||||||
return mergeFilter(
|
return mergeFilter(
|
||||||
[
|
[
|
||||||
mergeFilter([
|
mergeFilter([
|
||||||
isOToAny && !isInFilterFormBlock(fieldSchema)
|
isOToAny && !isInFilterFormBlock(fieldSchema) && collectionField?.foreignKey
|
||||||
? {
|
? {
|
||||||
[collectionField.foreignKey]: {
|
[collectionField.foreignKey]: {
|
||||||
$is: null,
|
$is: null,
|
||||||
@ -81,7 +81,11 @@ export default function useServiceOptions(props) {
|
|||||||
: null,
|
: null,
|
||||||
params?.filter,
|
params?.filter,
|
||||||
]),
|
]),
|
||||||
isOToAny && sourceValue !== undefined && sourceValue !== null && !isInFilterFormBlock(fieldSchema)
|
isOToAny &&
|
||||||
|
sourceValue !== undefined &&
|
||||||
|
sourceValue !== null &&
|
||||||
|
!isInFilterFormBlock(fieldSchema) &&
|
||||||
|
collectionField?.foreignKey
|
||||||
? {
|
? {
|
||||||
[collectionField.foreignKey]: {
|
[collectionField.foreignKey]: {
|
||||||
$eq: sourceValue,
|
$eq: sourceValue,
|
||||||
|
@ -6,9 +6,9 @@ import cls from 'classnames';
|
|||||||
import React, { ChangeEvent, MouseEvent, useMemo, useState } from 'react';
|
import React, { ChangeEvent, MouseEvent, useMemo, useState } from 'react';
|
||||||
import { SortableItem } from '../../common';
|
import { SortableItem } from '../../common';
|
||||||
import { useCompile, useDesigner, useProps } from '../../hooks';
|
import { useCompile, useDesigner, useProps } from '../../hooks';
|
||||||
|
import { EllipsisWithTooltip } from '../input';
|
||||||
import { getLabelFormatValue, useLabelUiSchema } from '../record-picker';
|
import { getLabelFormatValue, useLabelUiSchema } from '../record-picker';
|
||||||
import { AssociationFilter } from './AssociationFilter';
|
import { AssociationFilter } from './AssociationFilter';
|
||||||
import { EllipsisWithTooltip } from '../input';
|
|
||||||
|
|
||||||
const { Panel } = Collapse;
|
const { Panel } = Collapse;
|
||||||
|
|
||||||
@ -32,7 +32,10 @@ export const AssociationFilterItem = (props) => {
|
|||||||
|
|
||||||
const [searchVisible, setSearchVisible] = useState(false);
|
const [searchVisible, setSearchVisible] = useState(false);
|
||||||
|
|
||||||
const defaultActiveKeyCollapse = useMemo<React.Key[]>(() => (defaultCollapse ? [collectionField.name] : []), []);
|
const defaultActiveKeyCollapse = useMemo<React.Key[]>(
|
||||||
|
() => (defaultCollapse && collectionField?.name ? [collectionField.name] : []),
|
||||||
|
[],
|
||||||
|
);
|
||||||
const valueKey = _valueKey || collectionField?.targetKey || 'id';
|
const valueKey = _valueKey || collectionField?.targetKey || 'id';
|
||||||
const labelKey = _labelKey || fieldSchema['x-component-props']?.fieldNames?.label || valueKey;
|
const labelKey = _labelKey || fieldSchema['x-component-props']?.fieldNames?.label || valueKey;
|
||||||
|
|
||||||
@ -79,7 +82,7 @@ export const AssociationFilterItem = (props) => {
|
|||||||
_handleSearchInput(e);
|
_handleSearchInput(e);
|
||||||
};
|
};
|
||||||
|
|
||||||
const title = fieldSchema.title ?? collectionField.uiSchema?.title;
|
const title = fieldSchema.title ?? collectionField?.uiSchema?.title;
|
||||||
const labelUiSchema = useLabelUiSchema(collectionField, fieldNames?.title || 'label');
|
const labelUiSchema = useLabelUiSchema(collectionField, fieldNames?.title || 'label');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user