intellectualDesc.jsx 13 KB

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