comPatentChange.jsx 19 KB

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