intellectualDesc.jsx 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. propertyRightUrl: this.state.propertyRightUrl
  49. }
  50. }).done(function (data) {
  51. if (!data.error.length) {
  52. message.success('保存成功!');
  53. } else {
  54. message.warning(data.error[0].message);
  55. }
  56. }.bind(this)).always(function () {
  57. this.props.spinState(false);
  58. this.props.closeModal();
  59. this.props.form.resetFields();
  60. }.bind(this));
  61. }
  62. });
  63. },
  64. checkIdcardnum(rule, value, callback) {
  65. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  66. callback('请输入正确的身份证号!');
  67. } else {
  68. callback();
  69. }
  70. },
  71. render() {
  72. const FormItem = Form.Item;
  73. const { getFieldDecorator } = this.props.form;
  74. const formItemLayout = {
  75. labelCol: { span: 6 },
  76. wrapperCol: { span: 12 },
  77. };
  78. const _me = this;
  79. return (
  80. <Form horizontal onSubmit={this.handleSubmit}>
  81. <FormItem
  82. {...formItemLayout}
  83. label="知识产权编号"
  84. >
  85. {getFieldDecorator('intellectualPropertyNumber', {
  86. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  87. initialValue: this.props.data.intellectualPropertyNumber
  88. })(
  89. <Input placeholder="请输入知识产权编号" />
  90. )}
  91. </FormItem>
  92. <FormItem
  93. {...formItemLayout}
  94. label="知识产权名称"
  95. >
  96. {getFieldDecorator('intellectualPropertyName', {
  97. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  98. initialValue: this.props.data.intellectualPropertyName
  99. })(
  100. <Input placeholder="请输入知识产权名称" />
  101. )}
  102. </FormItem>
  103. <FormItem
  104. {...formItemLayout}
  105. label="排序号"
  106. >
  107. {getFieldDecorator('sortNumber', {
  108. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  109. initialValue: this.props.data.sortNumber
  110. })(
  111. <Input placeholder="请输入排序号" />
  112. )}
  113. </FormItem>
  114. <FormItem
  115. {...formItemLayout}
  116. label="知识产权类型"
  117. >
  118. {getFieldDecorator('catagory', {
  119. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  120. initialValue: this.props.data.catagory
  121. })(
  122. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  123. onChange={(e) => { this.state.catagory = e; }}>
  124. {this.state.catagoryOption}
  125. </Select>
  126. )}
  127. </FormItem>
  128. <FormItem
  129. {...formItemLayout}
  130. label="获得方式"
  131. >
  132. {getFieldDecorator('obtainWay', {
  133. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  134. initialValue: this.props.data.obtainWay
  135. })(
  136. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  137. onChange={(e) => { this.state.obtainWay = e; }}>
  138. {this.state.intellectualGetOption}
  139. </Select>
  140. )}
  141. </FormItem>
  142. <FormItem
  143. {...formItemLayout}
  144. label="授权号"
  145. >
  146. {getFieldDecorator('authorizationNumber', {
  147. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  148. initialValue: this.props.data.authorizationNumber
  149. })(
  150. <Input placeholder="请输入授权号" />
  151. )}
  152. </FormItem>
  153. <FormItem
  154. {...formItemLayout}
  155. label="授权日期"
  156. >
  157. {getFieldDecorator('authorizationDate', {
  158. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  159. initialValue: !this.props.data.authorizationDateFormattedDate ? null : moment(this.props.data.authorizationDateFormattedDate, 'YYYY/MM/DD')
  160. })(
  161. <DatePicker style={{ width: 200 }}
  162. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  163. )}
  164. </FormItem>
  165. <div className="hrSituation-roster">
  166. <Upload
  167. name="ratepay"
  168. action={globalConfig.context + "/techservice/cognizance/upload"}
  169. data={{ 'sign': this.props.year + 'propertyRight' }}
  170. beforeUpload={beforeUploadFile}
  171. onChange={(info) => {
  172. if (info.file.status !== 'uploading') {
  173. console.log(info.file, info.fileList);
  174. }
  175. if (info.file.status === 'done') {
  176. message.success(`${info.file.name} 文件上传成功!`);
  177. this.state.propertyRightUrl = info.file.response.data;
  178. } else if (info.file.status === 'error') {
  179. message.error(`${info.file.name} 文件上传失败。`);
  180. }
  181. }}
  182. >
  183. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  184. </Upload>
  185. </div>
  186. <FormItem>
  187. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  188. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  189. </FormItem>
  190. </Form >
  191. );
  192. },
  193. }));
  194. const intellectualDesc = React.createClass({
  195. getInitialState() {
  196. return {
  197. visible: false,
  198. loading: false
  199. };
  200. },
  201. componentWillReceiveProps(nextProps) {
  202. this.state.visible = nextProps.showDesc
  203. },
  204. showModal() {
  205. this.setState({
  206. visible: true,
  207. });
  208. },
  209. handleOk() {
  210. this.setState({
  211. visible: false,
  212. });
  213. this.props.closeDesc(false);
  214. },
  215. handleCancel(e) {
  216. this.setState({
  217. visible: false,
  218. });
  219. this.props.closeDesc(false);
  220. },
  221. spinChange(e) {
  222. this.setState({
  223. loading: e
  224. });
  225. },
  226. render() {
  227. return (
  228. <div className="patent-addNew">
  229. <Spin spinning={this.state.loading} className='spin-box'>
  230. <Modal title="知识产权详情" visible={this.state.visible}
  231. onOk={this.handleOk} onCancel={this.handleCancel}
  232. width='600px'
  233. footer=''
  234. >
  235. <IntellectualDescFrom data={this.props.data} spinState={this.spinChange} closeModal={this.handleCancel} />
  236. </Modal>
  237. </Spin>
  238. </div>
  239. );
  240. },
  241. });
  242. export default intellectualDesc;