import React , { Component } from "react"; import {Link} from 'react-router-dom'; import { Input ,Dropdown , Menu , Icon , Pagination , Spin } from 'antd'; import './merge.css'; import NoneData from '../../modules/courses/coursesPublic/NoneData'; import Nav from '../Order/Nav'; import OrderItem from './MergeItem'; import axios from 'axios'; const Search = Input.Search; /** * issue_chosen:下拉的筛选列表, * data:列表接口返回的所有数据, * issues:列表数组, * isSpin:加载中, * search:搜索关键字, * author_id:发布者id, * assigned_to_id:指派给。。。的id, * limit:每页条数, * page:当前页, * search_count:列表总条数 * issue_type:搜索条件 */ class merge extends Component{ constructor(props){ super(props); this.state={ issue_chosen:undefined, data:undefined, issues:undefined, isSpin:false, search:undefined, author_id:undefined, assigned_to_id:undefined, limit:15, page:1, search_count:undefined, issue_type:undefined, status_type:'1', //设置选择高亮 openselect:1, closeselect:undefined, } } componentDidMount=()=>{ this.getSelectList(); 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); }) } // 获取列表数据 getIssueList=(page,limit,search,author_id,assigned_to_id,id,value,status_type)=>{ 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, [id]:value } }).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); }) } getOption=(e,id)=>{ this.setState({ [id]:e.key }) const { page,limit,search,author_id,assigned_to_id } = this.state; if(e.key==="all"){ this.getIssueList(page,limit,search,author_id,assigned_to_id,id); }else{ this.getIssueList(page,limit,search,author_id,assigned_to_id,id,e.key); } } renderMenu =(array,name,id)=>{ return(
) } // 翻页 ChangePage=(page)=>{ this.setState({ page, isSpin:true }) const {limit,search} = this.state; this.getIssueList(page,limit,search); } // 搜索 searchFunc=(value)=>{ this.setState({ search:value, isSpin:true }) const {page,limit} = this.state; this.getIssueList(page,limit,value); } openorder=(type)=>{ if(type){ const { current_user } = this.props; if(type===1){ this.setState({ status_type:'1', openselect:current_user.user_id, closeselect:undefined }) this.getIssueList("","","","","","","",1); }else{ this.setState({ status_type:'2', openselect:undefined, closeselect:current_user.user_id }) this.getIssueList("","","","","","","",2); } } } // 筛选:全部、指派给我、由我创建 ChangeAssign=(type)=>{ const { limit, search} = this.state; this.setState({ isSpin:true }) if(type){ const { current_user } = this.props; if(type===1){ this.setState({ page:1, author_id:undefined, assigned_to_id:current_user.user_id }) this.getIssueList(1,limit,search,undefined,current_user.user_id); }else{ this.setState({ page:1, author_id:current_user.user_id, assigned_to_id:undefined }) this.getIssueList(1,limit,search,current_user.user_id,undefined); } }else{ this.setState({ page:1, author_id:undefined, assigned_to_id:undefined }) this.getIssueList(1,limit,search,undefined,undefined); } } render(){ const { issue_chosen , issues , limit , page , search_count , data , isSpin,openselect,closeselect } = this.state; const { projectsId } = this.props.match.params; const menu = ( ) const Paginations = (