import React,{Component} from 'react'; import {Button, DatePicker, Input, message, Modal, Radio} from "antd"; import { simpleState } from './type'; import moment from "moment"; import $ from "jquery"; import {splitUrl} from '@/tools' import ImgList from "../imgList"; class NowProjectStatus extends Component{ constructor(props) { super(props); this.state={ projectStatus: parseInt(props.projectStatus), list:simpleState, dataInfor:Object.assign({},props.projectTypeJSON), loading: false, fileList:[], } } updateProjectStatus(){ let arr = this.state.list.filter(v=>v.id === this.state.projectStatus); let dataInforLength = this.state.dataInfor[this.state.projectStatus] ? Object.keys(this.state.dataInfor[this.state.projectStatus]).length : 0; if(this.state.dataInfor[this.state.projectStatus] && this.state.dataInfor[this.state.projectStatus]['title']){ dataInforLength -= 1; } if(this.state.dataInfor[this.state.projectStatus] && this.state.dataInfor[this.state.projectStatus]['suspendImg']){ dataInforLength -= 1; } if(arr.length !== 0 && arr[0]['valueType'] && dataInforLength !== arr[0]['valueType'].length){ arr[0]['valueType'].map((v)=>{ if(!this.state.dataInfor[this.state.projectStatus][v]){ if(v === 'date'){ message.warning('请将'+arr[0]['name']+'时间补充完整') } if(v === 'certificateNumber'){ message.warning('请将'+arr[0]['name']+'的证书编号补充完整') } if(v === 'setUpAmount'){ message.warning('请将'+arr[0]['name']+'的立项金额补充完整') } if(v === 'appropriation'){ message.warning('请将'+arr[0]['name']+'的拨款金额补充完整') } return false; } }) return false; } // if((this.state.projectStatus === 2 || this.state.projectStatus === 3) && this.state.fileList.length === 0){ // message.warning('暂停附件未上传,请上传后保存!') // return false; // } this.setState({ loading: true, }) if((this.state.projectStatus === 2 || this.state.projectStatus === 3)){ if (this.state.fileList.length) { let picArr = [] this.state.fileList.map(function (item) { if (item.response && item.response.data && item.response.data.length) { picArr.push(item.response.data) } }) if(!this.state.dataInfor[2]){ this.state.dataInfor[2] = {}; } if(!this.state.dataInfor[3]){ this.state.dataInfor[3] = {}; } this.state.dataInfor[2]['suspendImg'] = picArr.join(','); this.state.dataInfor[3]['suspendImg'] = picArr.join(','); } } let data = Object.assign({},this.state.dataInfor); Object.keys(data).map(v=>{ if(Object.keys(data[v]).length === 0){ delete data[v]; } }) if(data[this.state.projectStatus]){ data[this.state.projectStatus]['title'] =arr[0]['label'] || arr[0]['name']; } let obj = { tid:this.props.tid, projectStatus: this.state.projectStatus, // timeRecord: JSON.stringify(data) } // if(arr[0]['valueType']){ // //证书编号 // let type = arr[0]['valueType'].filter(v=>v==='certificateNumber'); // if(type.length > 0){ // obj.certificateNumber = this.state.dataInfor[this.state.projectStatus]['certificateNumber'] // } // //立项金额 // let type1 = arr[0]['valueType'].filter(v=>v==='setUpAmount'); // if(type1.length > 0){ // obj.setUpAmount = this.state.dataInfor[this.state.projectStatus]['setUpAmount'] // } // } $.ajax({ url: globalConfig.context + '/api/admin/orderProject/updateProjectStatus', method: 'post', data: obj, }).done( function (data) { this.setState({ loading: false, }) if (!data.error.length) { message.success('保存成功!'); this.props.onPreservation(this.state.projectStatus); } else { message.warning(data.error[0].message) } }.bind(this) ) } componentDidMount() { /*旧数据处理 * endDate 完成时间 对应已提交时间 4 * acceptDate 受理时间 对应已推荐时间 6 * publicityDate 公示时间 对应已拟公示时间 8 * licenceDate 发证时间 对应已下证时间 10 * setUpAmount 立项金额 15 * */ const {endDate,acceptDate,publicityDate,licenceDate,setUpAmount} = this.props.oldData; if((!this.props.projectTypeJSON[4]) && endDate){ this.state.dataInfor[4]={title:'完成时间'}; this.state.dataInfor[4]['date'] = endDate; } if((!this.props.projectTypeJSON[6]) && acceptDate){ this.state.dataInfor[6]={title:'受理时间'}; this.state.dataInfor[6]['date'] = acceptDate; } if((!this.props.projectTypeJSON[8]) && publicityDate){ this.state.dataInfor[8]={title:'公示时间'}; this.state.dataInfor[8]['date'] = publicityDate; } if((!this.props.projectTypeJSON[10]) && licenceDate){ this.state.dataInfor[10]={title:'发证时间'}; this.state.dataInfor[10]['date'] = licenceDate; } // if((!this.props.projectTypeJSON[15]) && setUpAmount){ // this.state.dataInfor[15]={title:'立项金额'}; // this.state.dataInfor[15]['setUpAmount'] = setUpAmount; // } //图片 if(this.props.projectTypeJSON[2] && this.props.projectTypeJSON[2]['suspendImg']){ this.setState({ fileList: splitUrl( this.props.projectTypeJSON[2]['suspendImg'], ',', globalConfig.avatarHost + '/upload' ) }) }else{ this.setState({ fileList: [] }) } this.setState({ dataInfor: this.state.dataInfor, }) } render() { return( { this.props.onCancel(); }} onCancel={()=>{ this.props.onCancel(); }} >
项目状态:
{ if(!this.state.dataInfor[e.target.value]){ this.state.dataInfor[e.target.value] = {}; } this.state.dataInfor[this.state.projectStatus] = this.props.projectTypeJSON[this.state.projectStatus] || {}; this.setState({ projectStatus: e.target.value, dataInfor:this.state.dataInfor, }); }} > { this.state.list.map((v,k)=>(
{v.name} { (v.valueType || []).map(d=>( parseInt(this.state.projectStatus) !== parseInt(v.id) ? { d === 'appropriation' ? '拨款金额(万元):' : d === 'certificateNumber' ? '已出高新证书编号,编号:' : d === 'setUpAmount' ? '立项金额(万元):' : '' } { this.state.dataInfor[v.id] && this.state.dataInfor[v.id][d] } :d === 'date' ? {}} value={ this.state.dataInfor[v.id] && this.state.dataInfor[v.id][d] ? moment(this.state.dataInfor[v.id][d]) : null } onChange={(data, dataString) => { console.log(dataString) if(!this.state.dataInfor[v.id]){ this.state.dataInfor[v.id] = {}; } if(!dataString && this.state.dataInfor[v.id][d]){ delete this.state.dataInfor[v.id][d]; }else{ this.state.dataInfor[v.id][d] = dataString; } this.setState({ dataInfor:this.state.dataInfor, }) }} /> : d === 'setUpAmount' || d === 'certificateNumber' || d === 'appropriation' ? { d === 'appropriation' ? '拨款金额(万元)' : d === 'certificateNumber' ? '已出高新证书编号,编号' : d === 'setUpAmount' ? '立项金额(万元)' : '' } { if(!this.state.dataInfor[v.id]){ this.state.dataInfor[v.id] = {}; } if(!e.target.value && this.state.dataInfor[v.id][d]){ delete this.state.dataInfor[v.id][d]; }else{ this.state.dataInfor[v.id][d] = e.target.value; } this.setState({ dataInfor:this.state.dataInfor, }) }} /> : null )) } {v.explain}
)) }
{/*{*/} {/* (this.state.projectStatus === 2 || this.state.projectStatus === 3 || this.state.fileList.length > 0) &&*/} {/*
*/} {/*
*/} {/*
暂停附件:
*/} {/*
(请上传截图证明)
*/} {/*
*/} {/*
*/} {/* {*/} {/* let fileList = info.fileList;*/} {/* this.setState({ fileList });*/} {/* }}*/} {/* fileList={this.state.fileList}*/} {/* />*/} {/*
*/} {/*
*/} {/* */} {/*
*/} {/*
*/} {/*}*/}
注:请根据实际项目情况填写
) } } export default NowProjectStatus;