import React from 'react'; import { Input, Button, Form, Select, Upload, Icon, Spin, message, InputNumber, Modal, Cascader } from 'antd'; import './person.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import { areaSelect } from '../../NewDicProvinceList'; import { splitUrl, getBase64, beforeUpload } from '../../tools.js'; import { eduLevelList, zizhiArr, schoolArr ,mechanism} from '../../dataDic.js'; import ImgList from "../../common/imgList"; class Avatar extends React.Component { constructor(props) { super(props); this.state = { imageUrl: '', propsbool: true, } } handleChange(info) { if (info.file.status === 'done') { // Get this url from response in real world. getBase64(info.file.originFileObj, imageUrl => this.setState({ imageUrl })); this.props.urlData(info.file.response.data); } } componentWillReceiveProps(nextProps) { if (nextProps.logoUrl && this.state.propsbool) { this.state.imageUrl = globalConfig.avatarHost + "/upload" + nextProps.logoUrl; this.state.propsbool = false; } } render() { const imageUrl = this.state.imageUrl; return ( { imageUrl ? : } ); } }; class PicturesWall extends React.Component { constructor(props) { super(props); this.state = { previewVisible: false, propsbool: true, previewImage: '', fileList: [], } } handleCancel() { this.setState({ previewVisible: false }) } handlePreview(file) { this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); } handleChange(info) { let fileList = info.fileList; this.setState({ fileList }); this.props.fileList(fileList); } componentWillReceiveProps(nextProps) { if (nextProps.lifePhotoList && this.state.propsbool) { this.state.fileList = nextProps.lifePhotoList; this.state.propsbool = false; } } render() { const { previewVisible, previewImage, fileList } = this.state; const uploadButton = (
Upload
); return (
{ this.handleChange(infor) }} fileList={fileList} />
); } }; const PersonFrom = Form.create()(React.createClass({ getData() { this.props.spinState(true); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/api/user/member", success: function (data) { if (data.data && data.data.info && data.data.pro) { let theArr = splitUrl(data.data.info.publicityPictureUrl, ',', globalConfig.avatarHost + '/upload'); let comp=data.data.info.companyType; let pantt; switch(comp){ case 0: pantt='待定'; break; case 1: pantt='投资机构'; break; }; this.setState({ iid: data.data.info.id, pid: data.data.pro.id, province: [data.data.info.locationProvince, data.data.info.locationCity, data.data.info.locationArea], idttType: data.data.info.identityType, companyt: pantt, unitName: data.data.info.companyName, unitNumber: data.data.info.unitSize, unitIntro: data.data.info.companyIntroduction, unitFrom: data.data.info.homeUnit, logoUrl: data.data.info.logoUrl, publicityPictureUrl: data.data.info.publicityPictureUrl, companyLifePicList: theArr, qiyezizhi: data.data.pro.qualification, turnover: data.data.pro.turnover, schoolProp: data.data.pro.collegeAttribute, schoolTime: data.data.pro.collegeEstablishTime, aca: data.data.pro.academician, PhDTutor: data.data.pro.doctoralTutor, MSTutor: data.data.pro.masterTutor, otherExperts: data.data.pro.otherExpert, StateKeyLab: data.data.pro.nationalLab, EduKeyLab: data.data.pro.educationLab, ComCenter: data.data.pro.enterpriseCenter, otherCenter: data.data.pro.otherCenter, resTime: data.data.pro.institutionEstablishTime }); this.idttTypeChange(data.data.info.identityType); }; }.bind(this), }).always(function () { this.props.spinState(false); }.bind(this)); }, getInitialState() { return { loading: false, idttType: '企业', companyt:'待定', companyDis: 'block', schoolDis: 'none', resDis: 'none', companyLifePicObj: [], aca: 0, PhDTutor: 0, MSTutor: 0, otherExperts: 0, StateKeyLab: 0, EduKeyLab: 0, ComCenter: 0, otherCenter: 0 }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { let lifePhotoUrl = this.state.publicityPictureUrl; if (this.state.companyLifePicObj.length) { let leftPicArr = []; this.state.companyLifePicObj.map(function (item) { if ( item.response && item.response.data && item.response.data.length ){ leftPicArr.push(item.response.data); } }); lifePhotoUrl = leftPicArr.join(","); }; if (!err) { this.props.spinState(true); let ktt=values.companyType; let sktt; switch(ktt){ case '待定': sktt='0'; break; case '投资机构': sktt='1'; break; }; $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/orgPro", data: { "iid": this.state.iid, "pid": this.state.pid, "identityType": values.identityType, "companyType":sktt, "companyName": values.unitName, "locationProvince": values.province[0], "locationCity": values.province[1], "locationArea": values.province[2], "unitSize": values.unitNumber, "companyIntroduction": values.unitIntro, "homeUnit": values.unitFrom, "logoUrl": this.state.companyLogoUrl, "publicityPictureUrl": lifePhotoUrl, "qualification": values.qiyezizhi, "turnover": values.turnover, "collegeAttribute": values.schoolProp, "collegeEstablishTime": values.schoolTime, "academician": values.aca, "doctoralTutor": values.PhDTutor, "masterTutor": values.MSTutor, "otherExpert": values.otherExperts, "nationalLab": values.StateKeyLab, "educationLab": values.EduKeyLab, "enterpriseCenter": values.ComCenter, "otherCenter": values.otherCenter, "institutionEstablishTime": values.resTime } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); this.getData(); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, idttTypeChange(e) { if (e === '企业') { this.setState({ companyDis: 'block', schoolDis: 'none', companys:'block', resDis: 'none' }); } else if (e === '院校') { this.setState({ companyDis: 'none', schoolDis: 'block', companys:'none', resDis: 'none' }); } else if (e === '研究机构') { this.setState({ companyDis: 'none', schoolDis: 'none', companys:'none', resDis: 'block' }); } else { this.setState({ companyDis: 'none', schoolDis: 'none', companys:'none', resDis: 'none' }); } }, downloadPic(type) { window.open(globalConfig.context + "/open/downLoadPicture?path=" + type) }, companyLogoUrl(e) { this.state.companyLogoUrl = e; }, companyLifePicUrl(e) { this.state.companyLifePicObj = e; }, componentWillMount() { this.getData(); }, render() { const FormItem = Form.Item; const Option = Select.Option; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 3 }, wrapperCol: { span: 12 }, }; const _me = this; return (
{getFieldDecorator('identityType', { initialValue: this.state.idttType })( )} {getFieldDecorator('companyType', { initialValue: this.state.companyt })( )} {getFieldDecorator('unitName', { initialValue: this.state.unitName })( )} {getFieldDecorator('province', { initialValue: this.state.province || [] })( )} {getFieldDecorator('unitIntro', { initialValue: this.state.unitIntro })( )}

还可输入{ (() => { if (_me.props.form.getFieldValue('unitIntro') && _me.props.form.getFieldValue('unitIntro').length) { return 1000 - _me.props.form.getFieldValue('unitIntro').length; } else { return 1000; } })() }字/1000

{getFieldDecorator('unitFrom', { initialValue: this.state.unitFrom })( )} {getFieldDecorator('qiyezizhi', { initialValue: this.state.qiyezizhi })( )} {getFieldDecorator('schoolProp', { initialValue: this.state.schoolProp })( )} {getFieldDecorator('schoolTime', { initialValue: this.state.schoolTime || 0 })( )}
{getFieldDecorator('aca', { initialValue: this.state.aca || 0 })( )} {getFieldDecorator('PhDTutor', { initialValue: this.state.PhDTutor || 0 })( )} {getFieldDecorator('MSTutor', { initialValue: this.state.MSTutor || 0 })( )} {getFieldDecorator('otherExperts', { initialValue: this.state.otherExperts || 0 })( )} {getFieldDecorator('StateKeyLab', { initialValue: this.state.StateKeyLab || 0 })( )} {getFieldDecorator('EduKeyLab', { initialValue: this.state.EduKeyLab || 0 })( )} {getFieldDecorator('ComCenter', { initialValue: this.state.ComCenter || 0 })( )} {getFieldDecorator('otherCenter', { initialValue: this.state.otherCenter || 0 })( )}
{getFieldDecorator('resTime', { initialValue: this.state.resTime || 0 })( )} {getFieldDecorator('avatar')( )}

上传的照片图片格式应为jpg格式,大小在2M以内

{getFieldDecorator('companyLifePic')( )}
); }, })); const Person = React.createClass({ getInitialState() { return { loading: false }; }, spinChange(e) { this.setState({ loading: e }); }, render() { return (

单位资料

) } }); export default Person;