hrSituation.jsx 34 KB

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