intellectualDesc.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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.setState({
  11. loading: true
  12. });
  13. $.ajax({
  14. method: "get",
  15. dataType: "json",
  16. crossDomain: false,
  17. url: globalConfig.context + "/api/admin/intellectualDetail",
  18. data: {
  19. id: id ? id : this.props.data.id,
  20. type: type != undefined && type != null ? type : this.props.data.type
  21. }
  22. }).done((data) => {
  23. if (!data.data) {
  24. if (data.error && data.error.length) {
  25. message.warning(data.error[0].message);
  26. };
  27. this.state.data = {};
  28. } else { this.state.data = data.data };
  29. }).always(function () {
  30. this.setState({
  31. loading: false
  32. });
  33. }.bind(this));
  34. },
  35. getInitialState() {
  36. return {
  37. loading: false,
  38. intellectualGetOption: [],
  39. catagoryOption: [],
  40. data: {}
  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. if (this.props.data.id && this.props.data.type != undefined && this.props.data.type != null) {
  56. this.loadData();
  57. };
  58. },
  59. handleSubmit(e) {
  60. e.preventDefault();
  61. this.props.form.validateFields((err, values) => {
  62. if (!err) {
  63. this.props.spinState(true);
  64. $.ajax({
  65. method: "POST",
  66. dataType: "json",
  67. crossDomain: false,
  68. url: globalConfig.context + "/api/admin/intellectual",
  69. data: {
  70. id: this.props.data.id,
  71. uid: this.props.uid,
  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. componentWillReceiveProps(nextProps) {
  96. if (!this.props.visible && nextProps.visible) {
  97. if (nextProps.data.id) {
  98. this.loadData(nextProps.data.id, nextProps.data.type);
  99. };
  100. this.state.data = {};
  101. this.state.fileList = [];
  102. };
  103. },
  104. render() {
  105. const FormItem = Form.Item;
  106. const { getFieldDecorator } = this.props.form;
  107. const formItemLayout = {
  108. labelCol: { span: 6 },
  109. wrapperCol: { span: 12 },
  110. };
  111. const _me = this;
  112. const theData = this.state.data;
  113. return (
  114. <Form horizontal onSubmit={this.handleSubmit}>
  115. <FormItem
  116. {...formItemLayout}
  117. label="知识产权编号"
  118. >
  119. {getFieldDecorator('intellectualPropertyNumber', {
  120. rules: [{ required: true, message: '请输入,知识产权编号不能为空!' }],
  121. initialValue: theData.intellectualPropertyNumber
  122. })(
  123. <Input placeholder="请输入知识产权编号" />
  124. )}
  125. </FormItem>
  126. <FormItem
  127. {...formItemLayout}
  128. label="知识产权名称"
  129. >
  130. {getFieldDecorator('intellectualPropertyName', {
  131. rules: [{ required: true, message: '请输入,知识产权名称不能为空!' }],
  132. initialValue: theData.intellectualPropertyName
  133. })(
  134. <Input placeholder="请输入知识产权名称" />
  135. )}
  136. </FormItem>
  137. <FormItem
  138. {...formItemLayout}
  139. label="排序号"
  140. >
  141. {getFieldDecorator('sortNumber', {
  142. rules: [{ required: true, message: '请输入,排序号不能为空!' }],
  143. initialValue: theData.sortNumber
  144. })(
  145. <Input placeholder="请输入排序号" />
  146. )}
  147. </FormItem>
  148. <FormItem
  149. {...formItemLayout}
  150. label="知识产权类型"
  151. >
  152. {getFieldDecorator('catagory', {
  153. rules: [{ required: true, message: '请选择,知识产权类型不能为空!' }],
  154. initialValue: theData.catagory
  155. })(
  156. <Select placeholder="请选择知识产权类型" style={{ width: 200 }}
  157. onChange={(e) => { this.state.catagory = e; }}>
  158. {this.state.catagoryOption}
  159. </Select>
  160. )}
  161. </FormItem>
  162. <FormItem
  163. {...formItemLayout}
  164. label="获得方式"
  165. >
  166. {getFieldDecorator('obtainWay', {
  167. rules: [{ required: true, message: '请选择,获得方式不能为空!' }],
  168. initialValue: theData.obtainWay
  169. })(
  170. <Select placeholder="请选择获得方式" style={{ width: 200 }}
  171. onChange={(e) => { this.state.obtainWay = e; }}>
  172. {this.state.intellectualGetOption}
  173. </Select>
  174. )}
  175. </FormItem>
  176. <FormItem
  177. {...formItemLayout}
  178. label="授权号"
  179. >
  180. {getFieldDecorator('authorizationNumber', {
  181. rules: [{ required: true, message: '请输入,授权号不能为空!' }],
  182. initialValue: theData.authorizationNumber
  183. })(
  184. <Input placeholder="请输入授权号" />
  185. )}
  186. </FormItem>
  187. <FormItem
  188. {...formItemLayout}
  189. label="授权日期"
  190. >
  191. {getFieldDecorator('authorizationDate', {
  192. rules: [{ type: 'object', required: true, message: '请选择,授权日期不能为空!' }],
  193. initialValue: !theData.authorizationDateFormattedDate ? null : moment(theData.authorizationDateFormattedDate, 'YYYY/MM/DD')
  194. })(
  195. <DatePicker style={{ width: 200 }}
  196. onChange={(data, dataString) => { this.state.authorizationDateFormattedDate = dataString }} />
  197. )}
  198. </FormItem>
  199. <div className="hrSituation-roster">
  200. <Upload
  201. name="ratepay"
  202. action={globalConfig.context + "/api/admin/uploadPropertyRight"}
  203. data={{ 'sign': 'property_right', 'uid': this.props.uid }}
  204. beforeUpload={beforeUploadFile}
  205. fileList={this.state.fileList}
  206. onChange={(info) => {
  207. if (info.file.status !== 'uploading') {
  208. console.log(info.file, info.fileList);
  209. }
  210. if (info.file.status === 'done') {
  211. if (!info.file.response.error.length) {
  212. message.success(`${info.file.name} 文件上传成功!`);
  213. } else {
  214. message.warning(info.file.response.error[0].message);
  215. return;
  216. };
  217. this.state.propertyRightUrl = info.file.response.data;
  218. } else if (info.file.status === 'error') {
  219. message.error(`${info.file.name} 文件上传失败。`);
  220. };
  221. this.setState({ fileList: info.fileList.slice(-1) });
  222. }}
  223. >
  224. <Button><Icon type="upload" /> 上传知识产权证书 </Button>
  225. </Upload>
  226. <p style={{ margin: '10px 0' }}>
  227. {theData.propertyRightUrl ?
  228. <span className="download-file">
  229. <a onClick={newDownloadFile.bind(null, this.props.data.id, 'property_right', '/api/admin/downloadPropertyRight')}>{theData.propertyRightDownloadFileName}</a>
  230. <a onClick={() => { var newTab = window.open('about:blank'); getPreview(theData.id, 'intellectualProperty', 'property_right', function (data) {
  231. newTab.location.href = data;
  232. });
  233. }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
  234. </span>
  235. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传知识产权证书!</span>}
  236. </p>
  237. {theData.type != 0 ? <p style={{ margin: '10px 0' }}>
  238. {theData.manuscript ?
  239. <span className="download-file">
  240. <a onClick={newDownloadFile.bind(null, this.props.data.id, 'manuscript', '/api/admin/downloadManuscript', this.props.data.type)}>稿件下载</a>
  241. <a onClick={() => {
  242. var newTab = window.open('about:blank'); getPreview(theData.pid, 'intellectualProperty', theData.type == 1 ? 'patent_writing' : 'copyright_apply', function (data) { console.log(data); newTab.location.href = data; });
  243. }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
  244. </span>
  245. : <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. uid={this.props.uid}
  299. data={this.props.data}
  300. spinState={this.spinChange}
  301. closeModal={this.handleCancel}
  302. visible={this.state.visible}
  303. clickOk={this.handleOk} />
  304. </Modal>
  305. </Spin>
  306. </div>
  307. );
  308. },
  309. });
  310. export default intellectualDesc;