comPatentChange.jsx 20 KB

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