comPatentChange.jsx 20 KB

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