intellectualDesc.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. import React from 'react';
  2. import { Icon, Modal, Button, Form, message, Input, Spin, Select, DatePicker, Upload } from 'antd';
  3. import './patent.less';
  4. import { intellectualGetList, catagoryList } from '../../dataDic.js';
  5. import { beforeUploadFile, newDownloadFile } from '../../tools.js';
  6. import ajax from 'jquery/src/ajax/xhr.js'
  7. import $ from 'jquery/src/ajax';
  8. import moment from 'moment';
  9. const IntellectualDescFrom = Form.create()(React.createClass({
  10. loadData(id, type) {
  11. this.props.spinState(true);
  12. $.ajax({
  13. method: "get",
  14. dataType: "json",
  15. crossDomain: false,
  16. url: globalConfig.context + "/api/user/cognizance/intellectualDetail",
  17. data: {
  18. id: id ? id : this.props.data.id,
  19. type: type != undefined && type != null ? type : this.props.data.type
  20. }
  21. }).done((data) => {
  22. if (!data.data) {
  23. if (data.error && data.error.length) {
  24. message.warning(data.error[0].message);
  25. };
  26. this.state.data = {};
  27. } else { this.state.data = data.data };
  28. }).always(function () {
  29. this.props.spinState(false);
  30. }.bind(this));
  31. },
  32. getInitialState() {
  33. return {
  34. loading: false,
  35. intellectualGetOption: [],
  36. catagoryOption: [],
  37. data: {}
  38. };
  39. },
  40. componentWillMount() {
  41. let _me = this;
  42. intellectualGetList.map(function (item) {
  43. _me.state.intellectualGetOption.push(
  44. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  45. )
  46. });
  47. catagoryList.map(function (item) {
  48. _me.state.catagoryOption.push(
  49. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  50. )
  51. });
  52. if (this.props.data.id) {
  53. this.loadData(this.props.data.id, this.props.data.type);
  54. };
  55. },
  56. handleSubmit(e) {
  57. e.preventDefault();
  58. this.props.form.validateFields((err, values) => {
  59. if (!err) {
  60. this.props.spinState(true);
  61. $.ajax({
  62. method: "POST",
  63. dataType: "json",
  64. crossDomain: false,
  65. url: globalConfig.context + "/api/user/cognizance/intellectual",
  66. data: {
  67. id: this.props.data.id,
  68. intellectualPropertyNumber: values.intellectualPropertyNumber,
  69. intellectualPropertyName: values.intellectualPropertyName,
  70. catagory: values.catagory,
  71. obtainWay: values.obtainWay,
  72. sortNumber: values.sortNumber,
  73. authorizationNumber: values.authorizationNumber,
  74. authorizationDateFormattedDate: values.authorizationDate ? values.authorizationDate.format('YYYY-MM-DD') : null,
  75. propertyRightUrl: this.state.propertyRightUrl
  76. }
  77. }).done(function (data) {
  78. if (!data.error.length) {
  79. message.success('保存成功!');
  80. } else {
  81. message.warning(data.error[0].message);
  82. }
  83. }.bind(this)).always(function () {
  84. this.props.spinState(false);
  85. this.props.clickOk();
  86. this.props.form.resetFields();
  87. }.bind(this));
  88. }
  89. });
  90. },
  91. checkIdcardnum(rule, value, callback) {
  92. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  93. callback('请输入正确的身份证号!');
  94. } else {
  95. callback();
  96. }
  97. },
  98. componentWillReceiveProps(nextProps) {
  99. if (!this.props.visible && nextProps.visible) {
  100. if (nextProps.data.id) {
  101. this.loadData(nextProps.data.id, nextProps.data.type);
  102. };
  103. this.state.data = {};
  104. this.state.fileList = [];
  105. this.state.propertyRightUrl = undefined;
  106. };
  107. },
  108. render() {
  109. const FormItem = Form.Item;
  110. const { getFieldDecorator } = this.props.form;
  111. const formItemLayout = {
  112. labelCol: { span: 6 },
  113. wrapperCol: { span: 12 },
  114. };
  115. const _me = this;
  116. const theData = this.state.data;
  117. return (
  118. <Form horizontal onSubmit={this.handleSubmit}>
  119. <FormItem
  120. {...formItemLayout}
  121. label="知识产权编号"
  122. >
  123. {getFieldDecorator('intellectualPropertyNumber', {
  124. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  125. initialValue: theData.intellectualPropertyNumber
  126. })(
  127. <Input placeholder="请输入知识产权编号" />
  128. )}
  129. </FormItem>
  130. <FormItem
  131. {...formItemLayout}
  132. label="知识产权名称"
  133. >
  134. {getFieldDecorator('intellectualPropertyName', {
  135. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  136. initialValue: theData.intellectualPropertyName
  137. })(
  138. <Input placeholder="请输入知识产权名称" />
  139. )}
  140. </FormItem>
  141. <FormItem
  142. {...formItemLayout}
  143. label="排序号"
  144. >
  145. {getFieldDecorator('sortNumber', {
  146. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  147. initialValue: theData.sortNumber
  148. })(
  149. <Input placeholder="请输入排序号" />
  150. )}
  151. </FormItem>
  152. <FormItem
  153. {...formItemLayout}
  154. label="知识产权类型"
  155. >
  156. {getFieldDecorator('catagory', {
  157. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  158. initialValue: theData.catagory
  159. })(
  160. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  161. onChange={(e) => { this.state.catagory = e; }}>
  162. {this.state.catagoryOption}
  163. </Select>
  164. )}
  165. </FormItem>
  166. <FormItem
  167. {...formItemLayout}
  168. label="获得方式"
  169. >
  170. {getFieldDecorator('obtainWay', {
  171. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  172. initialValue: theData.obtainWay
  173. })(
  174. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  175. onChange={(e) => { this.state.obtainWay = e; }}>
  176. {this.state.intellectualGetOption}
  177. </Select>
  178. )}
  179. </FormItem>
  180. <FormItem
  181. {...formItemLayout}
  182. label="授权号"
  183. >
  184. {getFieldDecorator('authorizationNumber', {
  185. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  186. initialValue: theData.authorizationNumber
  187. })(
  188. <Input placeholder="请输入授权号" />
  189. )}
  190. </FormItem>
  191. <FormItem
  192. {...formItemLayout}
  193. label="授权日期"
  194. >
  195. {getFieldDecorator('authorizationDate', {
  196. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  197. initialValue: theData.authorizationDateFormattedDate ? moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD') : null
  198. })(
  199. <DatePicker style={{ width: 200 }}
  200. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  201. )}
  202. </FormItem>
  203. <div>
  204. <Upload
  205. name="ratepay"
  206. action={globalConfig.context + "/api/user/cognizance/uploadPropertyRight"}
  207. data={{ 'sign': 'property_right' }}
  208. beforeUpload={beforeUploadFile}
  209. fileList={this.state.fileList}
  210. onChange={(info) => {
  211. if (info.file.status !== 'uploading') {
  212. // console.log(info.file, info.fileList);
  213. }
  214. if (info.file.status === 'done') {
  215. if (!info.file.response.error.length) {
  216. message.success(`${info.file.name} 文件上传成功!`);
  217. } else {
  218. message.warning(info.file.response.error[0].message);
  219. return;
  220. };
  221. this.state.propertyRightUrl = info.file.response.data;
  222. } else if (info.file.status === 'error') {
  223. message.error(`${info.file.name} 文件上传失败。`);
  224. };
  225. this.setState({ fileList: info.fileList.slice(-1) });
  226. }}
  227. >
  228. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  229. </Upload>
  230. <p style={{ margin: '10px 0' }}>{theData.propertyRightUrl ? <a onClick={newDownloadFile.bind(null, theData.id, 'property_right', '/api/user/cognizance/downloadPropertyRight', 'downloadPropertyRight')}>{theData.propertyRightDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传知识产权证书!</span>}</p>
  231. {(theData.type && theData.type != 0) ? <p style={{ margin: '10px 0' }}>
  232. {theData.manuscript ? <a onClick={newDownloadFile.bind(null, theData.id, 'manuscript', '/api/user/cognizance/downloadManuscript', theData.type)}>稿件下载</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传稿件!</span>}
  233. </p> : <span></span>}
  234. </div>
  235. <FormItem>
  236. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  237. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  238. </FormItem>
  239. </Form >
  240. );
  241. },
  242. }));
  243. const intellectualDesc = React.createClass({
  244. getInitialState() {
  245. return {
  246. visible: false,
  247. loading: false
  248. };
  249. },
  250. componentWillReceiveProps(nextProps) {
  251. this.state.visible = nextProps.showDesc
  252. },
  253. showModal() {
  254. this.setState({
  255. visible: true,
  256. });
  257. },
  258. handleOk() {
  259. this.setState({
  260. visible: false,
  261. });
  262. this.props.closeDesc(false, true);
  263. },
  264. handleCancel(e) {
  265. this.setState({
  266. visible: false,
  267. });
  268. this.props.closeDesc(false);
  269. },
  270. spinChange(e) {
  271. this.setState({
  272. loading: e
  273. });
  274. },
  275. render() {
  276. return (
  277. <div className="patent-addNew">
  278. <Modal maskClosable={false} title="知识产权详情" visible={this.state.visible}
  279. onOk={this.handleOk} onCancel={this.handleCancel}
  280. width='600px'
  281. footer=''>
  282. <Spin spinning={this.state.loading} className='spin-box'>
  283. <IntellectualDescFrom
  284. visible={this.state.visible}
  285. data={this.props.data}
  286. spinState={this.spinChange}
  287. closeModal={this.handleCancel}
  288. clickOk={this.handleOk} />
  289. </Spin>
  290. </Modal>
  291. </div>
  292. );
  293. },
  294. });
  295. export default intellectualDesc;