import React, { Component } from 'react'; import { connect } from 'dva'; import { Form, Input, Select, Button, Radio, DatePicker, Checkbox, Row, Col, Cascader, message, Modal } from 'antd'; import * as ajax from "../../../services/api"; import moment from 'moment'; import "moment/locale/zh-cn"; import Drawer from 'react-motion-drawer'; import PCascader from '../../../components/Pro/PCascader'; import './less/report.less'; const FormItem = Form.Item; const { Option } = Select; const { TextArea } = Input; const confirm = Modal.confirm; const dateFormat = 'YYYY-MM-DD'; @connect(state => ({ profile: state.profile, })) @Form.create() export default class AddDistrictDetails extends Component { constructor(props, context) { super(props, context); this.state = { open2: this.props.visible, loading: false, securityRange: [],//安保范围 crossManageId: this.props.crossManageId,//传过来的方案id areas: [],//地区 messageList: { province: '', city: '', area: '', address: '',//详细地址 recordPoliceName: '',//备案公安机关名称 recordDate: '',//备案日期 responsPer: '',//负责人 responsPerPhone: '',//负责人手机号 idCardNo: '',//负责人身份证号 post: '',//负责人职务 startDate: '',//跨区经营开始日期 telePhone: '',//联系电话 securityRange: [],//安保范围 securityRangeContentArrays: [],//安保范围数组 }, // fan: false,//返回之前是否保存 }; } componentWillReceiveProps(props) { if(this.state.open2 !== props.visible) { this.setState({ open2: props.visible, crossManageId: props.crossManageId }); this.securityRangeList(); // this.getDistrict();//省市区选择 } } componentDidMount() { this.props.onRef(this); // this.securityRangeList(); // this.messageList(); // this.getDistrict();//省市区选择 } // //省市区 // getDistrict = () => { // ajax.getDistrictData().then((data) => { // console.log('省市区data:', data); // let areas = data.data.map((val) => { // return { // value: val.regionId, // label: val.regionName, // children: val.childs.map((valChild) => { // return { // value: valChild.regionId, // label: valChild.regionName, // children: valChild.childs.map((valChildChild) => { // return { // value: valChildChild.regionId, // label: valChildChild.regionName, // } // }) // } // }) // }; // } // ); // //console.log('areas:'+JSON.stringify(areas)); // this.setState({ // areas: areas, // }); // }) // }; //重置表单 resetFrom = () => { const { setFieldsValue } = this.props.form; setFieldsValue({ EconomicType:'', address:'',//详细地址 recordPoliceName:'',//备案公安机关名称 recordDate:null,//备案日期 responsPer:'',//负责人 responsPerPhone:'',//负责人手机号 idCardNo:'',//负责人身份证号 post:'',//负责人职务 startDate:null,//跨区经营开始日期 telePhone:'',//联系电话 securityRange:[],//安保范围 securityRangeContentArrays:[],//安保范围数组 }); } //安保范围 securityRangeList = () =>{ ajax.publicCommonDictGetDictByCodeTypes({codeTypes:'securityRange'}).then((data) => { if (data.data) { this.setState({ securityRange: data.data.securityRange, }); } }) }; //提交 handleSubmit = (e) => { e.preventDefault(); this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { console.log('保存-修改跨区经营', values); values.province = values.EconomicType[0]; if (values.EconomicType[1]) { values.city = values.EconomicType[1]; } else { values.city = 0; } if (values.EconomicType[2]) { values.area = values.EconomicType[2]; } else { values.area = 0; } values.recordDate = values['recordDate'].format('YYYY-MM-DD'); values.startDate = values['startDate'].format('YYYY-MM-DD'); delete values.EconomicType; values.securityRangeContentArrays = values.securityRange; if (this.state.crossManageId !== '00') { values.crossManageId = this.state.crossManageId; } let d1 = new Date(values.startDate.replace(/\-/g, "\/")); let d2 = new Date(values.recordDate.replace(/\-/g, "\/")); if (d1 < d2) { message.error('跨区经营开始日期不能早于备案日期'); } else { this.setState({ loading: true }); ajax.comStockSaveCrossManage({ ...values }).then((data) => { // console.log('提交成功'); // message.success('跨区经营详情保存成功!'); this.setState({ fan: true, loading: false, }, () => { this.props.close(); }); }, (err) => { this.setState({ loading: false }); }); } } }); }; callback = (key) => { console.log(key); }; onChangeCheck = (checkedValues) => { console.log('checked = ', checkedValues); }; //安保范围选择 renderList = () => { return this.state.securityRange.map((val, key) => { return