@@ -300,7 +320,7 @@ class merge extends Component {
data && data.search_count && data.search_count > 0 ?
-
+
{Paginations}
@@ -312,4 +332,5 @@ class merge extends Component {
)
}
}
-export default merge;
\ No newline at end of file
+export default merge;
+
diff --git a/src/forge/Order/order.js b/src/forge/Order/order.js
index 134d0c68..3d6e09d2 100644
--- a/src/forge/Order/order.js
+++ b/src/forge/Order/order.js
@@ -1,11 +1,11 @@
import React, { Component } from "react";
-import { Input, Dropdown, Menu, Icon, Pagination, Spin } from 'antd';
-import './order.css';
+import { Input, Dropdown, Menu, Icon, Pagination, Spin } from "antd";
+import "./order.css";
-import NoneData from '../Nodata';
-import OrderItem from './OrderItem';
+import NoneData from "../Nodata";
+import OrderItem from "./OrderItem";
-import axios from 'axios';
+import axios from "axios";
const Search = Input.Search;
/**
@@ -33,312 +33,284 @@ class order extends Component {
search: undefined,
author_id: undefined,
assigned_to_id: undefined,
- limit: 15,
- page: 1,
+ // limit: 15,
+ // page: 1,
search_count: undefined,
issue_type: undefined,
- status_type: '1',
+ status_type: "1",
//设置选择高亮
- openselect: 1,
- closeselect: undefined,
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
-
- }
+ // openselect: 1,
+ // closeselect: undefined,
+ issue_tag_ids: "标签",
+ tracker_ids: "所有分类",
+ author_ids: "发布人",
+ assigned_to_ids: "指派人",
+ priority_ids: "优先度",
+ done_ratios: "完成度",
+ paix: "排序",
+ select_params: {
+ status_type: "1", //开启中和关闭中,默认为开启中的
+ assigned_to_id: undefined, // 指派人
+ author_id: undefined, // 发布人
+ issue_tag_id: undefined, // 标签
+ tracker_id: undefined, //所有分类
+ done_ratio: undefined, // 完成度
+ priority_id: undefined, // 优先级
+ order_name: undefined,
+ order_type: undefined,
+ search: undefined,
+ page: 1,
+ limit: 15,
+ },
+ };
}
componentDidMount = () => {
this.getSelectList();
- this.getIssueList("", "", "", "", "", "1", "", "", "", "");
- }
+ this.getIssueList();
+ };
getSelectList = () => {
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/issues/index_chosen.json`;
- axios.get(url).then((result) => {
- if (result) {
- this.setState({
- issue_chosen: result.data.issue_chosen
- })
- }
- }).catch((error) => {
- console.log(error);
- })
- }
+ axios
+ .get(url)
+ .then((result) => {
+ if (result) {
+ this.setState({
+ issue_chosen: result.data.issue_chosen,
+ });
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
// 获取列表数据
- getIssueList = (page, limit, search, author_id, assigned_to_id, status_type, id, value, order_name, order_type) => {
+ getIssueList = () => {
+ const { select_params } = this.state;
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/issues.json`;
- axios.get(url, {
- params: {
- page, limit, search, author_id, assigned_to_id, status_type, order_name, order_type,
- [id]: value
- }
- }).then((result) => {
- if (result) {
+ axios
+ .get(url, {
+ params: select_params,
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ data: result.data,
+ issues: result.data.issues,
+ search_count: result.data.search_count,
+ isSpin: false,
+ });
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+ getMenu = (e, id, name) => {
+ this.setState({
+ isSpin: true,
+ });
+ let key_name = e.key.split("-");
+ if (key_name[0] === "created_on") {
+ if (e.item.props.value === "desc") {
this.setState({
- data: result.data,
- issues: result.data.issues,
- search_count: result.data.search_count,
- isSpin: false
- })
+ paix: "最新创建",
+ });
+ } else {
+ this.setState({
+ paix: "最早创建",
+ });
}
- }).catch((error) => {
- console.log(error);
- })
- }
+ this.state.select_params.order_name = e.key;
+ } else if (key_name[0] === "updated_on") {
+ if (e.item.props.value === "desc") {
+ this.setState({
+ paix: "最新更新",
+ });
+ } else {
+ this.setState({
+ paix: "最早更新",
+ });
+ }
+ }
+ this.state.select_params.order_name = key_name[0];
+ this.state.select_params.order_type = e.item.props.value;
+ this.state.select_params.page = 1;
+ this.getIssueList();
+ };
getOption = (e, id, name) => {
- if (id + 's' === "issue_tag_ids") {
- this.setState({
- [id]: e.key,
- issue_tag_ids: name
- })
- }
- if (id + 's' === "tracker_ids") {
- this.setState({
- [id]: e.key,
- tracker_ids: name
- })
- }
- if (id + 's' === "author_ids") {
- this.setState({
- [id]: e.key,
- author_ids: name
- })
- }
- if (id + 's' === "assigned_to_ids") {
- this.setState({
- [id]: e.key,
- assigned_to_ids: name
- })
- }
- if (id + 's' === "priority_ids") {
- this.setState({
- [id]: e.key,
- priority_ids: name
- })
- }
- if (id + 's' === "done_ratios") {
- this.setState({
- [id]: e.key,
- done_ratios: name
- })
- }
- if (e.key === "created_on") {
- if (e.item.props.value === "desc") {
- this.setState({
- [id]: e.key,
- paix: '最新创建'
- })
- } else {
- this.setState({
- [id]: e.key,
- paix: '最早创建'
- })
- }
- } else if (e.key === "updated_on") {
- if (e.item.props.value === "desc") {
- this.setState({
- [id]: e.key,
- paix: '最新更新'
- })
- } else {
- this.setState({
- [id]: e.key,
- paix: '最早更新'
- })
- }
- }
-
+ const { current_user } = this.props;
this.setState({
- [id]: e.key,
- })
- const { page, limit, search, author_id, assigned_to_id, status_type } = this.state;
- if (e.key === "all") {
- this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type, id);
- } else if (e.key === "created_on" || e.key === "updated_on") {
- this.setState({
- order_name: e.key,
- order_type: e.item.props.value
- })
- this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type, id, undefined, e.key, e.item.props.value);
+ isSpin: true,
+ });
+ let option_id = e.key === "all" ? undefined : e.key;
+ this.state.select_params[`${id}`] = option_id;
+ this.state.select_params.page = 1;
+ this.state[`${id}s`] = name;
+ if (current_user) {
+ if ( this.state.select_params.author_id && parseInt(this.state.select_params.author_id) === current_user.user_id) {
+ this.state.author_id = current_user.user_id;
+ } else {
+ this.state.author_id = undefined;
+ }
+
+ if (this.state.select_params.assigned_to_id && parseInt(this.state.select_params.assigned_to_id) === current_user.user_id ) {
+ this.state.assigned_to_id = current_user.user_id;
+ } else {
+ this.state.assigned_to_id = undefined;
+ }
}
- else {
- this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type, id, e.key);
- }
- }
+ this.getIssueList();
+ };
renderMenu = (array, name, id) => {
return (
- )
- }
+ );
+ };
// 翻页
ChangePage = (page) => {
this.setState({
- page,
- isSpin: true
- })
- const { limit, search, status_type, author_id, assigned_to_id } = this.state;
- this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type);
- }
+ isSpin: true,
+ });
+ this.state.select_params.page = page;
+ this.getIssueList();
+ };
// 搜索
searchFunc = (value) => {
this.setState({
search: value,
- isSpin: true
- })
- const { page, limit, status_type, author_id, assigned_to_id } = this.state;
- this.getIssueList(page, limit, value, author_id, assigned_to_id, status_type);
- }
+ isSpin: true,
+ });
+ this.state.select_params.search = value;
+ this.state.select_params.page = 1;
+ this.getIssueList();
+ };
openorder = (type) => {
+ this.setState({
+ isSpin: true,
+ });
if (type) {
- console.log(this.state.closeselect + "|" + this.state.openselect)
- const { current_user } = this.props;
- if (type === 1) {
- this.setState({
- status_type: '1',
- closeselect: undefined,
- openselect: 1,
-
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
- })
- this.getIssueList("", "", "", "", "", 1, "");
-
- } else {
- this.setState({
- status_type: '2',
- openselect: undefined,
- closeselect: 1,
-
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
- })
- this.getIssueList("", "", "", "", "", 2, "");
- }
+ this.setState({
+ author_id: undefined,
+ assigned_to_id: undefined,
+ status_type: type,
+ issue_tag_ids: "标签",
+ tracker_ids: "所有分类",
+ author_ids: "发布人",
+ assigned_to_ids: "指派人",
+ priority_ids: "优先度",
+ done_ratios: "完成度",
+ paix: "排序",
+ });
+ this.state.select_params = {
+ status_type: type,
+ search: undefined,
+ page: 1,
+ limit: 15,
+ };
+ this.getIssueList();
}
- }
-
-
+ };
// 筛选:全部、指派给我、由我创建
ChangeAssign = (type) => {
- const { limit, search, status_type } = this.state;
const { current_user } = this.props;
-
this.setState({
- isSpin: true
- })
- console.log(current_user)
-
+ isSpin: true,
+ });
if (type) {
if (current_user === undefined) {
this.setState({
- isSpin: false
- })
+ isSpin: false,
+ });
return;
}
if (type === 1) {
this.setState({
- page: 1,
- author_id: undefined,
+ assigned_to_ids: current_user.username,
assigned_to_id: current_user.user_id,
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
- })
- this.getIssueList(1, limit, search, undefined, current_user.user_id, status_type);
-
+ author_id: undefined,
+ author_ids: "发布人",
+ });
+ this.state.select_params.author_id = undefined;
+ this.state.select_params.assigned_to_id = current_user.user_id;
} else {
this.setState({
- page: 1,
+ author_ids: current_user.username,
author_id: current_user.user_id,
assigned_to_id: undefined,
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
- })
- this.getIssueList(1, limit, search, current_user.user_id, undefined, status_type);
+ assigned_to_ids: "指派人",
+ });
+ this.state.select_params.assigned_to_id = undefined;
+ this.state.select_params.author_id = current_user.user_id;
}
} else {
this.setState({
- page: 1,
+ author_ids: "发布人",
author_id: undefined,
+ assigned_to_ids: "指派人",
assigned_to_id: undefined,
- issue_tag_ids: '标签',
- tracker_ids: '所有分类',
- author_ids: '发布人',
- assigned_to_ids: '指派人',
- priority_ids: '优先度',
- done_ratios: '完成度',
- paix: '排序'
- })
- this.getIssueList(1, limit, search, undefined, undefined, status_type);
+ });
+ this.state.select_params.assigned_to_id = undefined;
+ this.state.select_params.author_id = undefined;
}
- }
+
+ this.getIssueList();
+ };
+
deletedetail = (id) => {
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/issues/${id}.json`;
- axios.delete(url, {
- data: {
- project_id: projectsId,
- id: id
- }
- }).then((result) => {
- if (result) {
- this.getIssueList()
- }
- }).catch((error) => {
- console.log(error);
- })
- console.log(id)
- }
+ axios
+ .delete(url, {
+ data: {
+ project_id: projectsId,
+ id: id,
+ },
+ })
+ .then((result) => {
+ if (result) {
+ this.getIssueList();
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ console.log(id);
+ };
islogin() {
const { projectsId } = this.props.match.params;
if (this.props.checkIfLogin() === false) {
- this.props.showLoginDialog()
- return
+ this.props.showLoginDialog();
+ return;
} else {
this.props.history.push(`/projects/${projectsId}/orders/new`);
}
@@ -347,33 +319,68 @@ class order extends Component {
render() {
const { current_user } = this.props;
- const { issue_chosen, issues, limit, page, search_count, data, assigned_to_id, author_id, isSpin, openselect, closeselect } = this.state;
+ const {
+ issue_chosen,
+ issues,
+ search_count,
+ data,
+ author_id,
+ assigned_to_id,
+ isSpin,
+ status_type,
+ select_params,
+ } = this.state;
const menu = (
-
- )
+ );
}
}
-export default order;
\ No newline at end of file
+export default order;
diff --git a/src/forge/Settings/Collaborator.js b/src/forge/Settings/Collaborator.js
index f3f4cb0a..65203b2d 100644
--- a/src/forge/Settings/Collaborator.js
+++ b/src/forge/Settings/Collaborator.js
@@ -1,208 +1,423 @@
-import React , { Component } from 'react';
-import { Link } from 'react-router-dom';
-import { Input , AutoComplete , Dropdown , Menu , Icon , Spin , Pagination } from 'antd';
-import axios from 'axios';
-import { getImageUrl } from 'educoder';
+import React, { Component } from "react";
+import { Link } from "react-router-dom";
+import {
+ Input,
+ AutoComplete,
+ Dropdown,
+ Menu,
+ Icon,
+ Spin,
+ Pagination,
+ Button,
+ Table,
+ Tooltip
+} from "antd";
+import NoneData from "../Nodata";
+import axios from "axios";
+import { getImageUrl } from "educoder";
+const { Search } = Input;
const { Option } = AutoComplete;
-const MENU_LIST = [{
- id:"Manager",
- name:'管理员'
-},{
- id:"Developer",
- name:'可写权限'
-},{
- id:"Reporter",
- name:'可读权限'
-}];
+const MENU_LIST = [
+ {
+ id: "Manager",
+ name: "管理员",
+ },
+ {
+ id: "Developer",
+ name: "开发者",
+ },
+ {
+ id: "Reporter",
+ name: "报告者",
+ },
+];
const LIMIT = 15;
-class Collaborator extends Component{
- constructor(props){
+class Collaborator extends Component {
+ constructor(props) {
super(props);
- this.state={
- listData:undefined,
- user:undefined,
- user_id:undefined,
- userDataSource:undefined,
- page:1,
- total_count:undefined,
- isSpin:true,
- searchKey: undefined
- }
+ this.state = {
+ listData: undefined,
+ user: undefined,
+ user_id: undefined,
+ userDataSource: undefined,
+ page: 1,
+ total_count: undefined,
+ isSpin: true,
+ searchKey: undefined,
+ search: undefined,
+ role: undefined,
+ otherSpin: false,
+ searchSpin: false,
+ roleName: undefined,
+ };
}
- componentDidMount=()=>{
- if(this.props.project_id){
- const { page } = this.state;
- this.getMember(this.props.project_id,page);
+ componentDidMount = () => {
+ if (this.props.project_id) {
+ this.getMember();
}
- }
+ };
- componentDidUpdate=(prevState)=>{
- if(this.props.project_id && this.props.project_id !== prevState.project_id){
- const { page } = this.state;
- this.getMember(this.props.project_id,page);
+ componentDidUpdate = (prevState) => {
+ if (
+ this.props.project_id &&
+ this.props.project_id !== prevState.project_id
+ ) {
+ this.getMember();
}
- }
+ };
// 获取项目协作者
- getMember=(project_id,page)=>{
- const url = `/projects/${project_id}/members.json`;
- axios.get(url,{
- params:{
- page,limit:LIMIT
- }
- }).then(result=>{
- if(result){
+ getMember = () => {
+ const { page, search, role } = this.state;
+ console.log("search", search);
+ console.log("role", role);
+ const url = `/projects/${this.props.project_id}/members.json`;
+ axios
+ .get(url, {
+ params: {
+ page,
+ search: search,
+ role: role,
+ limit: LIMIT,
+ },
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ listData: result.data.members,
+ isSpin: false,
+ otherSpin: false,
+ searchSpin: false,
+ total_count: result.data.total_count,
+ });
+ }
+ })
+ .catch((error) => {
this.setState({
- listData:result.data.members,
- isSpin:false,
- total_count:result.data.total_count
- })
- }
- }).catch(error=>{
- console.log(error);
- })
- }
+ isSpin: false,
+ otherSpin: false,
+ searchSpin: false,
+ });
+ console.log(error);
+ });
+ };
// 输入用户
- changeInputUser=(e)=>{
+ changeInputUser = (e) => {
this.setState({
- searchKey: e
- })
+ searchKey: e,
+ });
this.getUserList(e);
- }
- // 选择用户
- selectInputUser=(e,option)=>{
+ };
+ searchMember = (e) => {
+ this.state.search = e;
this.setState({
- user_id:e,
- searchKey: option.props.searchValue
+ searchSpin: true,
+ });
+ this.getMember();
+ };
+ orderMember = (id, name) => {
+ this.setState({
+ isSpin: true
})
+ this.state.role = id;
+ this.state.roleName = name;
+ this.getMember();
+ };
+ // 选择用户
+ selectInputUser = (e, option) => {
+ this.setState({
+ user_id: e,
+ searchKey: option.props.searchValue,
+ });
this.getUserList(option.props.searchValue);
- }
- getUserList=(e)=>{
+ };
+ getUserList = (e) => {
const url = `/users/list.json`;
- axios.get(url,{
- params:{
- search:e
- }
- }).then(result=>{
- if(result){
- this.setState({
- userDataSource:result.data.users
- })
- }
- }).catch(error=>{
- console.log(error);
- })
- }
+ axios
+ .get(url, {
+ params: {
+ search: e,
+ },
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ userDataSource: result.data.users,
+ });
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
// 增加协作者
- addCollaborator=()=>{
- const { project_id } = this.props;
+ addCollaborator = () => {
+ // const { project_id } = this.props;
+ this.setState({
+ otherSpin: true,
+ });
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);
- })
- }
+ const url = `/projects/${this.props.project_id}/members.json`;
+ axios
+ .post(url, {
+ user_id,
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ isSpin: true,
+ otherSpin: false,
+ });
+ this.getMember();
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
// 修改权限
- changeOperaiton=(e,id)=>{
- const { project_id , page } = this.props;
+ changeOperaiton = (e, id) => {
+ // const { project_id, page } = this.state;
this.setState({
- isSpin:true
- })
- const url = `/projects/${project_id}/members/change_role.json`;
- axios.put(url,{
- user_id:id,
- role:e.key
- }).then(result=>{
- if(result){
- this.setState({
- isSpin:true
- })
- this.props.showNotification('权限修改成功!');
- this.getMember(project_id,page);
- }
- }).catch(error=>{
- console.log(error);
- })
- }
+ isSpin: true,
+ });
+ const url = `/projects/${this.props.project_id}/members/change_role.json`;
+ axios
+ .put(url, {
+ user_id: id,
+ role: e.key,
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ isSpin: true,
+ });
+ this.props.showNotification("权限修改成功!");
+ this.getMember();
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
// 删除协作者
- deleteUser=(id)=>{
+ deleteUser = (id) => {
const { page } = this.state;
this.props.confirm({
- content:"确认将此成员从项目中移除?",
- onOk:()=>{
+ content: "确认将此成员从项目中移除?",
+ onOk: () => {
const { project_id } = this.props;
const url = `/projects/${project_id}/members/remove.json`;
- axios.delete(url,{ data: {
- user_id:id
- }
- }).then(result=>{
- if(result){
- this.setState({
- isSpin:true
- })
- this.props.showNotification("成员删除成功!");
- this.getMember(project_id,page);
- }
- }).catch(error=>{
- console.log(error);
- })
- }
- })
- }
- changePage=(page)=>{
+ axios
+ .delete(url, {
+ data: {
+ user_id: id,
+ },
+ })
+ .then((result) => {
+ if (result) {
+ this.setState({
+ isSpin: true,
+ });
+ this.props.showNotification("成员删除成功!");
+ this.getMember();
+ }
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ },
+ });
+ };
+ changePage = (page) => {
+ this.state.page = page;
this.setState({
- page
- })
- const { project_id } = this.props;
- this.getMember(project_id,page);
- }
- render(){
- const { userDataSource , listData , isSpin , page , total_count,searchKey } = this.state;
+ isSpin: true,
+ });
+ this.getMember();
+ };
+
+ render() {
+ const {
+ userDataSource,
+ listData,
+ isSpin,
+ page,
+ total_count,
+ searchKey,
+ otherSpin,
+ searchSpin,
+ roleName,
+ } = this.state;
// 获取当前项目的拥有者
const { author } = this.props;
- const menu =(id)=> (
-
- )
-
- const source = userDataSource && userDataSource.map((item,key)=>{
- return(
-