intellectualDesc.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. };
  106. },
  107. render() {
  108. const FormItem = Form.Item;
  109. const { getFieldDecorator } = this.props.form;
  110. const formItemLayout = {
  111. labelCol: { span: 6 },
  112. wrapperCol: { span: 12 },
  113. };
  114. const _me = this;
  115. const theData = this.state.data;
  116. return (
  117. <Form horizontal onSubmit={this.handleSubmit}>
  118. <FormItem
  119. {...formItemLayout}
  120. label="知识产权编号"
  121. >
  122. {getFieldDecorator('intellectualPropertyNumber', {
  123. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  124. initialValue: theData.intellectualPropertyNumber
  125. })(
  126. <Input placeholder="请输入知识产权编号" />
  127. )}
  128. </FormItem>
  129. <FormItem
  130. {...formItemLayout}
  131. label="知识产权名称"
  132. >
  133. {getFieldDecorator('intellectualPropertyName', {
  134. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  135. initialValue: theData.intellectualPropertyName
  136. })(
  137. <Input placeholder="请输入知识产权名称" />
  138. )}
  139. </FormItem>
  140. <FormItem
  141. {...formItemLayout}
  142. label="排序号"
  143. >
  144. {getFieldDecorator('sortNumber', {
  145. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  146. initialValue: theData.sortNumber
  147. })(
  148. <Input placeholder="请输入排序号" />
  149. )}
  150. </FormItem>
  151. <FormItem
  152. {...formItemLayout}
  153. label="知识产权类型"
  154. >
  155. {getFieldDecorator('catagory', {
  156. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  157. initialValue: theData.catagory
  158. })(
  159. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  160. onChange={(e) => { this.state.catagory = e; }}>
  161. {this.state.catagoryOption}
  162. </Select>
  163. )}
  164. </FormItem>
  165. <FormItem
  166. {...formItemLayout}
  167. label="获得方式"
  168. >
  169. {getFieldDecorator('obtainWay', {
  170. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  171. initialValue: theData.obtainWay
  172. })(
  173. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  174. onChange={(e) => { this.state.obtainWay = e; }}>
  175. {this.state.intellectualGetOption}
  176. </Select>
  177. )}
  178. </FormItem>
  179. <FormItem
  180. {...formItemLayout}
  181. label="授权号"
  182. >
  183. {getFieldDecorator('authorizationNumber', {
  184. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  185. initialValue: theData.authorizationNumber
  186. })(
  187. <Input placeholder="请输入授权号" />
  188. )}
  189. </FormItem>
  190. <FormItem
  191. {...formItemLayout}
  192. label="授权日期"
  193. >
  194. {getFieldDecorator('authorizationDate', {
  195. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  196. initialValue: theData.authorizationDateFormattedDate ? moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD') : null
  197. })(
  198. <DatePicker style={{ width: 200 }}
  199. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  200. )}
  201. </FormItem>
  202. <div>
  203. <Upload
  204. name="ratepay"
  205. action={globalConfig.context + "/api/user/cognizance/uploadPropertyRight"}
  206. data={{ 'sign': 'property_right' }}
  207. beforeUpload={beforeUploadFile}
  208. fileList={this.state.fileList}
  209. onChange={(info) => {
  210. if (info.file.status !== 'uploading') {
  211. console.log(info.file, info.fileList);
  212. }
  213. if (info.file.status === 'done') {
  214. if (!info.file.response.error.length) {
  215. message.success(`${info.file.name} 文件上传成功!`);
  216. } else {
  217. message.warning(info.file.response.error[0].message);
  218. return;
  219. };
  220. this.state.propertyRightUrl = info.file.response.data;
  221. } else if (info.file.status === 'error') {
  222. message.error(`${info.file.name} 文件上传失败。`);
  223. };
  224. this.setState({ fileList: info.fileList.slice(-1) });
  225. }}
  226. >
  227. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  228. </Upload>
  229. <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>
  230. {(theData.type && theData.type != 0) ? <p style={{ margin: '10px 0' }}>
  231. {theData.manuscript ? <a onClick={newDownloadFile.bind(null, this.props.data.id, 'manuscript', '/api/user/cognizance/downloadManuscript', this.props.data.type)}>稿件下载</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传稿件!</span>}
  232. </p> : <span></span>}
  233. </div>
  234. <FormItem>
  235. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  236. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  237. </FormItem>
  238. </Form >
  239. );
  240. },
  241. }));
  242. const intellectualDesc = React.createClass({
  243. getInitialState() {
  244. return {
  245. visible: false,
  246. loading: false
  247. };
  248. },
  249. componentWillReceiveProps(nextProps) {
  250. this.state.visible = nextProps.showDesc
  251. },
  252. showModal() {
  253. this.setState({
  254. visible: true,
  255. });
  256. },
  257. handleOk() {
  258. this.setState({
  259. visible: false,
  260. });
  261. this.props.closeDesc(false, true);
  262. },
  263. handleCancel(e) {
  264. this.setState({
  265. visible: false,
  266. });
  267. this.props.closeDesc(false);
  268. },
  269. spinChange(e) {
  270. this.setState({
  271. loading: e
  272. });
  273. },
  274. render() {
  275. return (
  276. <div className="patent-addNew">
  277. <Modal maskClosable={false} title="知识产权详情" visible={this.state.visible}
  278. onOk={this.handleOk} onCancel={this.handleCancel}
  279. width='600px'
  280. footer=''>
  281. <Spin spinning={this.state.loading} className='spin-box'>
  282. <IntellectualDescFrom
  283. visible={this.state.visible}
  284. data={this.props.data}
  285. spinState={this.spinChange}
  286. closeModal={this.handleCancel}
  287. clickOk={this.handleOk} />
  288. </Spin>
  289. </Modal>
  290. </div>
  291. );
  292. },
  293. });
  294. export default intellectualDesc;