hrSituation.jsx 35 KB

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