intellectualDesc.jsx 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker } from 'antd';
  3. import './patent.less';
  4. import { intellectualGetList, catagoryList } from '../../dataDic.js';
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. import moment from 'moment';
  8. const IntellectualDescFrom = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. loading: false,
  12. intellectualGetOption: [],
  13. catagoryOption: []
  14. };
  15. },
  16. componentWillMount() {
  17. let _me = this;
  18. intellectualGetList.map(function (item) {
  19. _me.state.intellectualGetOption.push(
  20. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  21. )
  22. });
  23. catagoryList.map(function (item) {
  24. _me.state.catagoryOption.push(
  25. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  26. )
  27. });
  28. },
  29. handleSubmit(e) {
  30. e.preventDefault();
  31. this.props.form.validateFields((err, values) => {
  32. if (!err) {
  33. this.props.spinState(true);
  34. $.ajax({
  35. method: "POST",
  36. dataType: "json",
  37. crossDomain: false,
  38. url: globalConfig.context + "/techservice/cognizance/intellectual",
  39. data: {
  40. id:this.props.data.id,
  41. intellectualPropertyNumber: values.intellectualPropertyNumber,
  42. intellectualPropertyName: values.intellectualPropertyName,
  43. catagory: values.catagory,
  44. obtainWay: values.obtainWay,
  45. sortNumber: values.sortNumber,
  46. authorizationNumber: values.authorizationNumber,
  47. authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate
  48. }
  49. }).done(function (data) {
  50. if (!data.error.length) {
  51. message.success('保存成功!');
  52. } else {
  53. message.warning(data.error[0].message);
  54. }
  55. }.bind(this)).always(function () {
  56. this.props.spinState(false);
  57. this.props.closeModal();
  58. this.props.form.resetFields();
  59. }.bind(this));
  60. }
  61. });
  62. },
  63. checkIdcardnum(rule, value, callback) {
  64. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  65. callback('请输入正确的身份证号!');
  66. } else {
  67. callback();
  68. }
  69. },
  70. render() {
  71. const FormItem = Form.Item;
  72. const { getFieldDecorator } = this.props.form;
  73. const formItemLayout = {
  74. labelCol: { span: 6 },
  75. wrapperCol: { span: 12 },
  76. };
  77. const _me = this;
  78. return (
  79. <Form horizontal onSubmit={this.handleSubmit}>
  80. <FormItem
  81. {...formItemLayout}
  82. label="知识产权编号"
  83. >
  84. {getFieldDecorator('intellectualPropertyNumber', {
  85. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  86. initialValue: this.props.data.intellectualPropertyNumber
  87. })(
  88. <Input placeholder="请输入知识产权编号" />
  89. )}
  90. </FormItem>
  91. <FormItem
  92. {...formItemLayout}
  93. label="知识产权名称"
  94. >
  95. {getFieldDecorator('intellectualPropertyName', {
  96. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  97. initialValue: this.props.data.intellectualPropertyName
  98. })(
  99. <Input placeholder="请输入知识产权名称" />
  100. )}
  101. </FormItem>
  102. <FormItem
  103. {...formItemLayout}
  104. label="排序号"
  105. >
  106. {getFieldDecorator('sortNumber', {
  107. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  108. initialValue: this.props.data.sortNumber
  109. })(
  110. <Input placeholder="请输入排序号" />
  111. )}
  112. </FormItem>
  113. <FormItem
  114. {...formItemLayout}
  115. label="知识产权类型"
  116. >
  117. {getFieldDecorator('catagory', {
  118. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  119. initialValue: this.props.data.catagory
  120. })(
  121. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  122. onChange={(e) => { this.state.catagory = e; }}>
  123. {this.state.catagoryOption}
  124. </Select>
  125. )}
  126. </FormItem>
  127. <FormItem
  128. {...formItemLayout}
  129. label="获得方式"
  130. >
  131. {getFieldDecorator('obtainWay', {
  132. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  133. initialValue: this.props.data.obtainWay
  134. })(
  135. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  136. onChange={(e) => { this.state.obtainWay = e; }}>
  137. {this.state.intellectualGetOption}
  138. </Select>
  139. )}
  140. </FormItem>
  141. <FormItem
  142. {...formItemLayout}
  143. label="授权号"
  144. >
  145. {getFieldDecorator('authorizationNumber', {
  146. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  147. initialValue: this.props.data.authorizationNumber
  148. })(
  149. <Input placeholder="请输入授权号" />
  150. )}
  151. </FormItem>
  152. <FormItem
  153. {...formItemLayout}
  154. label="授权日期"
  155. >
  156. {getFieldDecorator('authorizationDate', {
  157. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  158. initialValue: !this.props.data.authorizationDateFormattedDate ? null : moment(this.props.data.authorizationDateFormattedDate, 'YYYY/MM/DD')
  159. })(
  160. <DatePicker style={{ width: 200 }}
  161. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  162. )}
  163. </FormItem>
  164. <FormItem>
  165. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  166. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  167. </FormItem>
  168. </Form >
  169. );
  170. },
  171. }));
  172. const intellectualDesc = React.createClass({
  173. getInitialState() {
  174. return {
  175. visible: false,
  176. loading: false
  177. };
  178. },
  179. componentWillReceiveProps(nextProps) {
  180. this.state.visible = nextProps.showDesc
  181. },
  182. showModal() {
  183. this.setState({
  184. visible: true,
  185. });
  186. },
  187. handleOk() {
  188. this.setState({
  189. visible: false,
  190. });
  191. this.props.closeDesc(false);
  192. },
  193. handleCancel(e) {
  194. this.setState({
  195. visible: false,
  196. });
  197. this.props.closeDesc(false);
  198. },
  199. spinChange(e) {
  200. this.setState({
  201. loading: e
  202. });
  203. },
  204. render() {
  205. return (
  206. <div className="patent-addNew">
  207. <Spin spinning={this.state.loading} className='spin-box'>
  208. <Modal title="知识产权详情" visible={this.state.visible}
  209. onOk={this.handleOk} onCancel={this.handleCancel}
  210. width='600px'
  211. footer=''
  212. >
  213. <IntellectualDescFrom data={this.props.data} spinState={this.spinChange} closeModal={this.handleCancel} />
  214. </Modal>
  215. </Spin>
  216. </div>
  217. );
  218. },
  219. });
  220. export default intellectualDesc;