hrSituation.jsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  1. import React from 'react';
  2. import { Input, InputNumber, Button, Form, Icon, Spin, message, Tabs, Upload } from 'antd';
  3. import { beforeUpload } from '../../tools.js';
  4. import './person.less';
  5. import './hrSituation.less'
  6. import ajax from 'jquery/src/ajax/xhr.js'
  7. import $ from 'jquery/src/ajax';
  8. const PersonFrom = Form.create()(React.createClass({
  9. getData() {
  10. this.props.spinState(true);
  11. $.ajax({
  12. method: "get",
  13. dataType: "json",
  14. url: globalConfig.context + "/api/user/humanResource",
  15. data: {
  16. year: this.props.year
  17. },
  18. success: function (data) {
  19. if (data.data) {
  20. this.setState({
  21. aboveFifty: data.data.aboveFifty,
  22. belowThirty: data.data.belowThirty,
  23. college: data.data.college,
  24. doctor: data.data.doctor,
  25. firmAbroad: data.data.firmAbroad,
  26. firmCore: data.data.firmCore,
  27. firmForeign: data.data.firmForeign,
  28. firmInService: data.data.firmInService,
  29. firmPartTime: data.data.firmPartTime,
  30. firmTemporary: data.data.firmTemporary,
  31. firmTotal: data.data.firmTotal,
  32. fortyoneToFifty: data.data.fortyoneToFifty,
  33. intermediateTitle: data.data.intermediateTitle,
  34. juniorTitle: data.data.juniorTitle,
  35. master: data.data.master,
  36. seniorMechanic: data.data.seniorMechanic,
  37. seniorTitle: data.data.seniorTitle,
  38. techAbroad: data.data.techAbroad,
  39. techCore: data.data.techCore,
  40. techForeign: data.data.techForeign,
  41. techInService: data.data.techInService,
  42. techPartTime: data.data.techPartTime,
  43. techTemporary: data.data.techTemporary,
  44. techTotal: data.data.techTotal,
  45. thirtyoneToThirtyfour: data.data.thirtyoneToThirtyfour,
  46. undergraduate: data.data.undergraduate
  47. });
  48. }
  49. }.bind(this),
  50. }).always(function () {
  51. this.props.spinState(false);
  52. }.bind(this));
  53. },
  54. getInitialState() {
  55. return {
  56. loading: false
  57. };
  58. },
  59. handleSubmit(e) {
  60. e.preventDefault();
  61. this.props.form.validateFields((err, values) => {
  62. if (values.firmTotal < values.firmInService + values.firmPartTime + values.firmTemporary) {
  63. message.warning("总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数!");
  64. return;
  65. };
  66. if (values.firmTotal < values.techTotal) {
  67. message.warning("科技人员数小于等于企业职工总数!");
  68. return;
  69. };
  70. if (values.firmInService < values.techInService || values.firmPartTime < values.techPartTime || values.firmTemporary < values.techTemporary ||
  71. values.firmForeign < values.techForeign || values.firmAbroad < values.techAbroad || values.firmCore < values.techCore) {
  72. message.warning("科技人员各项人数小于等于企业职工各项人数!");
  73. return;
  74. };
  75. if (values.firmTotal < values.doctor + values.master + values.undergraduate + values.college) {
  76. message.warning("全体人员结构中学历一栏人数总和小于等于职工人数!");
  77. return;
  78. };
  79. if (values.firmTotal < values.belowThirty + values.thirtyoneToThirtyfour + values.fortyoneToFifty + values.aboveFifty) {
  80. message.warning("全体人员结构中年龄一栏人数总和小于等于职工人数!");
  81. return;
  82. };
  83. if (!err) {
  84. this.props.spinState(true);
  85. $.ajax({
  86. method: "POST",
  87. dataType: "json",
  88. crossDomain: false,
  89. url: globalConfig.context + "/api/user/SaveHumanResource",
  90. data: {
  91. year: this.props.year,
  92. aboveFifty: values.aboveFifty,
  93. belowThirty: values.belowThirty,
  94. college: values.college,
  95. doctor: values.doctor,
  96. firmAbroad: values.firmAbroad,
  97. firmCore: values.firmCore,
  98. firmForeign: values.firmForeign,
  99. firmInService: values.firmInService,
  100. firmPartTime: values.firmPartTime,
  101. firmTemporary: values.firmTemporary,
  102. firmTotal: values.firmTotal,
  103. fortyoneToFifty: values.fortyoneToFifty,
  104. intermediateTitle: values.intermediateTitle,
  105. juniorTitle: values.juniorTitle,
  106. master: values.master,
  107. seniorMechanic: values.seniorMechanic,
  108. seniorTitle: values.seniorTitle,
  109. techAbroad: values.techAbroad,
  110. techCore: values.techCore,
  111. techForeign: values.techForeign,
  112. techInService: values.techInService,
  113. techPartTime: values.techPartTime,
  114. techTemporary: values.techTemporary,
  115. techTotal: values.techTotal,
  116. thirtyoneToThirtyfour: values.thirtyoneToThirtyfour,
  117. undergraduate: values.undergraduate,
  118. rosterUrl:this.state.rosterUrl,
  119. socialSecurityUrl:this.state.socialSecurityUrl
  120. }
  121. }).done(function (data) {
  122. if (!data.error.length) {
  123. message.success('保存成功!');
  124. } else {
  125. message.warning(data.error[0].message);
  126. }
  127. }.bind(this)).always(function () {
  128. this.props.spinState(false);
  129. }.bind(this));
  130. }
  131. });
  132. },
  133. componentWillMount() {
  134. this.getData();
  135. },
  136. render() {
  137. const { getFieldDecorator } = this.props.form;
  138. const formItemLayout = {
  139. labelCol: { span: 8 },
  140. wrapperCol: { span: 16 },
  141. };
  142. const FormItem = Form.Item;
  143. return (
  144. <Form onSubmit={this.handleSubmit} className="hrSituation-form">
  145. <p className="hrSituation-title">总体情况</p>
  146. <div className="clearfix">
  147. <span className="hrSituation-span">总数(人)</span>
  148. <FormItem className="half-item"
  149. {...formItemLayout}
  150. label="企业职工"
  151. >
  152. {getFieldDecorator('firmTotal', {
  153. initialValue: this.state.firmTotal || null
  154. })(
  155. <InputNumber />
  156. )}
  157. </FormItem>
  158. <FormItem className="half-item"
  159. style={{ marginRight: "50%" }}
  160. {...formItemLayout}
  161. label="科技人员"
  162. >
  163. {getFieldDecorator('techTotal', {
  164. initialValue: this.state.techTotal || null
  165. })(
  166. <InputNumber />
  167. )}
  168. </FormItem>
  169. <span className="hrSituation-span">在职人员(人)</span>
  170. <FormItem className="half-item"
  171. {...formItemLayout}
  172. label="企业职工"
  173. >
  174. {getFieldDecorator('firmInService', {
  175. initialValue: this.state.firmInService || null
  176. })(
  177. <InputNumber />
  178. )}
  179. </FormItem>
  180. <FormItem className="half-item"
  181. {...formItemLayout}
  182. label="科技人员"
  183. >
  184. {getFieldDecorator('techInService', {
  185. initialValue: this.state.techInService || null
  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.state.firmPartTime || null
  197. })(
  198. <InputNumber />
  199. )}
  200. </FormItem>
  201. <FormItem className="half-item"
  202. {...formItemLayout}
  203. label="科技人员"
  204. >
  205. {getFieldDecorator('techPartTime', {
  206. initialValue: this.state.techPartTime || null
  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.state.firmTemporary || null
  218. })(
  219. <InputNumber />
  220. )}
  221. </FormItem>
  222. <FormItem className="half-item"
  223. {...formItemLayout}
  224. label="科技人员"
  225. >
  226. {getFieldDecorator('techTemporary', {
  227. initialValue: this.state.techTemporary || null
  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.state.firmForeign || null
  239. })(
  240. <InputNumber />
  241. )}
  242. </FormItem>
  243. <FormItem className="half-item"
  244. {...formItemLayout}
  245. label="科技人员"
  246. >
  247. {getFieldDecorator('techForeign', {
  248. initialValue: this.state.techForeign || null
  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.state.firmAbroad || null
  260. })(
  261. <InputNumber />
  262. )}
  263. </FormItem>
  264. <FormItem className="half-item"
  265. {...formItemLayout}
  266. label="科技人员"
  267. >
  268. {getFieldDecorator('techAbroad', {
  269. initialValue: this.state.techAbroad || null
  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.state.firmCore || null
  281. })(
  282. <InputNumber />
  283. )}
  284. </FormItem>
  285. <FormItem className="half-item"
  286. {...formItemLayout}
  287. label="科技人员"
  288. >
  289. {getFieldDecorator('techCore', {
  290. initialValue: this.state.techCore || null
  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.state.doctor || null
  305. })(
  306. <InputNumber />
  307. )}
  308. </FormItem>
  309. <FormItem className="half-item"
  310. {...formItemLayout}
  311. label="硕士"
  312. >
  313. {getFieldDecorator('master', {
  314. initialValue: this.state.master || null
  315. })(
  316. <InputNumber />
  317. )}
  318. </FormItem>
  319. <FormItem className="half-item"
  320. {...formItemLayout}
  321. label="本科"
  322. >
  323. {getFieldDecorator('undergraduate', {
  324. initialValue: this.state.undergraduate || null
  325. })(
  326. <InputNumber />
  327. )}
  328. </FormItem>
  329. <FormItem className="half-item"
  330. {...formItemLayout}
  331. label="大专及以下"
  332. >
  333. {getFieldDecorator('college', {
  334. initialValue: this.state.college || null
  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.state.seniorTitle || null
  348. })(
  349. <InputNumber />
  350. )}
  351. </FormItem>
  352. <FormItem className="half-item"
  353. {...formItemLayout}
  354. label="中级职称"
  355. >
  356. {getFieldDecorator('intermediateTitle', {
  357. initialValue: this.state.intermediateTitle || null
  358. })(
  359. <InputNumber />
  360. )}
  361. </FormItem>
  362. <FormItem className="half-item"
  363. {...formItemLayout}
  364. label="初级职称"
  365. >
  366. {getFieldDecorator('juniorTitle', {
  367. initialValue: this.state.juniorTitle || null
  368. })(
  369. <InputNumber />
  370. )}
  371. </FormItem>
  372. <FormItem className="half-item"
  373. {...formItemLayout}
  374. label="高级技工"
  375. >
  376. {getFieldDecorator('seniorMechanic', {
  377. initialValue: this.state.seniorMechanic || null
  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.state.belowThirty || null
  391. })(
  392. <InputNumber />
  393. )}
  394. </FormItem>
  395. <FormItem className="half-item"
  396. {...formItemLayout}
  397. label="31-34"
  398. >
  399. {getFieldDecorator('thirtyoneToThirtyfour', {
  400. initialValue: this.state.thirtyoneToThirtyfour || null
  401. })(
  402. <InputNumber />
  403. )}
  404. </FormItem>
  405. <FormItem className="half-item"
  406. {...formItemLayout}
  407. label="41-50"
  408. >
  409. {getFieldDecorator('fortyoneToFifty', {
  410. initialValue: this.state.fortyoneToFifty || null
  411. })(
  412. <InputNumber />
  413. )}
  414. </FormItem>
  415. <FormItem className="half-item"
  416. {...formItemLayout}
  417. label="50以上"
  418. >
  419. {getFieldDecorator('aboveFifty', {
  420. initialValue: this.state.aboveFifty || null
  421. })(
  422. <InputNumber />
  423. )}
  424. </FormItem>
  425. </div>
  426. <div className="hrSituation-roster">
  427. <Upload
  428. name="socialSecurity"
  429. action={globalConfig.context + "/techservice/cognizance/upload"}
  430. data={{ 'sign': this.props.year + 'socialSecurity' }}
  431. beforeUpload={beforeUpload}
  432. onChange={(info) => {
  433. if (info.file.status !== 'uploading') {
  434. console.log(info.file, info.fileList);
  435. }
  436. if (info.file.status === 'done') {
  437. message.success(`${info.file.name} 文件上传成功!`);
  438. this.state.socialSecurityUrl = info.file.response.data;
  439. } else if (info.file.status === 'error') {
  440. message.error(`${info.file.name} 文件上传失败。`);
  441. }
  442. }}
  443. >
  444. <Button><Icon type="upload" /> 上传社保文件 </Button>
  445. </Upload>
  446. </div>
  447. <div className="hrSituation-roster">
  448. <Upload
  449. name="roster"
  450. action={globalConfig.context + "/techservice/cognizance/upload"}
  451. data={{ 'sign': this.props.year + 'roster' }}
  452. beforeUpload={beforeUpload}
  453. onChange={(info) => {
  454. if (info.file.status !== 'uploading') {
  455. console.log(info.file, info.fileList);
  456. }
  457. if (info.file.status === 'done') {
  458. message.success(`${info.file.name} 文件上传成功!`);
  459. this.state.rosterUrl = info.file.response.data;
  460. } else if (info.file.status === 'error') {
  461. message.error(`${info.file.name} 文件上传失败。`);
  462. }
  463. }}
  464. >
  465. <Button><Icon type="upload" /> 上传花名册文件 </Button>
  466. </Upload>
  467. </div>
  468. <div>
  469. <span style={{ color: "red" }}>提示</span>
  470. <p>1、总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数。</p>
  471. <p>2、科技人员数小于等于企业职工总数。</p>
  472. <p>3、科技人员各项人数小于等于企业职工各项人数。</p>
  473. <p>4、全体人员结构中学历一栏人数总和小于等于职工人数。</p>
  474. <p>5、全体人员结构中年龄一栏人数总和小于等于职工人数。</p>
  475. <Button style={{ marginTop: "20px" }} className="set-submit" type="primary" htmlType="submit">保存</Button>
  476. </div>
  477. </Form >
  478. );
  479. },
  480. }));
  481. const Person = React.createClass({
  482. getInitialState() {
  483. return {
  484. loading: false
  485. };
  486. },
  487. spinChange(e) {
  488. this.setState({
  489. loading: e
  490. });
  491. },
  492. render() {
  493. const theYear = (new Date()).getFullYear() - 1;
  494. return (
  495. <Spin spinning={this.state.loading} className='spin-box'>
  496. <div className="set-person">
  497. <div className="acc-detail">
  498. <Tabs defaultActiveKey={String(theYear)} >
  499. <Tabs.TabPane tab={theYear} key={theYear}>
  500. <PersonFrom year={theYear} spinState={this.spinChange} urlData={this.urlData}/>
  501. </Tabs.TabPane>
  502. <Tabs.TabPane tab={theYear - 1} key={theYear - 1}>
  503. <PersonFrom year={theYear - 1} spinState={this.spinChange} urlData={this.urlData}/>
  504. </Tabs.TabPane>
  505. <Tabs.TabPane tab={theYear - 2} key={theYear - 2}>
  506. <PersonFrom year={theYear - 2} spinState={this.spinChange} urlData={this.urlData}/>
  507. </Tabs.TabPane>
  508. </Tabs>
  509. </div>
  510. </div>
  511. </Spin>
  512. )
  513. }
  514. });
  515. export default Person;