import React, {useEffect, useState} from 'react';
import {Button, Modal, WhiteSpace, WingBlank} from "antd-mobile";
import './index.less'
import axiosRequest from "../../../utils/request";

import TreeData from '../../../components/AddressList/TreeData'

const Send = (props) => {
    const {visible, onClose} = props;

    const closeModal = () => {
        onClose(false)
    };

    const [data, setData] = useState([]);
    useEffect(() => {
        axiosRequest({
            method: 'post',
            url: '/idtAppServiceV6/exclude/control/getList',
            body: {
                script: 'hysqTreeAll',
                args: JSON.stringify(['47c2c4f9235aa97f01235aa97f7c0000']),
            },
        }).then((res) => {
            res.map(item => {item.ATTACH_ID = ''; item.checked = false} );
            setData(res)
        })
    }, []);

    const onClick = (keyIndex) => {
        const newData = JSON.parse(JSON.stringify(data));
        // const result = newData.findIndex(item => item.XH === XH);
        newData[keyIndex].checked = !newData[keyIndex].checked;
        setData(newData)
    };

    const submit = val => {
        console.log(val)
    }

    return (
        <div>
            <Modal
                title="选择参会人员"
                className="date-modal"
                visible={visible}
                transparent
                onClose={() => onClose(false)}
            >
                <TreeData
                    data={data}
                    onClick={onClick}
                    closeModal={closeModal}
                />
            </Modal>
        </div>
    );
};

export default Send;
