comPatentChange.jsx 20 KB

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