/* @author:李霆 @update:2018/05/29 @descript:复制粘贴,拿起来就是干!! */ import React from 'react'; import { Radio, Icon, Button, Cascader, Input, Select, Spin, message, DatePicker, Modal, Upload, Form, Row, Col } from 'antd'; import $ from 'jquery/src/ajax'; import moment from 'moment'; import './unit.less'; import { areaSelect } from '@/NewDicProvinceList'; import { socialAttribute, industry,adviserType } from '@/dataDic.js'; import { splitUrl,getAuthState,getAdviserType ,getSocialAttribute } from '@/tools.js'; const FormItem = Form.Item; const monthFormat = 'YYYY/MM'; //图片组件 const PicturesWall = React.createClass({ getInitialState() { return { previewVisible: false, 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) { this.state.fileList = nextProps.pictureUrl; }, render() { const { previewVisible, previewImage, fileList } = this.state; const uploadButton = (
点击上传
); return (
{fileList.length >= 1 ? null : uploadButton} example
); } }); const Expert = React.createClass({ getInitialState() { return { loading: false, orgCodeUrl: [], companyLogoUrl: [], headPortraitUrl: [], adviserUrl:[], positiveIdUrl: [], oppositeIdUrl: [], authenticationState:undefined }; }, loadInformation(record) { this.setState({ loading: true }); $.ajax({ method: 'get', dataType: 'json', crossDomain: false, url: globalConfig.context + '/api/user/getUserDetail', success: function(data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); } thisData = {}; } let ProvinceCityArr = []; let ProvinceS = thisData.province; //getprovince let citys = thisData.city; let Areas = thisData.area; ProvinceCityArr.push(ProvinceS, citys, Areas); let month = thisData.dateOfBirthYear ? thisData.dateOfBirthYear + '/' + thisData.dateOfBirthMonth : undefined; let authenticationState=''; if(thisData.auditStatus=='3'){ authenticationState=(thisData.expert-1).toString() } this.setState({ InformationId: thisData.id, InformationUid: thisData.uid, authentication:thisData.authentication, authenticationState:authenticationState, dateOfBirthYear:thisData.dateOfBirthYear, dateOfBirthMonth:thisData.dateOfBirthMonth, type:thisData.type, //0-个人认证 1-企业认证 expert:thisData.expert, //认证类型 0-未认证专家顾问 1-专家认证 2-顾问认证 authMessage:thisData.auditInfo, auditStatus:thisData.auditStatus||'0', //认证状态 0-未认证 1-认证审核中 2-已认证 3-认证失败 headPortraitUrl: thisData.headPortraitUrl //专家照片 ? splitUrl(thisData.headPortraitUrl, ',', globalConfig.avatarHost + '/upload') : [], adviserUrl: thisData.adviserUrl //顾问照片 ? splitUrl(thisData.adviserUrl, ',', globalConfig.avatarHost + '/upload') : [], positiveIdUrl: thisData.positiveIdUrl ? splitUrl(thisData.positiveIdUrl, ',', globalConfig.avatarHost + '/upload') : [], oppositeIdUrl: thisData.oppositeIdUrl ? splitUrl(thisData.oppositeIdUrl, ',', globalConfig.avatarHost + '/upload') : [], data: thisData, ProvinceCity: ProvinceCityArr[0] != null ? ProvinceCityArr : undefined, yearMonth: month, workUnit:thisData.workUnit||'', graduateSchool: thisData.graduateSchool||'', professionalTitle: thisData.professionalTitle||'', qualification: thisData.qualification||'', majorCategory: thisData.majorCategory||'', adviserType: thisData.consultantType||'', headPortraitUrlCopy: thisData.headPortraitUrl, adviserUrlCopy: thisData.adviserUrl, positiveIdUrlCopy: thisData.positiveIdUrl, oppositeIdUrlCopy:thisData.oppositeIdUrl }); }.bind(this) }).always( function() { this.setState({ loading: false }); }.bind(this) ); }, //图片 getOrgCodeUrl(e) { this.setState({ orgCodeUrl: e }); }, getCompanyLogoUrl(e) { this.setState({ companyLogoUrl: e }); }, //基本信息提交 newSubmit(values={}){ this.state.data = []; let theorgCodeUrl = []; if (this.state.headPortraitUrl.length) { let picArr = []; this.state.headPortraitUrl.map(function(item) { if (item.response && item.response.data && item.response.data.length) { picArr.push(item.response.data); } }); theorgCodeUrl = picArr.join(','); } let thecompanyLogoUrl = []; if (this.state.positiveIdUrl.length) { let picArr = []; this.state.positiveIdUrl.map(function(item) { if (item.response && item.response.data && item.response.data.length) { picArr.push(item.response.data); } }); thecompanyLogoUrl = picArr.join(','); } let thecompanyLogoUrls = []; if (this.state.oppositeIdUrl.length) { let picArr = []; this.state.oppositeIdUrl.map(function(item) { if (item.response && item.response.data && item.response.data.length) { picArr.push(item.response.data); } }); thecompanyLogoUrls = picArr.join(','); } let years = []; years = this.state.yearList!=undefined?(this.state.yearList).split('/'):[this.state.dateOfBirthYear,this.state.dateOfBirthMonth]; this.setState({ loading: true }); let dataList={}; dataList={ id: this.state.InformationId, uid: this.state.InformationUid, type:this.state.type, societyTag: values.societyTag, identifyName: values.identifyName, industry: values.industry, dateOfBirthYear: years[0]||'', //出生年 dateOfBirthMonth: years[1]||'', //出生月 province: (values.ProvinceCity)[0], //省- city:(values.ProvinceCity)[1], //市 area:(values.ProvinceCity)[2], //区 sex: values.sex, expert:'0', authentication:this.state.authentication, // mobile: values.mobile, fixedTel: values.fixedTel, qq: values.qq, idNumber: values.idNumber, email: values.email, postalAddress: values.postalAddress, introduction: values.introduction, auditStatus:this.state.auditStatus||'0', } if(this.state.authenticationState=='0'){ dataList.expert='1', dataList.workUnit=values.workUnit; dataList.professionalTitle=values.professionalTitle; dataList.qualification=values.qualification; dataList.majorCategory=values.majorCategory; dataList.graduateSchool=values.graduateSchool; dataList.headPortraitUrl=theorgCodeUrl.length != 0 ? theorgCodeUrl : ''; dataList.positiveIdUrl=thecompanyLogoUrl.length != 0 ? thecompanyLogoUrl : ''; dataList.oppositeIdUrl=thecompanyLogoUrls.length != 0 ? thecompanyLogoUrls : ''; }else if(this.state.authenticationState=='1'){ dataList.expert='2'; dataList.consultantType=values.adviserType;//顾问类型 dataList.headPortraitUrl=theorgCodeUrl.length != 0 ? theorgCodeUrl : ''; //顾问照片 dataList.positiveIdUrl=thecompanyLogoUrl.length != 0 ? thecompanyLogoUrl : ''; dataList.oppositeIdUrl=thecompanyLogoUrls.length != 0 ? thecompanyLogoUrls : ''; } $.ajax({ method: 'post', dataType: 'json', url: globalConfig.context + '/api/user/updateUserDetail', data:dataList, }).done( function(data) { this.setState({ loading: false }); if (!data.error.length) { //认证状态判定说明 message.success((this.state.auditStatus=='0'||this.state.auditStatus=='3')&&(this.state.headPortraitUrl).length?'认证审核提交成功,请耐心等待。':'保存成功') this.loadInformation(); } else { message.warning(data.error[0].message); } }.bind(this) ); }, subFun(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if(!err){ if(this.state.authenticationState=='0'||this.state.authenticationState=='1'){ if(!(this.state.headPortraitUrl.length)){ message.warning(this.state.authenticationState=='1'?'请上传顾问照片!':'请上传专家照片'); return; } if(!(this.state.oppositeIdUrl.length)||!(this.state.positiveIdUrl.length)){ message.warning('请上传您的身份证正反照片!'); return; } this.setState({ visible: true, values :values }); }else{ this.newSubmit(values) } } }) }, handleOk() { this.newSubmit(this.state.values); this.setState({ visible: false }); }, handleCancel() { this.setState({ visible: false }); }, getHeadPortraitUrl(e) { this.setState({ headPortraitUrl: e }); }, getPositiveIdUrl(e) { this.setState({ positiveIdUrl: e }); }, getOppositeIdUrl(e) { this.setState({ oppositeIdUrl: e }); }, componentWillMount() { this.loadInformation(); }, componentWillReceiveProps(nextProps) {}, render() { const { getFieldDecorator } = this.props.form; const { MonthPicker } = DatePicker; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 14 } }; const theData = this.state.data || []; return (

个人资料

{this.state.auditStatus=='0'? {getFieldDecorator('identifyName', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.identifyName })()} : {theData.identifyName} } {theData.mobile} {this.state.auditStatus=='0'? {getFieldDecorator('societyTag', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.societyTag })( )} : {getSocialAttribute(theData.societyTag)} } {getFieldDecorator('industry', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.industry?theData.industry.toString():undefined })( )} {getFieldDecorator('sex', { initialValue: theData.sex })( )} { this.setState({ yearMonth: time,yearList:times }); }} /> {getFieldDecorator('idNumber', { initialValue: theData.idNumber })()}
{getFieldDecorator('ProvinceCity', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: this.state.ProvinceCity })()} {getFieldDecorator('postalAddress', { initialValue: theData.postalAddress })()} {getFieldDecorator('fixedTel', { initialValue: theData.fixedTel })()} {getFieldDecorator('qq', { initialValue: theData.qq })()} {getFieldDecorator('email', { initialValue: theData.email })()}
{getFieldDecorator('introduction', { initialValue: theData.introduction })()}
{(this.state.expert=='0'||this.state.auditStatus=='0'||this.state.expert==null||this.state.auditStatus=='3')&&this.state.type!=null?
{this.setState({ authenticationState:e.target.value })}}> 专家认证 顾问认证 {this.state.auditStatus=='3'?"(认证失败:"+this.state.authMessage+')':''}
{(this.state.authenticationState=='0'&&(this.state.auditStatus=='0'||this.state.auditStatus=='3'))?
{getFieldDecorator('graduateSchool', { initialValue: theData.graduateSchool, rules: [ { required: true, message: '此项为必填项!' } ], })()} {getFieldDecorator('majorCategory', { initialValue: theData.majorCategory, rules: [ { required: true, message: '此项为必填项!' } ], })()} {getFieldDecorator('qualification', { initialValue: theData.qualification, rules: [ { required: true, message: '此项为必填项!' } ], })()} {getFieldDecorator('workUnit', { initialValue: theData.workUnit, rules: [ { required: true, message: '此项为必填项!' } ], })()} {getFieldDecorator('professionalTitle', { initialValue: theData.professionalTitle, rules: [ { required: true, message: '此项为必填项!' } ], })()}
:this.state.authenticationState=='1'?
{getFieldDecorator('adviserType', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: (theData.consultantType||theData.consultantType=='0')&&theData.consultantType.toString() })( )}
:''} {this.state.authenticationState=='1'||this.state.authenticationState=='0'?
*{this.state.authenticationState=='0'?'专家照片':'顾问照片'} } >

建议:图片要清晰1。

*身份证正面 } >

建议:图片要清晰。

*身份证反面 } >

建议:图片要清晰。

:''}
:(this.state.auditStatus=='2'||this.state.auditStatus=='1')&&this.state.expert=='1'?
专家认证({getAuthState(this.state.auditStatus)})
{theData.graduateSchool} {theData.majorCategory} {theData.qualification} {theData.workUnit} {theData.professionalTitle}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
:(this.state.auditStatus=='2'||this.state.auditStatus=='1')&&this.state.expert=='2'?
顾问认证({getAuthState(this.state.auditStatus)})
{getAdviserType(theData.consultantType)}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
:''}
{this.state.authenticationState=='0'&&

是否申请专家认证?注意:认证成功后,您的信息将在本平台展示。

} {this.state.authenticationState=='1'&&

是否申请顾问认证?注意:认证成功后,您的信息将在本平台展示。

}
); } }); export default Form.create()(Expert);