comPatentChange.jsx 23 KB

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