intellectualDesc.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  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 != undefined ? id : this.props.data.id,
  21. type: type != undefined ? 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. };
  42. },
  43. componentWillMount() {
  44. let _me = this;
  45. intellectualGetList.map(function (item) {
  46. _me.state.intellectualGetOption.push(
  47. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  48. )
  49. });
  50. catagoryList.map(function (item) {
  51. _me.state.catagoryOption.push(
  52. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  53. )
  54. });
  55. this.loadData();
  56. },
  57. handleSubmit(e) {
  58. e.preventDefault();
  59. this.props.form.validateFields((err, values) => {
  60. if (!err) {
  61. this.props.spinState(true);
  62. $.ajax({
  63. method: "POST",
  64. dataType: "json",
  65. crossDomain: false,
  66. url: globalConfig.context + "/api/user/cognizance/intellectual",
  67. data: {
  68. id: this.props.data.id,
  69. intellectualPropertyNumber: values.intellectualPropertyNumber,
  70. intellectualPropertyName: values.intellectualPropertyName,
  71. catagory: values.catagory,
  72. obtainWay: values.obtainWay,
  73. sortNumber: values.sortNumber,
  74. authorizationNumber: values.authorizationNumber,
  75. authorizationDateFormattedDate: values.authorizationDate._i || this.state.authorizationDateFormattedDate,
  76. propertyRightUrl: this.state.propertyRightUrl
  77. }
  78. }).done(function (data) {
  79. if (!data.error.length) {
  80. message.success('保存成功!');
  81. } else {
  82. message.warning(data.error[0].message);
  83. }
  84. }.bind(this)).always(function () {
  85. this.props.spinState(false);
  86. this.props.clickOk();
  87. this.props.form.resetFields();
  88. }.bind(this));
  89. }
  90. });
  91. },
  92. checkIdcardnum(rule, value, callback) {
  93. if (!/(^\d{15}$)|(^\d{17}(\d|X)$)/.test(value)) {
  94. callback('请输入正确的身份证号!');
  95. } else {
  96. callback();
  97. }
  98. },
  99. componentWillReceiveProps(nextProps) {
  100. if (!this.props.visible && nextProps.visible) {
  101. if (nextProps.data.id) {
  102. this.loadData(nextProps.data.id, nextProps.data.type);
  103. };
  104. this.state.data = {};
  105. this.state.fileList = [];
  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 ? null : moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD')
  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 != 0 ? <p style={{ margin: '10px 0' }}>
  232. {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>}
  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. <Spin spinning={this.state.loading} className='spin-box'>
  279. <Modal maskClosable={false} title="知识产权详情" visible={this.state.visible}
  280. onOk={this.handleOk} onCancel={this.handleCancel}
  281. width='600px'
  282. footer=''
  283. >
  284. <IntellectualDescFrom
  285. visible={this.state.visible}
  286. data={this.props.data}
  287. spinState={this.spinChange}
  288. closeModal={this.handleCancel}
  289. clickOk={this.handleOk} />
  290. </Modal>
  291. </Spin>
  292. </div>
  293. );
  294. },
  295. });
  296. export default intellectualDesc;