diff --git a/src/forge/Component/AddGroup.jsx b/src/forge/Component/AddGroup.jsx new file mode 100644 index 000000000..5bef2565d --- /dev/null +++ b/src/forge/Component/AddGroup.jsx @@ -0,0 +1,84 @@ +import React, { useEffect, useState } from 'react'; +import { AutoComplete , Button , Icon } from 'antd'; +import axios from 'axios'; + +const { Option } = AutoComplete; +function AddGroup({organizeId,getGroupID}){ + const [ id , setID ] = useState(undefined); + const [ source , setSource ] = useState(undefined); + const [ searchKey , setSearchKey ] = useState(undefined); + + useEffect(()=>{ + getUserList(); + },[searchKey]) + + function getUserList(e){ + const url = `/organizations/${organizeId}/teams.json`; + axios.get(url, { + params: { + search: searchKey, + }, + }).then((result) => { + if (result) { + sourceOptions(result.data.teams); + } + }) + .catch((error) => { + console.log(error); + }); + }; + + function sourceOptions(userDataSource){ + const s = userDataSource && userDataSource.map((item, key) => { + return ( + + ); + }); + setSource(s); + } + + function changeInputUser(e){ + setSearchKey(e); + }; + + // 选择用户 + function selectInputUser(e, option){ + setID(e); + setSearchKey(option.props.name); + }; + + function addCollaborator(){ + getGroupID && getGroupID(id); + setSearchKey(undefined); + } + + return( +