intellectualDesc.jsx 13 KB

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