import React from 'react'; import { Input, InputNumber, Button, Form, Icon, Spin, message, Tabs, Upload } from 'antd'; import { beforeUpload } from '../../tools.js'; import './person.less'; import './hrSituation.less' import ajax from 'jquery/src/ajax/xhr.js' import $ from 'jquery/src/ajax'; const PersonFrom = Form.create()(React.createClass({ getData() { this.props.spinState(true); $.ajax({ method: "get", dataType: "json", url: globalConfig.context + "/api/user/humanResource", data: { year: this.props.year }, success: function (data) { if (data.data) { this.setState({ aboveFifty: data.data.aboveFifty, belowThirty: data.data.belowThirty, college: data.data.college, doctor: data.data.doctor, firmAbroad: data.data.firmAbroad, firmCore: data.data.firmCore, firmForeign: data.data.firmForeign, firmInService: data.data.firmInService, firmPartTime: data.data.firmPartTime, firmTemporary: data.data.firmTemporary, firmTotal: data.data.firmTotal, fortyoneToFifty: data.data.fortyoneToFifty, intermediateTitle: data.data.intermediateTitle, juniorTitle: data.data.juniorTitle, master: data.data.master, seniorMechanic: data.data.seniorMechanic, seniorTitle: data.data.seniorTitle, techAbroad: data.data.techAbroad, techCore: data.data.techCore, techForeign: data.data.techForeign, techInService: data.data.techInService, techPartTime: data.data.techPartTime, techTemporary: data.data.techTemporary, techTotal: data.data.techTotal, thirtyoneToThirtyfour: data.data.thirtyoneToThirtyfour, undergraduate: data.data.undergraduate }); } }.bind(this), }).always(function () { this.props.spinState(false); }.bind(this)); }, getInitialState() { return { loading: false }; }, handleSubmit(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (values.firmTotal < values.firmInService + values.firmPartTime + values.firmTemporary) { message.warning("总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数!"); return; }; if (values.firmTotal < values.techTotal) { message.warning("科技人员数小于等于企业职工总数!"); return; }; if (values.firmInService < values.techInService || values.firmPartTime < values.techPartTime || values.firmTemporary < values.techTemporary || values.firmForeign < values.techForeign || values.firmAbroad < values.techAbroad || values.firmCore < values.techCore) { message.warning("科技人员各项人数小于等于企业职工各项人数!"); return; }; if (values.firmTotal < values.doctor + values.master + values.undergraduate + values.college) { message.warning("全体人员结构中学历一栏人数总和小于等于职工人数!"); return; }; if (values.firmTotal < values.belowThirty + values.thirtyoneToThirtyfour + values.fortyoneToFifty + values.aboveFifty) { message.warning("全体人员结构中年龄一栏人数总和小于等于职工人数!"); return; }; if (!err) { this.props.spinState(true); $.ajax({ method: "POST", dataType: "json", crossDomain: false, url: globalConfig.context + "/api/user/SaveHumanResource", data: { year: this.props.year, aboveFifty: values.aboveFifty, belowThirty: values.belowThirty, college: values.college, doctor: values.doctor, firmAbroad: values.firmAbroad, firmCore: values.firmCore, firmForeign: values.firmForeign, firmInService: values.firmInService, firmPartTime: values.firmPartTime, firmTemporary: values.firmTemporary, firmTotal: values.firmTotal, fortyoneToFifty: values.fortyoneToFifty, intermediateTitle: values.intermediateTitle, juniorTitle: values.juniorTitle, master: values.master, seniorMechanic: values.seniorMechanic, seniorTitle: values.seniorTitle, techAbroad: values.techAbroad, techCore: values.techCore, techForeign: values.techForeign, techInService: values.techInService, techPartTime: values.techPartTime, techTemporary: values.techTemporary, techTotal: values.techTotal, thirtyoneToThirtyfour: values.thirtyoneToThirtyfour, undergraduate: values.undergraduate, rosterUrl: this.state.rosterUrl, socialSecurityUrl: this.state.socialSecurityUrl } }).done(function (data) { if (!data.error.length) { message.success('保存成功!'); } else { message.warning(data.error[0].message); } }.bind(this)).always(function () { this.props.spinState(false); }.bind(this)); } }); }, componentWillMount() { this.getData(); }, render() { const { getFieldDecorator } = this.props.form; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 16 }, }; const FormItem = Form.Item; return (
); }, })); const Person = React.createClass({ getInitialState() { return { loading: false }; }, spinChange(e) { this.setState({ loading: e }); }, render() { const theYear = (new Date()).getFullYear() - 1; return (