Reviewed-on: daoyoucloud/tachybase#866 Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
022c315523
commit
6f625b7ad8
@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { CustomCascader, SchemaComponent } from '../..';
|
import { CustomCascader, SchemaComponent } from '../..';
|
||||||
import { css, useAPIClient } from '../../..';
|
import { css, useAPIClient } from '../../..';
|
||||||
import { mergeFilter } from '../../../filter-provider/utils';
|
import { mergeFilter } from '../../../filter-provider/utils';
|
||||||
import { useAssociationFieldContext } from './hooks';
|
import useServiceOptions, { useAssociationFieldContext } from './hooks';
|
||||||
|
|
||||||
const SchemaField = createSchemaField({
|
const SchemaField = createSchemaField({
|
||||||
components: {
|
components: {
|
||||||
@ -55,7 +55,6 @@ const Cascade = connect((props) => {
|
|||||||
});
|
});
|
||||||
setSelectedOptions(defaultData);
|
setSelectedOptions(defaultData);
|
||||||
}
|
}
|
||||||
onDropdownVisibleChange('true');
|
|
||||||
}, [fieldSchema['x-component-props'].value]);
|
}, [fieldSchema['x-component-props'].value]);
|
||||||
const handleGetOptions = async () => {
|
const handleGetOptions = async () => {
|
||||||
const response = await resource.list({
|
const response = await resource.list({
|
||||||
@ -97,6 +96,8 @@ const Cascade = connect((props) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
onChange?.(options);
|
onChange?.(options);
|
||||||
|
} else {
|
||||||
|
onChange?.([]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const cascadeOption = (option) => {
|
const cascadeOption = (option) => {
|
||||||
@ -164,6 +165,7 @@ export const InternalCascader = observer(
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
|
const service = useServiceOptions(props);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = uid();
|
const id = uid();
|
||||||
selectForm.addEffects(id, () => {
|
selectForm.addEffects(id, () => {
|
||||||
@ -253,6 +255,7 @@ export const InternalCascader = observer(
|
|||||||
'x-component': AssociationCascadeSelect,
|
'x-component': AssociationCascadeSelect,
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
...props,
|
...props,
|
||||||
|
service,
|
||||||
style: { width: '100%' },
|
style: { width: '100%' },
|
||||||
},
|
},
|
||||||
'x-read-pretty': false,
|
'x-read-pretty': false,
|
||||||
@ -264,7 +267,7 @@ export const InternalCascader = observer(
|
|||||||
</FormProvider>
|
</FormProvider>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{ displayName: 'InternalCascade' },
|
{ displayName: 'InternalCascader' },
|
||||||
);
|
);
|
||||||
|
|
||||||
function extractLastNonNullValueObjects(data, flag?) {
|
function extractLastNonNullValueObjects(data, flag?) {
|
||||||
|
Loading…
Reference in New Issue
Block a user