comPatentChange.jsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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 } 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. if (data1[0].error && data1[0].error.length) {
  109. message.warning(data1[0].error[0].message);
  110. return;
  111. };
  112. this.state.stateTable = [];
  113. data1[0].data.map(function (item, i) {
  114. _me.state.stateTable.push({
  115. key: i,
  116. recordTimeFormattedDate: item.recordTimeFormattedDate,
  117. status: item.status,
  118. principal: item.principal,
  119. operator: item.operator,
  120. comment: item.comment
  121. });
  122. });
  123. //获取联系人
  124. if (data2[0].error && data2[0].error.length) {
  125. message.warning(data2[0].error[0].message);
  126. return;
  127. };
  128. this.state.contactsOption = [];
  129. for (let item in data2[0].data) {
  130. let theData = data2[0].data[item];
  131. _me.state.contactsOption.push(
  132. <Select.Option value={item} key={theData}>{theData}</Select.Option>
  133. );
  134. };
  135. //获取详细数据
  136. if (!data3[0].data && data3[0].error && data3[0].error.length) {
  137. message.warning(data3[0].error[0].message);
  138. return;
  139. };
  140. let detailData = data3[0].data;
  141. this.setState({
  142. id: detailData.id,
  143. province: detailData.province,
  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. }).always(function () {
  174. this.setState({
  175. loading: false
  176. });
  177. }.bind(this));
  178. },
  179. componentWillReceiveProps(nextProps) {
  180. if (!this.props.visible && nextProps.visible) {
  181. this.loadData(nextProps.data.uid, nextProps.data.id);
  182. };
  183. },
  184. handleSubmit(e) {
  185. e.preventDefault();
  186. this.props.form.validateFields((err, values) => {
  187. if (values.state || values.principal || values.recordTime || values.comment) {
  188. if (!values.state && !values.principal && !values.recordTime) {
  189. message.warning("请填写完整的状态流转信息!");
  190. return;
  191. };
  192. };
  193. if (!err) {
  194. this.props.spinState(true);
  195. $.ajax({
  196. method: "POST",
  197. dataType: "json",
  198. crossDomain: false,
  199. url: globalConfig.context + "/api/admin/copyright/modify",
  200. data: {
  201. "id": this.props.data.id,
  202. "contact": values.contact, // 联系人, 1,2,3
  203. //"copyrightInfo": values.copyrightInfo, // 软著简介,size 0-255
  204. "copyrightName": values.copyrightName, // 软著名称, size 0-60
  205. "copyrightNumber": values.copyrightNumber,
  206. "outsource": values.outsource, // 外包公司, size 0-60
  207. "workIssue": values.workIssue, // 派单信息, size 0-128
  208. "inUrgent": values.inUrgent, // 加急天数,
  209. "status": values.status, // 状态
  210. "comment": values.comment, // 备注 size 0-128
  211. "recordTime": values.recordTime ? values.recordTime.format("YYYY-MM-DD HH:mm:ss") : undefined, // 状态修改时间 yyyy-MM-dd HH:mm:ss
  212. "principal": values.principal // 负责人id
  213. }
  214. }).done(function (data) {
  215. if (!data.error.length) {
  216. message.success('保存成功!');
  217. this.props.clickOk();
  218. this.props.form.resetFields();
  219. this.props.spinState(false);
  220. } else {
  221. message.warning(data.error[0].message);
  222. this.props.spinState(false);
  223. }
  224. }.bind(this));
  225. }
  226. });
  227. },
  228. render() {
  229. const FormItem = Form.Item;
  230. const { getFieldDecorator } = this.props.form;
  231. const theData = this.state;
  232. const formItemLayout = {
  233. labelCol: { span: 6 },
  234. wrapperCol: { span: 12 },
  235. };
  236. const _me = this;
  237. return (
  238. <Form onSubmit={this.handleSubmit} id="CopyrightDesc-form">
  239. <Row className="express-desc-row">
  240. <Col span={4}>公司名称</Col>
  241. <Col span={6}>{theData.unitName}</Col>
  242. <Col span={4}>公司组织机构代码</Col>
  243. <Col span={6}>{theData.unitNumber}</Col>
  244. </Row>
  245. <Row className="express-desc-row">
  246. <Col span={4}>公司地址</Col>
  247. <Col span={6}>{theData.province}/{theData.city}/{theData.area}</Col>
  248. <Col span={4}>联系人</Col>
  249. <Col span={6}>
  250. {getFieldDecorator('contact', {
  251. rules: [{ required: true, message: '此项为必填项!' }],
  252. initialValue: theData.contact
  253. })(
  254. <Select
  255. style={{ display: 'inline-block', width: '200px' }}
  256. placeholder='选择一个联系人'>
  257. {this.state.contactsOption}
  258. </Select>
  259. )}
  260. </Col>
  261. </Row>
  262. <Row className="express-desc-row">
  263. <Col span={4}>编号</Col>
  264. <Col span={6}>{theData.serialNumber}</Col>
  265. <Col span={4}>外包公司</Col>
  266. <Col span={6}>
  267. {getFieldDecorator('outsource', {
  268. initialValue: theData.outsource
  269. })(
  270. <Input placeholder="请输入外包公司" />
  271. )}
  272. </Col>
  273. </Row>
  274. <Row className="express-desc-row">
  275. <Col span={4}>派单详情</Col>
  276. <Col span={16}>
  277. {getFieldDecorator('workIssue', {
  278. initialValue: theData.workIssue
  279. })(
  280. <Input type="textarea"
  281. placeholder="多行输入"
  282. rows={6} />
  283. )}
  284. </Col>
  285. </Row>
  286. <Row className="express-desc-row">
  287. <Col span={4}>软著名称</Col>
  288. <Col span={6}>
  289. {getFieldDecorator('copyrightName', {
  290. initialValue: theData.copyrightName
  291. })(
  292. <Input style={{ width: 160 }} placeholder="请输入软著名称" />
  293. )}
  294. </Col>
  295. <Col span={4}>软著编号</Col>
  296. <Col span={6}>
  297. {getFieldDecorator('copyrightNumber', {
  298. initialValue: theData.copyrightNumber
  299. })(
  300. <Input placeholder="请输入软著编号" />
  301. )}
  302. </Col>
  303. </Row>
  304. <Row className="express-desc-row">
  305. <Col span={4}>加急天数</Col>
  306. <Col span={6}>
  307. {getFieldDecorator('inUrgent', {
  308. initialValue: theData.inUrgent ? String(theData.inUrgent) : undefined
  309. })(
  310. <Select
  311. placeholder="请选择加急时间"
  312. style={{ width: 160 }}>
  313. <Select.Option value="0">不加急(45个工作日)</Select.Option>
  314. <Select.Option value="3">3个工作日</Select.Option>
  315. <Select.Option value="5">5个工作日</Select.Option>
  316. <Select.Option value="10">6-10个工作日</Select.Option>
  317. <Select.Option value="15">11-15个工作日</Select.Option>
  318. <Select.Option value="20">16-20个工作日</Select.Option>
  319. <Select.Option value="25">21-25个工作日</Select.Option>
  320. <Select.Option value="30">26-30个工作日</Select.Option>
  321. </Select>
  322. )}
  323. </Col>
  324. </Row>
  325. {theData.authorizedDateFormattedDate ? <Row className="express-desc-row">
  326. <Col span={3}>下证时间</Col>
  327. <Col span={6}>{theData.authorizedDateFormattedDate}</Col>
  328. </Row> :
  329. <Row className="express-desc-row">
  330. <Col span={3}>下证时间(预计)</Col>
  331. <Col span={6}>
  332. {(() => {
  333. if (theData.expectTime && theData.expectTime[0]) {
  334. if (theData.expectTime[1]) {
  335. return getTime(getInUrgentTime(moment(theData.expectTime[0]), theData.expectTime[1]))
  336. } else {
  337. return getTime(getInUrgentTime(moment(theData.expectTime[0]), 45))
  338. };
  339. };
  340. })()}
  341. </Col>
  342. </Row>}
  343. <div className="hrSituation-roster">
  344. <Upload
  345. name="copyright_apply"
  346. action={globalConfig.context + "/api/admin/copyright/upload"}
  347. data={{ 'sign': 'copyright_apply', id: this.props.data.id }}
  348. beforeUpload={beforeUploadFile}
  349. showUploadList={false}
  350. onChange={(info) => {
  351. if (info.file.status !== 'uploading') {
  352. console.log(info.file, info.fileList);
  353. }
  354. if (info.file.status === 'done') {
  355. if (!info.file.response.error.length) {
  356. message.success(`${info.file.name} 文件上传成功!`);
  357. } else {
  358. message.warning(info.file.response.error[0].message);
  359. return;
  360. };
  361. this.state.copyrightApplyUrl = info.file.response.data;
  362. } else if (info.file.status === 'error') {
  363. message.error(`${info.file.name} 文件上传失败。`);
  364. }
  365. }}
  366. >
  367. <Button><Icon type="upload" /> 上传软著申请书 </Button>
  368. </Upload>
  369. <p style={{ margin: '10px 0' }}>{theData.applicationUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_apply', '/api/admin/copyright/download')}>{theData.applicationUrlDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  370. </div>
  371. <div className="hrSituation-roster">
  372. <Upload
  373. name="copyright_auth"
  374. action={globalConfig.context + "/api/admin/copyright/upload"}
  375. data={{ 'sign': 'copyright_auth', id: this.props.data.id }}
  376. beforeUpload={beforeUploadFile}
  377. showUploadList={false}
  378. onChange={(info) => {
  379. if (info.file.status !== 'uploading') {
  380. console.log(info.file, info.fileList);
  381. }
  382. if (info.file.status === 'done') {
  383. if (!info.file.response.error.length) {
  384. message.success(`${info.file.name} 文件上传成功!`);
  385. } else {
  386. message.warning(info.file.response.error[0].message);
  387. return;
  388. };
  389. this.state.copyrightAuthUrl = info.file.response.data;
  390. } else if (info.file.status === 'error') {
  391. message.error(`${info.file.name} 文件上传失败。`);
  392. }
  393. }}
  394. >
  395. <Button><Icon type="upload" /> 上传软著证书 </Button>
  396. </Upload>
  397. <p style={{ margin: '10px 0' }}>{theData.certificateUrl ? <a onClick={copyrightDownloadFile.bind(null, theData.id, 'copyright_auth', '/api/admin/copyright/download')}>{theData.certificateUrlDownloadFileName}</a> : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
  398. </div>
  399. <p>状态流转记录: </p>
  400. <Table style={{ margin: '10px 0' }}
  401. pagination={false}
  402. dataSource={this.state.stateTable}
  403. columns={this.state.stateColumns} />
  404. <div className="clearfix">
  405. <FormItem className="third-item"
  406. {...formItemLayout}
  407. label="状态流转"
  408. >
  409. {getFieldDecorator('status')(
  410. <Select placeholder="选择一个状态">{this.state.stateOption}</Select>
  411. )}
  412. </FormItem>
  413. <FormItem className="third-item"
  414. labelCol={{ span: 6 }}
  415. wrapperCol={{ span: 12 }}
  416. label="处理时间"
  417. >
  418. {getFieldDecorator('recordTime')(
  419. <DatePicker />
  420. )}
  421. </FormItem>
  422. <FormItem className="third-item"
  423. {...formItemLayout}
  424. label="负责人"
  425. >
  426. {getFieldDecorator('principal')(
  427. <Select placeholder="选择负责人">{this.props.authorOption}</Select>
  428. )}
  429. </FormItem>
  430. </div>
  431. <FormItem
  432. labelCol={{ span: 2 }}
  433. wrapperCol={{ span: 12 }}
  434. label="备注"
  435. >
  436. {getFieldDecorator('comment')(
  437. <Input />
  438. )}
  439. </FormItem>
  440. <FormItem style={{ marginTop: '20px' }}>
  441. <Button className="set-submit" type="primary" htmlType="submit">保存</Button>
  442. <Button type="ghost" style={{ marginLeft: '20px' }} onClick={this.props.closeModal}>取消</Button>
  443. </FormItem>
  444. </Form>
  445. );
  446. }
  447. }));
  448. const CopyrightDesc = React.createClass({
  449. getInitialState() {
  450. return {
  451. visible: false,
  452. loading: false
  453. };
  454. },
  455. componentWillReceiveProps(nextProps) {
  456. this.state.visible = nextProps.showDesc
  457. },
  458. showModal() {
  459. this.setState({
  460. visible: true,
  461. });
  462. },
  463. handleOk() {
  464. this.setState({
  465. visible: false,
  466. });
  467. this.props.closeDesc(false, true);
  468. },
  469. handleCancel(e) {
  470. this.setState({
  471. visible: false,
  472. });
  473. this.props.closeDesc(false);
  474. },
  475. spinChange(e) {
  476. this.setState({
  477. loading: e
  478. });
  479. },
  480. render() {
  481. return (
  482. <div className="patent-addNew">
  483. <Spin spinning={this.state.loading} className='spin-box'>
  484. <Modal title="软著详情" visible={this.state.visible}
  485. onOk={this.handleOk} onCancel={this.handleCancel}
  486. width='800px'
  487. footer=''
  488. >
  489. <CopyrightDescForm
  490. visible={this.state.visible}
  491. authorOption={this.props.authorOption}
  492. data={this.props.data}
  493. spinState={this.spinChange}
  494. closeModal={this.handleCancel}
  495. clickOk={this.handleOk} />
  496. </Modal>
  497. </Spin>
  498. </div>
  499. );
  500. }
  501. });
  502. export default CopyrightDesc;