fix: 修改级联组件适配
This commit is contained in:
parent
e03e68232e
commit
dcf3cf63e3
@ -132,8 +132,21 @@ export const SchemaSettingsSortingRule = function SortRuleConfigure(props) {
|
||||
});
|
||||
_.set(field.componentProps, 'service.params.sort', sortArr);
|
||||
props?.onSubmitCallBack?.(sortArr);
|
||||
fieldSchema['x-component-props']['service']['params']['sort'] = field.componentProps?.service.params?.sort;
|
||||
const service = fieldSchema['x-component-props']?.service;
|
||||
if (service) {
|
||||
service.params['sort'] = field.componentProps?.service.params?.sort;
|
||||
} else {
|
||||
fieldSchema['x-component-props']['service'] = {
|
||||
params: {
|
||||
sort: field.componentProps?.service.params?.sort,
|
||||
},
|
||||
};
|
||||
}
|
||||
const componentProps = fieldSchema['x-component-props'];
|
||||
const path = field.path?.splice(field.path?.length - 1, 1);
|
||||
field.form.query(`${path.concat(`*.` + fieldSchema.name)}`).forEach((f) => {
|
||||
f.componentProps = componentProps;
|
||||
});
|
||||
dn.emit('patch', {
|
||||
schema: {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
@ -206,45 +219,6 @@ const titleField: any = {
|
||||
},
|
||||
};
|
||||
|
||||
export const allowMultiple: any = {
|
||||
name: 'allowMultiple',
|
||||
type: 'switch',
|
||||
useVisible() {
|
||||
const isFieldReadPretty = useIsFieldReadPretty();
|
||||
const collectionField = useCollectionField();
|
||||
return !isFieldReadPretty && ['hasMany', 'belongsToMany'].includes(collectionField?.type);
|
||||
},
|
||||
useComponentProps() {
|
||||
const { t } = useTranslation();
|
||||
const field = useField<Field>();
|
||||
const { fieldSchema: tableColumnSchema } = useColumnSchema();
|
||||
const schema = useFieldSchema();
|
||||
const fieldSchema = tableColumnSchema || schema;
|
||||
const { dn, refresh } = useDesignable();
|
||||
return {
|
||||
title: t('Allow multiple'),
|
||||
checked:
|
||||
fieldSchema['x-component-props']?.multiple === undefined ? true : fieldSchema['x-component-props'].multiple,
|
||||
onChange(value) {
|
||||
const schema = {
|
||||
['x-uid']: fieldSchema['x-uid'],
|
||||
};
|
||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||
field.componentProps = field.componentProps || {};
|
||||
|
||||
fieldSchema['x-component-props'].multiple = value;
|
||||
field.componentProps.multiple = value;
|
||||
|
||||
schema['x-component-props'] = fieldSchema['x-component-props'];
|
||||
dn.emit('patch', {
|
||||
schema,
|
||||
});
|
||||
refresh();
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
const setDefaultSortingRules = {
|
||||
name: 'setDefaultSortingRules',
|
||||
Component: SchemaSettingsSortingRule,
|
||||
@ -290,7 +264,16 @@ const setTheDataScope: any = {
|
||||
onSubmit: ({ filter }) => {
|
||||
filter = removeNullCondition(filter);
|
||||
_.set(field.componentProps, 'service.params.filter', filter);
|
||||
fieldSchema['x-component-props']['service']['params']['filter'] = filter;
|
||||
const service = fieldSchema['x-component-props']?.service;
|
||||
if (service) {
|
||||
service.params['filter'] = filter;
|
||||
} else {
|
||||
fieldSchema['x-component-props']['service'] = {
|
||||
params: {
|
||||
filter: { ...filter },
|
||||
},
|
||||
};
|
||||
}
|
||||
const componentProps = fieldSchema['x-component-props'];
|
||||
const path = field.path?.splice(field.path?.length - 1, 1);
|
||||
field.form.query(`${path.concat(`*.` + fieldSchema.name)}`).forEach((f) => {
|
||||
@ -363,9 +346,8 @@ export const cascaderComponentFieldSettings = new SchemaSettings({
|
||||
{
|
||||
...setTheDataScope,
|
||||
useVisible() {
|
||||
const isSelectFieldMode = useIsSelectFieldMode();
|
||||
const isFieldReadPretty = useIsFieldReadPretty();
|
||||
return isSelectFieldMode && !isFieldReadPretty;
|
||||
return !isFieldReadPretty;
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -377,9 +359,8 @@ export const cascaderComponentFieldSettings = new SchemaSettings({
|
||||
};
|
||||
},
|
||||
useVisible() {
|
||||
const isSelectFieldMode = useIsSelectFieldMode();
|
||||
const isFieldReadPretty = useIsFieldReadPretty();
|
||||
return isSelectFieldMode && !isFieldReadPretty;
|
||||
return !isFieldReadPretty;
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -31,7 +31,8 @@ const Cascade = connect((props) => {
|
||||
const { options: collectionField, field: associationField } = useAssociationFieldContext<any>();
|
||||
const resource = api.resource(collectionField.target);
|
||||
const fieldNames = associationField?.componentProps?.fieldNames;
|
||||
const fieldFilter = fieldSchema['x-component-props']['service']['params']['filter'];
|
||||
const fieldFilter = fieldSchema['x-component-props']?.service?.params?.filter;
|
||||
const sort = fieldSchema['x-component-props']?.service?.params?.sort;
|
||||
const field: any = useField();
|
||||
useEffect(() => {
|
||||
if (props.value) {
|
||||
@ -52,6 +53,7 @@ const Cascade = connect((props) => {
|
||||
const response = await resource.list({
|
||||
pageSize: 9999,
|
||||
filter: mergeFilter([fieldFilter, filter]),
|
||||
sort,
|
||||
tree: true,
|
||||
});
|
||||
return response?.data?.data;
|
||||
@ -210,7 +212,7 @@ export const InternalCascader = observer(
|
||||
...props,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
'x-read-pretty': 'false',
|
||||
'x-read-pretty': false,
|
||||
},
|
||||
remove: {
|
||||
type: 'void',
|
||||
@ -243,6 +245,7 @@ export const InternalCascader = observer(
|
||||
...props,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
'x-read-pretty': false,
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
|
Loading…
Reference in New Issue
Block a user