|
|
@ -43,7 +43,6 @@ class Collaborator extends Component{
|
|
|
|
// 获取项目协作者
|
|
|
|
// 获取项目协作者
|
|
|
|
getMember=(project_id)=>{
|
|
|
|
getMember=(project_id)=>{
|
|
|
|
const { page } = this.state;
|
|
|
|
const { page } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
const url = `/projects/${project_id}/members.json`;
|
|
|
|
const url = `/projects/${project_id}/members.json`;
|
|
|
|
axios.get(url,{
|
|
|
|
axios.get(url,{
|
|
|
|
params:{
|
|
|
|
params:{
|
|
|
@ -60,26 +59,16 @@ class Collaborator extends Component{
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 选择用户
|
|
|
|
// 输入用户
|
|
|
|
changeInputUser=(e)=>{
|
|
|
|
changeInputUser=(e)=>{
|
|
|
|
console.log(e);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
user:e
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.getUserList(e);
|
|
|
|
this.getUserList(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
changeUser=(e)=>{
|
|
|
|
// 选择用户
|
|
|
|
console.log("click",e);
|
|
|
|
selectInputUser=(e,option)=>{
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
user_id:e,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
serachUser=(e)=>{
|
|
|
|
|
|
|
|
console.log("select",e);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
user:e.item.props.children
|
|
|
|
user_id:e
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
this.getUserList(option.props.children);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
getUserList=(e)=>{
|
|
|
|
getUserList=(e)=>{
|
|
|
|
const url = `/users/list.json`;
|
|
|
|
const url = `/users/list.json`;
|
|
|
@ -98,6 +87,25 @@ class Collaborator extends Component{
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 增加协作者
|
|
|
|
|
|
|
|
addCollaborator=()=>{
|
|
|
|
|
|
|
|
const { project_id } = this.props;
|
|
|
|
|
|
|
|
const { user_id } = this.state;
|
|
|
|
|
|
|
|
const url = `/projects/${project_id}/members.json`;
|
|
|
|
|
|
|
|
axios.post(url,{
|
|
|
|
|
|
|
|
user_id
|
|
|
|
|
|
|
|
}).then(result=>{
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
isSpin:true
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.getMember(project_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 修改权限
|
|
|
|
// 修改权限
|
|
|
|
changeOperaiton=(e,id)=>{
|
|
|
|
changeOperaiton=(e,id)=>{
|
|
|
|
const { project_id } = this.props;
|
|
|
|
const { project_id } = this.props;
|
|
|
@ -110,36 +118,44 @@ class Collaborator extends Component{
|
|
|
|
role:e.key
|
|
|
|
role:e.key
|
|
|
|
}).then(result=>{
|
|
|
|
}).then(result=>{
|
|
|
|
if(result){
|
|
|
|
if(result){
|
|
|
|
this.props.showNotification('权限修改成功!');
|
|
|
|
|
|
|
|
this.getMember(project_id);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
isSpin:false
|
|
|
|
isSpin:true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
this.props.showNotification('权限修改成功!');
|
|
|
|
|
|
|
|
this.getMember(project_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error=>{
|
|
|
|
}).catch(error=>{
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 增加协作者
|
|
|
|
// 删除协作者
|
|
|
|
addCollaborator=()=>{
|
|
|
|
deleteUser=(id)=>{
|
|
|
|
const { projectsId } = this.props.match.params;
|
|
|
|
this.props.confirm({
|
|
|
|
const { project_id } = this.props;
|
|
|
|
content:"确认将此成员从项目中移除?",
|
|
|
|
const { user_id } = this.state;
|
|
|
|
onOk:()=>{
|
|
|
|
const url = `/projects/${projectsId}/members.json`;
|
|
|
|
const { project_id } = this.props;
|
|
|
|
axios.post(url,{
|
|
|
|
const url = `/projects/${project_id}/members/remove.json`;
|
|
|
|
user_id
|
|
|
|
axios.delete(url,{
|
|
|
|
}).then(result=>{
|
|
|
|
user_id:id
|
|
|
|
if(result){
|
|
|
|
}).then(result=>{
|
|
|
|
this.getMember(project_id);
|
|
|
|
if(result){
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
isSpin:true
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
this.props.showNotification("成员删除成功!");
|
|
|
|
|
|
|
|
this.getMember(project_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error=>{
|
|
|
|
|
|
|
|
console.log(error);
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render(){
|
|
|
|
render(){
|
|
|
|
const { user , userDataSource , listData , isSpin } = this.state;
|
|
|
|
const { userDataSource , listData , isSpin } = this.state;
|
|
|
|
|
|
|
|
// 获取当前项目的拥有者
|
|
|
|
|
|
|
|
const { author } = this.props;
|
|
|
|
const menu =(id)=> (
|
|
|
|
const menu =(id)=> (
|
|
|
|
<Menu>
|
|
|
|
<Menu>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -154,7 +170,7 @@ class Collaborator extends Component{
|
|
|
|
|
|
|
|
|
|
|
|
const source = userDataSource && userDataSource.map((item,key)=>{
|
|
|
|
const source = userDataSource && userDataSource.map((item,key)=>{
|
|
|
|
return(
|
|
|
|
return(
|
|
|
|
<Option key={key} value={`${item.user_id}`} onClick={this.serachUser}>{item.username}</Option>
|
|
|
|
<Option key={key} value={`${item.user_id}`}>{item.username}</Option>
|
|
|
|
)
|
|
|
|
)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return(
|
|
|
|
return(
|
|
|
@ -172,12 +188,21 @@ class Collaborator extends Component{
|
|
|
|
<div className="collaboratorItem">
|
|
|
|
<div className="collaboratorItem">
|
|
|
|
<span><Link to={``} className="color-blue">{item.name}</Link></span>
|
|
|
|
<span><Link to={``} className="color-blue">{item.name}</Link></span>
|
|
|
|
<span>
|
|
|
|
<span>
|
|
|
|
<Dropdown overlay={menu(`${item.id}`)} placement={"bottomCenter"}>
|
|
|
|
{
|
|
|
|
<span>{operation && operation[0].name}<Icon type="down" /></span>
|
|
|
|
author && author.login === item.login ?
|
|
|
|
</Dropdown>
|
|
|
|
<label>{operation && operation[0].name}</label>
|
|
|
|
|
|
|
|
:
|
|
|
|
|
|
|
|
<Dropdown overlay={menu(`${item.id}`)} placement={"bottomCenter"}>
|
|
|
|
|
|
|
|
<span>{operation && operation[0].name}<Icon type="down" /></span>
|
|
|
|
|
|
|
|
</Dropdown>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<span style={{justifyContent:"center"}}>
|
|
|
|
<span style={{justifyContent:"center"}}>
|
|
|
|
<a className="red_btn">删除</a>
|
|
|
|
{
|
|
|
|
|
|
|
|
author && author.login !== item.login &&
|
|
|
|
|
|
|
|
<a className="red_btn" onClick={()=>this.deleteUser(item.id)}>删除</a>
|
|
|
|
|
|
|
|
}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -189,12 +214,11 @@ class Collaborator extends Component{
|
|
|
|
</Spin>
|
|
|
|
</Spin>
|
|
|
|
<div className="addPanel">
|
|
|
|
<div className="addPanel">
|
|
|
|
<AutoComplete
|
|
|
|
<AutoComplete
|
|
|
|
value={user}
|
|
|
|
|
|
|
|
dataSource={source}
|
|
|
|
dataSource={source}
|
|
|
|
style={{ width: 200 }}
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={this.changeInputUser}
|
|
|
|
onChange={this.changeInputUser}
|
|
|
|
|
|
|
|
onSelect={this.selectInputUser}
|
|
|
|
placeholder="搜索用户"
|
|
|
|
placeholder="搜索用户"
|
|
|
|
onSelect={this.changeUser}
|
|
|
|
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
|
|
|
|
<a className="small_submitBtn ml20" onClick={this.addCollaborator}>增加协作者</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|