intellectualDesc.jsx 14 KB

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