comPatentChange.jsx 19 KB

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