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