step6.jsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React from 'react';
  2. import { Spin, Form, Button, InputNumber, message } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. const FormItem = Form.Item;
  6. const formItemLayout = {
  7. labelCol: { span: 6 },
  8. wrapperCol: { span: 10 },
  9. };
  10. const EvaluateStep6 = Form.create({})(React.createClass({
  11. getInitialState() {
  12. return {
  13. loading: false,
  14. initialData: {}
  15. };
  16. },
  17. componentWillMount() {
  18. this.state.initialData = this.props.data || {};
  19. },
  20. next() {
  21. if (this.state.loading) {
  22. return;
  23. }
  24. this.props.form.validateFields((err, values) => {
  25. if (!err) {
  26. this.setState({
  27. loading: true
  28. })
  29. $.ajax({
  30. url: globalConfig.context + '/api/user/evaluate/step6',
  31. method: 'post',
  32. data: {
  33. id: this.props.id,
  34. taxRate: values.taxRate
  35. }
  36. }).done(function (res) {
  37. if (res.error && res.error.length) {
  38. message.error(res.error[0].message)
  39. } else {
  40. if (this.props.next) {
  41. this.props.next(values);
  42. }
  43. }
  44. }.bind(this)).fail(function () {
  45. this.setState({
  46. loading: false
  47. })
  48. }.bind(this));
  49. }
  50. });
  51. },
  52. prev() {
  53. if (this.props.prev) {
  54. this.props.prev();
  55. }
  56. },
  57. stringify(val) {
  58. return val && String(val)
  59. },
  60. render() {
  61. let { loading, initialData } = this.state;
  62. const { getFieldDecorator } = this.props.form;
  63. return (
  64. <Spin spinning={loading}>
  65. <div style={{ marginBottom: 10 }}>提示:一般企业所得税率为25%,如果应用该项技术的公司有所得税优惠政策,按照优惠政策填列。如为高新技术企业请填15%</div>
  66. <Form className="steps-form">
  67. <FormItem label="预估企业所得税率(%)" {...formItemLayout}>
  68. {getFieldDecorator('taxRate', {
  69. initialValue: this.stringify(initialData.taxRate),
  70. rules: [{ required: true, message: '请输入预估企业所得税率!' }, {
  71. validator: (rule, value, callback) => {
  72. if (!Number(value)) {
  73. callback('请输入预估企业所得税率!');
  74. } else {
  75. callback();
  76. }
  77. },
  78. }]
  79. })(
  80. <InputNumber min={0} placeholder="请输入预估企业所得税率" />
  81. )}
  82. </FormItem>
  83. </Form>
  84. <div className="steps-action">
  85. <Button type="primary" onClick={() => this.next()}>保存,下一步</Button>
  86. <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>上一步</Button>
  87. </div>
  88. </Spin>
  89. )
  90. },
  91. }));
  92. export default EvaluateStep6;