hrSituation.jsx 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. import React from 'react';
  2. import { Input, InputNumber, Button, Form, Icon, Spin, message, Table, Modal, Upload, Select } from 'antd';
  3. import { beforeUpload } from '../../tools.js';
  4. import './hrSituation.less'
  5. import ajax from 'jquery/src/ajax/xhr.js'
  6. import $ from 'jquery/src/ajax';
  7. const HrSituationDescFrom = Form.create()(React.createClass({
  8. getInitialState() {
  9. return {
  10. loading: false,
  11. yearOption: []
  12. };
  13. },
  14. handleSubmit(e) {
  15. e.preventDefault();
  16. this.props.form.validateFields((err, values) => {
  17. if (values.firmTotal < values.firmInService + values.firmPartTime + values.firmTemporary) {
  18. message.warning("总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数!");
  19. return;
  20. };
  21. if (values.firmTotal < values.techTotal) {
  22. message.warning("科技人员数小于等于企业职工总数!");
  23. return;
  24. };
  25. if (values.firmInService < values.techInService || values.firmPartTime < values.techPartTime || values.firmTemporary < values.techTemporary ||
  26. values.firmForeign < values.techForeign || values.firmAbroad < values.techAbroad || values.firmCore < values.techCore) {
  27. message.warning("科技人员各项人数小于等于企业职工各项人数!");
  28. return;
  29. };
  30. if (values.firmTotal < values.doctor + values.master + values.undergraduate + values.college) {
  31. message.warning("全体人员结构中学历一栏人数总和小于等于职工人数!");
  32. return;
  33. };
  34. if (values.firmTotal < values.belowThirty + values.thirtyoneToThirtyfour + values.fortyoneToFifty + values.aboveFifty) {
  35. message.warning("全体人员结构中年龄一栏人数总和小于等于职工人数!");
  36. return;
  37. };
  38. if (!this.state.year && !this.props.data.year) {
  39. message.warning("请选择一个年份!")
  40. return;
  41. };
  42. if (!err) {
  43. this.props.spinState(true);
  44. $.ajax({
  45. method: "POST",
  46. dataType: "json",
  47. crossDomain: false,
  48. url: globalConfig.context + "/api/user/SaveHumanResource",
  49. data: {
  50. id: this.props.data.id,
  51. year: this.state.year || this.props.data.year,
  52. aboveFifty: values.aboveFifty,
  53. belowThirty: values.belowThirty,
  54. college: values.college,
  55. doctor: values.doctor,
  56. firmAbroad: values.firmAbroad,
  57. firmCore: values.firmCore,
  58. firmForeign: values.firmForeign,
  59. firmInService: values.firmInService,
  60. firmPartTime: values.firmPartTime,
  61. firmTemporary: values.firmTemporary,
  62. firmTotal: values.firmTotal,
  63. fortyoneToFifty: values.fortyoneToFifty,
  64. intermediateTitle: values.intermediateTitle,
  65. juniorTitle: values.juniorTitle,
  66. master: values.master,
  67. seniorMechanic: values.seniorMechanic,
  68. seniorTitle: values.seniorTitle,
  69. techAbroad: values.techAbroad,
  70. techCore: values.techCore,
  71. techForeign: values.techForeign,
  72. techInService: values.techInService,
  73. techPartTime: values.techPartTime,
  74. techTemporary: values.techTemporary,
  75. techTotal: values.techTotal,
  76. thirtyoneToThirtyfour: values.thirtyoneToThirtyfour,
  77. undergraduate: values.undergraduate,
  78. rosterUrl: this.state.rosterUrl,
  79. socialSecurityUrl: this.state.socialSecurityUrl,
  80. newEmployment: values.newEmployment,
  81. graduateNumber: values.graduateNumber
  82. }
  83. }).done(function (data) {
  84. if (!data.error.length) {
  85. message.success('保存成功!');
  86. this.props.closeModal();
  87. this.props.spinState(false);
  88. this.props.form.resetFields();
  89. } else {
  90. message.warning(data.error[0].message);
  91. this.props.spinState(false);
  92. }
  93. }.bind(this));
  94. }
  95. });
  96. },
  97. componentWillMount() {
  98. let d = new Date();
  99. let _me = this;
  100. d = d.getFullYear();
  101. for (let i = d; i > d - 20; i--) {
  102. _me.state.yearOption.push(
  103. <Select.Option value={i.toString()} key={i}>{i}</Select.Option>
  104. )
  105. };
  106. },
  107. render() {
  108. const { getFieldDecorator } = this.props.form;
  109. const formItemLayout = {
  110. labelCol: { span: 8 },
  111. wrapperCol: { span: 16 },
  112. };
  113. const FormItem = Form.Item;
  114. return (
  115. <Form onSubmit={this.handleSubmit} className="hrSituation-form">
  116. <div className="clearfix">
  117. <div className="activityCost-title"><span>年份: </span>
  118. {
  119. this.props.data.year ? <span>{this.props.data.year}</span> :
  120. <Select placeholder="请选择年份" style={{ width: 200 }}
  121. onSelect={(e, n) => { this.state.year = e }}>
  122. {this.state.yearOption}
  123. </Select>
  124. }
  125. </div>
  126. </div>
  127. <p className="hrSituation-title">总体情况</p>
  128. <div className="clearfix">
  129. <span className="hrSituation-span">总数(人)</span>
  130. <FormItem className="half-item"
  131. {...formItemLayout}
  132. label="企业职工"
  133. >
  134. {getFieldDecorator('firmTotal', {
  135. initialValue: this.props.data.firmTotal || null
  136. })(
  137. <InputNumber />
  138. )}
  139. </FormItem>
  140. <FormItem className="half-item"
  141. {...formItemLayout}
  142. label="科技人员"
  143. >
  144. {getFieldDecorator('techTotal', {
  145. initialValue: this.props.data.techTotal || null
  146. })(
  147. <InputNumber />
  148. )}
  149. </FormItem>
  150. <FormItem className="half-item" style={{ width: '50%' }}>
  151. <span>其中科技人员占比
  152. {(() => {
  153. if (!this.props.form.getFieldValue('techTotal') || !this.props.form.getFieldValue('firmTotal')) {
  154. return 0
  155. }
  156. return (this.props.form.getFieldValue('techTotal') / this.props.form.getFieldValue('firmTotal') * 100).toFixed(2)
  157. })()}
  158. %</span>
  159. </FormItem>
  160. <span className="hrSituation-span">在职人员(人)</span>
  161. <FormItem className="half-item"
  162. {...formItemLayout}
  163. label="企业职工"
  164. >
  165. {getFieldDecorator('firmInService', {
  166. initialValue: this.props.data.firmInService || null
  167. })(
  168. <InputNumber />
  169. )}
  170. </FormItem>
  171. <FormItem className="half-item"
  172. {...formItemLayout}
  173. label="科技人员"
  174. >
  175. {getFieldDecorator('techInService', {
  176. initialValue: this.props.data.techInService || null
  177. })(
  178. <InputNumber />
  179. )}
  180. </FormItem>
  181. <span className="hrSituation-span">兼职人员(人)</span>
  182. <FormItem className="half-item"
  183. {...formItemLayout}
  184. label="企业职工"
  185. >
  186. {getFieldDecorator('firmPartTime', {
  187. initialValue: this.props.data.firmPartTime || null
  188. })(
  189. <InputNumber />
  190. )}
  191. </FormItem>
  192. <FormItem className="half-item"
  193. {...formItemLayout}
  194. label="科技人员"
  195. >
  196. {getFieldDecorator('techPartTime', {
  197. initialValue: this.props.data.techPartTime || null
  198. })(
  199. <InputNumber />
  200. )}
  201. </FormItem>
  202. <span className="hrSituation-span">临时聘用人员(人)</span>
  203. <FormItem className="half-item"
  204. {...formItemLayout}
  205. label="企业职工"
  206. >
  207. {getFieldDecorator('firmTemporary', {
  208. initialValue: this.props.data.firmTemporary || null
  209. })(
  210. <InputNumber />
  211. )}
  212. </FormItem>
  213. <FormItem className="half-item"
  214. {...formItemLayout}
  215. label="科技人员"
  216. >
  217. {getFieldDecorator('techTemporary', {
  218. initialValue: this.props.data.techTemporary || null
  219. })(
  220. <InputNumber />
  221. )}
  222. </FormItem>
  223. <span className="hrSituation-span">外籍人员(人)</span>
  224. <FormItem className="half-item"
  225. {...formItemLayout}
  226. label="企业职工"
  227. >
  228. {getFieldDecorator('firmForeign', {
  229. initialValue: this.props.data.firmForeign || null
  230. })(
  231. <InputNumber />
  232. )}
  233. </FormItem>
  234. <FormItem className="half-item"
  235. {...formItemLayout}
  236. label="科技人员"
  237. >
  238. {getFieldDecorator('techForeign', {
  239. initialValue: this.props.data.techForeign || null
  240. })(
  241. <InputNumber />
  242. )}
  243. </FormItem>
  244. <span className="hrSituation-span">留学归国人员(人)</span>
  245. <FormItem className="half-item"
  246. {...formItemLayout}
  247. label="企业职工"
  248. >
  249. {getFieldDecorator('firmAbroad', {
  250. initialValue: this.props.data.firmAbroad || null
  251. })(
  252. <InputNumber />
  253. )}
  254. </FormItem>
  255. <FormItem className="half-item"
  256. {...formItemLayout}
  257. label="科技人员"
  258. >
  259. {getFieldDecorator('techAbroad', {
  260. initialValue: this.props.data.techAbroad || null
  261. })(
  262. <InputNumber />
  263. )}
  264. </FormItem>
  265. <span className="hrSituation-span">干人计划人员(人)</span>
  266. <FormItem className="half-item"
  267. {...formItemLayout}
  268. label="企业职工"
  269. >
  270. {getFieldDecorator('firmCore', {
  271. initialValue: this.props.data.firmCore || null
  272. })(
  273. <InputNumber />
  274. )}
  275. </FormItem>
  276. <FormItem className="half-item"
  277. {...formItemLayout}
  278. label="科技人员"
  279. >
  280. {getFieldDecorator('techCore', {
  281. initialValue: this.props.data.techCore || null
  282. })(
  283. <InputNumber />
  284. )}
  285. </FormItem>
  286. </div>
  287. <p className="hrSituation-title">全体人员结构</p>
  288. <div className="clearfix">
  289. <span className="hrSituation-span">学历人数</span>
  290. <FormItem className="half-item"
  291. {...formItemLayout}
  292. label="博士"
  293. >
  294. {getFieldDecorator('doctor', {
  295. initialValue: this.props.data.doctor || null
  296. })(
  297. <InputNumber />
  298. )}
  299. </FormItem>
  300. <FormItem className="half-item"
  301. {...formItemLayout}
  302. label="硕士"
  303. >
  304. {getFieldDecorator('master', {
  305. initialValue: this.props.data.master || null
  306. })(
  307. <InputNumber />
  308. )}
  309. </FormItem>
  310. <FormItem className="half-item"
  311. {...formItemLayout}
  312. label="本科"
  313. >
  314. {getFieldDecorator('undergraduate', {
  315. initialValue: this.props.data.undergraduate || null
  316. })(
  317. <InputNumber />
  318. )}
  319. </FormItem>
  320. <FormItem className="half-item"
  321. {...formItemLayout}
  322. label="大专及以下"
  323. >
  324. {getFieldDecorator('college', {
  325. initialValue: this.props.data.college || null
  326. })(
  327. <InputNumber />
  328. )}
  329. </FormItem>
  330. </div>
  331. <div className="clearfix">
  332. <span className="hrSituation-span">职称人数</span>
  333. <FormItem className="half-item"
  334. {...formItemLayout}
  335. label="高级职称"
  336. >
  337. {getFieldDecorator('seniorTitle', {
  338. initialValue: this.props.data.seniorTitle || null
  339. })(
  340. <InputNumber />
  341. )}
  342. </FormItem>
  343. <FormItem className="half-item"
  344. {...formItemLayout}
  345. label="中级职称"
  346. >
  347. {getFieldDecorator('intermediateTitle', {
  348. initialValue: this.props.data.intermediateTitle || null
  349. })(
  350. <InputNumber />
  351. )}
  352. </FormItem>
  353. <FormItem className="half-item"
  354. {...formItemLayout}
  355. label="初级职称"
  356. >
  357. {getFieldDecorator('juniorTitle', {
  358. initialValue: this.props.data.juniorTitle || null
  359. })(
  360. <InputNumber />
  361. )}
  362. </FormItem>
  363. <FormItem className="half-item"
  364. {...formItemLayout}
  365. label="高级技工"
  366. >
  367. {getFieldDecorator('seniorMechanic', {
  368. initialValue: this.props.data.seniorMechanic || null
  369. })(
  370. <InputNumber />
  371. )}
  372. </FormItem>
  373. </div>
  374. <div className="clearfix">
  375. <span className="hrSituation-span">年龄人数</span>
  376. <FormItem className="half-item"
  377. {...formItemLayout}
  378. label="30及以下"
  379. >
  380. {getFieldDecorator('belowThirty', {
  381. initialValue: this.props.data.belowThirty || null
  382. })(
  383. <InputNumber />
  384. )}
  385. </FormItem>
  386. <FormItem className="half-item"
  387. {...formItemLayout}
  388. label="31-34"
  389. >
  390. {getFieldDecorator('thirtyoneToThirtyfour', {
  391. initialValue: this.props.data.thirtyoneToThirtyfour || null
  392. })(
  393. <InputNumber />
  394. )}
  395. </FormItem>
  396. <FormItem className="half-item"
  397. {...formItemLayout}
  398. label="41-50"
  399. >
  400. {getFieldDecorator('fortyoneToFifty', {
  401. initialValue: this.props.data.fortyoneToFifty || null
  402. })(
  403. <InputNumber />
  404. )}
  405. </FormItem>
  406. <FormItem className="half-item"
  407. {...formItemLayout}
  408. label="50以上"
  409. >
  410. {getFieldDecorator('aboveFifty', {
  411. initialValue: this.props.data.aboveFifty || null
  412. })(
  413. <InputNumber />
  414. )}
  415. </FormItem>
  416. </div>
  417. <p className="hrSituation-title">每年新增员工数</p>
  418. <div className="clearfix">
  419. <FormItem
  420. labelCol={{ span: 16 }}
  421. wrapperCol={{ span: 8 }}
  422. label="新增就业人数"
  423. >
  424. {getFieldDecorator('newEmployment', {
  425. initialValue: this.props.data.newEmployment || null
  426. })(
  427. <InputNumber />
  428. )}
  429. </FormItem>
  430. <FormItem
  431. labelCol={{ span: 16 }}
  432. wrapperCol={{ span: 8 }}
  433. label="高校应届毕业生人数"
  434. >
  435. {getFieldDecorator('graduateNumber', {
  436. initialValue: this.props.data.graduateNumber || null
  437. })(
  438. <InputNumber />
  439. )}
  440. </FormItem>
  441. </div>
  442. <div className="hrSituation-roster">
  443. <Upload
  444. name="socialSecurity"
  445. action={globalConfig.context + "/techservice/cognizance/upload"}
  446. data={{ 'sign': this.props.year + 'socialSecurity' }}
  447. beforeUpload={beforeUpload}
  448. onChange={(info) => {
  449. if (info.file.status !== 'uploading') {
  450. console.log(info.file, info.fileList);
  451. }
  452. if (info.file.status === 'done') {
  453. message.success(`${info.file.name} 文件上传成功!`);
  454. this.state.socialSecurityUrl = info.file.response.data;
  455. } else if (info.file.status === 'error') {
  456. message.error(`${info.file.name} 文件上传失败。`);
  457. }
  458. }}
  459. >
  460. <Button><Icon type="upload" /> 上传社保文件 </Button>
  461. </Upload>
  462. </div>
  463. <div className="hrSituation-roster">
  464. <Upload
  465. name="roster"
  466. action={globalConfig.context + "/techservice/cognizance/upload"}
  467. data={{ 'sign': this.props.year + 'roster' }}
  468. beforeUpload={beforeUpload}
  469. onChange={(info) => {
  470. if (info.file.status !== 'uploading') {
  471. console.log(info.file, info.fileList);
  472. }
  473. if (info.file.status === 'done') {
  474. message.success(`${info.file.name} 文件上传成功!`);
  475. this.state.rosterUrl = info.file.response.data;
  476. } else if (info.file.status === 'error') {
  477. message.error(`${info.file.name} 文件上传失败。`);
  478. }
  479. }}
  480. >
  481. <Button><Icon type="upload" /> 上传花名册文件 </Button>
  482. </Upload>
  483. </div>
  484. <div>
  485. <span style={{ color: "red" }}>提示</span>
  486. <p>1、总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数。</p>
  487. <p>2、科技人员数小于等于企业职工总数。</p>
  488. <p>3、科技人员各项人数小于等于企业职工各项人数。</p>
  489. <p>4、全体人员结构中学历一栏人数总和小于等于职工人数。</p>
  490. <p>5、全体人员结构中年龄一栏人数总和小于等于职工人数。</p>
  491. <Button style={{ marginTop: "20px" }} className="set-submit" type="primary" htmlType="submit">保存</Button>
  492. </div>
  493. </Form >
  494. );
  495. },
  496. }));
  497. const HrSituationDesc = React.createClass({
  498. getInitialState() {
  499. return {
  500. visible: false,
  501. loading: false
  502. };
  503. },
  504. componentWillReceiveProps(nextProps) {
  505. this.state.visible = nextProps.showDesc
  506. },
  507. showModal() {
  508. this.setState({
  509. visible: true,
  510. });
  511. },
  512. handleOk() {
  513. this.setState({
  514. visible: false,
  515. });
  516. this.props.closeDesc(false);
  517. },
  518. handleCancel(e) {
  519. this.setState({
  520. visible: false,
  521. });
  522. this.props.closeDesc(false);
  523. },
  524. spinChange(e) {
  525. this.setState({
  526. loading: e
  527. });
  528. },
  529. render() {
  530. return (
  531. <div className="patent-addNew">
  532. <Spin spinning={this.state.loading} className='spin-box'>
  533. <Modal title="人力资源状况" visible={this.state.visible}
  534. onOk={this.handleOk} onCancel={this.handleCancel}
  535. width='1200px'
  536. footer=''
  537. >
  538. <HrSituationDescFrom data={this.props.data}
  539. spinState={this.spinChange} closeModal={this.handleCancel} />
  540. </Modal>
  541. </Spin>
  542. </div>
  543. );
  544. },
  545. });
  546. const HrSituation = React.createClass({
  547. loadData(pageNo) {
  548. this.state.data = [];
  549. this.setState({
  550. loading: true
  551. });
  552. $.ajax({
  553. method: "get",
  554. dataType: "json",
  555. crossDomain: false,
  556. url: globalConfig.context + "/api/user/humanResource",
  557. data: {
  558. pageNo: pageNo || 1,
  559. pageSize: this.state.pagination.pageSize
  560. }
  561. }).done((data) => {
  562. if (data.error.length || !data.data || !data.data.list) {
  563. message.warning(data.error[0].message);
  564. return;
  565. };
  566. for (let i = 0; i < data.data.list.length; i++) {
  567. let thisdata = data.data.list[i];
  568. this.state.data.push({
  569. key: i,
  570. id: thisdata.id,
  571. uid: thisdata.uid,
  572. year: thisdata.year,
  573. aboveFifty: thisdata.aboveFifty,
  574. belowThirty: thisdata.belowThirty,
  575. college: thisdata.college,
  576. doctor: thisdata.doctor,
  577. firmAbroad: thisdata.firmAbroad,
  578. firmCore: thisdata.firmCore,
  579. firmForeign: thisdata.firmForeign,
  580. firmInService: thisdata.firmInService,
  581. firmPartTime: thisdata.firmPartTime,
  582. firmTemporary: thisdata.firmTemporary,
  583. firmTotal: thisdata.firmTotal,
  584. fortyoneToFifty: thisdata.fortyoneToFifty,
  585. intermediateTitle: thisdata.intermediateTitle,
  586. juniorTitle: thisdata.juniorTitle,
  587. master: thisdata.master,
  588. seniorMechanic: thisdata.seniorMechanic,
  589. seniorTitle: thisdata.seniorTitle,
  590. techAbroad: thisdata.techAbroad,
  591. techCore: thisdata.techCore,
  592. techForeign: thisdata.techForeign,
  593. techInService: thisdata.techInService,
  594. techPartTime: thisdata.techPartTime,
  595. techTemporary: thisdata.techTemporary,
  596. techTotal: thisdata.techTotal,
  597. thirtyoneToThirtyfour: thisdata.thirtyoneToThirtyfour,
  598. undergraduate: thisdata.undergraduate,
  599. attachment: [thisdata.rosterDownloadFileName, thisdata.socialSecurityDownloadFileName],
  600. newEmployment: thisdata.newEmployment,
  601. graduateNumber: thisdata.graduateNumber
  602. });
  603. };
  604. this.state.pagination.current = data.data.pageNo;
  605. this.state.pagination.total = data.data.totalCount;
  606. this.setState({
  607. dataSource: this.state.data,
  608. pagination: this.state.pagination
  609. });
  610. }).always(function () {
  611. this.setState({
  612. loading: false
  613. });
  614. }.bind(this));
  615. },
  616. getInitialState() {
  617. return {
  618. selectedRowKeys: [],
  619. selectedRows: [],
  620. loading: false,
  621. pagination: {
  622. defaultCurrent: 1,
  623. defaultPageSize: 10,
  624. showQuickJumper: true,
  625. pageSize: 10,
  626. onChange: function (page) {
  627. this.loadData(page);
  628. }.bind(this),
  629. showTotal: function (total) {
  630. return '共' + total + '条数据';
  631. }
  632. },
  633. columns: [
  634. {
  635. title: '年份',
  636. dataIndex: 'year',
  637. key: 'year'
  638. }, {
  639. title: '总人数',
  640. dataIndex: 'firmTotal',
  641. key: 'firmTotal'
  642. }, {
  643. title: '科技人员',
  644. dataIndex: 'techTotal',
  645. key: 'techTotal'
  646. }, {
  647. title: '博士人数',
  648. dataIndex: 'doctor',
  649. key: 'doctor',
  650. }, {
  651. title: '高级职称人数',
  652. dataIndex: 'seniorTitle',
  653. key: 'seniorTitle',
  654. }, {
  655. title: '30岁以下人数',
  656. dataIndex: 'belowThirty',
  657. key: 'belowThirty',
  658. }, {
  659. title: '相关附件',
  660. dataIndex: 'attachment',
  661. key: 'attachment',
  662. render: (text) => {
  663. <a href="" onClick={() => {
  664. window.open(globalConfig.context + "/techservice/patent/downloadFile?path=" + text + "&sign=" + "type")
  665. }}></a>
  666. }
  667. }
  668. ],
  669. dataSource: []
  670. };
  671. },
  672. componentWillMount() {
  673. this.loadData();
  674. },
  675. tableRowClick(record, index) {
  676. this.state.RowData = record;
  677. this.setState({
  678. showDesc: true
  679. });
  680. },
  681. delectRow() {
  682. let deletedIds = [];
  683. for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
  684. let rowItem = this.state.selectedRows[idx];
  685. if (rowItem.id) {
  686. deletedIds.push(rowItem.id)
  687. }
  688. }
  689. this.setState({
  690. selectedRowKeys: [],
  691. loading: deletedIds.length > 0
  692. });
  693. $.ajax({
  694. method: "POST",
  695. dataType: "json",
  696. crossDomain: false,
  697. url: globalConfig.context + "/techservice/cognizance/deleteFinance",
  698. data: {
  699. ids: deletedIds
  700. }
  701. }).done(function (data) {
  702. if (!data.error.length) {
  703. message.success('保存成功!');
  704. this.setState({
  705. loading: false,
  706. });
  707. } else {
  708. message.warning(data.error[0].message);
  709. };
  710. this.loadData();
  711. }.bind(this));
  712. },
  713. closeDesc(e) {
  714. this.state.showDesc = e;
  715. this.loadData();
  716. },
  717. render() {
  718. const rowSelection = {
  719. selectedRowKeys: this.state.selectedRowKeys,
  720. onChange: (selectedRowKeys, selectedRows) => {
  721. this.setState({
  722. selectedRows: selectedRows,
  723. selectedRowKeys: selectedRowKeys
  724. });
  725. }
  726. };
  727. const hasSelected = this.state.selectedRowKeys.length > 0;
  728. return (
  729. <div className="user-content" >
  730. <div className="content-title">
  731. <span>人力资源状况</span>
  732. </div>
  733. <div className="user-search">
  734. <p>
  735. <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
  736. onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
  737. <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
  738. disabled={!hasSelected}
  739. onClick={this.delectRow}>删除<Icon type="minus" /></Button>
  740. </p>
  741. </div>
  742. <div className="patent-table">
  743. <Spin spinning={this.state.loading}>
  744. <Table columns={this.state.columns}
  745. dataSource={this.state.dataSource}
  746. pagination={this.state.pagination}
  747. rowSelection={rowSelection}
  748. onRowClick={this.tableRowClick} />
  749. </Spin>
  750. </div>
  751. <HrSituationDesc data={this.state.RowData}
  752. showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
  753. </div >
  754. );
  755. }
  756. });
  757. export default HrSituation;