/*
@author:李霆
@update:2018/05/29
*/
import React from 'react';
import {
Radio,
Icon,
Button,
Input,
Select,
Spin,
message,
DatePicker,
Modal,
Upload,
Form,
Row,
Col,
InputNumber
} from 'antd';
import $ from 'jquery/src/ajax';
import './unit.less';
import {
socialAttribute,
industry,
} from '@/dataDic.js';
import {
splitUrl,
} from '@/tools.js';
const FormItem = Form.Item;
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}
);
}
});
const PicturesWallMore = 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 >= 8 ? null : uploadButton}
);
}
});
const Unit = React.createClass({
getInitialState() {
return {
loading: false,
orgCodeUrl: [],
companyLogoUrl: [],
ProvinceCity:[],
qualiUrl:[]
};
},
loadInformation(record) {
this.setState({
loading:true
})
$.ajax({
method: 'get',
dataType: 'json',
url: globalConfig.context + '/api/user/getOrganizationDetail',
success: function(data) {
let thisData = data.data;
if (!thisData) {
if (data.error && data.error.length) {
message.warning(data.error[0].message);
}
thisData = {};
}
this.setState({
InformationId: thisData.id,
InformationUid: thisData.uid,
identifyName: thisData.identifyName,
listed: thisData.listed,
highTechZone: thisData.highTechZone,
orgCodeUrl: thisData.orgCodeUrl
? splitUrl(thisData.orgCodeUrl, ',', globalConfig.avatarHost + '/upload')
: [],
companyLogoUrl:thisData.companyLogoUrl?thisData.companyLogoUrl.split(','):[],
qualiUrl: thisData.honorPicture
? splitUrl(thisData.honorPicture, ',', globalConfig.avatarHost + '/upload')
: [],
dataInformation: thisData,
//ProvinceCity: ProvinceCityArr[0] != null ? ProvinceCityArr : undefined,
industry: String(thisData.industry) == 'null' ? undefined : String(thisData.industry),
societyTag: thisData.societyTag || undefined,
introduction: thisData.introduction,
postalAddress: thisData.postalAddress,
fixedTel: thisData.fixedTel,
registeredCapital: thisData.registeredCapital,
enterpriseScale: thisData.enterpriseScale,
legalPerson: thisData.legalPerson,
legalPersonIdCard: thisData.legalPersonIdCard,
legalPersonTel: thisData.legalPersonTel,
legalPersonEmail: thisData.legalPersonEmail,
businessScope: thisData.businessScope,
orgCode: thisData.orgCode,
type:thisData.type,
qq:thisData.qq,
email:thisData.email,
authentication:thisData.authentication
});
}.bind(this)
}).always(
function() {
this.setState({
loading: false
});
}.bind(this)
);
},
//图片
getOrgCodeUrl(e) {
this.setState({
orgCodeUrl: e
});
},
getCompanyLogoUrl(e) {
this.setState({
companyLogoUrl: e
});
},
getQualiUrl(e) {
this.setState({
qualiUrl: e
});
},
//基本信息提交
newSubmit(e) {
this.setState({
selectedRowKeys: []
});
let theorgCodeUrl = [];
if (this.state.orgCodeUrl.length) {
let picArr = [];
this.state.orgCodeUrl.map(function(item) {
if (item.response && item.response.data && item.response.data.length) {
picArr.push(item.response.data);
}
});
theorgCodeUrl = picArr.join(',');
}
let thequaliUrl = [];
if (this.state.qualiUrl.length) {
let picArr = [];
this.state.qualiUrl.map(function(item) {
if (item.response && item.response.data && item.response.data.length) {
picArr.push(item.response.data);
}
});
thequaliUrl = picArr.join(',');
}
this.setState({
loading: true
});
$.ajax({
method: 'post',
dataType: 'json',
url: globalConfig.context + '/api/user/updateOrganizationDetail',
data: {
id: this.state.InformationId,
uid: this.state.InformationUid,
societyTag: this.state.societyTag,
identifyName: this.state.identifyName, //单位名称
introduction: this.state.introduction,
unitName: this.state.unitName,
industry: this.state.industry,
postalAddress: this.state.postalAddress,
fixedTel: this.state.fixedTel,
contactsFax: this.state.contactsFax,
registeredCapital: this.state.registeredCapital ? this.state.registeredCapital : 0,
enterpriseScale: this.state.enterpriseScale,
legalPerson: this.state.legalPerson,
legalPersonIdCard: this.state.legalPersonIdCard,
legalPersonTel: this.state.legalPersonTel,
legalPersonEmail: this.state.legalPersonEmail,
highTechZone: this.state.highTechZone,
listed: this.state.listed,
contacts: this.state.contacts,
orgCode: this.state.orgCode,
businessScope: this.state.businessScope,
introduction: this.state.introduction,
// companyLogoUrl: thecompanyLogoUrl.length != 0 ? thecompanyLogoUrl : '',
companyLogoUrl:this.state.companyLogoUrl.length>0?(this.state.companyLogoUrl).join(','):[],
honorPicture: thequaliUrl.length != 0 ? thequaliUrl : '',
orgCodeUrl: theorgCodeUrl.length != 0 ? theorgCodeUrl : '',
auditStatus: this.state.auditStatus,
authentication:this.state.authentication,
type:this.state.type,
qq:this.state.qq,
email:this.state.email
}
}).done(
function(data) {
this.setState({
loading: false
});
if (!data.error.length) {
message.success('保存成功');
this.loadInformation();
} else {
message.warning(data.error[0].message);
}
}.bind(this)
);
},
subFun(){
if(!this.state.identifyName){
message.warning("请填写单位名称")
return;
}
if (!this.state.industry) {
message.warning('请选择行业!');
return false;
}
if (!this.state.societyTag) {
message.warning('请选择社会性质!');
return false;
}
if (isNaN(this.state.registeredCapital)) {
message.warning('注册资本只能输入数字!');
return false;
}
if (!this.state.email) {
message.warning('请填写企业邮箱!');
return false;
}
if (!this.state.qq) {
message.warning('请填写企业QQ!');
return false;
}
if (this.state.companyLogoUrl&&(this.state.companyLogoUrl.length)<1) {
message.warning('请上传企业LOGO.');
return false;
}
if(!this.state.businessScope){
message.warning('请填写业务范围!');
return false;
}
if(!this.state.introduction){
message.warning('请填写企业简介!');
return false;
}
if (this.state.qualiUrl&&(this.state.qualiUrl.length)<1) {
message.warning('请上传资质荣誉照片.');
return false;
}
this.newSubmit()
},
handleOk(){
this.newSubmit();
this.setState({
visible:false
})
},
handleCancel(){
this.setState({
visible:false
})
},
//logo图片获取
getAllImg(imgArr){
this.setState({
companyLogoUrl:imgArr
})
},
componentWillMount() {
this.loadInformation();
},
componentWillReceiveProps(nextProps) {
},
render() {
return (
);
}
});
export default Unit;