step2.jsx 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 { accessMethods, legalStatus, maintenanceStatus, confidentialities, decidabilities, rightLimitations } from './dict.js';
  6. const FormItem = Form.Item;
  7. const Option = Select.Option;
  8. const formItemLayout = {
  9. labelCol: { span: 6 },
  10. wrapperCol: { span: 10 }
  11. };
  12. const EvaluateStep2 = 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/step2',
  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. <Form className="steps-form">
  66. <FormItem label="取得方式" {...formItemLayout}>
  67. {getFieldDecorator('accessMethod', {
  68. rules: [{ required: true, message: '请选择技术取得的方式!' }],
  69. initialValue: this.stringify(initialData.accessMethod)
  70. })(
  71. <Select placeholder="请选择技术取得的方式">
  72. {accessMethods.map((it) => {
  73. return <Option key={it.id} value={it.id}>{it.text}</Option>
  74. })}
  75. </Select>
  76. )}
  77. </FormItem>
  78. <FormItem label="法律状态" {...formItemLayout}>
  79. {getFieldDecorator('legalStatus', {
  80. rules: [{ required: true, message: '请选择法律保护状态!' }],
  81. initialValue: this.stringify(initialData.legalStatus)
  82. })(
  83. <Select placeholder="请选择法律保护状态">
  84. {legalStatus.map((it) => {
  85. return <Option key={it.id} value={it.id}>{it.text}</Option>
  86. })}
  87. </Select>
  88. )}
  89. </FormItem>
  90. <FormItem label="专利维护" {...formItemLayout}>
  91. {getFieldDecorator('patentMaintenance', {
  92. rules: [{ required: true, message: '请选择专利维护状态!' }],
  93. initialValue: this.stringify(initialData.patentMaintenance)
  94. })(
  95. <Select placeholder="请选择专利维护状态">
  96. {maintenanceStatus.map((it) => {
  97. return <Option key={it.id} value={it.id}>{it.text}</Option>
  98. })}
  99. </Select>
  100. )}
  101. </FormItem>
  102. <FormItem label="保密性" {...formItemLayout}>
  103. {getFieldDecorator('confidentiality', {
  104. rules: [{ required: true, message: '请选择保密性!' }],
  105. initialValue: this.stringify(initialData.confidentiality)
  106. })(
  107. <Select placeholder="请选择保密性">
  108. {confidentialities.map((it) => {
  109. return <Option key={it.id} value={it.id}>{it.text}</Option>
  110. })}
  111. </Select>
  112. )}
  113. </FormItem>
  114. <FormItem label="他人侵权的易判定性" {...formItemLayout}>
  115. {getFieldDecorator('decidability', {
  116. rules: [{ required: true, message: '请选择他人侵权的易判定性!' }],
  117. initialValue: this.stringify(initialData.decidability)
  118. })(
  119. <Select placeholder="请选择他人侵权的易判定性">
  120. {decidabilities.map((it) => {
  121. return <Option key={it.id} value={it.id}>{it.text}</Option>
  122. })}
  123. </Select>
  124. )}
  125. </FormItem>
  126. <FormItem label="是否涉及质押、担保、诉讼等权利限制" {...formItemLayout}>
  127. {getFieldDecorator('hasRightLimitation', {
  128. rules: [{ required: true, message: '请选择是否涉及质押、担保、诉讼等权利限制!' }],
  129. initialValue: this.stringify(initialData.hasRightLimitation)
  130. })(
  131. <Select placeholder="请选择是否涉及质押、担保、诉讼等权利限制">
  132. {rightLimitations.map((it) => {
  133. return <Option key={it.id} value={it.id}>{it.text}</Option>
  134. })}
  135. </Select>
  136. )}
  137. </FormItem>
  138. </Form>
  139. <div className="steps-action">
  140. <Button type="primary" onClick={this.next}>保存,下一步</Button>
  141. <Button style={{ marginLeft: 8 }} onClick={this.prev}>上一步</Button>
  142. </div>
  143. </Spin>
  144. )
  145. },
  146. }));
  147. export default EvaluateStep2;