intellectualDesc.jsx 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker } from 'antd';
  3. import { intellectualGetList, catagoryList } from '../../../../dataDic.js';
  4. import ajax from 'jquery/src/ajax/xhr.js'
  5. import $ from 'jquery/src/ajax';
  6. import moment from 'moment';
  7. const IntellectualDescFrom = Form.create()(React.createClass({
  8. getInitialState() {
  9. return {
  10. loading: false,
  11. intellectualGetOption: [],
  12. catagoryOption: []
  13. };
  14. },
  15. componentWillMount() {
  16. let _me = this;
  17. intellectualGetList.map(function (item) {
  18. _me.state.intellectualGetOption.push(
  19. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  20. )
  21. });
  22. catagoryList.map(function (item) {
  23. _me.state.catagoryOption.push(
  24. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  25. )
  26. });
  27. },
  28. handleSubmit(e) {
  29. e.preventDefault();
  30. this.props.form.validateFields((err, values) => {
  31. if (!err) {
  32. this.props.spinState(true);
  33. $.ajax({
  34. method: "POST",
  35. dataType: "json",
  36. crossDomain: false,
  37. url: globalConfig.context + "/techservice/cognizance/intellectual",
  38. data: {
  39. id: this.props.data.id,
  40. intellectualPropertyNumber: values.intellectualPropertyNumber,
  41. intellectualPropertyName: values.intellectualPropertyName,
  42. catagory: values.catagory,
  43. obtainWay: values.obtainWay,
  44. sortNumber: values.sortNumber,
  45. authorizationNumber: values.authorizationNumber,
  46. authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate,
  47. propertyRightUrl: this.state.propertyRightUrl
  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. <div className="hrSituation-roster">
  165. <Upload
  166. name="ratepay"
  167. action={globalConfig.context + "/techservice/cognizance/upload"}
  168. data={{ 'sign': this.props.year + 'propertyRight' }}
  169. beforeUpload={beforeUploadFile}
  170. onChange={(info) => {
  171. if (info.file.status !== 'uploading') {
  172. console.log(info.file, info.fileList);
  173. }
  174. if (info.file.status === 'done') {
  175. message.success(`${info.file.name} 文件上传成功!`);
  176. this.state.propertyRightUrl = info.file.response.data;
  177. } else if (info.file.status === 'error') {
  178. message.error(`${info.file.name} 文件上传失败。`);
  179. }
  180. }}
  181. >
  182. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  183. </Upload>
  184. </div>
  185. <FormItem>
  186. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  187. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  188. </FormItem>
  189. </Form >
  190. );
  191. },
  192. }));
  193. const intellectualDesc = React.createClass({
  194. getInitialState() {
  195. return {
  196. visible: false,
  197. loading: false
  198. };
  199. },
  200. componentWillReceiveProps(nextProps) {
  201. this.state.visible = nextProps.showDesc
  202. },
  203. showModal() {
  204. this.setState({
  205. visible: true,
  206. });
  207. },
  208. handleOk() {
  209. this.setState({
  210. visible: false,
  211. });
  212. this.props.closeDesc(false);
  213. },
  214. handleCancel(e) {
  215. this.setState({
  216. visible: false,
  217. });
  218. this.props.closeDesc(false);
  219. },
  220. spinChange(e) {
  221. this.setState({
  222. loading: e
  223. });
  224. },
  225. render() {
  226. return (
  227. <div className="patent-addNew">
  228. <Spin spinning={this.state.loading} className='spin-box'>
  229. <Modal title="知识产权详情" visible={this.state.visible}
  230. onOk={this.handleOk} onCancel={this.handleCancel}
  231. width='600px'
  232. footer=''
  233. >
  234. <IntellectualDescFrom data={this.props.data} spinState={this.spinChange} closeModal={this.handleCancel} />
  235. </Modal>
  236. </Spin>
  237. </div>
  238. );
  239. },
  240. });
  241. export default intellectualDesc;