comPatentChange.jsx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Input, Select, Button, Row, Col, Table, Form, Upload } from 'antd';
  3. import './comprehensive.less';
  4. import ajax from 'jquery/src/ajax/xhr.js';
  5. import $ from 'jquery/src/ajax';
  6. import moment from 'moment';
  7. import { copyrightStateList } from '../../../dataDic.js';
  8. import { getCopyrightState, getTime, copyrightDownloadFile, beforeUploadFile, getInUrgentTime } from '../../../tools.js';
  9. const CopyrightDescForm = Form.create()(React.createClass({
  10. getInitialState() {
  11. return {
  12. visible: false,
  13. loading: false,
  14. stateOption: [],
  15. stateTable: [],
  16. contactsOption: [],
  17. stateColumns: [{
  18. title: '申请状态',
  19. dataIndex: 'status',
  20. key: 'status',
  21. render: (text) => { return getCopyrightState(text) }
  22. }, {
  23. title: '处理时间',
  24. dataIndex: 'recordTimeFormattedDate',
  25. key: 'recordTimeFormattedDate',
  26. }, {
  27. title: '负责人',
  28. dataIndex: 'principal',
  29. key: 'principal',
  30. }, {
  31. title: '操作人',
  32. dataIndex: 'operator',
  33. key: 'operator',
  34. }, {
  35. title: '备注',
  36. dataIndex: 'comment',
  37. key: 'comment',
  38. }]
  39. };
  40. },
  41. componentWillMount() {
  42. let _me = this;
  43. copyrightStateList.map(function (item) {
  44. _me.state.stateOption.push(
  45. <Select.Option value={item.value} key={item.key}>{item.key}</Select.Option>
  46. )
  47. });
  48. this.loadData();
  49. },
  50. loadData(id) {
  51. this.setState({
  52. loading: true
  53. });
  54. $.when($.ajax({
  55. method: "get",
  56. dataType: "json",
  57. crossDomain: false,
  58. cache: false,
  59. url: globalConfig.context + "/api/user/copyright/logs",
  60. data: {
  61. id: id || this.props.data.id
  62. }
  63. }), $.ajax({
  64. method: "get",
  65. dataType: "json",
  66. crossDomain: false,
  67. cache: false,
  68. url: globalConfig.context + "/api/user/cognizance/getContacts"
  69. }), $.ajax({
  70. method: "get",
  71. dataType: "json",
  72. crossDomain: false,
  73. cache: false,
  74. url: globalConfig.context + "/api/user/copyright/detail",
  75. data: {
  76. id: id || this.props.data.id
  77. }
  78. })).done((data1, data2, data3) => {
  79. let _me = this;
  80. //状态流转table
  81. this.state.stateTable = [];
  82. if (data1[0].error && data1[0].error.length) {
  83. message.warning(data1[0].error[0].message);
  84. } else {
  85. data1[0].data.map(function (item, i) {
  86. _me.state.stateTable.push({
  87. key: i,
  88. recordTimeFormattedDate: item.recordTimeFormattedDate,
  89. status: item.status,
  90. principal: item.principal,
  91. operator: item.operator,
  92. comment: item.comment
  93. });
  94. });
  95. };
  96. //获取联系人
  97. this.state.contactsOption = [];
  98. if (data2[0].error && data2[0].error.length) {
  99. message.warning(data2[0].error[0].message);
  100. } else {
  101. for (let item in data2[0].data) {
  102. let theData = data2[0].data[item];
  103. _me.state.contactsOption.push(
  104. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  105. );
  106. };
  107. };
  108. //获取详细数据
  109. if (!data3[0].data && data3[0].error && data3[0].error.length) {
  110. message.warning(data3[0].error[0].message);
  111. } else {
  112. let detailData = data3[0].data;
  113. this.setState({
  114. id: detailData.id,
  115. province: detailData.province,
  116. unitName: detailData.unitName,
  117. serialNumber: detailData.serialNumber,
  118. createTime: detailData.createTime,
  119. acceptTime: detailData.acceptTime,
  120. principal: detailData.principal,
  121. contact: detailData.contact,
  122. copyrightName: detailData.copyrightName,
  123. copyrightNumber: detailData.copyrightNumber,
  124. status: detailData.status,
  125. comment: detailData.comment,
  126. copyrightInfo: detailData.copyrightInfo,
  127. workIssue: detailData.workIssue,
  128. outsource: detailData.outsource,
  129. inUrgent: detailData.inUrgent,
  130. authorizedDate: detailData.authorizedDate,
  131. fisrtContact: detailData.fisrtContact,
  132. secondContact: detailData.secondContact,
  133. thirdContact: detailData.thirdContact,
  134. city: detailData.city,
  135. area: detailData.area,
  136. postcode: detailData.postcode,
  137. certificateUrl: detailData.certificateUrl,
  138. applicationUrl: detailData.applicationUrl,
  139. certificateUrlDownloadFileName: detailData.certificateUrlDownloadFileName,
  140. applicationUrlDownloadFileName: detailData.applicationUrlDownloadFileName,
  141. authorizedDateFormattedDate: detailData.authorizedDateFormattedDate,
  142. createTimeFormattedDate: detailData.createTimeFormattedDate,
  143. acceptTimeFormattedDate: detailData.acceptTimeFormattedDate,
  144. expectTime: [detailData.acceptTime, detailData.inUrgent]
  145. });
  146. };
  147. }).always(function () {
  148. this.setState({
  149. loading: false
  150. });
  151. }.bind(this));
  152. },
  153. componentWillReceiveProps(nextProps) {
  154. if (!this.props.visible && nextProps.visible) {
  155. this.loadData(nextProps.data.id);
  156. this.state.fileList_copyright_apply = [];
  157. this.state.fileList_copyright_auth = [];
  158. };
  159. },
  160. handleSubmit(e) {
  161. e.preventDefault();
  162. this.props.form.validateFields((err, values) => {
  163. if (!err) {
  164. this.props.spinState(true);
  165. $.ajax({
  166. method: "POST",
  167. dataType: "json",
  168. crossDomain: false,
  169. url: globalConfig.context + "/api/user/copyright/modify",
  170. data: {
  171. "id": this.props.data.id,
  172. "contact": values.contact, // 联系人, 1,2,3
  173. "copyrightInfo": values.copyrightInfo, // 软著简介,size 0-255
  174. "copyrightName": values.copyrightName, // 软著名称, size 0-60
  175. //"copyrightNumber": values.copyrightNumber,
  176. //"outsource": values.outsource, // 外包公司, size 0-60
  177. //"workIssue": values.workIssue, // 派单信息, size 0-128
  178. "inUrgent": values.inUrgent, // 加急天数,
  179. //"status": values.status, // 状态
  180. //"comment": values.comment, // 备注 size 0-128
  181. //"recordTime": values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined, // 状态修改时间 yyyy-MM-dd HH:mm:ss
  182. //"principal": values.principal, // 负责人id
  183. }
  184. }).done(function (data) {
  185. if (!data.error.length) {
  186. message.success('保存成功!');
  187. this.props.clickOk();
  188. this.props.form.resetFields();
  189. this.props.spinState(false);
  190. } else {
  191. message.warning(data.error[0].message);
  192. this.props.spinState(false);
  193. }
  194. }.bind(this));
  195. }
  196. });
  197. },
  198. render() {
  199. const FormItem = Form.Item;
  200. const { getFieldDecorator } = this.props.form;
  201. const theData = this.state;
  202. const formItemLayout = {
  203. labelCol: { span: 8 },
  204. wrapperCol: { span: 16 },
  205. };
  206. const _me = this;
  207. return (
  208. <Form onSubmit={this.handleSubmit} id="CopyrightDesc-form">
  209. <div className="clearfix">
  210. <FormItem className="half-item"
  211. {...formItemLayout}
  212. label="公司名称" >
  213. <span>{theData.unitName}</span>
  214. </FormItem>
  215. <FormItem className="half-item"
  216. {...formItemLayout}
  217. label="组织机构代码" >
  218. <span>{theData.unitNumber}</span>
  219. </FormItem>
  220. </div>
  221. <div className="clearfix">
  222. <FormItem className="half-item"
  223. {...formItemLayout}
  224. label="公司地址" >
  225. <span>{theData.postalAddress}</span>
  226. </FormItem>
  227. <FormItem className="half-item"
  228. {...formItemLayout}
  229. label="联系人" >
  230. {getFieldDecorator('contact', {
  231. rules: [{ required: true, message: '此项为必填项!' }],
  232. initialValue: theData.contact
  233. })(
  234. <Select
  235. style={{ display: 'inline-block', width: '200px' }}
  236. placeholder='选择一个联系人'>
  237. {this.state.contactsOption}
  238. </Select>
  239. )}
  240. </FormItem>
  241. </div>
  242. <Row className="express-desc-row">
  243. <Col span={4}>编号</Col>
  244. <Col span={8}>{theData.serialNumber}</Col>
  245. <Col span={4}>软著名称</Col>
  246. <Col span={8}>
  247. {getFieldDecorator('copyrightName', {
  248. initialValue: theData.copyrightName
  249. })(
  250. <Input placeholder="请输入软著名称" />
  251. )}
  252. </Col>
  253. </Row>
  254. <Row className="express-desc-row">
  255. <Col span={4}>软著编号</Col>
  256. <Col span={8}>{theData.copyrightNumber}</Col>
  257. </Row>
  258. <Row className="express-desc-row">
  259. <Col span={4}>软著简介</Col>
  260. <Col span={16}>
  261. {getFieldDecorator('copyrightInfo', {
  262. initialValue: theData.copyrightInfo
  263. })(
  264. <Input type="textarea"
  265. placeholder="多行输入"
  266. rows={6} />
  267. )}
  268. </Col>
  269. </Row>
  270. <Row className="express-desc-row">
  271. <Col span={4}>派单详情</Col>
  272. <Col span={16}>{theData.workIssue}</Col>
  273. </Row>
  274. <Row className="express-desc-row">
  275. <Col span={4}>加急天数</Col>
  276. <Col span={8}>
  277. {(() => {
  278. switch (theData.inUrgent) {
  279. case 0:
  280. return '不加急(45个工作日)';
  281. case 3:
  282. return '3个工作日';
  283. case 5:
  284. return '5个工作日';
  285. case 10:
  286. return '6-10个工作日';
  287. case 15:
  288. return '11-15个工作日';
  289. case 20:
  290. return '16-20个工作日';
  291. case 25:
  292. return '21-25个工作日';
  293. case 30:
  294. return '26-30个工作日';
  295. case 35:
  296. return '31-35个工作日';
  297. }
  298. })()}
  299. </Col>
  300. </Row>
  301. {theData.authorizedDateFormattedDate ? <Row className="express-desc-row">
  302. <Col span={4}>下证时间</Col>
  303. <Col span={8}>{theData.authorizedDateFormattedDate}</Col>
  304. </Row> :
  305. <Row className="express-desc-row">
  306. <Col span={4}>下证时间(预计)</Col>
  307. <Col span={6}>
  308. {(() => {
  309. if (theData.expectTime && theData.expectTime[0]) {
  310. if (theData.expectTime[1]) {
  311. return getTime(getInUrgentTime(moment(theData.expectTime[0]), theData.expectTime[1]))
  312. } else {
  313. return getTime(getInUrgentTime(moment(theData.expectTime[0]), 45))
  314. };
  315. };
  316. })()}
  317. </Col>
  318. </Row>}
  319. <div className="hrSituation-roster">
  320. <Upload
  321. name="copyright_apply"
  322. action={globalConfig.context + "/api/user/copyright/upload"}
  323. data={{ 'sign': 'copyright_apply', id: this.props.data.id }}
  324. beforeUpload={beforeUploadFile}
  325. fileList={this.state.fileList_copyright_apply}
  326. onChange={(info) => {
  327. if (info.file.status !== 'uploading') {
  328. console.log(info.file, info.fileList);
  329. }
  330. if (info.file.status === 'done') {
  331. if (!info.file.response.error.length) {
  332. message.success(`${info.file.name} 文件上传成功!`);
  333. } else {
  334. message.warning(info.file.response.error[0].message);
  335. return;
  336. };
  337. this.state.copyrightApplyUrl = info.file.response.data;
  338. } else if (info.file.status === 'error') {
  339. message.error(`${info.file.name} 文件上传失败。`);
  340. };
  341. this.setState({ fileList_copyright_apply: info.fileList.slice(-1) });
  342. }}
  343. >
  344. <Button><Icon type="upload" /> 上传软著申请书 </Button>
  345. </Upload>
  346. <p style={{ margin: '10px 0' }}>{theData.applicationUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_apply', '/api/user/copyright/download')}>软著申请书</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  347. </div>
  348. <div className="hrSituation-roster">
  349. <Upload
  350. name="copyright_auth"
  351. action={globalConfig.context + "/api/user/copyright/upload"}
  352. data={{ 'sign': 'copyright_auth', id: this.props.data.id }}
  353. beforeUpload={beforeUploadFile}
  354. fileList={this.state.fileList_copyright_auth}
  355. onChange={(info) => {
  356. if (info.file.status !== 'uploading') {
  357. console.log(info.file, info.fileList);
  358. }
  359. if (info.file.status === 'done') {
  360. if (!info.file.response.error.length) {
  361. message.success(`${info.file.name} 文件上传成功!`);
  362. } else {
  363. message.warning(info.file.response.error[0].message);
  364. return;
  365. };
  366. this.state.copyrightAuthUrl = info.file.response.data;
  367. } else if (info.file.status === 'error') {
  368. message.error(`${info.file.name} 文件上传失败。`);
  369. };
  370. this.setState({ fileList_copyright_auth: info.fileList.slice(-1) });
  371. }}
  372. >
  373. <Button><Icon type="upload" /> 上传软著证书 </Button>
  374. </Upload>
  375. <p style={{ margin: '10px 0' }}>{theData.certificateUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_auth', '/api/user/copyright/download')}>软著证书</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  376. </div>
  377. <p>状态流转记录: </p>
  378. <Table style={{ margin: '10px 0' }}
  379. pagination={false}
  380. dataSource={this.state.stateTable}
  381. columns={this.state.stateColumns} />
  382. <FormItem style={{ marginTop: '20px' }}>
  383. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  384. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  385. </FormItem>
  386. </Form>
  387. );
  388. }
  389. }));
  390. const CopyrightDesc = React.createClass({
  391. getInitialState() {
  392. return {
  393. visible: false,
  394. loading: false
  395. };
  396. },
  397. componentWillReceiveProps(nextProps) {
  398. this.state.visible = nextProps.showDesc
  399. },
  400. showModal() {
  401. this.setState({
  402. visible: true,
  403. });
  404. },
  405. handleOk() {
  406. this.setState({
  407. visible: false,
  408. });
  409. this.props.closeDesc(false, true);
  410. },
  411. handleCancel(e) {
  412. this.setState({
  413. visible: false,
  414. });
  415. this.props.closeDesc(false);
  416. },
  417. spinChange(e) {
  418. this.setState({
  419. loading: e
  420. });
  421. },
  422. render() {
  423. return (
  424. <div className="patent-addNew">
  425. <Spin spinning={this.state.loading} className='spin-box'>
  426. <Modal maskClosable={false} title="软著详情" visible={this.state.visible}
  427. onOk={this.handleOk} onCancel={this.handleCancel}
  428. width='800px'
  429. footer=''
  430. >
  431. <CopyrightDescForm
  432. visible={this.state.visible}
  433. authorOption={this.props.authorOption}
  434. data={this.props.data}
  435. spinState={this.spinChange}
  436. closeModal={this.handleCancel}
  437. clickOk={this.handleOk} />
  438. </Modal>
  439. </Spin>
  440. </div>
  441. );
  442. }
  443. });
  444. export default CopyrightDesc;