Skip to content

Commit b1914db

Browse files
twinkle77liujuping
authored andcommitted
1 parent 78d46fa commit b1914db

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

packages/plugin-datasource-pane/src/components/Forms/form-lazy-obj.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import _pick from 'lodash/pick';
1212
import { JSFunction } from './jsFunction';
1313
import { RemoveBtn } from './form-lazy-obj-remove-btn';
1414
import { generateClassName } from '../../utils/misc';
15+
import { isJSFunction } from '@alilc/lowcode-types';
1516

1617
const { Item: MenuButtonItem } = MenuButton;
1718

@@ -22,11 +23,18 @@ export interface FormLazyObjProps {
2223

2324
export const FormLazyObj = observer((props: FormLazyObjProps) => {
2425
const { addText = '添加' } = props;
26+
2527
const field = useField<VoidField>();
26-
const [selectedProperties, setSelectedProperties] = useState<string[]>([]);
28+
2729
const schema = useFieldSchema();
2830

29-
useEffect(() => {}, [field]);
31+
const [selectedProperties, setSelectedProperties] = useState<string[]>(() => {
32+
// 自动回填数据处理函数
33+
return Object.keys(schema.properties || {}).filter(property => {
34+
return isJSFunction(field.form.values[property])
35+
})
36+
});
37+
3038
const properties = useMemo(() => {
3139
return Object.keys(schema.properties || {})
3240
.filter((i) => selectedProperties.indexOf(i) === -1)
@@ -69,6 +77,7 @@ export const FormLazyObj = observer((props: FormLazyObjProps) => {
6977
});
7078
const schemaJSON = schema.toJSON();
7179
const schemaProperties = _pick(schemaJSON.properties, selectedProperties);
80+
7281
return (
7382
<SchemaField
7483
schema={{

0 commit comments

Comments
 (0)