import React,{Component} from "react"; import {Form, Input, Button, Checkbox, Select, Spin} from 'antd'; import $ from "jquery/src/ajax"; import {message, Modal} from "antd"; class AddSoftWritingPrice extends Component{ constructor(props) { super(props); this.state={ loading: false } } //增加 修改 addSoftWritingPriceFn(e) { e.preventDefault(); this.props.form.validateFields((err, values) => { if (!err) { this.setState({ loading: true }); let api ; if(Object.keys(this.props.infor).length){ api = '/api/admin/company/updateSoftWritingPrice'; values.id = this.props.infor.id; } else { api = '/api/admin/company/addSoftWritingPrice'; } $.ajax({ method: "post", dataType: "json", crossDomain: false, url:globalConfig.context + api, data:values, }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success(Object.keys(this.props.infor).length ? '修改成功!' : '新增成功!'); this.props.successFn(); } else { message.warning(data.error[0].message); } }.bind(this)); } }); } render() { const { getFieldDecorator } = this.props.form; return (
{ this.addSoftWritingPriceFn(e) }}> {getFieldDecorator('companyName', { initialValue: this.props.infor.companyName, rules: [{ required: true, message: '请输入公司名称!' }], })( )} {getFieldDecorator('unitPrice', { initialValue: this.props.infor.unitPrice, rules: [{ required: true, message: '请输入单价!' }], })( )} {getFieldDecorator('material', { initialValue: this.props.infor.material, rules: [{ required: true, message: '请选择是否有材料!' }], })( )} {getFieldDecorator('urgent', { initialValue: this.props.infor.urgent, rules: [{ required: true, message: '请选择加急天数!' }], })( )} {Object.keys(this.props.infor).length ? {getFieldDecorator('status', { initialValue: this.props.infor.status, rules: [{ required: true, message: '请输选择状态!' }], })( )} :
} {getFieldDecorator('remarks', { initialValue: this.props.infor.remarks, rules: [{ required: false, message: '请输入备注!' }], })( )} ) } } const WrappedHorizontalLoginForm = Form.create()(AddSoftWritingPrice); export default WrappedHorizontalLoginForm