step3.jsx 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import React from 'react';
  2. import { Spin, Form, Button, Select, message } from 'antd';
  3. import ajax from 'jquery/src/ajax/xhr.js'
  4. import $ from 'jquery/src/ajax';
  5. import { progressiveness, innovativeness, ripeness, alternatives, defensive, prospect, supplyAndDemand, rangeOfApplication, imitable, profitability } from './dict.js';
  6. import SpinContainer from "../../../SpinContainer";
  7. const FormItem = Form.Item;
  8. const Option = Select.Option;
  9. const formItemLayout = {
  10. labelCol: { span: 4 },
  11. wrapperCol: { span: 14 },
  12. };
  13. const EvaluateStep3 = Form.create({})(React.createClass({
  14. getInitialState() {
  15. return {
  16. loading: false,
  17. initialData: {}
  18. };
  19. },
  20. componentWillMount() {
  21. this.state.initialData = this.props.data || {};
  22. },
  23. next() {
  24. if (this.state.loading) {
  25. return;
  26. }
  27. this.props.form.validateFields((err, values) => {
  28. if (!err) {
  29. this.setState({
  30. loading: true
  31. })
  32. values.id = this.props.id;
  33. $.ajax({
  34. url: globalConfig.context + '/api/user/evaluate/step3',
  35. method: 'post',
  36. data: values
  37. }).done(function (res) {
  38. if (res.error && res.error.length) {
  39. message.error(res.error[0].message)
  40. } else {
  41. if (this.props.next) {
  42. this.props.next(values);
  43. }
  44. }
  45. }.bind(this)).fail(function () {
  46. this.setState({
  47. loading: false
  48. })
  49. }.bind(this));
  50. }
  51. });
  52. },
  53. prev() {
  54. if (this.props.prev) {
  55. this.props.prev();
  56. }
  57. },
  58. stringify(val) {
  59. return val && String(val)
  60. },
  61. render() {
  62. let { loading, initialData } = this.state;
  63. const { getFieldDecorator } = this.props.form;
  64. return (
  65. <SpinContainer spinning={loading}>
  66. <Form className="steps-form">
  67. <FormItem label="先进性" {...formItemLayout}>
  68. {getFieldDecorator('progressiveness', {
  69. rules: [{ required: true, message: '请选择技术的先进性!' }],
  70. initialValue: this.stringify(initialData.progressiveness)
  71. })(
  72. <Select placeholder="请选择技术的先进性">
  73. {progressiveness.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('innovativeness', {
  81. rules: [{ required: true, message: '请选择技术的创新性!' }],
  82. initialValue: this.stringify(initialData.innovativeness)
  83. })(
  84. <Select placeholder="请选择技术的创新性">
  85. {innovativeness.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('ripeness', {
  93. rules: [{ required: true, message: '请选择技术的成熟度!' }],
  94. initialValue: this.stringify(initialData.ripeness)
  95. })(
  96. <Select placeholder="请选择技术的成熟度">
  97. {ripeness.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('alternatives', {
  105. rules: [{ required: true, message: '请选择技术的替代性!' }],
  106. initialValue: this.stringify(initialData.alternatives)
  107. })(
  108. <Select placeholder="请选择技术的替代性">
  109. {alternatives.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('defensive', {
  117. rules: [{ required: true, message: '请选择技术的防御力!' }],
  118. initialValue: this.stringify(initialData.defensive)
  119. })(
  120. <Select placeholder="请选择技术的防御力">
  121. {defensive.map((it) => {
  122. return <Option key={it.id} value={it.id}>{it.text}</Option>
  123. })}
  124. </Select>
  125. )}
  126. </FormItem>
  127. <FormItem label="技术领域发展前景" {...formItemLayout}>
  128. {getFieldDecorator('prospect', {
  129. rules: [{ required: true, message: '请选择技术领域发展前景!' }],
  130. initialValue: this.stringify(initialData.prospect)
  131. })(
  132. <Select placeholder="请选择技术领域发展前景">
  133. {prospect.map((it) => {
  134. return <Option key={it.id} value={it.id}>{it.text}</Option>
  135. })}
  136. </Select>
  137. )}
  138. </FormItem>
  139. <FormItem label="供求关系" {...formItemLayout}>
  140. {getFieldDecorator('supplyAndDemand', {
  141. rules: [{ required: true, message: '请选择技术的供求关系!' }],
  142. initialValue: this.stringify(initialData.supplyAndDemand)
  143. })(
  144. <Select placeholder="请选择技术的供求关系">
  145. {supplyAndDemand.map((it) => {
  146. return <Option key={it.id} value={it.id}>{it.text}</Option>
  147. })}
  148. </Select>
  149. )}
  150. </FormItem>
  151. <FormItem label="产品应用范围" {...formItemLayout}>
  152. {getFieldDecorator('rangeOfApplication', {
  153. rules: [{ required: true, message: '请选择技术的应用范围!' }],
  154. initialValue: this.stringify(initialData.rangeOfApplication)
  155. })(
  156. <Select placeholder="请选择技术的应用范围">
  157. {rangeOfApplication.map((it) => {
  158. return <Option key={it.id} value={it.id}>{it.text}</Option>
  159. })}
  160. </Select>
  161. )}
  162. </FormItem>
  163. <FormItem label="遭他人模仿可能性" {...formItemLayout}>
  164. {getFieldDecorator('imitable', {
  165. rules: [{ required: true, message: '请选择技术的模仿可能性!' }],
  166. initialValue: this.stringify(initialData.imitable)
  167. })(
  168. <Select placeholder="请选择技术的模仿可能性">
  169. {imitable.map((it) => {
  170. return <Option key={it.id} value={it.id}>{it.text}</Option>
  171. })}
  172. </Select>
  173. )}
  174. </FormItem>
  175. <FormItem label="独立获利能力" {...formItemLayout}>
  176. {getFieldDecorator('profitability', {
  177. rules: [{ required: true, message: '请选择技术的独立获利能力!' }],
  178. initialValue: this.stringify(initialData.profitability)
  179. })(
  180. <Select placeholder="请选择技术的独立获利能力">
  181. {profitability.map((it) => {
  182. return <Option key={it.id} value={it.id}>{it.text}</Option>
  183. })}
  184. </Select>
  185. )}
  186. </FormItem>
  187. </Form>
  188. <div className="steps-action">
  189. <Button type="primary" onClick={() => this.next()}>保存,下一步</Button>
  190. <Button style={{ marginLeft: 8 }} onClick={() => this.prev()}>上一步</Button>
  191. </div>
  192. </SpinContainer>
  193. )
  194. },
  195. }));
  196. export default EvaluateStep3;