123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613 |
- 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 (
- <Upload
- className="avatar-uploader"
- name="avatar"
- showUploadList={false}
- action={globalConfig.context + "/api/user/avatar/uploadReplace"}
- data={{ 'sign': this.props.name }}
- beforeUpload={beforeUpload}
- onChange={this.handleChange.bind(this)}
- >
- {
- imageUrl ?
- <img src={imageUrl} role="presentation" className="avatar" /> :
- <Icon type="plus" className="avatar-uploader-trigger" />
- }
- </Upload>
- );
- }
- };
- 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 = (
- <div>
- <Icon type="plus" />
- <div className="ant-upload-text">Upload</div>
- </div>
- );
- return (
- <div className="clearfix">
- <ImgList
- domId={this.props.domId}
- uploadConfig={{
- action:globalConfig.context + "/api/user/avatar/upload",
- data:{ 'sign': this.props.pictureSign, 'uid': this.props.uid},
- multiple:true,
- listType:"picture-card",
- }}
- onChange={(infor)=>{
- this.handleChange(infor)
- }}
- fileList={fileList}
- />
- </div>
- );
- }
- };
- 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 (
- <Form horizontal onSubmit={this.handleSubmit} className="person-form">
- <FormItem
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 8 }}
- label="身份类型"
- >
- {getFieldDecorator('identityType', {
- initialValue: this.state.idttType
- })(
- <Select className="acc-edu-lvl" onChange={this.idttTypeChange}>
- {
- eduLevelList.map(function (item) {
- return <Option key={item.key} >{item.key}</Option>
- })
- }
- </Select>
- )}
- </FormItem>
- <FormItem style={{ 'display': this.state.companys}}
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 8 }}
- label="企业类型"
- >
- {getFieldDecorator('companyType', {
- initialValue: this.state.companyt
- })(
- <Select className="acc-edu-lvl">
- {
- mechanism.map(function (item) {
- return <Option key={item.key} >{item.key}</Option>
- })
- }
- </Select>
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="单位名称"
- >
- {getFieldDecorator('unitName', {
- initialValue: this.state.unitName
- })(
- <Input />
- )}
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="所在地"
- >
- {getFieldDecorator('province', {
- initialValue: this.state.province || []
- })(
- <Cascader options={areaSelect()} placeholder="请选择所在地" />
- )}
- </FormItem>
- <FormItem
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 20 }}
- label="单位简介"
- >
- {getFieldDecorator('unitIntro', {
- initialValue: this.state.unitIntro
- })(
- <Input type="textarea"
- placeholder="全面介绍自己,让商友更深入了解您,内容长度不超过1000个字。"
- rows={6} />
- )}
- <p>还可输入{
- (() => {
- if (_me.props.form.getFieldValue('unitIntro') && _me.props.form.getFieldValue('unitIntro').length) {
- return 1000 - _me.props.form.getFieldValue('unitIntro').length;
- } else {
- return 1000;
- }
- })()
- }字/1000</p>
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="归属单位"
- >
- {getFieldDecorator('unitFrom', {
- initialValue: this.state.unitFrom
- })(
- <Input placeholder="非法人单位填写。" />
- )}
- </FormItem>
- <FormItem style={{ 'display': this.state.companyDis }}
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 8 }}
- label="企业资质"
- >
- {getFieldDecorator('qiyezizhi', {
- initialValue: this.state.qiyezizhi
- })(
- <Select className="acc-edu-lvl">
- {
- zizhiArr.map(function (item, i) {
- return <Option key={i} value={item} >{item}</Option>
- })
- }
- </Select>
- )}
- </FormItem>
- <FormItem style={{ 'display': this.state.schoolDis }}
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 8 }}
- label="院校属性"
- >
- {getFieldDecorator('schoolProp', {
- initialValue: this.state.schoolProp
- })(
- <Select className="acc-edu-lvl">
- {
- schoolArr.map(function (item, i) {
- return <Option key={i} value={item} >{item}</Option>
- })
- }
- </Select>
- )}
- </FormItem>
- <FormItem style={{ 'display': this.state.schoolDis }}
- {...formItemLayout}
- label="创办时间"
- >
- {getFieldDecorator('schoolTime', {
- initialValue: this.state.schoolTime || 0
- })(
- <InputNumber />
- )}
- <span>年</span>
- </FormItem>
- <div className="school-props clearfix" style={{ 'display': this.state.schoolDis }}>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="院士"
- >
- {getFieldDecorator('aca', {
- initialValue: this.state.aca || 0
- })(
- <InputNumber />
- )}
- <span>人</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="博士生导师"
- >
- {getFieldDecorator('PhDTutor', {
- initialValue: this.state.PhDTutor || 0
- })(
- <InputNumber />
- )}
- <span>人</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="硕士生导师"
- >
- {getFieldDecorator('MSTutor', {
- initialValue: this.state.MSTutor || 0
- })(
- <InputNumber />
- )}
- <span>人</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="其他专家"
- >
- {getFieldDecorator('otherExperts', {
- initialValue: this.state.otherExperts || 0
- })(
- <InputNumber />
- )}
- <span>人</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="国家级重点实验室"
- >
- {getFieldDecorator('StateKeyLab', {
- initialValue: this.state.StateKeyLab || 0
- })(
- <InputNumber />
- )}
- <span>所</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="教育部重点实验室"
- >
- {getFieldDecorator('EduKeyLab', {
- initialValue: this.state.EduKeyLab || 0
- })(
- <InputNumber />
- )}
- <span>所</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="企业共建研究中心"
- >
- {getFieldDecorator('ComCenter', {
- initialValue: this.state.ComCenter || 0
- })(
- <InputNumber />
- )}
- <span>所</span>
- </FormItem>
- <FormItem
- labelCol={{ span: 10 }}
- wrapperCol={{ span: 12 }}
- label="其他研究中心"
- >
- {getFieldDecorator('otherCenter', {
- initialValue: this.state.otherCenter || 0
- })(
- <InputNumber />
- )}
- <span>所</span>
- </FormItem>
- </div>
- <FormItem style={{ 'display': this.state.resDis }}
- {...formItemLayout}
- label="创办时间"
- >
- {getFieldDecorator('resTime', {
- initialValue: this.state.resTime || 0
- })(
- <InputNumber />
- )}
- <span>年</span>
- </FormItem>
- <FormItem
- {...formItemLayout}
- label="LOGO"
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 20 }}
- >
- {getFieldDecorator('avatar')(
- <Avatar name="companyLogo" urlData={this.companyLogoUrl} logoUrl={this.state.logoUrl} />
- )}
- </FormItem>
- <div className="set-explain">
- <p>上传的照片图片格式应为jpg格式,大小在2M以内</p>
- </div>
- <FormItem
- labelCol={{ span: 3 }}
- wrapperCol={{ span: 21 }}
- label="宣传图片"
- >
- {getFieldDecorator('companyLifePic')(
- <PicturesWall
- domId={'company1'}
- fileList={this.companyLifePicUrl}
- lifePhotoList={this.state.companyLifePicList}
- />
- )}
- </FormItem>
- <FormItem wrapperCol={{ span: 12, offset: 3 }}>
- <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
- </FormItem>
- </Form >
- );
- },
- }));
- const Person = React.createClass({
- getInitialState() {
- return {
- loading: false
- };
- },
- spinChange(e) {
- this.setState({
- loading: e
- });
- },
- render() {
- return (
- <Spin spinning={this.state.loading} className='spin-box'>
- <div className="set-person">
- <div className="acc-detail">
- <p className="acc-title">单位资料</p>
- <PersonFrom spinState={this.spinChange} />
- </div>
- </div>
- </Spin>
- )
- }
- });
- export default Person;
|