2021-02-01 15:20:38 +08:00
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
|
import { WhiteBack , FlexAJ } from '../../Component/layout';
|
|
|
|
|
|
import { Menu , Table , Pagination , Icon , Tooltip , Popconfirm } from 'antd';
|
2020-06-28 15:53:46 +08:00
|
|
|
|
import Title from '../../Component/Title';
|
|
|
|
|
|
import Search from '../../Component/Search';
|
2020-06-24 10:10:47 +08:00
|
|
|
|
import styled from 'styled-components';
|
|
|
|
|
|
import { getImageUrl } from 'educoder';
|
2021-02-01 15:20:38 +08:00
|
|
|
|
import axios from 'axios';
|
2020-06-24 10:10:47 +08:00
|
|
|
|
|
|
|
|
|
|
const Img = styled.img`{
|
|
|
|
|
|
width:30px;
|
|
|
|
|
|
height:30px;
|
|
|
|
|
|
border-radius:50%;
|
|
|
|
|
|
}`
|
|
|
|
|
|
|
|
|
|
|
|
const demoData = [
|
|
|
|
|
|
{
|
|
|
|
|
|
img:"images/avatars/User/g",
|
|
|
|
|
|
name:"蔡世",
|
|
|
|
|
|
email:"1149225589@qq.com",
|
|
|
|
|
|
team:"caicaizi",
|
|
|
|
|
|
role:"管理者",
|
|
|
|
|
|
operation:"移除成员",
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2021-02-01 15:20:38 +08:00
|
|
|
|
export default (({organizeDetail})=>{
|
2020-06-24 10:10:47 +08:00
|
|
|
|
const [ choiceId , serChoiceId ] = useState(undefined);
|
|
|
|
|
|
const [ page , setPage ] = useState(1);
|
|
|
|
|
|
const [ limit , setLimit ] = useState(15);
|
|
|
|
|
|
const [ total , setTotal ] = useState(0);
|
2021-02-01 15:20:38 +08:00
|
|
|
|
const [ search , setSearch ] = useState(undefined);
|
2020-06-24 10:10:47 +08:00
|
|
|
|
const [ data , setData ] = useState(demoData);
|
|
|
|
|
|
|
2021-02-01 15:20:38 +08:00
|
|
|
|
useEffect(()=>{
|
|
|
|
|
|
if(organizeDetail && organizeDetail.id){
|
|
|
|
|
|
getData(search);
|
|
|
|
|
|
}
|
|
|
|
|
|
},[organizeDetail,search])
|
|
|
|
|
|
|
|
|
|
|
|
function getData(search){
|
|
|
|
|
|
const url = `/organizations/${organizeDetail.id}/organization_users.json`;
|
|
|
|
|
|
axios.get(url,{
|
|
|
|
|
|
params:{
|
|
|
|
|
|
page,limit, search
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
setData(result.data.organization_users);
|
|
|
|
|
|
setTotal(result.data.total_count);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
2021-01-29 17:26:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-24 10:10:47 +08:00
|
|
|
|
// 获取搜索用户框里面选择的用户ID,方便添加组织成员
|
2021-02-01 15:20:38 +08:00
|
|
|
|
function getUser(login){
|
|
|
|
|
|
serChoiceId(login);
|
2020-06-24 10:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 切换分页
|
|
|
|
|
|
function ChangePage(page){
|
|
|
|
|
|
setPage(page);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const menu=(
|
|
|
|
|
|
<Menu>
|
|
|
|
|
|
<Menu.Item key="all">全部</Menu.Item>
|
|
|
|
|
|
<Menu.Item key="Manager">管理员</Menu.Item>
|
|
|
|
|
|
<Menu.Item key="Developer">开发者</Menu.Item>
|
|
|
|
|
|
<Menu.Item key="Reporter">报告者</Menu.Item>
|
|
|
|
|
|
</Menu>
|
|
|
|
|
|
)
|
|
|
|
|
|
const roleTitle = (
|
|
|
|
|
|
<div><span className="mr3">角色</span>
|
|
|
|
|
|
<Tooltip placement='bottom' title=
|
|
|
|
|
|
{
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<div className="mb3">管理员:拥有仓库设置功能、代码库读、写操作</div>
|
|
|
|
|
|
<div className="mb3">开发人员:只拥有代码库读、写操作</div>
|
|
|
|
|
|
<div className="mb3">报告者:只拥有代码库读操作</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Icon type="question-circle"></Icon>
|
|
|
|
|
|
</Tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
const columns = [
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '头像',
|
2021-02-01 15:20:38 +08:00
|
|
|
|
dataIndex: 'image_url',
|
|
|
|
|
|
width:"5%",
|
2020-06-24 10:10:47 +08:00
|
|
|
|
render:(value,item)=>{
|
|
|
|
|
|
return(
|
2021-02-01 15:20:38 +08:00
|
|
|
|
item.user && <Img src={getImageUrl('images/'+item.user.image_url)}></Img>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '用户名',
|
|
|
|
|
|
dataIndex: 'name',
|
2021-02-01 15:20:38 +08:00
|
|
|
|
width:"15%",
|
|
|
|
|
|
render:(value,item)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
item.user && item.user.name
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2020-06-24 10:10:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '邮箱',
|
2021-02-01 15:20:38 +08:00
|
|
|
|
dataIndex: 'mail',
|
2020-06-24 10:10:47 +08:00
|
|
|
|
width:"25%",
|
2021-02-01 15:20:38 +08:00
|
|
|
|
align:"left",
|
|
|
|
|
|
render:(value,item)=>{
|
|
|
|
|
|
return(
|
|
|
|
|
|
item.user && item.user.mail
|
|
|
|
|
|
)
|
|
|
|
|
|
}
|
2020-06-24 10:10:47 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '所属团队',
|
|
|
|
|
|
dataIndex: 'team',
|
|
|
|
|
|
width:"20%",
|
|
|
|
|
|
render:(value,item)=>{
|
2021-02-01 15:20:38 +08:00
|
|
|
|
return item.team_names && item.team_names.length > 0 && item.team_names[0]
|
2020-06-24 10:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-02-01 15:20:38 +08:00
|
|
|
|
// {
|
|
|
|
|
|
// title: roleTitle,
|
|
|
|
|
|
// dataIndex: 'role',
|
|
|
|
|
|
// width:"20%",
|
|
|
|
|
|
// render:(value,item)=>{
|
|
|
|
|
|
// return(
|
|
|
|
|
|
// item.role
|
|
|
|
|
|
// )
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
2020-06-24 10:10:47 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '操作',
|
|
|
|
|
|
dataIndex: 'operation',
|
|
|
|
|
|
width:"15%",
|
|
|
|
|
|
render:(value,item)=>{
|
2021-02-01 15:20:38 +08:00
|
|
|
|
return (organizeDetail && organizeDetail.is_admin ? "" :
|
|
|
|
|
|
<Popconfirm title="是否将此成员移出组织?" okText={"是"} cancelText={"否"} onConfirm={()=>deleteMember(item.login)}><a className="color-grey-8">移除成员</a></Popconfirm>
|
|
|
|
|
|
)
|
2020-06-24 10:10:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2021-02-01 15:20:38 +08:00
|
|
|
|
|
|
|
|
|
|
function deleteMember(login){
|
|
|
|
|
|
const url = `/organizations/${organizeDetail && organizeDetail.id}/organization_users/${login}.json`;
|
|
|
|
|
|
axios.delete(url).then(result=>{
|
|
|
|
|
|
if(result && result.data){
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(error=>{})
|
|
|
|
|
|
}
|
2020-06-24 10:10:47 +08:00
|
|
|
|
return(
|
|
|
|
|
|
<WhiteBack>
|
|
|
|
|
|
<Title>
|
|
|
|
|
|
<span>组织成员管理</span>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
{/* <AlignCenter>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
<SearchUser getUser={getUser}/>
|
|
|
|
|
|
<Blueline className="ml30">+ 添加用户</Blueline>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
</AlignCenter> */}
|
2020-06-24 10:10:47 +08:00
|
|
|
|
</Title>
|
|
|
|
|
|
<FlexAJ className="padding20-30">
|
|
|
|
|
|
<div style={{width:"580px"}}>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
<Search placeholder="输入用户名或邮箱、团队名搜索" onSearch={(value)=>{setSearch(value)}}/>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
</div>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
{/* <Sort menu={menu}>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
<a className="color-blue">角色筛选<i className="iconfont icon-sanjiaoxing-down ml3 font-14"></i></a>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
</Sort> */}
|
2020-06-24 10:10:47 +08:00
|
|
|
|
</FlexAJ>
|
2021-02-01 15:20:38 +08:00
|
|
|
|
<div className="pl30 pr30 pb30" style={{minHeight:"400px"}}>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
<Table
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
columns={columns}
|
|
|
|
|
|
dataSource={data}
|
|
|
|
|
|
pagination={false}
|
|
|
|
|
|
className="teamMemberTable"
|
|
|
|
|
|
></Table>
|
|
|
|
|
|
{
|
|
|
|
|
|
total > limit ?
|
|
|
|
|
|
<div className="edu-txt-center mt30 mb20">
|
2021-02-01 15:20:38 +08:00
|
|
|
|
<Pagination simple current={page} total={total} pageSize={limit} onChange={ChangePage}></Pagination>
|
2020-06-24 10:10:47 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
:""
|
|
|
|
|
|
}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</WhiteBack>
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|