intellectualDesc.jsx 13 KB

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