import React , { Component } from "react"; import {Link} from 'react-router-dom'; import { Dropdown , Menu , Icon , Pagination , Spin } from 'antd'; import './order.css'; import NoneData from '../../modules/courses/coursesPublic/NoneData'; import OrderItem from './OrderItem'; import axios from 'axios'; /** * issue_chosen:下拉的筛选列表, * data:列表接口返回的所有数据, * issues:列表数组, * isSpin:加载中, * search:搜索关键字, * author_id:发布者id, * assigned_to_id:指派给。。。的id, * limit:每页条数, * page:当前页, * search_count:列表总条数 * issue_type:搜索条件 * status_type: issue的关闭和开启,1表示开启中的,2表示关闭的 */ class MilepostDetail 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, miledata:undefined, // status_type: undefined issue_tag_ids:'标签', tracker_ids:'所有分类', author_ids:'发布人', assigned_to_ids:'指派人', priority_ids:'优先度', done_ratios:'完成度', paix:'排序' } } componentDidMount=()=>{ this.getSelectList(); this.getIssueList(); this.getmeil(); } getmeil=()=>{ const { projectsId } = this.props.match.params; const { meilid } = this.props.match.params; const url = `/projects/${projectsId}/versions/${meilid}/edit.json`; axios.get(url,{ params:{ projectsId,meilid } }).then((result)=>{ if(result){ this.setState({ miledata:result.data, }) this.props.form.setFieldsValue({ name:result.data.name, description:result.data.description }); } }).catch((error)=>{ console.log(error); }) } 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,meilid} = this.props.match.params; const url = `/projects/${projectsId}/versions/${meilid}.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,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 } = 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( this.getOption(e,id,name)}>{name} { array && array.length > 0 && array.map((item,key)=>{ return( this.getOption(e,id,item.name)}>{item.name} ) }) } ) } // 翻页 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); } } } render(){ const { issue_chosen , issues , limit , page , search_count , data , miledata , isSpin,openselect,closeselect } = this.state; const { projectsId,meilid } = this.props.match.params; const menu = ( this.getOption(e)}> 最新创建 最早创建 最新更新 最早更新 ) const Paginations = ( { search_count > limit ?
:"" }
) return(

{miledata&&miledata.name}

编辑里程碑 创建工单
{/*

*/}
  • this.openorder(1)}>{data && data.open_issues_count}个开启中
  • this.openorder(2)}>{data && data.close_issues_count}个已关闭
  • {/*
  • @我的
  • */}
  • {this.state.issue_tag_ids}
  • {/*
  • */} {/**/} {/*类型*/} {/**/} {/*
  • */}
  • {this.state.tracker_ids}
  • {this.state.author_ids}
  • {this.state.assigned_to_ids}
  • {this.state.priority_ids}
  • {this.state.done_ratios}
  • {this.state.paix}
{ search_count === 0 ? : } { Paginations }
) } } export default MilepostDetail;