intellectualDesc.jsx 14 KB

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