comPatentChange.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  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 { copyrightStateList } from '../../../dataDic.js';
  7. import { getCopyrightState, getTime, copyrightDownloadFile, beforeUploadFile, getInUrgentTime } from '../../../tools.js';
  8. const CopyrightDescForm = Form.create()(React.createClass({
  9. getInitialState() {
  10. return {
  11. visible: false,
  12. loading: false,
  13. stateOption: [],
  14. stateTable: [],
  15. contactsOption: [],
  16. stateColumns: [{
  17. title: '申请状态',
  18. dataIndex: 'status',
  19. key: 'status',
  20. render: (text) => { return getCopyrightState(text) }
  21. }, {
  22. title: '处理时间',
  23. dataIndex: 'recordTimeFormattedDate',
  24. key: 'recordTimeFormattedDate',
  25. }, {
  26. title: '负责人',
  27. dataIndex: 'principal',
  28. key: 'principal',
  29. }, {
  30. title: '操作人',
  31. dataIndex: 'operator',
  32. key: 'operator',
  33. }, {
  34. title: '备注',
  35. dataIndex: 'comment',
  36. key: 'comment',
  37. }]
  38. };
  39. },
  40. componentWillMount() {
  41. this.loadData();
  42. this.getOptionList();
  43. },
  44. getOptionList() {
  45. this.setState({
  46. loading: true
  47. });
  48. $.ajax({
  49. method: "get",
  50. dataType: "json",
  51. crossDomain: false,
  52. url: globalConfig.context + "/api/admin/copyright/status",
  53. success: function (data) {
  54. let _me = this;
  55. if (!data.data) {
  56. if (data.error && data.error.length) {
  57. message.warning(data.error[0].message);
  58. return;
  59. };
  60. };
  61. _me.state.stateOption = [];
  62. for (var item in data.data) {
  63. _me.state.stateOption.push(
  64. <Select.Option value={item} key={item}>{data.data[item]}</Select.Option>
  65. )
  66. };
  67. }.bind(this),
  68. }).always(function () {
  69. this.setState({
  70. loading: false
  71. });
  72. }.bind(this));
  73. },
  74. loadData(uid, id) {
  75. this.setState({
  76. loading: true
  77. });
  78. $.when($.ajax({
  79. method: "get",
  80. dataType: "json",
  81. crossDomain: false,
  82. cache: false,
  83. url: globalConfig.context + "/api/admin/copyright/logs",
  84. data: {
  85. id: id || this.props.data.id
  86. }
  87. }), $.ajax({
  88. method: "get",
  89. dataType: "json",
  90. crossDomain: false,
  91. cache: false,
  92. url: globalConfig.context + "/api/admin/getContacts",
  93. data: {
  94. uid: uid || this.props.data.uid
  95. }
  96. }), $.ajax({
  97. method: "get",
  98. dataType: "json",
  99. crossDomain: false,
  100. cache: false,
  101. url: globalConfig.context + "/api/admin/copyright/detail",
  102. data: {
  103. id: id || this.props.data.id
  104. }
  105. })).done((data1, data2, data3) => {
  106. let _me = this;
  107. //状态流转table
  108. this.state.stateTable = [];
  109. if (data1[0].error && data1[0].error.length) {
  110. message.warning(data1[0].error[0].message);
  111. } else {
  112. data1[0].data.map(function (item, i) {
  113. _me.state.stateTable.push({
  114. key: i,
  115. recordTimeFormattedDate: item.recordTimeFormattedDate,
  116. status: item.status,
  117. principal: item.principal,
  118. operator: item.operator,
  119. comment: item.comment
  120. });
  121. });
  122. };
  123. //获取联系人
  124. this.state.contactsOption = [];
  125. if (data2[0].error && data2[0].error.length) {
  126. message.warning(data2[0].error[0].message);
  127. } else {
  128. for (let item in data2[0].data) {
  129. let theData = data2[0].data[item];
  130. _me.state.contactsOption.push(
  131. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  132. );
  133. };
  134. };
  135. //获取详细数据
  136. if (!data3[0].data && data3[0].error && data3[0].error.length) {
  137. message.warning(data3[0].error[0].message);
  138. } else if (data3[0].data) {
  139. let detailData = data3[0].data;
  140. this.setState({
  141. id: detailData.id,
  142. province: detailData.province,
  143. postalAddress: detailData.postalAddress,
  144. unitName: detailData.unitName,
  145. serialNumber: detailData.serialNumber,
  146. createTime: detailData.createTime,
  147. acceptTime: detailData.acceptTime,
  148. principal: detailData.principal,
  149. contact: detailData.contact,
  150. copyrightName: detailData.copyrightName,
  151. copyrightNumber: detailData.copyrightNumber,
  152. status: detailData.status,
  153. comment: detailData.comment,
  154. workIssue: detailData.workIssue,
  155. outsource: detailData.outsource,
  156. inUrgent: detailData.inUrgent,
  157. authorizedDate: detailData.authorizedDate,
  158. fisrtContact: detailData.fisrtContact,
  159. secondContact: detailData.secondContact,
  160. thirdContact: detailData.thirdContact,
  161. city: detailData.city,
  162. area: detailData.area,
  163. postcode: detailData.postcode,
  164. certificateUrl: detailData.certificateUrl,
  165. applicationUrl: detailData.applicationUrl,
  166. certificateUrlDownloadFileName: detailData.certificateUrlDownloadFileName,
  167. applicationUrlDownloadFileName: detailData.applicationUrlDownloadFileName,
  168. authorizedDateFormattedDate: detailData.authorizedDateFormattedDate,
  169. createTimeFormattedDate: detailData.createTimeFormattedDate,
  170. acceptTimeFormattedDate: detailData.acceptTimeFormattedDate,
  171. expectTime: [detailData.acceptTime, detailData.inUrgent]
  172. });
  173. };
  174. }).always(function () {
  175. this.setState({
  176. loading: false
  177. });
  178. }.bind(this));
  179. },
  180. componentWillReceiveProps(nextProps) {
  181. if (!this.props.visible && nextProps.visible) {
  182. this.loadData(nextProps.data.uid, nextProps.data.id);
  183. };
  184. },
  185. handleSubmit(e) {
  186. e.preventDefault();
  187. this.props.form.validateFields((err, values) => {
  188. if (values.state || values.principal || values.recordTime || values.comment) {
  189. if (!values.state && !values.principal && !values.recordTime) {
  190. message.warning("请填写完整的状态流转信息!");
  191. return;
  192. };
  193. };
  194. if (!err) {
  195. this.props.spinState(true);
  196. $.ajax({
  197. method: "POST",
  198. dataType: "json",
  199. crossDomain: false,
  200. url: globalConfig.context + "/api/admin/copyright/modify",
  201. data: {
  202. "id": this.props.data.id,
  203. "contact": values.contact, // 联系人, 1,2,3
  204. //"copyrightInfo": values.copyrightInfo, // 软著简介,size 0-255
  205. "copyrightName": values.copyrightName, // 软著名称, size 0-60
  206. "copyrightNumber": values.copyrightNumber,
  207. "outsource": values.outsource, // 外包公司, size 0-60
  208. //"workIssue": values.workIssue, // 派单信息, size 0-128
  209. "inUrgent": values.inUrgent, // 加急天数,
  210. "status": values.status, // 状态
  211. "comment": values.comment, // 备注 size 0-128
  212. "recordTime": values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined, // 状态修改时间 yyyy-MM-dd HH:mm:ss
  213. "principal": values.principal // 负责人id
  214. }
  215. }).done(function (data) {
  216. if (!data.error.length) {
  217. message.success('保存成功!');
  218. this.props.clickOk();
  219. this.props.form.resetFields();
  220. this.props.spinState(false);
  221. } else {
  222. message.warning(data.error[0].message);
  223. this.props.spinState(false);
  224. }
  225. }.bind(this));
  226. }
  227. });
  228. },
  229. render() {
  230. const FormItem = Form.Item;
  231. const { getFieldDecorator } = this.props.form;
  232. const theData = this.state;
  233. const formItemLayout = {
  234. labelCol: { span: 6 },
  235. wrapperCol: { span: 12 },
  236. };
  237. const _me = this;
  238. return (
  239. <Form onSubmit={this.handleSubmit} id="CopyrightDesc-form">
  240. <Row className="express-desc-row">
  241. <Col span={4}>公司名称</Col>
  242. <Col span={6}>{theData.unitName}</Col>
  243. <Col span={4}>组织机构代码</Col>
  244. <Col span={6}>{theData.unitNumber}</Col>
  245. </Row>
  246. <Row className="express-desc-row">
  247. <Col span={4}>公司地址</Col>
  248. <Col span={6}>{theData.postalAddress}</Col>
  249. <Col span={4}>联系人</Col>
  250. <Col span={6}>
  251. {getFieldDecorator('contact', {
  252. rules: [{ required: true, message: '此项为必填项!' }],
  253. initialValue: theData.contact
  254. })(
  255. <Select
  256. style={{ display: 'inline-block', width: '200px' }}
  257. placeholder='选择一个联系人'>
  258. {this.state.contactsOption}
  259. </Select>
  260. )}
  261. </Col>
  262. </Row>
  263. <Row className="express-desc-row">
  264. <Col span={4}>编号</Col>
  265. <Col span={6}>{theData.serialNumber}</Col>
  266. <Col span={4}>外包公司</Col>
  267. <Col span={6}>
  268. {getFieldDecorator('outsource', {
  269. initialValue: theData.outsource
  270. })(
  271. <Input placeholder="请输入外包公司" />
  272. )}
  273. </Col>
  274. </Row>
  275. <Row className="express-desc-row">
  276. <Col span={4}>软著名称</Col>
  277. <Col span={6}>
  278. {getFieldDecorator('copyrightName', {
  279. initialValue: theData.copyrightName
  280. })(
  281. <Input style={{ width: 160 }} placeholder="请输入软著名称" />
  282. )}
  283. </Col>
  284. <Col span={4}>软著编号</Col>
  285. <Col span={6}>
  286. {getFieldDecorator('copyrightNumber', {
  287. initialValue: theData.copyrightNumber
  288. })(
  289. <Input placeholder="请输入软著编号" />
  290. )}
  291. </Col>
  292. </Row>
  293. <Row className="express-desc-row">
  294. <Col span={4}>加急天数</Col>
  295. <Col span={6}>
  296. {getFieldDecorator('inUrgent', {
  297. initialValue: theData.inUrgent ? String(theData.inUrgent) : '0'
  298. })(
  299. <Select
  300. placeholder="请选择加急时间"
  301. style={{ width: 160 }}>
  302. <Select.Option value="0">不加急(45个工作日)</Select.Option>
  303. <Select.Option value="3">3个工作日</Select.Option>
  304. <Select.Option value="5">5个工作日</Select.Option>
  305. <Select.Option value="10">6-10个工作日</Select.Option>
  306. <Select.Option value="15">11-15个工作日</Select.Option>
  307. <Select.Option value="20">16-20个工作日</Select.Option>
  308. <Select.Option value="25">21-25个工作日</Select.Option>
  309. <Select.Option value="30">26-30个工作日</Select.Option>
  310. <Select.Option value="35">31-35个工作日</Select.Option>
  311. </Select>
  312. )}
  313. </Col>
  314. </Row>
  315. {theData.authorizedDateFormattedDate ? <Row className="express-desc-row">
  316. <Col span={3}>下证时间</Col>
  317. <Col span={6}>{theData.authorizedDateFormattedDate}</Col>
  318. </Row> :
  319. <Row className="express-desc-row">
  320. <Col span={3}>下证时间(预计)</Col>
  321. <Col span={6}>
  322. {(() => {
  323. if (theData.expectTime && theData.expectTime[0]) {
  324. if (theData.expectTime[1]) {
  325. return getTime(getInUrgentTime(moment(theData.expectTime[0]), theData.expectTime[1]))
  326. } else {
  327. return getTime(getInUrgentTime(moment(theData.expectTime[0]), 45))
  328. };
  329. };
  330. })()}
  331. </Col>
  332. </Row>}
  333. <div className="hrSituation-roster">
  334. <Upload
  335. name="copyright_apply"
  336. action={globalConfig.context + "/api/admin/copyright/upload"}
  337. data={{ 'sign': 'copyright_apply', 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.copyrightApplyUrl = 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.applicationUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_apply', '/api/admin/copyright/download')}>软著申请书</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  360. </div>
  361. <div className="hrSituation-roster">
  362. <Upload
  363. name="copyright_auth"
  364. action={globalConfig.context + "/api/admin/copyright/upload"}
  365. data={{ 'sign': 'copyright_auth', id: this.props.data.id }}
  366. beforeUpload={beforeUploadFile}
  367. showUploadList={false}
  368. onChange={(info) => {
  369. if (info.file.status !== 'uploading') {
  370. console.log(info.file, info.fileList);
  371. }
  372. if (info.file.status === 'done') {
  373. if (!info.file.response.error.length) {
  374. message.success(`${info.file.name} 文件上传成功!`);
  375. } else {
  376. message.warning(info.file.response.error[0].message);
  377. return;
  378. };
  379. this.state.copyrightAuthUrl = info.file.response.data;
  380. } else if (info.file.status === 'error') {
  381. message.error(`${info.file.name} 文件上传失败。`);
  382. }
  383. }}
  384. >
  385. <Button><Icon type="upload" /> 上传软著证书 </Button>
  386. </Upload>
  387. <p style={{ margin: '10px 0' }}>{theData.certificateUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_auth', '/api/admin/copyright/download')}>软著证书</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  388. </div>
  389. <p>状态流转记录: </p>
  390. <Table style={{ margin: '10px 0' }}
  391. pagination={false}
  392. dataSource={this.state.stateTable}
  393. columns={this.state.stateColumns} />
  394. <div className="clearfix">
  395. <FormItem className="third-item"
  396. {...formItemLayout}
  397. label="状态流转"
  398. >
  399. {getFieldDecorator('status')(
  400. <Select placeholder="选择一个状态">{this.state.stateOption}</Select>
  401. )}
  402. </FormItem>
  403. <FormItem className="third-item"
  404. labelCol={{ span: 6 }}
  405. wrapperCol={{ span: 12 }}
  406. label="处理时间"
  407. >
  408. {getFieldDecorator('recordTime')(
  409. <DatePicker />
  410. )}
  411. </FormItem>
  412. <FormItem className="third-item"
  413. {...formItemLayout}
  414. label="负责人"
  415. >
  416. {getFieldDecorator('principal')(
  417. <Select placeholder="选择负责人">{this.props.authorOption}</Select>
  418. )}
  419. </FormItem>
  420. </div>
  421. <FormItem
  422. labelCol={{ span: 2 }}
  423. wrapperCol={{ span: 12 }}
  424. label="备注"
  425. >
  426. {getFieldDecorator('comment')(
  427. <Input />
  428. )}
  429. </FormItem>
  430. <FormItem style={{ marginTop: '20px' }}>
  431. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  432. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  433. </FormItem>
  434. </Form>
  435. );
  436. }
  437. }));
  438. const CopyrightDesc = React.createClass({
  439. getInitialState() {
  440. return {
  441. visible: false,
  442. loading: false
  443. };
  444. },
  445. componentWillReceiveProps(nextProps) {
  446. this.state.visible = nextProps.showDesc
  447. },
  448. showModal() {
  449. this.setState({
  450. visible: true,
  451. });
  452. },
  453. handleOk() {
  454. this.setState({
  455. visible: false,
  456. });
  457. this.props.closeDesc(false, true);
  458. },
  459. handleCancel(e) {
  460. this.setState({
  461. visible: false,
  462. });
  463. this.props.closeDesc(false);
  464. },
  465. spinChange(e) {
  466. this.setState({
  467. loading: e
  468. });
  469. },
  470. render() {
  471. return (
  472. <div className="patent-addNew">
  473. <Spin spinning={this.state.loading} className='spin-box'>
  474. <Modal title="软著详情" visible={this.state.visible}
  475. onOk={this.handleOk} onCancel={this.handleCancel}
  476. width='800px'
  477. footer=''
  478. >
  479. <CopyrightDescForm
  480. visible={this.state.visible}
  481. authorOption={this.props.authorOption}
  482. data={this.props.data}
  483. spinState={this.spinChange}
  484. closeModal={this.handleCancel}
  485. clickOk={this.handleOk} />
  486. </Modal>
  487. </Spin>
  488. </div>
  489. );
  490. }
  491. });
  492. export default CopyrightDesc;