comPatentChange.jsx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. import React from 'react';
  2. import { Icon, Modal, message, Spin, Input, Select, DatePicker, 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. if (data1[0].error && data1[0].error.length) {
  82. message.warning(data1[0].error[0].message);
  83. return;
  84. };
  85. this.state.stateTable = [];
  86. data1[0].data.map(function (item, i) {
  87. _me.state.stateTable.push({
  88. key: i,
  89. recordTimeFormattedDate: item.recordTimeFormattedDate,
  90. status: item.status,
  91. principal: item.principal,
  92. operator: item.operator,
  93. comment: item.comment
  94. });
  95. });
  96. //获取联系人
  97. if (data2[0].error && data2[0].error.length) {
  98. message.warning(data2[0].error[0].message);
  99. return;
  100. };
  101. this.state.contactsOption = [];
  102. for (let item in data2[0].data) {
  103. let theData = data2[0].data[item];
  104. _me.state.contactsOption.push(
  105. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  106. );
  107. };
  108. //获取详细数据
  109. if (!data3[0].data && data3[0].error && data3[0].error.length) {
  110. message.warning(data3[0].error[0].message);
  111. return;
  112. };
  113. let detailData = data3[0].data;
  114. this.setState({
  115. id: detailData.id,
  116. province: detailData.province,
  117. unitName: detailData.unitName,
  118. serialNumber: detailData.serialNumber,
  119. createTime: detailData.createTime,
  120. acceptTime: detailData.acceptTime,
  121. principal: detailData.principal,
  122. contact: detailData.contact,
  123. copyrightName: detailData.copyrightName,
  124. copyrightNumber: detailData.copyrightNumber,
  125. status: detailData.status,
  126. comment: detailData.comment,
  127. copyrightInfo: detailData.copyrightInfo,
  128. workIssue: detailData.workIssue,
  129. outsource: detailData.outsource,
  130. inUrgent: detailData.inUrgent,
  131. authorizedDate: detailData.authorizedDate,
  132. fisrtContact: detailData.fisrtContact,
  133. secondContact: detailData.secondContact,
  134. thirdContact: detailData.thirdContact,
  135. city: detailData.city,
  136. area: detailData.area,
  137. postcode: detailData.postcode,
  138. certificateUrl: detailData.certificateUrl,
  139. applicationUrl: detailData.applicationUrl,
  140. certificateUrlDownloadFileName: detailData.certificateUrlDownloadFileName,
  141. applicationUrlDownloadFileName: detailData.applicationUrlDownloadFileName,
  142. authorizedDateFormattedDate: detailData.authorizedDateFormattedDate,
  143. createTimeFormattedDate: detailData.createTimeFormattedDate,
  144. acceptTimeFormattedDate: detailData.acceptTimeFormattedDate,
  145. expectTime: [detailData.acceptTime, detailData.inUrgent]
  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={3}>公司名称</Col>
  209. <Col span={6}>{theData.unitName}</Col>
  210. <Col span={4}>公司组织机构代码</Col>
  211. <Col span={6}>{theData.unitNumber}</Col>
  212. </Row>
  213. <Row className="express-desc-row">
  214. <Col span={3}>公司地址</Col>
  215. <Col span={6}>{theData.province}/{theData.city}/{theData.area}</Col>
  216. <Col span={4}>联系人</Col>
  217. <Col span={6}>
  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={3}>编号</Col>
  232. <Col span={6}>{theData.serialNumber}</Col>
  233. <Col span={4}>软著名称</Col>
  234. <Col span={6}>
  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={3}>软著编号</Col>
  244. <Col span={6}>{theData.copyrightNumber}</Col>
  245. </Row>
  246. <Row className="express-desc-row">
  247. <Col span={3}>软著简介</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={3}>派单详情</Col>
  260. <Col span={16}>{theData.workIssue}</Col>
  261. </Row>
  262. <Row className="express-desc-row">
  263. <Col span={3}>加急天数</Col>
  264. <Col span={6}>
  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. }
  284. })()}
  285. </Col>
  286. </Row>
  287. {theData.authorizedDateFormattedDate ? <Row className="express-desc-row">
  288. <Col span={3}>下证时间</Col>
  289. <Col span={6}>{theData.authorizedDateFormattedDate}</Col>
  290. </Row> :
  291. <Row className="express-desc-row">
  292. <Col span={3}>下证时间(预计)</Col>
  293. <Col span={6}>
  294. {(() => {
  295. if (theData.expectTime && theData.expectTime[0]) {
  296. if (theData.expectTime[1]) {
  297. return getTime(getInUrgentTime(moment(theData.expectTime[0]), theData.expectTime[1]))
  298. } else {
  299. return getTime(getInUrgentTime(moment(theData.expectTime[0]), 45))
  300. };
  301. };
  302. })()}
  303. </Col>
  304. </Row>}
  305. <div className="hrSituation-roster">
  306. <Upload
  307. name="copyright_apply"
  308. action={globalConfig.context + "/api/user/copyright/upload"}
  309. data={{ 'sign': 'copyright_apply', id: this.props.data.id }}
  310. beforeUpload={beforeUploadFile}
  311. showUploadList={false}
  312. onChange={(info) => {
  313. if (info.file.status !== 'uploading') {
  314. console.log(info.file, info.fileList);
  315. }
  316. if (info.file.status === 'done') {
  317. if (!info.file.response.error.length) {
  318. message.success(`${info.file.name} 文件上传成功!`);
  319. } else {
  320. message.warning(info.file.response.error[0].message);
  321. return;
  322. };
  323. this.state.copyrightApplyUrl = info.file.response.data;
  324. } else if (info.file.status === 'error') {
  325. message.error(`${info.file.name} 文件上传失败。`);
  326. }
  327. }}
  328. >
  329. <Button><Icon type="upload" /> 上传软著申请书 </Button>
  330. </Upload>
  331. <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>
  332. </div>
  333. <div className="hrSituation-roster">
  334. <Upload
  335. name="copyright_auth"
  336. action={globalConfig.context + "/api/user/copyright/upload"}
  337. data={{ 'sign': 'copyright_auth', id: this.props.data.id }}
  338. beforeUpload={beforeUploadFile}
  339. showUploadList={false}
  340. onChange={(info) => {
  341. if (info.file.status !== 'uploading') {
  342. console.log(info.file, info.fileList);
  343. }
  344. if (info.file.status === 'done') {
  345. if (!info.file.response.error.length) {
  346. message.success(`${info.file.name} 文件上传成功!`);
  347. } else {
  348. message.warning(info.file.response.error[0].message);
  349. return;
  350. };
  351. this.state.copyrightAuthUrl = info.file.response.data;
  352. } else if (info.file.status === 'error') {
  353. message.error(`${info.file.name} 文件上传失败。`);
  354. }
  355. }}
  356. >
  357. <Button><Icon type="upload" /> 上传软著证书 </Button>
  358. </Upload>
  359. <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>
  360. </div>
  361. <p>状态流转记录: </p>
  362. <Table style={{ margin: '10px 0' }}
  363. pagination={false}
  364. dataSource={this.state.stateTable}
  365. columns={this.state.stateColumns} />
  366. <FormItem style={{ marginTop: '20px' }}>
  367. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  368. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  369. </FormItem>
  370. </Form>
  371. );
  372. }
  373. }));
  374. const CopyrightDesc = React.createClass({
  375. getInitialState() {
  376. return {
  377. visible: false,
  378. loading: false
  379. };
  380. },
  381. componentWillReceiveProps(nextProps) {
  382. this.state.visible = nextProps.showDesc
  383. },
  384. showModal() {
  385. this.setState({
  386. visible: true,
  387. });
  388. },
  389. handleOk() {
  390. this.setState({
  391. visible: false,
  392. });
  393. this.props.closeDesc(false, true);
  394. },
  395. handleCancel(e) {
  396. this.setState({
  397. visible: false,
  398. });
  399. this.props.closeDesc(false);
  400. },
  401. spinChange(e) {
  402. this.setState({
  403. loading: e
  404. });
  405. },
  406. render() {
  407. return (
  408. <div className="patent-addNew">
  409. <Spin spinning={this.state.loading} className='spin-box'>
  410. <Modal title="软著详情" visible={this.state.visible}
  411. onOk={this.handleOk} onCancel={this.handleCancel}
  412. width='800px'
  413. footer=''
  414. >
  415. <CopyrightDescForm
  416. visible={this.state.visible}
  417. authorOption={this.props.authorOption}
  418. data={this.props.data}
  419. spinState={this.spinChange}
  420. closeModal={this.handleCancel}
  421. clickOk={this.handleOk} />
  422. </Modal>
  423. </Spin>
  424. </div>
  425. );
  426. }
  427. });
  428. export default CopyrightDesc;