/* @author:李霆 @update:2018/05/29 */ 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, lawType } from '@/dataDic.js'; import { splitUrl, getAuthState, getAdviserType, getSocialAttribute } from '@/tools.js'; const FormItem = Form.Item; const monthFormat = 'YYYY/MM'; import Crop from '@/crop/cropBlock'; //图片组件 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:[], lawState: false, adviserUrl: [], positiveIdUrl: [], lawUrl: [], 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, 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') : [], companyLogoUrl:thisData.headPortraitUrl?thisData.headPortraitUrl.split(','):[], 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') : [], lawUrl: thisData.consultantCertificateUrl ? splitUrl(thisData.consultantCertificateUrl, ',', globalConfig.avatarHost + '/upload') : [], data: thisData, lawState: thisData.consultantType=='4'?true:false, 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 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 lawUrls = []; if (this.state.lawUrl.length) { let picArr = []; this.state.lawUrl.map(function(item) { if (item.response && item.response.data && item.response.data.length) { picArr.push(item.response.data); } }); lawUrls = 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 = this.state.companyLogoUrl.length>0?(this.state.companyLogoUrl).join(','):[]; dataList.positiveIdUrl = thecompanyLogoUrl.length != 0 ? thecompanyLogoUrl : ''; dataList.oppositeIdUrl = thecompanyLogoUrls.length != 0 ? thecompanyLogoUrls : ''; } else if (this.state.authenticationState == '1') { dataList.expert = '2'; dataList.typicalCase = values.adviserType == '4' ? values.typicalCase : ''; dataList.workUnit1 = values.adviserType == '4' ? values.workUnit1 : ''; dataList.honer = values.adviserType == '4' ? values.honer : ''; dataList.goodAtIndustry = values.adviserType == '4' ? values.goodAtIndustry : ''; dataList.consultantCertificateUrl = values.adviserType == '4' && lawUrls.length != 0 ? lawUrls : ''; //法律职业资格证 dataList.consultantType = values.adviserType; //顾问类型 dataList.headPortraitUrl = this.state.companyLogoUrl.length>0?(this.state.companyLogoUrl).join(','):[]; 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.companyLogoUrl.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.companyLogoUrl.length)<1) { message.warning(this.state.authenticationState == '1' ? '请上传顾问照片!' : '请上传专家照片'); return; } if(values.adviserType=='4'&&!(this.state.lawUrl.length)){ message.warning('请上传您的律师职业资格证!'); 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 }); }, //顾问选择法律顾问 handleSelectChange(value) { if (value == '4') { this.setState({ lawState: true }); } else { this.setState({ lawState: false }); } }, getHeadPortraitUrl(e) { this.setState({ companyLogoUrl: e }); }, getPositiveIdUrl(e) { this.setState({ positiveIdUrl: e }); }, getOppositeIdUrl(e) { this.setState({ oppositeIdUrl: e }); }, componentWillMount() { this.loadInformation(); }, authenticationChange(e){ this.setState({ authenticationState: e.target.value, }); if(this.state.auditStatus=='3'){ this.loadInformation(); } }, //logo图片获取 getAllImg(imgArr){ this.setState({ companyLogoUrl:imgArr }) }, 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 || undefined })( )} ) : ( {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, rules: [ { required: true, message: '此项为必填项!' } ] })( )}
{(this.state.expert == '0' || this.state.auditStatus == '0' || this.state.expert == null || this.state.auditStatus == '3') && this.state.type != null ? (
{/* 专家认证 */} 顾问认证 {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() : undefined })( )}
) : ( '' )} {this.state.lawState && this.state.authenticationState == '1' ? (
{getFieldDecorator('workUnit1', { rules: [ { required: true, message: '此项为必填项!' } ], initialValue: theData.workUnit1 })()}
{getFieldDecorator('honer', { initialValue: theData.honer })()}
{getFieldDecorator('goodAtIndustry', { initialValue: theData.goodAtIndustry, })( )}
{getFieldDecorator('typicalCase', { initialValue: theData.typicalCase, rules: [ { required: true, message: '此项为必填项!' } ] })( )}
) : ( '' )} {this.state.authenticationState == '1' || this.state.authenticationState == '0' ? (
* {this.state.authenticationState == '0' ? '专家照片' : '顾问照片'} } >

建议:图片要清晰。

{this.state.lawState && this.state.authenticationState == '1' ? ( * 律师职业资格证 } > { this.setState({ lawUrl: e }); }} pictureUrl={this.state.lawUrl} />

建议:图片要清晰。

) : ( '' )}
* 身份证正面 } >

建议:图片要清晰。

* 身份证反面 } >

建议:图片要清晰。

) : ( '' )}
) : (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)} {theData.consultantType == '4' ? (
{theData.workUnit1}
{theData.honer}
{theData.goodAtIndustry}
{theData.typicalCase}
) : ( '' )}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true }); }} /> { this.setState({ previewVisible: false }); }} > {theData.consultantType == '4' && ( { 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);