hrSituation.jsx 37 KB

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