hrSituation.jsx 34 KB

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