step7.jsx 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import React from 'react';
  2. import { Spin, Form, Button, Select } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import { political, technical, market, capital, management } from './dict.js';
  6. const FormItem = Form.Item;
  7. const Option = Select.Option;
  8. const formItemLayout = {
  9. labelCol: { span: 4 },
  10. wrapperCol: { span: 10 },
  11. };
  12. const EvaluateStep7 = Form.create({})(React.createClass({
  13. getInitialState() {
  14. return {
  15. loading: false,
  16. initialData: {}
  17. };
  18. },
  19. componentWillMount() {
  20. this.state.initialData = this.props.data || {};
  21. },
  22. next() {
  23. if (this.state.loading) {
  24. return;
  25. }
  26. this.props.form.validateFields((err, values) => {
  27. if (!err) {
  28. this.setState({
  29. loading: true
  30. })
  31. values.id = this.props.id;
  32. $.ajax({
  33. url: globalConfig.context + '/api/user/evaluate/step7',
  34. method: 'post',
  35. data: values
  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 }}>项目整体获利情况受政策、技术、市场、资金、管理等影响。</div>
  66. <Form className="steps-form">
  67. <FormItem label="政策风险" {...formItemLayout}>
  68. {getFieldDecorator('political', {
  69. rules: [{ required: true, message: '请选择政策风险!' }],
  70. initialValue: this.stringify(initialData.political)
  71. })(
  72. <Select placeholder="请选择政策风险">
  73. {political.map((it) => {
  74. return <Option key={it.id} value={it.id}>{it.text}</Option>
  75. })}
  76. </Select>
  77. )}
  78. </FormItem>
  79. <FormItem label="技术风险" {...formItemLayout}>
  80. {getFieldDecorator('technical', {
  81. rules: [{ required: true, message: '请选择技术风险!' }],
  82. initialValue: this.stringify(initialData.technical)
  83. })(
  84. <Select placeholder="请选择技术风险">
  85. {technical.map((it) => {
  86. return <Option key={it.id} value={it.id}>{it.text}</Option>
  87. })}
  88. </Select>
  89. )}
  90. </FormItem>
  91. <FormItem label="市场风险" {...formItemLayout}>
  92. {getFieldDecorator('market', {
  93. rules: [{ required: true, message: '请选择市场风险!' }],
  94. initialValue: this.stringify(initialData.market)
  95. })(
  96. <Select placeholder="请选择市场风险">
  97. {market.map((it) => {
  98. return <Option key={it.id} value={it.id}>{it.text}</Option>
  99. })}
  100. </Select>
  101. )}
  102. </FormItem>
  103. <FormItem label="资金风险" {...formItemLayout}>
  104. {getFieldDecorator('capital', {
  105. rules: [{ required: true, message: '请选择资金风险!' }],
  106. initialValue: this.stringify(initialData.capital)
  107. })(
  108. <Select placeholder="请选择资金风险">
  109. {capital.map((it) => {
  110. return <Option key={it.id} value={it.id}>{it.text}</Option>
  111. })}
  112. </Select>
  113. )}
  114. </FormItem>
  115. <FormItem label="管理风险" {...formItemLayout}>
  116. {getFieldDecorator('management', {
  117. rules: [{ required: true, message: '请选择管理风险!' }],
  118. initialValue: this.stringify(initialData.management)
  119. })(
  120. <Select placeholder="请选择管理风险">
  121. {management.map((it) => {
  122. return <Option key={it.id} value={it.id}>{it.text}</Option>
  123. })}
  124. </Select>
  125. )}
  126. </FormItem>
  127. </Form>
  128. <div className="steps-action">
  129. <Button type="primary" onClick={() => this.next()}>保存,下一步</Button>
  130. <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>上一步</Button>
  131. </div>
  132. </Spin>
  133. )
  134. },
  135. }));
  136. export default EvaluateStep7;