steps.jsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React from 'react';
  2. import { Steps, Spin } from 'antd';
  3. import './steps.less';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import Step1 from './steps/step1';
  7. import Step2 from './steps/step2';
  8. import Step3 from './steps/step3';
  9. import Step4 from './steps/step4';
  10. import Step5 from './steps/step5';
  11. import Step6 from './steps/step6';
  12. import Step7 from './steps/step7';
  13. import Step8 from './steps/step8';
  14. const Step = Steps.Step;
  15. const steps = [{
  16. title: '基本信息',
  17. content: Step1
  18. }, {
  19. title: '法律状况评估',
  20. content: Step2
  21. }, {
  22. title: '技术状况评估',
  23. content: Step3
  24. }, {
  25. title: '历史收入',
  26. content: Step4
  27. }, {
  28. title: '收入预估',
  29. content: Step5
  30. }, {
  31. title: '所得税预估',
  32. content: Step6
  33. }, {
  34. title: '风险预估',
  35. content: Step7
  36. }, {
  37. title: '评估值',
  38. content: Step8
  39. }];
  40. const EvaluateSteps = React.createClass({
  41. getInitialState() {
  42. return {
  43. current: 0,
  44. loading: true,
  45. steps: {}
  46. };
  47. },
  48. next(values) {
  49. const current = this.state.current + 1;
  50. this.state.steps[this.state.current] = values;
  51. if (this.state.current === 0 && this.props.title) {
  52. this.props.title(values.name);
  53. }
  54. this.setState({
  55. current: current,
  56. steps: this.state.steps
  57. });
  58. },
  59. prev() {
  60. const current = this.state.current - 1;
  61. this.setState({ current });
  62. },
  63. componentWillMount() {
  64. $.ajax({
  65. url: globalConfig.context + '/api/user/evaluate/info/' + this.props.id
  66. }).done(function (res) {
  67. this.setState({
  68. steps: res || {},
  69. loading: false
  70. })
  71. }.bind(this)).fail(function () {
  72. this.setState({
  73. loading: false
  74. })
  75. }.bind(this));
  76. this.setState({
  77. current: this.props.step || 0
  78. })
  79. },
  80. render() {
  81. this.state.StepContent = steps[this.state.current].content;
  82. return (
  83. <Spin spinning={this.state.loading}>
  84. <div style={{ marginTop: 10 }}>
  85. <Steps current={this.state.current} progressDot>
  86. {steps.map(item => <Step key={item.title} title={item.title} />)}
  87. </Steps>
  88. <div className="steps-content">{
  89. <this.state.StepContent next={this.next} prev={this.prev} id={this.props.id} data={this.state.steps[this.state.current]} record={this.state.steps}/>
  90. }</div>
  91. </div>
  92. </Spin>
  93. )
  94. },
  95. });
  96. export default EvaluateSteps;