|  | @@ -1,4 +1,4 @@
 | 
	
		
			
				|  |  | -import React, { useState } from 'react';
 | 
	
		
			
				|  |  | +import React, { useState, useEffect } from 'react';
 | 
	
		
			
				|  |  |  import FormContent from './FormContent';
 | 
	
		
			
				|  |  |  import ComponentLibrary from './ComponentLibrary';
 | 
	
		
			
				|  |  |  import ItemAttribute from './ItemAttribute';
 | 
	
	
		
			
				|  | @@ -6,13 +6,14 @@ import { uuidv4 } from '@antv/xflow';
 | 
	
		
			
				|  |  |  import { Button } from 'antd';
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  function AuditForm(props) {
 | 
	
		
			
				|  |  | +  const { value, onChange } = props;
 | 
	
		
			
				|  |  |    const [formList, setFormList] = useState([]);
 | 
	
		
			
				|  |  |    const [select, setSelect] = useState(-1);
 | 
	
		
			
				|  |  |    const [visible, setVisible] = useState(false);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    const handleAddItem = item => {
 | 
	
		
			
				|  |  |      const formItem = generateItem(item);
 | 
	
		
			
				|  |  | -    setFormList([...formList, formItem]);
 | 
	
		
			
				|  |  | +    handleChangeList([...formList, formItem]);
 | 
	
		
			
				|  |  |      setVisible(false);
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -27,9 +28,20 @@ function AuditForm(props) {
 | 
	
		
			
				|  |  |    const onChangeAttribute = newItem => {
 | 
	
		
			
				|  |  |      let oldValue = formList[select].props;
 | 
	
		
			
				|  |  |      formList[select].props = { ...oldValue, ...newItem };
 | 
	
		
			
				|  |  | -    setFormList([...formList]);
 | 
	
		
			
				|  |  | +    handleChangeList([...formList]);
 | 
	
		
			
				|  |  |    };
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  const handleChangeList = list => {
 | 
	
		
			
				|  |  | +    setFormList(list);
 | 
	
		
			
				|  |  | +    onChange?.(list);
 | 
	
		
			
				|  |  | +  };
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +  useEffect(() => {
 | 
	
		
			
				|  |  | +    if (value instanceof Array) {
 | 
	
		
			
				|  |  | +      setFormList([...value]);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }, [value]);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return (
 | 
	
		
			
				|  |  |      <div>
 | 
	
		
			
				|  |  |        <Button onClick={() => setVisible(true)}>增加控件</Button>
 | 
	
	
		
			
				|  | @@ -42,7 +54,7 @@ function AuditForm(props) {
 | 
	
		
			
				|  |  |            marginTop: 20,
 | 
	
		
			
				|  |  |          }}
 | 
	
		
			
				|  |  |        >
 | 
	
		
			
				|  |  | -        <FormContent onSelect={setSelect} onChange={setFormList} list={formList}></FormContent>
 | 
	
		
			
				|  |  | +        <FormContent onSelect={setSelect} onChange={handleChangeList} list={formList}></FormContent>
 | 
	
		
			
				|  |  |          <ItemAttribute item={formList[select]} onChange={onChangeAttribute}></ItemAttribute>
 | 
	
		
			
				|  |  |        </div>
 | 
	
		
			
				|  |  |        <ComponentLibrary
 |