comPatentChange.jsx 21 KB

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