intellectualDesc.jsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. 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. 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)) });
  228. }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
  229. </span>
  230. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传知识产权证书!</span>}
  231. </p>
  232. {theData.type != 0 ? <p style={{ margin: '10px 0' }}>
  233. {theData.manuscript ?
  234. <span className="download-file">
  235. <a onClick={newDownloadFile.bind(null, this.props.data.id, 'manuscript', '/api/admin/downloadManuscript', this.props.data.type)}>稿件下载</a>
  236. <a onClick={() => {
  237. 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)) });
  238. }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
  239. </span>
  240. : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传稿件!</span>}
  241. </p> : <span></span>}
  242. </div>
  243. <FormItem>
  244. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  245. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  246. </FormItem>
  247. </Form >
  248. );
  249. },
  250. }));
  251. const intellectualDesc = React.createClass({
  252. getInitialState() {
  253. return {
  254. visible: false,
  255. loading: false
  256. };
  257. },
  258. componentWillReceiveProps(nextProps) {
  259. this.state.visible = nextProps.showDesc
  260. },
  261. showModal() {
  262. this.setState({
  263. visible: true,
  264. });
  265. },
  266. handleOk() {
  267. this.setState({
  268. visible: false,
  269. });
  270. this.props.closeDesc(false, true);
  271. },
  272. handleCancel(e) {
  273. this.setState({
  274. visible: false,
  275. });
  276. this.props.closeDesc(false);
  277. },
  278. spinChange(e) {
  279. this.setState({
  280. loading: e
  281. });
  282. },
  283. render() {
  284. return (
  285. <div className="patent-addNew">
  286. <Spin spinning={this.state.loading} className='spin-box'>
  287. <Modal title="知识产权详情" visible={this.state.visible}
  288. onOk={this.handleOk} onCancel={this.handleCancel}
  289. width='600px'
  290. footer=''
  291. >
  292. <IntellectualDescFrom
  293. uid={this.props.uid}
  294. data={this.props.data}
  295. spinState={this.spinChange}
  296. closeModal={this.handleCancel}
  297. visible={this.state.visible}
  298. clickOk={this.handleOk} />
  299. </Modal>
  300. </Spin>
  301. </div>
  302. );
  303. },
  304. });
  305. export default intellectualDesc;