import React , {Component} from 'react'; import {Link} from 'react-router-dom'; import axios from 'axios'; import Nav from './Nav'; import UploadComponent from '../Upload/Index'; import { getImageUrl } from 'educoder'; import{ Modal,Col,Form,Input,Tooltip,Select } from 'antd' import NoneData from '../../modules/courses/coursesPublic/NoneData'; import Attachments from '../Upload/attachment' const TextArea = Input.TextArea; const Option = Select.Option; class CopyDetail extends Component{ constructor(props){ super(props); this.state={ data:undefined, isShow:false, imgsrc:'', journalsdata:undefined, //图片区域是否显示 none 隐藏 block 显示 display:'none', titledisplay:'none', subject:'', branch_name:"", issue_tag_ids:"", fixed_version_id:"", tracker_id:0, issue_type:0, status_id:0, assigned_to_id:"", priority_id:0, done_ratio:0, textcount:"", fileList:undefined, get_attachments: undefined } } componentDidMount=()=>{ this.InitData(); this.getDetail(); //this.getSelectList(); } InitData=()=>{ // this.props.form.setFieldsValue({ // ...this.state // }); } getDetail=()=>{ const { projectsId , orderId} = this.props.match.params; const url = `/projects/${projectsId}/issues/${orderId}/edit.json`; axios.get(url).then((result)=>{ if(result){ this.setState({ data:result.data, subject:result.data.subject, issue_chosen:result.data.issue_chosen, branches:result.data.branches, tracker_id:result.data.tracker_id, issue_type:result.data.issue_type, status_id:result.data.status_id, priority_id:result.data.priority_id, done_ratio:result.data.done_ratio, textcount:result.data.description, branch_name: result.data.branch_name, get_attachments: result.data.attachments, fileList:undefined, issue_tag_ids: result.data.issue_tags && result.data.issue_tags[0].id, fixed_version_id: result.data.fixed_version_id, assigned_to_id: result.data.assigned_to_id }) this.getjournalslist(); } }).catch((error)=>{ console.log(error); }) } handleok=() => { this.setState({ isShow:false }); }; handleCancel=()=>{ this.setState({ isShow:false }); } imgshow=()=>{ this.setState({ isShow:true }); }; //删除工单 deleteorder=(id)=>{ const { projectsId , orderId} = this.props.match.params; const url = `/projects/${projectsId}/issues/${orderId}.json`; axios.delete(url,{ data: { project_id: projectsId, id:id } }).then((result)=>{ if(result){ this.props.history.push(`/projects/${projectsId}/orders`); } }).catch((error)=>{ console.log(error); }) } changmodelname=(e)=>{ this.setState({ subject:e.target.value }) } changmodelcount=(e)=>{ this.setState({ textcount:e.target.value }) } renderSelect=(list)=>{ if(list && list.length >0){ return( list.map((item,key)=>{ return( ) }) ) } } handleSubmit=()=>{ const { fileList } = this.state; this.props.form.validateFieldsAndScroll((err, values) => { if(!err){ const { projectsId,orderId} = this.props.match.params; const { subject } = this.state; const url = `/projects/${projectsId}/issues/${orderId}.json`; if(values.issue_tag_ids===0){ values.issue_tag_ids = "" }else{ values.issue_tag_ids = [values.issue_tag_ids] } if(values.assigned_to_id===0){ values.assigned_to_id = "" } axios.put(url,{ project_id:projectsId, subject:subject, id: orderId, description:this.state.textcount, attachment_ids:fileList, ...values }).then(result=>{ if(result){ this.props.history.push(`/projects/${projectsId}/orders`); } }).catch(error=>{ console.log(error); }) } }) } render(){ const { projectsId,orderId } = this.props.match.params; const { getFieldDecorator } = this.props.form; const { current_user } = this.props; const { issue_tag_ids , fixed_version_id , branch_name , status_id , tracker_id , issue_type ,assigned_to_id , priority_id , done_ratio, issue_chosen , branches, subject, textcount,get_attachments } = this.state; return(