import { useState,useEffect } from 'react';
import apiObj from '@api/index';
import { Tree  } from 'antd';

//const { post,api } = apiObj;
function MenuTree(props){
    const { data, checkEv, checkeds} = props;

    //菜单选中事件
    function onCheck(checkedKeys,e){
        const {checkedNodes} = e;
        const sourceIds  = [];
        checkedNodes.map((it)=>{
            if(it.softwareResourceId){
                sourceIds.push(it.softwareResourceId);
            }
        });
        checkEv(checkedKeys,sourceIds)
        console.log(211,checkedKeys,sourceIds)
    }
    function onSelect(){

    }
    const treeData = data?[data]:null;
    
    return (
        <Tree
            checkable
            onCheck={onCheck}
            defaultCheckedKeys={checkeds ? checkeds.softwareMenuIds : []}
            onSelect={onSelect}
            treeData={treeData}
        />
    )
}

export default MenuTree;