change issues/merges sort methods

This commit is contained in:
sylor_huang@126.com 2020-05-19 18:14:21 +08:00
parent 2d89a6ef8e
commit 98a685f37a
3 changed files with 651 additions and 488 deletions

View File

@ -1,112 +1,151 @@
import React , { Component } from 'react';
import { Link } from 'react-router-dom';
import {Popconfirm} from "antd";
import React, { Component } from "react";
import { Link } from "react-router-dom";
import { Popconfirm } from "antd";
class MergeItem extends Component{
constructor(props){
class MergeItem extends Component {
constructor(props) {
super(props);
this.state={
this.state = {
//显示 隐藏
isdisplay:false,
orderid:'',
}
isdisplay: false,
orderid: "",
};
}
onMouseMove=(type)=>{
onMouseMove = (type) => {
this.setState({
isdisplay:true,
orderid:type
})
}
isdisplay: true,
orderid: type,
});
};
onMouseOut=()=>{
onMouseOut = () => {
this.setState({
isdisplay:false
})
}
isdisplay: false,
});
};
set_issue_tags =(issue_tags)=>{
if(issue_tags && issue_tags.length > 0){
return(
issue_tags.map((item,key)=>{
return(
<span className="issue-tag-show" style={{background: item.color}}>{item.name}</span>
)
})
)
}else{
return("--")
set_issue_tags = (issue_tags) => {
if (issue_tags && issue_tags.length > 0) {
return issue_tags.map((item, key) => {
return (
<span className="issue-tag-show" style={{ background: item.color }}>
{item.name}
</span>
);
});
} else {
return "--";
}
}
};
render(){
const { issues , search_count , page , limit } = this.props;
render() {
const { issues, search_count, page, limit } = this.props;
const { projectsId } = this.props.match.params;
const { current_user } = this.props;
const renderList =()=>{
if(issues && issues.length > 0){
return(
issues.map((item,key)=>{
return(
<div className="issueItem">
const renderList = () => {
if (issues && issues.length > 0) {
return issues.map((item, key) => {
return (
<div className="issueItem">
<div className="flex-1">
<p className="mb15 df">
<span className={item.issue_status==="关闭"? "issueNo":"issueNo issueOpen"}># {search_count - (key + (page-1) * limit)}</span>
<Link to={`/projects/${projectsId}/merge/${item.pull_request_id}/Messagecount`} className="flex-1 hide-1 font-16 color-grey-3 lineh-30">{item.name}</Link>
</p>
<p className="color-grey-6 font-12">
<span>{item.format_time}</span><span className="ml5"></span>
{
item.updated_at === item.format_time ?
""
:
<span className="ml20"><span>{item.updated_at}</span><span className="ml5"></span></span>
<p className="mb15 df">
<span
className={
item.issue_status === "关闭"
? "issueNo"
: "issueNo issueOpen"
}
</p>
</div>
<ul className="topWrapper_select no-cursor" onMouseMove={()=>this.onMouseMove(item.id)} onMouseOut={()=>this.onMouseOut()}>
<li>{this.set_issue_tags(item.issue_tags)}</li>
{/*<li>{item.issue_type || "--"}</li>*/}
<li>{item.version || "--"}</li>
<li>
{
item.assign_user_name ?
<Link to={`/users/${item.assign_user_login}/projects`} className="show-user-link">
{item.assign_user_name}
</Link>
: "--"
}
</li>
<li>
<div className="flex-1">
<p>
{ item.journals_count ? <Link to={`/projects/${projectsId}/merge/${item.pull_request_id}/Messagecount`}><i className="iconfont icon-pinglun1 mr3 font-16"></i>{item.journals_count}</Link> : "" }
</p>
{
current_user && current_user.login ?
<div className="milepostleft" style={{display:this.state.orderid===item.id&&this.state.isdisplay?'flex':'none'}}>
<div className="grid-item mr15 color-grey-9">
<Link to={`/projects/${projectsId}/merge/${item.pull_request_id}/updatemerge`} className="color-grey-9"><i className="iconfont icon-bianji3 font-14 mr5"></i></Link>
</div>
</div>
:""
}
</div>
</li>
</ul>
>
# {search_count - (key + (page - 1) * limit)}
</span>
<Link
to={`/projects/${projectsId}/merge/${item.pull_request_id}/Messagecount`}
className="flex-1 hide-1 font-16 color-grey-3 lineh-30"
>
{item.name}
</Link>
</p>
<p className="color-grey-6 font-12">
<span>{item.format_time}</span>
<span className="ml5">发布</span>
{item.updated_at === item.format_time ? (
""
) : (
<span className="ml20">
<span>{item.updated_at}</span>
<span className="ml5">更新</span>
</span>
)}
</p>
</div>
)
})
)
<ul
className="topWrapper_select no-cursor"
onMouseMove={() => this.onMouseMove(item.id)}
onMouseOut={() => this.onMouseOut()}
>
<li>{this.set_issue_tags(item.issue_tags)}</li>
{/*<li>{item.issue_type || "--"}</li>*/}
<li>{item.version || "--"}</li>
<li>
{item.assign_user_name ? (
<Link
to={`/users/${item.assign_user_login}/projects`}
className="show-user-link"
>
{item.assign_user_name}
</Link>
) : (
"--"
)}
</li>
<li>
<div className="flex-1">
<p>
{item.journals_count ? (
<Link
to={`/projects/${projectsId}/merge/${item.pull_request_id}/Messagecount`}
>
<i className="iconfont icon-pinglun1 mr3 font-16"></i>
{item.journals_count}
</Link>
) : (
""
)}
</p>
{current_user && current_user.login ? (
<div
className="milepostleft"
style={{
display:
this.state.orderid === item.id &&
this.state.isdisplay
? "flex"
: "none",
}}
>
<div className="grid-item mr15 color-grey-9">
<Link
to={`/projects/${projectsId}/merge/${item.pull_request_id}/updatemerge`}
className="color-grey-9"
>
<i className="iconfont icon-bianji3 font-14 mr5"></i>
</Link>
</div>
</div>
) : (
""
)}
</div>
</li>
</ul>
</div>
);
});
}
}
return(
<div>
{renderList()}
</div>
)
};
return <div>{renderList()}</div>;
}
}
export default MergeItem;
export default MergeItem;

View File

@ -33,8 +33,8 @@ class merge 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',
@ -44,7 +44,17 @@ class merge extends Component {
issue_tag_ids: '标签',
fixed_version_ids: '里程碑',
assigned_to_ids: '指派人',
paix: '排序'
paix: '排序',
select_params: {
status_type: "1", //开启中和关闭中,默认为开启中的
assigned_to_id: undefined, // 指派人
fixed_version_id: undefined,
order_name: undefined,
order_type: undefined,
search: undefined,
page: 1,
limit: 15,
},
}
}
@ -70,14 +80,12 @@ class merge extends Component {
}
// 获取列表数据
getIssueList = (page, limit, search, author_id, assigned_to_id, status_type, id, value, order_type, order_name) => {
getIssueList = () => {
const { select_params } = this.state;
const { projectsId } = this.props.match.params;
const url = `/projects/${projectsId}/pull_requests.json`;
axios.get(url, {
params: {
page, limit, search, author_id, assigned_to_id, status_type, order_type, order_name,
[id]: value
}
params: select_params,
}).then((result) => {
if (result) {
this.setState({
@ -92,34 +100,51 @@ class merge extends Component {
})
}
getOption = (e, id, name) => {
if (id + 's' === "issue_tag_ids") {
this.setState({
[id]: e.key,
issue_tag_ids: name
})
}
if (id + 's' === "fixed_version_ids") {
this.setState({
[id]: e.key,
fixed_version_ids: name
})
}
if (id + 's' === "assigned_to_ids") {
this.setState({
[id]: e.key,
assigned_to_ids: name
})
}
getMenu = (e, id, name) => {
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 {
this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type, id, e.key);
isSpin: true,
});
let key_name = e.key.split("-");
if (key_name[0] === "created_on") {
if (e.item.props.value === "desc") {
this.setState({
paix: "最新创建",
});
} else {
this.setState({
paix: "最早创建",
});
}
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) => {
this.setState({
isSpin: true,
});
let option_id = e.key === "all" ? undefined : e.key;
this.setState({
["${id}s"]: name,
});
this.state.select_params[`${id}`] = option_id;
this.state.select_params.page = 1;
this.state[`${id}s`] = name;
this.getIssueList();
}
renderMenu = (array, name, id) => {
@ -140,85 +165,72 @@ class merge extends Component {
// 翻页
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) => {
if (type) {
if (type === 1) {
this.setState({
status_type: '1',
closeselect: undefined,
openselect: '123',
issue_tag_ids: '标签',
fixed_version_ids: '里程碑',
assigned_to_ids: '指派人',
paix: '排序'
})
this.getIssueList("", "", "", "", "", 1, "");
// if (type) {
// if (type === 1) {
// this.setState({
// status_type: '1',
// closeselect: undefined,
// openselect: '123',
// issue_tag_ids: '标签',
// fixed_version_ids: '里程碑',
// assigned_to_ids: '指派人',
// paix: '排序'
// })
// this.getIssueList("", "", "", "", "", 1, "");
} else {
this.setState({
status_type: '2',
openselect: undefined,
closeselect: '123',
issue_tag_ids: '标签',
fixed_version_ids: '里程碑',
assigned_to_ids: '指派人',
paix: '排序'
})
this.getIssueList("", "", "", "", "", 2, "");
}
}
}
arrayList = (e) => {
const { limit, search, status_type, author_id, assigned_to_id } = this.state;
if (e.key === 'created_on') {
if (e.item.props.value === "desc") {
this.setState({
paix: '最新创建'
})
} else {
this.setState({
paix: '最早创建'
})
}
} else {
if (e.item.props.value === "desc") {
this.setState({
paix: '最新更新'
})
} else {
this.setState({
paix: '最早更新'
})
}
}
// } else {
// this.setState({
// status_type: '2',
// openselect: undefined,
// closeselect: '123',
// issue_tag_ids: '标签',
// fixed_version_ids: '里程碑',
// assigned_to_ids: '指派人',
// paix: '排序'
// })
// this.getIssueList("", "", "", "", "", 2, "");
// }
// }
this.setState({
order_name: e.key,
order_type: e.item.props.value
})
this.getIssueList(1, limit, search, author_id, assigned_to_id, status_type, undefined, undefined, e.item.props.value, e.key);
}
isSpin: true,
});
if (type) {
this.setState({
status_type: type,
issue_tag_ids: '标签',
fixed_version_ids: '里程碑',
assigned_to_ids: '指派人',
paix: '排序'
});
this.state.select_params = {
status_type: type,
search: undefined,
page: 1,
limit: 15,
};
this.getIssueList();
}}
islogin() {
const { projectsId } = this.props.match.params;
@ -230,15 +242,23 @@ class merge extends Component {
}
}
render() {
const { issue_chosen, issues, limit, page, search_count, data, isSpin, openselect, closeselect } = this.state;
const { issue_chosen, issues, limit, page, search_count, data, isSpin, status_type, select_params } = this.state;
const menu = (
<Menu onClick={(e) => this.arrayList(e)}>
<Menu.Item key={'created_on'} value="desc">最新创建</Menu.Item>
<Menu.Item key={'created_on'} value="asc">最早创建</Menu.Item>
<Menu.Item key={'updated_on'} value="desc">最新更新</Menu.Item>
<Menu.Item key={'updated_on'} value="asc">最早更新</Menu.Item>
<Menu onClick={(e) => this.getMenu(e)}>
<Menu.Item key={"created_on-desc"} value="desc">
最新创建
</Menu.Item>
<Menu.Item key={"created_on-asc"} value="asc">
最早创建
</Menu.Item>
<Menu.Item key={"updated_on-desc"} value="desc">
最新更新
</Menu.Item>
<Menu.Item key={"updated_on-asc"} value="asc">
最早更新
</Menu.Item>
</Menu>
)
);
const Paginations = (
<React.Fragment>
@ -254,8 +274,8 @@ class merge extends Component {
<div className="main">
<div className="topWrapper" style={{ borderBottom: "none" }}>
<p className="topWrapper_type">
<li className={openselect ? "active" : ""} onClick={() => this.openorder(1)}>{data && data.open_count ? data.open_count : 0}个开启中</li>
<li className={closeselect ? "active" : ""} onClick={() => this.openorder(2)}>{data && data.close_count ? data.close_count : 0}个已关闭</li>
<li className={status_type === "1" ? "active" : ""} onClick={() => this.openorder("1")}>{data && data.open_count ? data.open_count : 0}个开启中</li>
<li className={status_type === "2" ? "active" : ""} onClick={() => this.openorder("2")}>{data && data.close_count ? data.close_count : 0}个已关闭</li>
</p>
<div className="topWrapper_select">
@ -300,7 +320,7 @@ class merge extends Component {
data && data.search_count && data.search_count > 0 ?
<div>
<Spin spinning={isSpin}>
<OrderItem issues={issues} search_count={search_count} page={page} limit={limit} {...this.props} {...this.state}></OrderItem>
<OrderItem issues={issues} search_count={search_count} page={select_params.page} limit={select_params.limit} {...this.props} {...this.state}></OrderItem>
{Paginations}
</Spin>
</div>
@ -312,4 +332,5 @@ class merge extends Component {
)
}
}
export default merge;
export default merge;

View File

@ -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,271 @@ 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: '最早更新'
})
}
}
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);
}
else {
this.getIssueList(page, limit, search, author_id, assigned_to_id, status_type, id, e.key);
}
}
isSpin: true,
});
let option_id = e.key === "all" ? undefined : e.key;
this.setState({
["${id}s"]: name,
});
this.state.select_params[`${id}`] = option_id;
this.state.select_params.page = 1;
this.state[`${id}s`] = name;
this.getIssueList();
};
renderMenu = (array, name, id) => {
return (
<Menu>
<Menu.Item key={"all"} onClick={(e) => this.getOption(e, id, name)}>{name}</Menu.Item>
{
array && array.length > 0 && array.map((item, key) => {
<Menu.Item key={"all"} onClick={(e) => this.getOption(e, id, name)}>
{name}
</Menu.Item>
{array &&
array.length > 0 &&
array.map((item, key) => {
return (
<Menu.Item key={item.id} onClick={(e) => this.getOption(e, id, item.name)}>{item.name}</Menu.Item>
)
})
}
<Menu.Item
key={item.id}
onClick={(e) => this.getOption(e, id, item.name)}
>
{item.name}
</Menu.Item>
);
})}
</Menu>
)
}
);
};
// 翻页
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({
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 +306,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 = (
<Menu onClick={(e) => this.getOption(e)}>
<Menu.Item key={'created_on'} value="desc">最新创建</Menu.Item>
<Menu.Item key={'created_on'} value="asc">最早创建</Menu.Item>
<Menu.Item key={'updated_on'} value="desc">最新更新</Menu.Item>
<Menu.Item key={'updated_on'} value="asc">最早更新</Menu.Item>
<Menu onClick={(e) => this.getMenu(e)}>
<Menu.Item key={"created_on-desc"} value="desc">
最新创建
</Menu.Item>
<Menu.Item key={"created_on-asc"} value="asc">
最早创建
</Menu.Item>
<Menu.Item key={"updated_on-desc"} value="desc">
最新更新
</Menu.Item>
<Menu.Item key={"updated_on-asc"} value="asc">
最早更新
</Menu.Item>
</Menu>
)
);
const Paginations = (
<React.Fragment>
{
search_count > limit ?
<div className="mt30 mb50 edu-txt-center">
<Pagination simple defaultCurrent={page} total={search_count} pageSize={limit} onChange={this.ChangePage}></Pagination>
</div> : ""
}
{search_count > select_params.limit ? (
<div className="mt30 mb50 edu-txt-center">
<Pagination
simple
defaultCurrent={select_params.page}
total={search_count}
pageSize={select_params.limit}
onChange={this.ChangePage}
></Pagination>
</div>
) : (
""
)}
</React.Fragment>
)
);
return (
<div className="main">
<div className="topWrapper" style={{ borderBottom: "none" }}>
<p className="topWrapper_type">
<li className={openselect ? "active" : ""} onClick={() => this.openorder(1)}>{data && data.open_count}个开启中</li>
<li className={closeselect ? "active" : ""} onClick={() => this.openorder(2)}>{data && data.close_count}个已关闭</li>
<li
className={status_type === "1" ? "active" : ""}
onClick={() => this.openorder("1")}
>
{data && data.open_count}个开启中
</li>
<li
className={status_type === "2" ? "active" : ""}
onClick={() => this.openorder("2")}
>
{data && data.close_count}个已关闭
</li>
</p>
<div className="topWrapper_select">
@ -385,67 +379,176 @@ class order extends Component {
style={{ width: 300 }}
/>
</div>
<a className="topWrapper_btn ml10" onClick={() => this.islogin()} >创建任务</a>
<a className="topWrapper_btn ml10" onClick={() => this.islogin()}>
创建任务
</a>
</div>
</div>
<Spin spinning={isSpin}>
<div className="f-wrap-between mb20">
<ul className="topWrapper_type">
<li className={!author_id && !assigned_to_id ? "active" : ""} onClick={() => this.ChangeAssign()}>全部</li>
{}
<li style={{ display: current_user && current_user.login === "" ? 'none' : 'flex' }} className={assigned_to_id ? "active" : ""} onClick={() => this.ChangeAssign(1)}>指派给我</li>
<li style={{ display: current_user && current_user.login === "" ? 'none' : 'flex' }} className={author_id ? "active" : ""} onClick={() => this.ChangeAssign(2)}>由我创建</li>
<li
className={!author_id && !assigned_to_id ? "active" : ""}
onClick={() => this.ChangeAssign()}
>
全部
</li>
<li
style={{
display:
current_user && current_user.login === "" ? "none" : "flex",
}}
className={assigned_to_id ? "active" : ""}
onClick={() => this.ChangeAssign(1)}
>
指派给我
</li>
<li
style={{
display:
current_user && current_user.login === "" ? "none" : "flex",
}}
className={author_id ? "active" : ""}
onClick={() => this.ChangeAssign(2)}
>
由我创建
</li>
</ul>
<ul className="topWrapper_select">
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.issue_tag, '标签', 'issue_tag_id')} trigger={['click']} placement="bottomCenter">
<span>{this.state.issue_tag_ids}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.issue_tag,
"标签",
"issue_tag_id"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.issue_tag_ids}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.tracker, '所有分类', 'tracker_id')} trigger={['click']} placement="bottomCenter">
<span>{this.state.tracker_ids}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.tracker,
"所有分类",
"tracker_id"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.tracker_ids}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.assign_user, '发布人', 'author_id')} trigger={['click']} placement="bottomCenter">
<span>{this.state.author_ids}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.assign_user,
"发布人",
"author_id"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.author_ids}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.assign_user, '指派人', 'assigned_to_id')} trigger={['click']} placement="bottomCenter">
<span>{this.state.assigned_to_ids}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.assign_user,
"指派人",
"assigned_to_id"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.assigned_to_ids}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.priority, '优先度', 'priority_id')} trigger={['click']} placement="bottomCenter">
<span>{this.state.priority_ids}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.priority,
"优先度",
"priority_id"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.priority_ids}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={this.renderMenu(issue_chosen && issue_chosen.done_ratio, '完成度', 'done_ratio')} trigger={['click']} placement="bottomCenter">
<span>{this.state.done_ratios}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={this.renderMenu(
issue_chosen && issue_chosen.done_ratio,
"完成度",
"done_ratio"
)}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.done_ratios}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
<li>
<Dropdown className="topWrapperSelect" overlay={menu} trigger={['click']} placement="bottomCenter">
<span>{this.state.paix}<Icon type="caret-down" className="ml5" /></span>
<Dropdown
className="topWrapperSelect"
overlay={menu}
trigger={["click"]}
placement="bottomCenter"
>
<span>
{this.state.paix}
<Icon type="caret-down" className="ml5" />
</span>
</Dropdown>
</li>
</ul>
</div>
{
search_count === 0 ?
<NoneData _html="暂时还没有相关数据哦!" />
:
<OrderItem issues={issues} search_count={search_count} page={page} limit={limit} {...this.props} {...this.state} deletedetail={this.deletedetail}></OrderItem>
}
{search_count === 0 ? (
<NoneData _html="暂时还没有相关数据哦!" />
) : (
<OrderItem
issues={issues}
search_count={search_count}
page={select_params.page}
limit={select_params.limit}
{...this.props}
{...this.state}
deletedetail={this.deletedetail}
></OrderItem>
)}
{Paginations}
</Spin>
</div>
)
);
}
}
export default order;
export default order;