import React from 'react'; import moment from 'moment'; import "moment/locale/zh-cn"; import { Form, Input, Button, DatePicker, Popover, Icon, Select, InputNumber } from 'antd'; import { formItemLayout1 } from './constants'; import { DrawHeader, Empty, DrawBottomBtns, DrawTitle, ImageDontDelete } from './styles'; import { OrganName } from './components'; import PCascader from '../../../components/Pro/PCascader'; import PFromUpload from '../../../components/Pro/PFromUpload'; import PDrawer from '../../../components/Pro/PDrawer'; import { enterpriseCompanyComBaseInfoGetComBaseInfoById, publicCommonDictGetDictByCodeTypes, enterpriseCompanyGetComIndustryinfo, enterpriseCompanyComIndustryGetComBranchIndustryInfoByComId, } from '../../../services/api'; const FormItem = Form.Item; const { Option } = Select; const { TextArea } = Input; const dateFormat = 'YYYY-MM-DD'; @Form.create() export default class DrawChildCompanyIdentification extends React.Component { constructor(props, context) { super(props, context); this.state = { dataSource: { legalRepName: "",//法定代表人 nationality: "",//国籍/地区 legalRepPhone: "",//手机号 idCardType: "",//证件类型 idCardNo: "",//证件号 regAmount: "",//注册资金(万元) fixedAssets: "",//固定资产 annualTurnover: "",//年营业额 annualProfitTax: "",//年利率 comCerType: "",//企业证件类型 comCerNo: "",//证件号 comCerUrl: "",// 证件扫描件 }, codeTypes: { nationality: [],//国籍 idCardType_bak: [],//证件类型 conf_association: [],//所属行业保安协会 conf_safeRange: [],//安全范围 conf_manpowerLevel: [],//人力防范等级 conf_armedLevel: [],//武装押运等级 conf_safeTechLevel: [],//安全技术防范等级 conf_riskLevel: [],//风险评估等级 comCerType: [],//企业证件类型 }, industryInfo: [],// 行业资质 showIndustry: false,//是否展示特殊字段信息, specialArray: [],//特殊字段信息 comId: '', //特殊字段接口请求参数 institutionType: '',//企业基础信息,企业机构类型 }; } /******************************生命周期******************************/ componentDidMount = () => { this.publicCommonDictGetDictByCodeTypes(); } componentWillReceiveProps = (nextProps, newState) => { if (nextProps.visible && !this.props.visible && nextProps.comId) { this.ajaxDetail(nextProps.comId); this.enterpriseCompanyGetComIndustryinfo(nextProps.comId); } } /******************************ajax请求******************************/ // 查询详情 ajaxDetail = (comBranchId) => { enterpriseCompanyComBaseInfoGetComBaseInfoById({ comBranchId }) .then( (data) => { console.log("子公司基础信息", data); const { dataSource } = this.state.dataSource; this.setState({ dataSource: { ...dataSource, ...data.data }, comId: data.data.comId, institutionType: data.data.institutionType }, () => { console.log('企业信息-认证申请-获得企业机构特殊信息-comId', this.state.comId); //分公司、子公司通过ID获得企业行业信息-获得企业机构特殊信息 enterpriseCompanyComIndustryGetComBranchIndustryInfoByComId({ comId: this.state.comId, institutionType: this.state.institutionType }).then( (res) => { console.log("分公司、子公司通过ID获得企业行业信息", 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 }); }); console.log('tmp---------tmp', tmp); this.setState({ specialArray: tmp, showIndustry: true }); } }, (err) => { console.log("分公司、子公司通过ID获得企业行业信息", err); } ); }); } ) .catch( (err) => { console.log(err); } ); } //类型查询 publicCommonDictGetDictByCodeTypes = () => { const codeTypes = "nationality,idCardType_bak,conf_association,conf_safeRange,conf_manpowerLevel,conf_armedLevel,conf_safeTechLevel,conf_riskLevel,comCerType"; publicCommonDictGetDictByCodeTypes({ codeTypes }).then(({ data = {} }) => { this.setState({ codeTypes: data }); }, (err) => { console.log(err); }); } //企业信息-认证申请-行业资质查询 enterpriseCompanyGetComIndustryinfo = (comId) => { enterpriseCompanyGetComIndustryinfo({ comId }).then( ({ data }) => { console.log("industryInfo", data); if (!data || data.length === 0) { return; } this.setState({ industryInfo: data }); console.log(data); }, (err) => { console.log(err); } ); } /******************************相关事件******************************/ /**** * 特殊字段 */ 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 )}
); }); return arr; }; renderMap = ( fieldType, fieldName, fieldCode, isRequired, fieldValue, maxLength, fieldOptions, scriptFunction ) => { 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}` } ] })(