import React, { Component } from 'react';
import { connect } from 'dva';
import moment from 'moment';
import {
Form,
Input,
Select,
Button,
Upload,
Icon,
Modal,
Alert,
DatePicker,
InputNumber,
message
} from 'antd';
import style from 'styled-components';
import * as ajax from '../../../services/api';
import PFromUpload from '../../../components/Pro/PFromUpload';
// import styles from './Company.less';
import './Company.less';
import PSelect from '../../../components/Pro/PSelect';
const FormItem = Form.Item;
const { Option } = Select;
const InputGroup = Input.Group;
const { confirm } = Modal;
const { TextArea } = Input;
const dateFormat = 'YYYY-MM-DD';
@connect(state => ({
profile: state.profile,
currentUser: state.user.currentUser.userName,
companyInfo: state.global.companyInfo
}))
@Form.create()
/** 企业认证信息 */
export default class Authentication extends Component {
constructor(props, context) {
super(props, context);
this.state = {
selectedIdCardType: '',
status: '',
conf_securityLicenseUrl: '', //行业资质 图片上传
// "comCerUrl":'',
// "conf_securityLicenseUrl":"",
conf_armedLevel: [], //武装押运守护等级
conf_association: [], //所属行业保安协会
conf_manpowerLevel: [], //人力防范等级
conf_riskLevel: [], //风险评估等级
conf_safeRange: [], //安全范围
conf_safeTechLevel: [], //安全技术防范等级
message: '',
loading: false,
btnVisible: true,
getting: false, //获取验证码,判断是否正在获取中,true,正在获取中
countDown: 60, //倒计时60秒
gettingNoPhone: false, //法人手机号未验证时
countDownNoPhone: 60, //法人手机号未验证时倒计时
certificationData: {
legalRepName: '',
nationality: '',
idCardNo: '',
certificationType: '', //企业
legalRepPhone: '',
idCardType: '',
regAmount: '',
fixedAssets: '',
annualTurnover: '',
annualProfitTax: '',
comCerType: '',
comCerUrl: '',
comCerNo: '',
authStatus: '0' //认证状态
},
qualificationsData: {
conf_armedLevel: [], //武装押运守护等级
conf_association: [], //所属行业保安协会
conf_manpowerLevel: [], //人力防范等级
conf_riskLevel: [], //风险评估等级
conf_safeRange: [], //安全范围
conf_safeTechLevel: [], //安全技术防范等级
conf_securityLicenseNum: '', //保安服务许可证号
conf_securityLicenseUrl: '' //保安服务许可证
},
idCardType: [], //身份证选择
nationality: [], //国籍
certificationType: [], //企业
visibleCode: false, //法人手机号存在时验证码弹窗
visibleNoPhoneCode: false, //法人手机号不存在时验证码弹窗
phoneHas: '123',
// phoneLegalRepCode:'',//法人手机验证码
modalLegPerson: true,
modalFooter: true, //是否显示modal的footer
noPhoneContent: '', //法人手机号为空时是否展示下一个弹窗
hasPnone: '',
modalFooterNoPhone: true, //法人手机号为空时是否显示modal的footer
phone_yin: '', //手机号中间隐藏四位
color_abc: true, //验证码下的P标签是否出现
statusBianDisabled: false,
showIndustry: false, //隐藏特殊资质信息;10-11,冠男取消隐藏
institutionType: '', //企业基础信息,企业机构类型
specialArray: [],
administratorRelative: {
administrator: '', // 管理员名字
phoneValue: '', // 管理员电话
openValidAdminModal: false,
phoneValueHiddenMiddle: '', // 带*号的管理员手机号
hasValidCode: false, // 管理员手机验证码
isValidCode: false, // 管理员手机验证码是否正确
countDownNoPhone: 60 // 管理员手机验证码倒计时
}
};
}
/****
* 特殊字段
*/
showSpecialFields = () => {
const arr = this.state.specialArray.map((value, index) => {
return (
{this.renderMap(
value.fieldType,
value.fieldName,
value.fieldCode,
parseInt(value.isRequired, 10),
value.fieldValue,
value.maxLength,
value.fieldOptions,
value.scriptFunction,
value.isEdit,
)}
);
});
return arr;
};
renderMap = (
fieldType,
fieldName,
fieldCode,
isRequired,
fieldValue,
maxLength,
fieldOptions,
scriptFunction,
isEdit,
) => {
const formItemLayout = {
labelCol: {
xs: {
span: 24
},
sm: {
span: 7
}
},
wrapperCol: {
xs: {
span: 24
},
sm: {
span: 12
},
md: {
span: 10
}
}
};
const { getFieldDecorator } = this.props.form;
if (fieldType === '1') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
required: isRequired,
message: `请输入${fieldName}`
}
]
})(
)}
);
} else if (fieldType === '2') {
let max;
if (maxLength) {
max = Number(1 + new Array(parseInt(maxLength, 10) + 1).join('0')) - 1;
} else {
max = 999999;
}
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
required: isRequired,
message: `请输入${fieldName}`
}
]
})(
)}
);
} else if (fieldType === '3') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue ? moment(fieldValue, dateFormat) : null,
rules: [
{
required: isRequired,
message: `请选择${fieldName}`
},
{
validator: (rule, value, callback) => {
const moment = require('moment');
scriptFunction
? eval(`${scriptFunction}`)(rule, value, callback)
: callback();
}
}
]
})(
)}
);
} else if (fieldType === '4') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
required: isRequired,
message: `请选择${fieldName}`
}
]
})(
)}
);
} else if (fieldType === '5') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
required: isRequired,
message: `请选择${fieldName}`
}
]
})(
)}
);
} else if (fieldType === '8') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
required: isRequired,
message: `请选择${fieldName}`
}
]
})()}
每张不超过:8M,格式为:jpg,jpeg,png
);
} else if (fieldType === '9') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue ? moment(fieldValue, dateFormat) : null,
rules: [
{
required: isRequired,
message: `请选择${fieldName}`
}
]
})(
)}
);
} else if (fieldType === '10') {
return (
{getFieldDecorator(`${fieldCode}`, {
initialValue: fieldValue || '',
rules: [
{
// required: isRequired, message: `请选择${fieldName}`,
required: isRequired,
message: `请输入${fieldName}`
}
]
})(
)}
);
}
};
/** 组件初始化请求 */
initFun = () => {
//获取是否显示提交按钮
// ajax.getCertificationData({}).then(data => {
// console.log("公司状态公司状态公司状态", data);
// if (data.data) {
// this.setState({
// status: data.data.authStatus
// });
// if (this.state.status === "0") {
// //未认证
// this.state.btnVisible = true;
// } else if (this.state.status === "1") {
// //认证中
// this.state.btnVisible = false;
// } else if (this.state.status === "2") {
// //已认证
// this.state.btnVisible = false;
// } else if (this.state.status === "3") {
// //认证不通过
// this.state.btnVisible = true;
// } else if (this.state.status === "") {
// //未认证
// this.state.btnVisible = true;
// }
// }
// });
//获取基本信息
ajax.getCertificationData({}).then(data => {
//判断获取数据是否为空
if (data.data) {
this.setState(
{
certificationData: data.data,
phone_yin: data.data.legalRepPhone,
// statusBianDisabled: data.data.authStatus === "0" ? false : data.data.authStatus === "" ? false : true,
institutionType: data.data.institutionType
},
() => {
this.props.form.setFieldsValue({
comCerUrl: data.data.comCerUrl
});
//企业信息-认证申请-获得企业机构特殊信息
ajax
.enterpriseCompanyComIndustryGetIndustryConfigByComId({
institutionType: this.state.institutionType
})
.then(
res => {
if (res.data && res.data.length) {
const tmp = res.data.map((val, i) => {
if (val.fieldType && val.fieldType === '4') {
val.fieldOptions = val.fieldOptions
? val.fieldOptions.split(',')
: [];
}
if (val.fieldType && val.fieldType === '5') {
val.fieldOptions = val.fieldOptions
? val.fieldOptions.split(',')
: [];
val.fieldValue = val.fieldValue
? val.fieldValue.split(',')
: [];
}
return Object.assign({}, val, {
key: i + 1
});
});
this.setState({
specialArray: tmp,
showIndustry: true
});
}
},
err => {
console.log('企业信息-认证申请-获得企业机构特殊信息', err);
}
);
}
);
}
});
//获取行业特殊信息
// ajax.enterpriseCompanyGetComIndustryinfo({}).then(data => {
// console.log('认证申请行业资质data:', data);
// if (data.data) {
// const tmp = data.data;
// const qualificationsData = { ...this.state.qualificationsData };
// tmp.map(val => {
// if (val.fieldCode === 'conf_armedLevel') {
// qualificationsData.conf_armedLevel = val.fieldValue;
// } else if (val.fieldCode === 'conf_manpowerLevel') {
// qualificationsData.conf_manpowerLevel = val.fieldValue;
// } else if (val.fieldCode === 'conf_riskLevel') {
// qualificationsData.conf_riskLevel = val.fieldValue;
// } else if (val.fieldCode === 'conf_safeTechLevel') {
// qualificationsData.conf_safeTechLevel = val.fieldValue;
// } else if (val.fieldCode === 'conf_securityLicenseNum') {
// qualificationsData.conf_securityLicenseNum = val.fieldValue;
// } else if (val.fieldCode === 'conf_securityLicenseUrl') {
// qualificationsData.conf_securityLicenseUrl = val.fieldValue;
// } else if (val.fieldCode === 'conf_association') {
// if (val.fieldValue !== '') {
// qualificationsData.conf_association = val.fieldValue.split(',');
// }
// } else if (val.fieldCode === 'conf_safeRange') {
// if (val.fieldValue !== '') {
// qualificationsData.conf_safeRange = val.fieldValue.split(',');
// }
// }
// return '1';
// });
// console.log('获取的企业特殊信息数据:', qualificationsData);
// this.setState({ qualificationsData }, () => {
// this.props.form.setFieldsValue({
// conf_securityLicenseUrl: qualificationsData.conf_securityLicenseUrl
// });
// });
// }
// });
};
initFunMount = () => {
//字典下拉
ajax
.publicCommonDictGetDictByCodeTypes({
codeTypes:
'idCardType,nationality,comCerType,conf_armedLevel,conf_association,conf_manpowerLevel,conf_riskLevel,conf_safeRange,conf_safeTechLevel'
})
.then(data => {
//判断获取数据是否为空
if (data.data) {
this.setState(
{
idCardType: data.data.idCardType, //身份
nationality: data.data.nationality, //国籍
certificationType: data.data.comCerType, //营业证件选择
conf_armedLevel: data.data.conf_armedLevel, //武装押运守护等级
conf_association: data.data.conf_association, //所属行业保安协会
conf_manpowerLevel: data.data.conf_manpowerLevel, //人力防范等级
conf_riskLevel: data.data.conf_riskLevel, //风险评估等级
conf_safeRange: data.data.conf_safeRange, //安全范围
conf_safeTechLevel: data.data.conf_safeTechLevel //安全技术防范等级
},
() => {
this.initFun();
}
);
}
});
};
componentDidMount() {
this.initFunMount();
this.getComAdmin();
}
componentWillMount() { }
//法人手机号存在时验证码弹窗
showCodeModal = () => {
// const { form } = this.props;
// form.setFieldsValue(
// { codeOne: "" },
// { codeTwo: "" },
// { legalRepPhone_two: "" }
// );
if (
this.state.certificationData.legalRepPhone !== '' &&
this.state.certificationData.legalRepPhone !== undefined
) {
this.setState({
visibleCode: true,
hasPnone: '123'
});
}
};
//法人手机号不存在时验证码弹窗
showCodeModalNoPhone = () => {
const { form } = this.props;
form.setFieldsValue({ legalRepNoPhone: '' }, { legalRepNoPhoneCode: '' });
this.setState({
visibleNoPhoneCode: true
});
};
handleCodeOk = () => {
if (this.state.phoneHas !== '') {
const { form } = this.props;
const one_val = form.getFieldValue('codeOne');
if (one_val === '' || one_val === undefined) {
if (this.state.color_abc) {
document.getElementById('code_p1').style.display = 'block';
document.getElementById('code_p1').innerHTML = '验证码不能为空';
document.getElementById('code_a1').classList.add('abc_color');
}
} else {
if (/^[0-9]{4,6}$/.test(one_val)) {
ajax
.enterpriseComAuthInfoCheckLegalAuthCode({
phone: this.state.certificationData.legalRepPhone,
code: one_val
})
.then(
data => {
// alert('发送成功'+data.msg);
clearInterval(this.countDownTimeId);
document.getElementById('code_p1').style.display = 'none';
document.getElementById('code_p1').innerHTML = '';
document
.getElementById('code_a1')
.classList.remove('abc_color');
if (data.retType === '0') {
this.setState({
phoneHas: '',
getting: false,
countDown: 60
});
document.getElementById('code_a3').value = '';
} else {
document.getElementById('code_p1').style.display = 'block';
document.getElementById('code_p1').innerHTML = '验证码错误';
document.getElementById('code_a1').classList.add('abc_color');
}
},
err => {
document.getElementById('code_p1').style.display = 'block';
document.getElementById('code_p1').innerHTML = '验证码不匹配';
document.getElementById('code_a1').classList.add('abc_color');
}
);
}
}
} else {
const { form } = this.props;
const two_val = form.getFieldValue('legalRepPhone_two');
const two_code = form.getFieldValue('codeTwo1');
if (two_val === '' || two_val === undefined) {
document.getElementById('code_p2').style.display = 'block';
document.getElementById('code_p2').innerHTML = '手机号码不能为空';
document.getElementById('code_a2').classList.add('abc_color');
} else if (two_code === '' || two_code === undefined) {
document.getElementById('code_p3').style.display = 'block';
document.getElementById('code_p3').innerHTML = '验证码不能为空';
document.getElementById('code_a3').classList.add('abc_color');
} else if (/^[0-9]{4,6}$/.test(two_code)) {
ajax
.enterpriseComAuthInfoCheckLegalAuthCode({
phone: two_val,
code: two_code
})
.then(
(res) => {
console.log(res)
if(res.retType==='0'){
clearInterval(this.countDownTimeId);
document.getElementById('code_p2').style.display = 'none';
document.getElementById('code_p2').innerHTML = '';
document.getElementById('code_a2').classList.remove('abc_color');
document.getElementById('code_a2').value = '';
document.getElementById('code_p3').style.display = 'none';
document.getElementById('code_p3').innerHTML = '';
document.getElementById('code_a3').classList.remove('abc_color');
document.getElementById('code_a3').value = '';
this.setState({
phoneHas: '123',
getting: false,
countDown: 60,
modalLegPerson: false,
certificationData: {
legalRepPhone: two_val
},
modalFooter: false,
phone_yin: two_val
});
ajax.updateComLegalRepPhone({legalRepPhone: two_val}).then(result => {
ajax.getCertificationData({}).then(data => {
//判断获取数据是否为空
if (data.data) {
this.setState({
certificationData: data.data,
phone_yin: data.data.legalRepPhone
});
}
});
});
}
},
err => {
document.getElementById('code_p3').style.display = 'block';
document.getElementById('code_p3').innerHTML = err.msg;
document.getElementById('code_a3').classList.add('abc_color');
}
);
}
}
};
codeChange = () => {
document.getElementById('code_p1').style.display = 'none';
document.getElementById('code_p1').innerHTML = '';
document.getElementById('code_a1').classList.remove('abc_color');
this.setState({
color_abc: false
});
};
codeChangeOne = () => {
document.getElementById('code_p2').style.display = 'none';
document.getElementById('code_p2').innerHTML = '';
document.getElementById('code_a2').classList.remove('abc_color');
};
codeChangeTwo = () => {
document.getElementById('code_p3').style.display = 'none';
document.getElementById('code_p3').innerHTML = '';
document.getElementById('code_a3').classList.remove('abc_color');
};
codeChangeThree = () => {
document.getElementById('code_p4').style.display = 'none';
document.getElementById('code_p4').innerHTML = '';
document.getElementById('code_a4').classList.remove('abc_color');
};
codeChangeFour = () => {
document.getElementById('code_p5').style.display = 'none';
document.getElementById('code_p5').innerHTML = '';
document.getElementById('code_a5').classList.remove('abc_color');
};
//法人手机号为空时
handleNoPhoneCodeOk = () => {
const { form } = this.props;
const phone_val = form.getFieldValue('legalRepNoPhone');
const code_val = form.getFieldValue('legalRepNoPhoneCode');
if (phone_val === '' || phone_val === undefined) {
document.getElementById('code_p4').style.display = 'block';
document.getElementById('code_p4').innerHTML = '手机号码不能为空';
document.getElementById('code_a4').classList.add('abc_color');
} else if (code_val === '' || code_val === undefined) {
document.getElementById('code_p5').style.display = 'block';
document.getElementById('code_p5').innerHTML = '验证码不能为空';
document.getElementById('code_a5').classList.add('abc_color');
} else if (
/^[0-9]{4,6}$/.test(code_val) &&
/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[7]))\d{8}$/.test(phone_val)
) {
ajax
.enterpriseComAuthInfoCheckLegalAuthCode({
phone: phone_val,
code: code_val
})
.then(
() => {
clearInterval(this.countDownTimeIdNoPhone);
document.getElementById('code_p4').style.display = 'none';
document.getElementById('code_p4').innerHTML = '';
document.getElementById('code_a4').classList.remove('abc_color');
document.getElementById('code_a4').value = '';
document.getElementById('code_p5').style.display = 'none';
document.getElementById('code_p5').innerHTML = '';
document.getElementById('code_a5').classList.remove('abc_color');
document.getElementById('code_a5').value = '';
this.setState({
gettingNoPhone: false,
countDownNoPhone: 60,
noPhoneContent: '123',
modalFooterNoPhone: false,
phone_yin: phone_val
});
ajax.getCertificationData({}).then(data => {
//判断获取数据是否为空
if (data.data) {
this.setState({
certificationData: data.data,
phone_yin: data.data.legalRepPhone
});
}
});
},
() => {
document.getElementById('code_p5').style.display = 'block';
document.getElementById('code_p5').innerHTML = '验证码输入错误';
document.getElementById('code_a5').classList.add('abc_color');
}
);
}
};
// 获取验证码
onGetCode = () => {
if (this.state.phoneHas !== '') {
ajax
.enterpriseCompanySendLegalAuthCode({
phone: this.state.certificationData.legalRepPhone
})
.then(
data => {
console.log('法人手机验证码:' + data);
},
err => {
console.log('获取法人手机验证码err', err);
}
);
this.setState({
getting: true
});
} else {
const { form } = this.props;
const two_val = form.getFieldValue('legalRepPhone_two');
if (
two_val &&
/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[6,7,9]))\d{8}$/.test(
two_val
)
) {
ajax.enterpriseCompanySendLegalAuthCode({ phone: two_val }).then(
data => {
this.setState({
getting: true
});
},
err => {
console.log('获取法人手机验证码err', err);
}
);
}
}
};
// 法人手机号为空时获取验证码
onGetCodeNoPhone = () => {
const { form } = this.props;
const sd_val = form.getFieldValue('legalRepNoPhone');
if (
sd_val === '' ||
!/^((1[3,5,8][0-9])|(14[5,7])|(17[0,6,7,8])|(19[6,7,9]))\d{8}$/.test(
sd_val
)
) {
message.error('法人手机号不能为空或手机号码格式不正确');
} else {
ajax.enterpriseCompanySendLegalAuthCode({ phone: sd_val }).then(
data => {
console.log('法人手机验证码:' + data);
},
err => {
console.log('获取法人手机验证码err', err);
}
);
this.setState({
gettingNoPhone: true
});
}
};
handleCodeCancel = () => {
clearInterval(this.countDownTimeId);
this.setState({
visibleCode: false,
modalLegPerson: true,
phoneHas: '123',
getting: false,
countDown: 60,
modalFooter: true,
color_abc: true
});
if(document.getElementById('code_a1')) {
document.getElementById('code_a1').value = '';
document.getElementById('code_a1').classList.remove('abc_color');
}
if(document.getElementById('code_p1')) {
document.getElementById('code_p1').innerHTML = '';
}
const { form } = this.props;
form.setFieldsValue({ codeOne: '123456' });
};
//法人手机号为空时点击取消
handleNoPhoneCodeCancel = () => {
clearInterval(this.countDownTimeIdNoPhone);
this.setState({
visibleNoPhoneCode: false,
gettingNoPhone: false,
countDownNoPhone: 60,
modalFooterNoPhone: true
});
};
renderIdCard = () => {
return this.state.idCardType.map((val, key) => {
return (
);
});
};
renderNationality = () => {
return this.state.nationality.map((val, key) => {
return (
);
});
};
renderCertification = () => {
return this.state.certificationType.map((val, key) => {
return (
);
});
};
renderManpowerLevel = () => {
return this.state.conf_manpowerLevel.map((val, key) => {
return (
);
});
};
renderArmedLevel = () => {
return this.state.conf_armedLevel.map((val, key) => {
return (
);
});
};
renderSafeTechLevel = () => {
return this.state.conf_safeTechLevel.map((val, key) => {
return (
);
});
};
renderRiskLevel = () => {
return this.state.conf_riskLevel.map((val, key) => {
return (
);
});
};
timerCount = () => {
//防止重复计算
if (this.state.countDown !== 60) {
return;
}
this.countDownTimeId = setInterval(() => {
if (this.state.countDown > 0) {
this.setState(prevState => ({
countDown: prevState.countDown - 1
}));
if (this.state.countDown === 0) {
this.setState({
getting: false,
countDown: 60
});
clearInterval(this.countDownTimeId);
}
} else {
clearInterval(this.countDownTimeId);
}
}, 1000);
};
//法人手机号为空时
timerCountNoPhone = () => {
//防止重复计算
if (this.state.countDownNoPhone !== 60) {
return;
}
this.countDownTimeIdNoPhone = setInterval(() => {
if (this.state.countDownNoPhone > 0) {
this.setState(prevState => ({
countDownNoPhone: prevState.countDownNoPhone - 1
}));
if (this.state.countDownNoPhone === 0) {
this.setState({
gettingNoPhone: false,
countDownNoPhone: 60
});
clearInterval(this.countDownTimeIdNoPhone);
}
} else {
clearInterval(this.countDownTimeIdNoPhone);
}
}, 1000);
};
componentWillUnmount = () => {
//离开页面时候,清除计时器
if (this.countDownTimeId != null || this.countDownTimeId != undefined) {
clearInterval(this.countDownTimeId);
}
};
beforeUpload = file => {
const types = ['image/png', 'image/jpeg', 'image/jpg'];
if (types.indexOf(file.type) === -1) {
message.error('只能上传图片!');
return false;
}
const isLt8M = file.size / 1024 / 1024 < 8;
if (!isLt8M) {
message.error('图片大小大于8MB!');
return false;
}
return true;
// return isJPG && isPNG && isLt8M;
};
handleChange = (info, field) => {
const { setFieldsValue } = this.props.form;
let { fileList } = info;
fileList = fileList.slice(-1);
this.setState({ [field + 'List']: fileList });
if (info.file.status === 'removed') {
message.error('至少需要一张图片');
return;
}
if (info.file.status !== 'uploading') {
if (info.file.response) {
if (info.file.response.retType === '-1') {
message.error(info.file.response.msg);
return;
}
} else {
return;
}
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`);
this.setState({
[field + 'List']: fileList,
[field]: fileList[0].response.data
});
setFieldsValue({ [field]: fileList.slice(-1) });
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败.`);
}
};
handleSubmit = e => {
e.preventDefault();
this.props.form.validateFieldsAndScroll((err, values) => {
values.codeOne = 1234;
values.legalRepPhone_two = 15012365498;
values.codeTwo = 2345;
values.legalRepNoPhone = 15012365498;
values.legalRepNoPhoneCode = 3456;
values.legalRepPhone = this.state.certificationData.legalRepPhone;
//特殊字段日期类型处理
Object.keys(values).forEach(key => {
if (
key.slice(0, 4) === 'conf' &&
(key.slice(-4) === 'Date' || key.slice(-4) === 'date')
) {
values[key] = values[key] ? values[key].format('YYYY-MM-DD') : null;
}
});
if (!err) {
//确认提交提示
//暂时隐藏特殊字段信息;冠男取消隐藏
// values.conf_armedLevel = values.conf_armedLevel.toString();
// values.conf_association = values.conf_association.toString();
// values.conf_manpowerLevel = values.conf_manpowerLevel.toString();
// values.conf_riskLevel = values.conf_riskLevel.toString();
// values.conf_safeRange = values.conf_safeRange.toString();
// values.conf_safeTechLevel = values.conf_safeTechLevel.toString();
const that = this;
// 验证管理员身份
if (
this.props.currentUser !==
this.state.administratorRelative.phoneValue &&
(!this.state.administratorRelative.hasValidCode ||
!this.state.administratorRelative.isValidCode)
) {
this.setState({
administratorRelative: {
...this.state.administratorRelative,
openValidAdminModal: true
}
});
return;
}
// confirm({
// title: '提交成功后3个工作日内审核完毕,是否提交?',
// okText: '确认',
// cancelText: '取消',
// onOk() {
// values.authStatus = 1; //修改认证状态
// ajax.enterpriseCompanyUpdateComAuthInfo({ ...values }).then(
// () => {
// that.setState({
// certificationData: values,
// qualificationsData: values,
// btnVisible: false,
// loading: false,
// statusBianDisabled: true
// });
// that.props.changeStatus();
// that.setState({ certificationData: { authStatus: '1' } });
// // message.success('提交成功!');
// },
// () => {
// that.setState({ loading: false });
// }
// );
// },
// onCancel() {}
// });
ajax.enterpriseCompanyUpdateComAuthInfo({ ...values }).then(
() => {
that.setState({
certificationData: values,
qualificationsData: values,
// btnVisible: false,
loading: false
// statusBianDisabled: true
});
that.props.changeStatus();
// that.setState({ certificationData: { authStatus: '1' } });
// message.success('提交成功!');
},
() => {
that.setState({ loading: false });
}
);
} else {
// console.log('errrrrr' + JSON.stringify(err));
}
});
};
callback = key => {
console.log(key);
};
//验证手机号码
checkPhone = (rule, value, callback) => {
if (value && !/^1[0-9]{10}$/.test(value)) {
callback('请输入正确的手机号码!');
} else {
callback();
}
};
//验证码的发送
onGetCaptcha = () => {
const disableStyle = {
background: '#f7f7f7',
marginLeft: 16,
borderColor: '#d9d9d9',
marginTop: 4
};
//验证通过,没有获取
if (!this.state.getting) {
return (
);
//验证通过,正在获取
} else {
this.timerCount();
return (
);
}
};
//法人手机号未验证时发送验证码
onGetCaptchaNoPhone = () => {
const disableStyle = {
background: '#f7f7f7',
marginLeft: 16,
borderColor: '#d9d9d9'
};
//验证通过,没有获取
if (!this.state.gettingNoPhone) {
return (
);
//验证通过,正在获取
} else {
this.timerCountNoPhone();
return (
);
}
};
onGetCaptchaData = () => {
return (
);
};
onGetCapt = () => {
return (
);
};
//审核结果
statusBian = () => {
const s_val = this.state.certificationData.authStatus;
if (s_val === '0') {
return (
);
} else if (s_val === '1') {
return (
);
} else if (s_val === '2') {
return (
);
} else if (s_val === '3') {
return (
);
} else if (s_val === '') {
return (
);
}
};
//验证名称类,限制不能全角输入
checkFullWidth = (rule, value, callback) => {
if (value && !/^[\u4e00-\u9fa5]{1,10}$/.test(value)) {
callback('请输入最大10个字符长度的汉字!');
} else {
callback();
}
};
//证件类型-号码验证
checkIdCardNo = (rule, value, callback) => {
const { form } = this.props;
const idType = form.getFieldValue('idCardType');
if (
idType === '1' &&
value &&
!/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(
value
)
) {
callback('请输入正确的身份证号码!');
} else {
callback();
}
};
checkJiShuMore = (rule, value, callback) => {
if (
value &&
!/^-?(([0-9][0-9]{0,9})|(([0]\.\d{1,4}|[1-9][0-9]{0,9}\.\d{1,4})))$/.test(
value
)
) {
callback('最多输入10位整数,并且小数点后面最多输入4位!');
} else {
callback();
}
};
//验证手机验证码
checkPhoneCodeVlue = (rule, value, callback) => {
if (value === '') {
callback('手机验证码不能为空!');
} else if (value && !/^[0-9]{4,6}$/.test(value)) {
callback('请输入正确的手机验证码!');
} else {
callback();
}
};
showModalFooter = () => {
const value_text = this.state.modalFooter;
if (!value_text) {
return null;
}
};
showNoPhoneModalFooter = () => {
const code_text = this.state.modalFooterNoPhone;
if (!code_text) {
return null;
}
};
//证件类型-号码验证-身份证
checkIdCardNo = (rule, value, callback) => {
// const form = this.props.form;
// const idType = form.getFieldValue('idCardType');
if (value && !/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
callback('请输入正确的身份证号码!');
} else {
callback();
}
};
//证件类型-号码验证-其他
checkCardNo = (rule, value, callback) => {
if (value && !/^[A-Za-z0-9]{1,20}$/.test(value)) {
callback('请输入最大20位长度的证件号码!');
} else {
callback();
}
};
//身份证改变事件
idCardTypeOnChangeHandler = value => {
// this.props.form.validateFields(['cerNo']);
this.props.form.setFieldsValue({ idCardNo: '' });
this.setState({ selectedIdCardType: value });
};
// 管理员身份验证码弹窗确认事件
handleValidAdminModalOk = e => {
this.props.form.validateFields((err, values) => {
if (!values['adminValidCode']) {
this.props.form.setFields({
adminValidCode: {
value: values.user,
errors: [new Error('请输入验证码')]
}
});
return false;
}
if (!err) {
ajax
.systemPlatNewsVerificationCode({
mobile: this.state.administratorRelative.phoneValue,
code: values['adminValidCode']
})
.then(
() => {
this.setState(
{
administratorRelative: {
...this.state.administratorRelative,
isValidCode: true,
openValidAdminModal: false
}
},
() => {
this.handleSubmit(e);
}
);
},
error => {
console.log('验证码是否正确-error:', error);
// message.error('请填写正确的验证码信息');
}
);
}
});
};
// 管理员身份验证码弹窗取消事件
handleValidAdminModalCancel = () => {
this.setState({
administratorRelative: {
...this.state.administratorRelative,
openValidAdminModal: false
}
});
};
//获得企业管理员
getComAdmin = () => {
ajax.selectComAdmin({}).then(data => {
let phoneValueHiddenMiddle = data.data[0].userName;
phoneValueHiddenMiddle = phoneValueHiddenMiddle.replace(
/(\d{3})\d{4}(\d{4})/,
'$1****$2'
);
//判断获取数据是否为空
this.setState({
administratorRelative: {
...this.state.administratorRelative,
administrator: data.data[0].name,
phoneValue: data.data[0].userName, // 我也不知道为啥叫这个名字,反正后台这个字段是电话
phoneValueHiddenMiddle
}
});
});
};
// 获取管理员验证码按钮逻辑
getAdminValidCodeButton = () => {
const disableStyle = {
background: '#f7f7f7',
marginLeft: 16,
borderColor: '#d9d9d9'
};
// 验证通过,没有获取
if (!this.state.administratorRelative.hasValidCode) {
return (
);
//验证通过,正在获取
} else {
this.timerCountForAdminValidCode();
return (
);
}
};
// 获取管理员验证码
getAdminValidCode = () => {
ajax
.systemPlatNewsSendVerificationCode({
mobile: this.state.administratorRelative.phoneValue
})
.then(
res => {
if (res.retType === '0') {
this.setState({
administratorRelative: {
...this.state.administratorRelative,
hasValidCode: true,
isValidCode: false
}
});
}
},
err => {
console.log('获取验证码错误信息:', err);
}
);
};
// 管理员验证码倒计时
timerCountForAdminValidCode = () => {
//防止重复计算
if (this.state.administratorRelative.countDownNoPhone !== 60) {
return;
}
this.countDownTimeForAdminValidCode = setInterval(() => {
if (this.state.administratorRelative.countDownNoPhone > 0) {
this.setState(prevState => ({
administratorRelative: {
...this.state.administratorRelative,
countDownNoPhone:
prevState.administratorRelative.countDownNoPhone - 1
}
}));
if (this.state.administratorRelative.countDownNoPhone === 0) {
this.setState({
administratorRelative: {
...this.state.administratorRelative,
countDownNoPhone: 60,
hasValidCode: false
}
});
clearInterval(this.countDownTimeForAdminValidCode);
}
} else {
clearInterval(this.countDownTimeForAdminValidCode);
}
}, 1000);
};
render() {
const { showIndustry } = this.state;
const { getFieldDecorator,getFieldValue } = this.props.form;
const formItemLayout = {
labelCol: {
xs: { span: 24 },
sm: { span: 7 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 12 },
md: { span: 10 }
}
};
const formItemLayoutMore = {
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 18 },
md: { span: 16 }
}
};
//保安协会
const renderAssociation = [];
this.state.conf_association.map((val, key) => {
renderAssociation.push(
);
});
//安全范围
const renderSafeRange = [];
this.state.conf_safeRange.map((val, key) => {
renderSafeRange.push(
);
});
const con_title = (
法人手机变更
*
法人信息如有变更,需要验证原法人的身份真实、有效。
);
return (
{/*
{this.statusBian()}
*/}
{this.state.hasPnone !== '' ? (
{this.state.modalLegPerson === true ? (
this.state.phoneHas !== '' ? (
) : (
)
) : (
)}
) : (
''
)}
{this.state.noPhoneContent === '' ? (
) : (
)}
);
}
}
/*********************样式*************************** */
const Container = style.div`{
.password-header{
font-size: 20px;
color: #333333;
padding-bottom:16px;
border-bottom:1px solid #e9e9e9;
}
.ant-btn-primary.getCaptcha{
background-color: #0F71FF;
}
.authentication-sub-title{
text-align:right;
font-size: 16px;
color: #333333;
margin-bottom:24px;
}
.ant-upload-select-picture-card i {
font-size: 32px;
color: #999;
}
.ant-upload-select-picture-card .ant-upload-text {
margin-top: 8px;
color: #666;
}
}`;