项目-团队管理

This commit is contained in:
caishi 2021-02-04 17:47:30 +08:00
parent 0c5dd61fdc
commit eaa46dbcee
5 changed files with 113 additions and 17 deletions

View File

@ -6,14 +6,14 @@ const { Option } = AutoComplete;
function AddGroup({organizeId,getGroupID}){
const [ id , setID ] = useState(undefined);
const [ source , setSource ] = useState(undefined);
const [ searchKey , setSearchKey ] = useState(undefined);
const [ searchKey , setSearchKey ] = useState("");
useEffect(()=>{
getUserList();
},[searchKey])
function getUserList(e){
const url = `/organizations/${organizeId}/teams.json`;
const url = `/organizations/${organizeId}/teams/search.json`;
axios.get(url, {
params: {
search: searchKey,
@ -44,7 +44,7 @@ function AddGroup({organizeId,getGroupID}){
}
function changeInputUser(e){
setSearchKey(e);
setSearchKey(e || "");
};
//
@ -55,7 +55,6 @@ function AddGroup({organizeId,getGroupID}){
function addCollaborator(){
getGroupID && getGroupID(id);
setSearchKey(undefined);
}
return(

View File

@ -67,7 +67,6 @@ function AddMember({getID,login}){
function addCollaborator(){
getID && getID(id);
setSearchKey(undefined);
}
return(

View File

@ -11,6 +11,8 @@ function Collaborator(props){
const [ newGroupId , setNewGroupId] = useState(undefined);
const {projectsId ,owner} = props.match.params;
const author = props.projectDetail && props.projectDetail.author;
function getID(id){
setNewId(id);
}
@ -21,24 +23,28 @@ function Collaborator(props){
return (
<WhiteBack>
<div className="flex-a-center baseForm bbr">
<span>
<span style={{cursor:"pointer"}} className={nav === "1" ? "font-18 text-black color-blue":"font-18 text-black"} onClick={()=>setNav("1")}>协作者管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>setNav("2")}>团队管理</span>
</span>
{
author && author.type === "Organization" ?
<span>
<span style={{cursor:"pointer"}} className={nav === "1" ? "font-18 text-black color-blue":"font-18 text-black"} onClick={()=>setNav("1")}>协作者管理</span>
<span style={{cursor:"pointer"}} className={nav === "2" ? "font-18 text-black ml30 color-blue":"font-18 text-black ml30"} onClick={()=>setNav("2")}>团队管理</span>
</span>
:
<span className="font-18 text-black">协作者管理</span>
}
{
nav === "1" ?
<AddMember getID={getID} login/>
:
<AddGroup getGroupID={getGroupID} organizeId={owner}/>
}
</div>
<div>
{
nav === "1" ?
<Member newId={newId} projectsId={projectsId} owner={owner} project_id={props.project_id} author={props.author} showNotification={props.showNotification}/>
:
<Group {...props} newGroupId={newGroupId}/>
<Group owner={owner} projectsId={projectsId} newGroupId={newGroupId}/>
}
</div>
</WhiteBack>

View File

@ -1,18 +1,107 @@
import React, { useEffect, useState } from 'react';
import { Table , Button , Popconfirm , Pagination } from 'antd';
import { Link } from 'react-router-dom';
import axios from 'axios';
const roles = {
owner:"所有者",
admin:"管理者",
write:"开发者",
read:"报告者"
}
const limit = 15;
function CollaboratorGroup({newGroupId,owner , projectsId}){
const [ list , setList ] = useState(undefined);
const [ isSpin , setIsSpin ] = useState(false);
const [ page , setPage ] = useState(1);
const [ total , setTotal ] = useState(0);
function CollaboratorGroup(props,{newGroupId}){
useEffect(()=>{
getData();
},[])
function getData(){
const url = `/${owner}/${projectsId}/teams.json`;
axios.get(url,{
params:{
page,limit
}
}).then(result=>{
if(result && result.data){
setList(result.data.teams);
setTotal(result.data.total_count);
}
}).catch(error=>{})
}
useEffect(()=>{
if(newGroupId){
addGroup(newGroupId);
}
},[newGroupId])
//
function addGroup(id){
const url = `/${owner}/${projectsId}/teams.json`;
axios.post(url,{
team_id:id
}).then(result=>{
if(result && result.data){
getData();
}
}).catch(error=>{})
}
//
function deleteGroup(id){
const url = `/${owner}/${projectsId}/teams/${id}.json`;
axios.delete(url).then(result=>{
if(result && result.data){
getData();
}
}).catch(error=>{})
}
const columns = [
{
title:"团队名",
dataIndex:"name",
render:(value,item)=>{
return <Link to={`/organize/${owner}/group/${item.id}`}>{value}</Link>
}
},{
title:"权限",
dataIndex:"authorize",
width:"20%",
render:(value,item)=>{
return roles[value]
}
},{
title:"操作",
dataIndex:"operation",
width:"25%",
render:(value,item)=>{
return(
item.can_remove && <Popconfirm title={`确定要删除‘${item.name}’团队?`} okText="是" cancelText="否" onConfirm={()=>{deleteGroup(item.id)}}><Button type="danger">删除</Button></Popconfirm>
)
}
}
]
return(
<div>团队管理</div>
<div className="padding20-30" style={{minHeight:"400px"}}>
<Table
dataSource={list}
columns={columns}
pagination={false}
loading={isSpin}
></Table>
{
total > limit ?
<div className="pb20 mt20 edu-txt-center">
<Pagination simple current={page}total={total} pageSize={limit} onChange={(page)=>{setPage(page)}}/>
</div>
:""
}
</div>
)
}
export default CollaboratorGroup;

View File

@ -232,6 +232,7 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
},
];
return(
listData && listData.length>0 ?
<React.Fragment>
<div className="baseForm" style={{display:'flex',justifyContent:"space-between",alignItems:"center"}}>
<Dropdown overlay={roles} placement={"bottomCenter"}>
@ -249,16 +250,16 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
</div>
<Spin spinning={isSpin}>
<div className="collaboratorList baseForm">
{listData && listData.length>0 ? (
{ listData && listData.length>0 ?
<Table
pagination={false}
columns={columns}
dataSource={listData}
rowKey={(record) => record.id}
></Table>
) : (
:
<NoneData _html="暂时还没有相关数据!" />
)}
}
</div>
</Spin>
{total > LIMIT ?
@ -273,6 +274,8 @@ function CollaboratorMember({projectsId,owner,project_id,author,showNotification
</div>
:""}
</React.Fragment>
:
<NoneData _html="暂时还没有相关数据!" />
)
}
export default CollaboratorMember;