intellectualDesc.jsx 14 KB

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