import React from 'react'; import $ from 'jquery/src/ajax'; import { Modal, message, Spin, Upload, Input, Button, Form, Icon } from 'antd'; import { getAdviserType,getIndustry,getSocialAttribute,splitUrl } from '@/tools.js'; import { getProvince } from '@/NewDicProvinceList'; const AuthDetail = Form.create()(React.createClass({ getInitialState() { return { visible: false, loading: false, pictureUrl: [], headPortraitUrl: [], adviserUrl:[], positiveIdUrl: [], oppositeIdUrl: [], lawUrl:[], }; }, loadData(id) { this.setState({ loading: true }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + '/api/admin/getUserIdentityByUid' , data: { uid: id }, success: function (data) { let thisData = data.data; if (!thisData) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; thisData = {}; }; let provice; provice=getProvince(thisData.province,thisData.city,thisData.area); this.setState({ id:thisData.id, data: thisData, ProvinceCity:provice, 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') : [], lawUrl:thisData.consultantCertificateUrl ? splitUrl(thisData.consultantCertificateUrl, ',', globalConfig.avatarHost + '/upload') : [], }); }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); }, cancelFun(){ this.props.closeDesc(); }, //审核通过/拒绝 updateFun(index){ this.setState({ loading:true }); $.ajax({ method: "post", dataType: "JSON", crossDomain: false, url: globalConfig.context + '/api/admin/auditing', data: { id: this.state.id, auditStatus:index, auditInfo:this.state.refuseValue } }).done(function (data) { if (!data.error.length) { message.success('操作成功!'); this.setState({ loading: false, }); this.props.handOk() } else { message.warning(data.error[0].message); }; }.bind(this)); }, beforeUpload(file) { const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg'; if (!isJPG) { message.error('只能上传图片文件!'); return isJPG; } const isLt2M = file.size / 1024 / 1024 < 10; if (!isLt2M) { message.error('图片大小不能超过 10MB!'); return isLt2M; } return isJPG && isLt2M; }, //上传图片 updateConsultantFun(){ this.setState({ loading:true }); $.ajax({ method: "get", dataType: "JSON", crossDomain: false, url: globalConfig.context + '/api/admin/updatePictureUrl', data: { url:this.state.consultantFileData, uid:this.props.data.uid, } }).done(function (data) { if (!data.error.length) { message.success('操作成功!'); this.setState({ loading: false, consultantFileData: '', }); // this.props.handOk() } else { message.warning(data.error[0].message); }; }.bind(this)); }, //审核拒绝 refuse(){ this.setState({ refuseValue:'', refuseVisible:true }) }, refuseOk(){ if(!this.state.refuseValue){ message.warning('请填写拒绝原因。') return; } this.setState({ refuseVisible:false }) this.updateFun(3) }, refuseCancel(){ this.setState({ refuseValue:'', refuseVisible:false }) }, componentWillMount() { if (this.props.data.id) { this.loadData(this.props.data.uid); } else { this.state.data = {}; }; }, componentWillReceiveProps(nextProps) { if (!this.props.visible && nextProps.visible) { if (nextProps.data.id) { this.loadData(nextProps.data.uid); } else { this.state.data = {}; }; this.props.form.resetFields(); }; }, render() { const theData = this.state.data || {}; const FormItem = Form.Item const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 12 }, }; const uploadButton = (
点击上传
); return (
{theData.identifyName} {getIndustry(theData.industry)} {getSocialAttribute(theData.societyTag)} {theData.sex} {theData.dateOfBirthYear?theData.dateOfBirthYear + '/' + theData.dateOfBirthMonth:''} {theData.idNumber} {this.state.ProvinceCity} {theData.postalAddress} {theData.contactMobile} {theData.fixedTel} {theData.qq} {theData.email}
{theData.introduction}

{theData.expert=='1'?'专家认证':'顾问认证'}

{theData.expert=='1'?
{theData.graduateSchool} {theData.majorCategory} {theData.qualification} {theData.workUnit} {theData.professionalTitle}
{ this.setState({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} > { this.setState({ previewVisible: false }) }}>
:
{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({ previewImage: file.url || file.thumbUrl, previewVisible: true, }); }} onChange={(info)=>{ if(info.file.status) { let fileList = info.fileList; this.setState({ headPortraitUrl: fileList, }); if (info.file.status === 'done') { this.setState({ consultantFileData: info.file.response.data, }); } } }}> {this.state.headPortraitUrl.length === 0 ? uploadButton : null} { 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.props.examineState&& }
{this.setState({refuseValue:e.target.value})}}/>
) } })); export default AuthDetail;