import React,{Component} from "react"; import {Button, Cascader, DatePicker, Form, Input, message, Modal, Radio, Select, Spin, Checkbox} from "antd"; import { areaSelect, Birthplace } from "@/areaList"; import { getProvinceList } from "@/addressList"; import moment from "moment"; import $ from "jquery/src/ajax"; import UserProcessing from './userProcessing'; const FormItem = Form.Item; const formItemLayout = { labelCol: { span: 6 }, wrapperCol: { span: 16 }, }; class UserProfile extends Component{ constructor(props) { super(props); this.state={ loading: false, doorId:'', employeeId:'', name:'', establish: props.aid ? true : false, aid:props.aid, } this.verifyDoor = this.verifyDoor.bind(this); this.verifyId = this.verifyId.bind(this); this.addOk = this.addOk.bind(this); this.editOk = this.editOk.bind(this); this.editPeo = this.editPeo.bind(this); } componentDidMount() { let areaArr = getProvinceList(); let Area = areaSelect(areaArr); let Birthplaces = Birthplace(areaArr); this.setState({ Area, Birthplaces: Birthplaces, }); if(this.props.ModalData && !this.state.isAddPeo){ this.editPeo(); } } verifyDoor() { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/personnel/checkDoorId", data: { doorId: this.state.doorId, id: this.props.id, }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success("此编号未被占用"); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } verifyId() { this.setState({ loading: true, }); $.ajax({ method: "get", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/personnel/checkEmployeeId", data: { employeeId: this.state.employeeId, id: this.props.id }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success("此编号未被占用"); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } inspect(fn) { if(!this.state.name){ message.warning('请输入姓名'); return; } if(!this.state.employeeId){ message.warning('请输入员工编号'); return; } if(!this.state.doorId){ message.warning('请输入门禁编号'); return; } if(isNaN(parseInt(this.state.sex))){ message.warning('请选择性别'); return; } if(!this.state.nation){ message.warning('请输入民族'); return; } if(!(this.state.residence) || this.state.residence.length === 0){ message.warning('请选择户籍地址'); return; } if((!this.state.nativePlace) || this.state.nativePlace.length === 0){ message.warning('请选择籍贯'); return; } if((!this.state.now) || this.state.now.length === 0){ message.warning('请选择现住地址'); return; } fn(); } addOk(aid) { this.setState({ loading: true, aid, }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/personnel/add", data: { name: this.state.name, doorId: this.state.doorId, aid, sex: this.state.sex, nation: this.state.nation, residenceProvince: this.state.residence[0], residenceCity: this.state.residence[1], residenceArea: this.state.residence[2], residenceAddress: this.state.residenceAddress, nativePlaceProvince: this.state.nativePlace[0], nativePlaceCity: this.state.nativePlace[1], nowProvince: this.state.now[0], nowCity: this.state.now[1], nowArea: this.state.now[2], nowAddress: this.state.nowAddress, idCard: this.state.idCard, certificationAuthority: this.state.certificationAuthority, marriage: this.state.marriage, politicalOutlook: this.state.politicalOutlook, son: this.state.son, girl: this.state.girl, birthdays: this.state.birthdays, employeeId: this.state.employeeId, }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success("添加成功!"); this.props.setNowAid(aid); this.props.onCancel(); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } editOk(aid) { this.setState({ loading: true, aid, }); $.ajax({ method: "post", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/admin/personnel/update", data: { aid, id: this.props.id, name: this.state.name, doorId: this.state.doorId, sex: this.state.sex, nation: this.state.nation, residenceProvince: this.state.residence[0], residenceCity: this.state.residence[1], residenceArea: this.state.residence[2], residenceAddress: this.state.residenceAddress, nativePlaceProvince: this.state.nativePlace[0], nativePlaceCity: this.state.nativePlace[1], nowProvince: this.state.now[0], nowCity: this.state.now[1], nowArea: this.state.now[2], nowAddress: this.state.nowAddress, idCard: this.state.idCard, certificationAuthority: this.state.certificationAuthority, marriage: this.state.marriage, politicalOutlook: this.state.politicalOutlook, son: this.state.son, girl: this.state.girl, birthdays: this.state.birthdays, employeeId: this.state.employeeId, }, success: function (data) { if (data.error && data.error.length) { message.warning(data.error[0].message); } else { message.success("修改成功!"); this.props.setNowAid(aid); this.props.onCancel(); } }.bind(this), }).always( function () { this.setState({ loading: false, }); }.bind(this) ); } editPeo() { let residence = []; residence[0] = this.props.ModalData.residenceProvince; residence[1] = this.props.ModalData.residenceCity; residence[2] = this.props.ModalData.residenceArea; let nativePlace = []; nativePlace[0] = this.props.ModalData.nativePlaceProvince; nativePlace[1] = this.props.ModalData.nativePlaceCity; let now = []; now[0] = this.props.ModalData.nowProvince; now[1] = this.props.ModalData.nowCity; now[2] = this.props.ModalData.nowArea; this.setState({ id: this.props.ModalData.id, doorId: this.props.ModalData.doorId, name: this.props.ModalData.name, birthdays: this.props.ModalData.birthdays, sex: this.props.ModalData.sex, nation: this.props.ModalData.nation, residence: residence ? residence : [], residenceAddress: this.props.ModalData.residenceAddress, now: now ? now : [], nowAddress: this.props.ModalData.nowAddress, nativePlace: nativePlace ? nativePlace : [], idCard: this.props.ModalData.idCard, certificationAuthority: this.props.ModalData.certificationAuthority, marriage: this.props.ModalData.marriage, son: this.props.ModalData.son, girl: this.props.ModalData.girl, politicalOutlook: this.props.ModalData.politicalOutlook || this.props.ModalData.politicalOutlook == 0 ? this.props.ModalData.politicalOutlook : undefined, employeeId: this.props.ModalData.employeeId, }); } render() { return (

{this.props.isAddPeo ? "新增人事档案" : "修改人事档案"}

{ this.setState({ employeeId: e.target.value, }); }} /> { this.setState({ doorId: e.target.value, }); }} />
{ this.setState({ name: e.target.value, }); }} /> { this.setState({ birthdays: t, }); }} />
{ this.setState({ sex: e.target.value }); }} value={this.state.sex} > { this.setState({ nation: e.target.value, }); }} />
{ this.setState({ residence: e }); }} /> { this.setState({ residenceAddress: e.target.value, }); }} />
{ this.setState({ now: e }); }} /> { this.setState({ nowAddress: e.target.value, }); }} />
{ this.setState({ nativePlace: e }); }} /> { this.setState({ idCard: e.target.value, }); }} />
{ // let reg = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/; this.setState({ certificationAuthority: e.target.value, }); }} /> {/* * */} { this.setState({ marriage: e.target.value }); }} value={this.state.marriage} > 未婚 已婚 离异
儿子: { this.setState({ son: e.target.value, }); }} /> 女儿: { this.setState({ girl: e.target.value, }); }} />
{ this.setState({ establish: e.target.checked }); }}> 是否同步创建系统账户 {!this.state.establish ? : null} {this.state.establish ?
----------------------------------------------------------------------------------------------------------------------------------------------------------------
{this.inspect(v)}} onPreservation={(aid)=>{ if(this.props.isAddPeo){ this.addOk(aid); }else{ this.editOk(aid); } }} />
: null}
) } } export default UserProfile;