import React, { useState, useEffect } from 'react';
import { Modal, Space, Button } from 'antd';
import ParseForm from 'parseForm';
import styles from './index.less';
const PerviewPrase = props => {
  const { visible, onCancel, accountData } = props;
  const [loading, setLoading] = useState(false);
  const [data, setData] = useState({});

  useEffect(() => {
    console.log(accountData);
    if (visible) {
      let tablesSchema = {
        child: {},
        groups: accountData.flowNodeMeta.groups,
        values: [],
        modules: [],
        relationForm: {},
      };

      setData(tablesSchema);
    }
  }, [visible]);

  return (
    <div className={styles.PerviewParse}>
      <Modal
        title="预览"
        bodyStyle={{
          width: '100%',
          minHeight: '200px',
          maxHeight: '780px',
          overflow: 'scroll',
          overflowX: 'hidden',
        }}
        width="1800px"
        style={{ marginTop: '-80px' }}
        destroyOnClose
        maskClosable={false}
        footer={
          <Space>
            <Button onClick={onCancel} type="primary">
              关闭
            </Button>
          </Space>
        }
        {...props}
        confirmLoading={loading}
        forceRender
        getContainer={false}
      >
        {console.log(window.globalConfig.mapsettings)}
        {visible && <ParseForm tablesSchema={data} noButtons />}
      </Modal>
    </div>
  );
};
export default PerviewPrase;
