代码库-默认显示
This commit is contained in:
parent
31edf6ff45
commit
0290822ebf
|
@ -1,107 +1,139 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from "react";
|
||||||
import { Table , Button , Popconfirm , Pagination } from 'antd';
|
import { Table, Button, Popconfirm, Pagination } from "antd";
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from "react-router-dom";
|
||||||
import axios from 'axios';
|
import axios from "axios";
|
||||||
|
|
||||||
const roles = {
|
const roles = {
|
||||||
owner:"所有者",
|
owner: "所有者",
|
||||||
admin:"管理者",
|
admin: "管理者",
|
||||||
write:"开发者",
|
write: "开发者",
|
||||||
read:"报告者"
|
read: "报告者",
|
||||||
}
|
};
|
||||||
const limit = 15;
|
const limit = 15;
|
||||||
function CollaboratorGroup({newGroupId,owner , projectsId}){
|
function CollaboratorGroup({ newGroupId, owner, projectsId }) {
|
||||||
const [ list , setList ] = useState(undefined);
|
const [list, setList] = useState(undefined);
|
||||||
const [ isSpin , setIsSpin ] = useState(false);
|
const [isSpin, setIsSpin] = useState(true);
|
||||||
const [ page , setPage ] = useState(1);
|
const [page, setPage] = useState(1);
|
||||||
const [ total , setTotal ] = useState(0);
|
const [total, setTotal] = useState(0);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
getData();
|
getData();
|
||||||
},[])
|
}, []);
|
||||||
|
|
||||||
function getData(){
|
function getData() {
|
||||||
const url = `/${owner}/${projectsId}/teams.json`;
|
const url = `/${owner}/${projectsId}/teams.json`;
|
||||||
axios.get(url,{
|
axios
|
||||||
params:{
|
.get(url, {
|
||||||
page,limit
|
params: {
|
||||||
}
|
page,
|
||||||
}).then(result=>{
|
limit,
|
||||||
if(result && result.data){
|
},
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
if (result && result.data) {
|
||||||
setList(result.data.teams);
|
setList(result.data.teams);
|
||||||
setTotal(result.data.total_count);
|
setTotal(result.data.total_count);
|
||||||
|
setIsSpin(false);
|
||||||
}
|
}
|
||||||
}).catch(error=>{})
|
})
|
||||||
|
.catch((error) => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(() => {
|
||||||
if(newGroupId){
|
if (newGroupId) {
|
||||||
addGroup(newGroupId);
|
addGroup(newGroupId);
|
||||||
}
|
}
|
||||||
},[newGroupId])
|
}, [newGroupId]);
|
||||||
// 添加团队
|
// 添加团队
|
||||||
function addGroup(id){
|
function addGroup(id) {
|
||||||
const url = `/${owner}/${projectsId}/teams.json`;
|
const url = `/${owner}/${projectsId}/teams.json`;
|
||||||
axios.post(url,{
|
axios
|
||||||
team_id:id
|
.post(url, {
|
||||||
}).then(result=>{
|
team_id: id,
|
||||||
if(result && result.data){
|
})
|
||||||
|
.then((result) => {
|
||||||
|
if (result && result.data) {
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
}).catch(error=>{})
|
})
|
||||||
|
.catch((error) => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除团队
|
// 删除团队
|
||||||
function deleteGroup(id){
|
function deleteGroup(id) {
|
||||||
const url = `/${owner}/${projectsId}/teams/${id}.json`;
|
const url = `/${owner}/${projectsId}/teams/${id}.json`;
|
||||||
axios.delete(url).then(result=>{
|
axios
|
||||||
if(result && result.data){
|
.delete(url)
|
||||||
|
.then((result) => {
|
||||||
|
if (result && result.data) {
|
||||||
getData();
|
getData();
|
||||||
}
|
}
|
||||||
}).catch(error=>{})
|
})
|
||||||
|
.catch((error) => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title:"团队名",
|
title: "团队名",
|
||||||
dataIndex:"name",
|
dataIndex: "name",
|
||||||
render:(value,item)=>{
|
render: (value, item) => {
|
||||||
return <Link to={`/organize/${owner}/group/${item.id}`}>{value}</Link>
|
return <Link to={`/organize/${owner}/group/${item.id}`}>{value}</Link>;
|
||||||
}
|
},
|
||||||
},{
|
},
|
||||||
title:"权限",
|
{
|
||||||
dataIndex:"authorize",
|
title: "权限",
|
||||||
width:"20%",
|
dataIndex: "authorize",
|
||||||
render:(value,item)=>{
|
width: "20%",
|
||||||
return roles[value]
|
render: (value, item) => {
|
||||||
}
|
return roles[value];
|
||||||
},{
|
},
|
||||||
title:"操作",
|
},
|
||||||
dataIndex:"operation",
|
{
|
||||||
width:"25%",
|
title: "操作",
|
||||||
render:(value,item)=>{
|
dataIndex: "operation",
|
||||||
return(
|
width: "25%",
|
||||||
item.can_remove && <Popconfirm title={`确定要删除‘${item.name}’团队?`} okText="是" cancelText="否" onConfirm={()=>{deleteGroup(item.id)}}><Button type="danger">删除</Button></Popconfirm>
|
render: (value, item) => {
|
||||||
|
return (
|
||||||
|
item.can_remove && (
|
||||||
|
<Popconfirm
|
||||||
|
title={`确定要删除‘${item.name}’团队?`}
|
||||||
|
okText="是"
|
||||||
|
cancelText="否"
|
||||||
|
onConfirm={() => {
|
||||||
|
deleteGroup(item.id);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Button type="danger">删除</Button>
|
||||||
|
</Popconfirm>
|
||||||
)
|
)
|
||||||
}
|
);
|
||||||
}
|
},
|
||||||
]
|
},
|
||||||
return(
|
];
|
||||||
<div className="padding20-30" style={{minHeight:"400px"}}>
|
return (
|
||||||
|
<div className="padding20-30" style={{ minHeight: "400px" }}>
|
||||||
<Table
|
<Table
|
||||||
dataSource={list}
|
dataSource={list}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
loading={isSpin}
|
loading={isSpin}
|
||||||
></Table>
|
></Table>
|
||||||
{
|
{total > limit ? (
|
||||||
total > limit ?
|
|
||||||
<div className="pb20 mt20 edu-txt-center">
|
<div className="pb20 mt20 edu-txt-center">
|
||||||
<Pagination simple current={page}total={total} pageSize={limit} onChange={(page)=>{setPage(page)}}/>
|
<Pagination
|
||||||
|
simple
|
||||||
|
current={page}
|
||||||
|
total={total}
|
||||||
|
pageSize={limit}
|
||||||
|
onChange={(page) => {
|
||||||
|
setPage(page);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
:""
|
) : (
|
||||||
}
|
""
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
export default CollaboratorGroup;
|
export default CollaboratorGroup;
|
|
@ -24,7 +24,7 @@ class Setting extends Component {
|
||||||
LanguageList: undefined,
|
LanguageList: undefined,
|
||||||
private_check: undefined,
|
private_check: undefined,
|
||||||
loading:true,
|
loading:true,
|
||||||
project_units:['home',"activity"]
|
project_units:['home',"activity","code"]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ class Setting extends Component {
|
||||||
const { projectsId , owner } = this.props.match.params;
|
const { projectsId , owner } = this.props.match.params;
|
||||||
const navUrl = `/${owner}/${projectsId}/project_units.json`;
|
const navUrl = `/${owner}/${projectsId}/project_units.json`;
|
||||||
|
|
||||||
let unit = values.project_units.filter(item => (item !== "home" && item!== "activity"));
|
let unit = values.project_units.filter(item => (item !== "home" && item!== "activity" && item!== "code"));
|
||||||
axios.post(navUrl, {
|
axios.post(navUrl, {
|
||||||
unit_types:unit
|
unit_types:unit
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
|
@ -261,7 +261,7 @@ class Setting extends Component {
|
||||||
<Checkbox
|
<Checkbox
|
||||||
key={key}
|
key={key}
|
||||||
value={item.index}
|
value={item.index}
|
||||||
disabled={item.index === "home" || item.index === "activity"}
|
disabled={item.index === "home" || item.index === "activity" || item.index === "code"}
|
||||||
>{item.name}</Checkbox>
|
>{item.name}</Checkbox>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue