import React from 'react'; import { Input, Button, Form, Select, Upload, Icon, Spin, message, InputNumber,Modal } from 'antd'; import './person.less'; import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; import { addressInit ,splitUrl} from '../../tools.js'; function getBase64(img, callback) { const reader = new FileReader(); reader.addEventListener('load', () => callback(reader.result)); reader.readAsDataURL(img); }; function beforeUpload(file) { const isJPG = file.type === 'image/jpeg'; if (!isJPG) { message.error('You can only upload JPG file!'); } const isLt2M = file.size / 1024 / 1024 < 2; if (!isLt2M) { message.error('Image must smaller than 2MB!'); } return isJPG && isLt2M; }; class Avatar extends React.Component { constructor(props) { super(props); this.state = { imageUrl: '' } } 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); } } 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 (
{fileList.length >= 9 ? null : uploadButton} example
); } }; 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) { addressInit('cmbProvince', 'cmbCity', 'cmbArea', data.data.locationProvince, data.data.locationCity, data.data.locationArea); let theArr = splitUrl(data.data.info.publicityPictureUrl, ',', globalConfig.staticHost + '/upload'); this.setState({ idttType: data.data.info.identityType, unitName: data.data.info.companyName, unitNumber: data.data.info.unitSize, unitIntro: data.data.info.companyIntroduction, unitFrom: data.data.info.homeUnit, companyLifePicUrl: 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 }); } }.bind(this), }).always(function () { this.props.spinState(false); }.bind(this)); }, getInitialState() { return { loading: false, idttType: '企业', companyDis: 'block', schoolDis: 'none', resDis: 'none', 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 cmbP = document.getElementById('cmbProvince').value; let cmbC = document.getElementById('cmbCity').value; let cmbA = document.getElementById('cmbArea').value; // let leftPicArr = []; this.state.companyLifePicObj.map(function (item) { leftPicArr.push(item.response.data); }); let lifePhotoUrl = leftPicArr.join(","); if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/orgPro", data: { "info.identityType": values.identityType, "info.companyName": values.unitName, "info.locationProvince": cmbP, "info.locationCity": cmbC, "info.locationArea": cmbA, "info.unitSize": values.unitNumber, "info.companyIntroduction": values.unitIntro, "info.homeUnit": values.unitFrom, "info.logoUrl": this.state.companyLogoUrl, "info.publicityPictureUrl": lifePhotoUrl, "pro.qualification": values.qiyezizhi, "pro.turnover": values.turnover, "pro.collegeAttribute": values.schoolProp, "pro.collegeEstablishTime": values.schoolTime, "pro.academician": this.state.aca, "pro.doctoralTutor": this.state.PhDTutor, "pro.masterTutor": this.state.MSTutor, "pro.otherExpert": this.state.otherExperts, "pro.nationalLab": this.state.StateKeyLab, "pro.educationLab": this.state.EduKeyLab, "pro.enterpriseCenter": this.state.ComCenter, "pro.otherCenter": this.state.otherCenter, "pro.institutionEstablishTime": values.resTime } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, idttTypeChange(e) { if (e === '企业') { this.props.form.setFieldsValue({ 'indentityType': e }); this.setState({ companyDis: 'block', schoolDis: 'none', resDis: 'none' }); } else if (e === '院校') { this.props.form.setFieldsValue({ 'indentityType': e }); this.setState({ companyDis: 'none', schoolDis: 'block', resDis: 'none' }); } else if (e === '研究机构') { this.props.form.setFieldsValue({ 'indentityType': e }); this.setState({ companyDis: 'none', schoolDis: 'none', resDis: 'block' }); } else { this.props.form.setFieldsValue({ 'indentityType': e }); this.setState({ companyDis: 'none', schoolDis: 'none', resDis: 'none' }); } }, downloadPic(type) { $.ajax({ method: "post", dataType: "json", url: globalConfig.context + "/open/downLoadPicture", data: { path: type, isPrivate: true }, success: function (data) { }.bind(this), }); }, companyLogoUrl(e) { this.state.companyLogoUrl = e; }, companyLifePicUrl(e) { this.state.companyLifePicObj = e; }, componentDidMount() { addressInit('cmbProvince', 'cmbCity', 'cmbArea'); this.getData(); }, render() { const FormItem = Form.Item; const Option = Select.Option; const edulvlArr = ["企业", "院校", "研究机构", "政府部门", "非法人团体"]; const zizhiArr = ["高新技术型企业", "创新型企业", "双软企业", "小心微利企业", "科技部认定示范企业", "其他"]; const schoolArr = ["普通本科院校", "高职专科院校", "独立学院", "中央部署院校", "地方所属院校", "211工程院校", "985工程院校"]; const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 3 }, wrapperCol: { span: 12 }, }; const _me = this; return (
{getFieldDecorator('identityType', { initialValue: this.state.idttType })( )} {getFieldDecorator('unitName', { initialValue: this.state.unitName })( )} {getFieldDecorator('province')(
)}
{getFieldDecorator('unitNumber', { initialValue: this.state.unitNumber })( )} {getFieldDecorator('unitIntro', { initialValue: this.state.unitIntro })( )}

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

{getFieldDecorator('unitFrom', { initialValue: this.state.unitFrom })( )} {getFieldDecorator('qiyezizhi', { initialValue: this.state.qiyezizhi })( )} {getFieldDecorator('turnover', { initialValue: this.state.turnover })( )} 万元 {getFieldDecorator('schoolProp', { initialValue: this.state.schoolProp })( )} {getFieldDecorator('schoolTime', { initialValue: this.state.schoolTime })( )}
院士:
博士生导师:
硕士生导师:
其他专家:
国家级重点实验室:
教育部重点实验室:
企业共建研究中心:
其他研究中心:
{getFieldDecorator('resTime', { initialValue: this.state.resTime })( )} {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;