123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837 |
- import React from 'react';
- import { Switch, Input, InputNumber, Button, Form, Icon, Spin, message, Table, Modal, Upload, Select } from 'antd';
- import { beforeUploadFile, newDownloadFile, getProportion, saveProportion, getPreview } from '../../../../tools.js';
- import './hrSituation.less'
- import ajax from 'jquery/src/ajax/xhr.js'
- import $ from 'jquery/src/ajax';
- const HrSituationDescFrom = Form.create()(React.createClass({
- getInitialState() {
- return {
- loading: false,
- yearOption: []
- };
- },
- componentWillMount() {
- let d = new Date();
- let _me = this;
- d = d.getFullYear();
- for (let i = d; i > d - 20; i--) {
- _me.state.yearOption.push(
- <Select.Option value={i.toString()} key={i}>{i}</Select.Option>
- )
- }
- },
- handleSubmit(e) {
- e.preventDefault();
- this.props.form.validateFields((err, values) => {
- if (values.firmTotal < values.firmInService + values.firmPartTime + values.firmTemporary) {
- message.warning("总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数!");
- return;
- };
- if (values.firmTotal < values.techTotal) {
- message.warning("科技人员数小于等于企业职工总数!");
- return;
- };
- if (values.firmInService < values.techInService || values.firmPartTime < values.techPartTime || values.firmTemporary < values.techTemporary ||
- values.firmForeign < values.techForeign || values.firmAbroad < values.techAbroad || values.firmCore < values.techCore) {
- message.warning("科技人员各项人数小于等于企业职工各项人数!");
- return;
- };
- if (values.firmTotal < values.doctor + values.master + values.undergraduate + values.college) {
- message.warning("全体人员结构中学历一栏人数总和小于等于职工人数!");
- return;
- };
- if (values.firmTotal < values.belowThirty + values.thirtyoneToThirtyfour + values.fortyoneToFifty + values.aboveFifty) {
- message.warning("全体人员结构中年龄一栏人数总和小于等于职工人数!");
- return;
- };
- if (!this.state.year && !this.props.data.year) {
- message.warning("请输入年份!");
- return;
- };
- if (!err) {
- this.props.spinState(true);
- $.ajax({
- method: "POST",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/updateOrgHumanResource",
- data: {
- id: this.props.data.id,
- uid: this.props.uid,
- year: this.state.year || this.props.data.year,
- aboveFifty: values.aboveFifty,
- belowThirty: values.belowThirty,
- college: values.college,
- doctor: values.doctor,
- firmAbroad: values.firmAbroad,
- firmCore: values.firmCore,
- firmForeign: values.firmForeign,
- firmInService: values.firmInService,
- firmPartTime: values.firmPartTime,
- firmTemporary: values.firmTemporary,
- firmTotal: values.firmTotal,
- fortyoneToFifty: values.fortyoneToFifty,
- intermediateTitle: values.intermediateTitle,
- juniorTitle: values.juniorTitle,
- master: values.master,
- seniorMechanic: values.seniorMechanic,
- seniorTitle: values.seniorTitle,
- techAbroad: values.techAbroad,
- techCore: values.techCore,
- techForeign: values.techForeign,
- techInService: values.techInService,
- techPartTime: values.techPartTime,
- techTemporary: values.techTemporary,
- techTotal: values.techTotal,
- thirtyoneToThirtyfour: values.thirtyoneToThirtyfour,
- undergraduate: values.undergraduate,
- rosterUrl: this.state.rosterUrl,
- socialSecurityUrl: this.state.socialSecurityUrl,
- newEmployment: values.newEmployment,
- graduateNumber: values.graduateNumber
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('保存成功!');
- this.props.clickOk();
- this.props.spinState(false);
- this.props.form.resetFields();
- } else {
- message.warning(data.error[0].message);
- this.props.spinState(false);
- }
- }.bind(this));
- }
- });
- },
- componentWillReceiveProps(nextProps) {
- if (!this.props.visible && nextProps.visible) {
- this.props.form.resetFields();
- this.state.fileList_roster = [];
- this.state.fileList_social_security = [];
- this.state.rosterUrl = undefined;
- this.state.socialSecurityUrl = undefined;
- };
- },
- render() {
- const { getFieldDecorator } = this.props.form;
- const formItemLayout = {
- labelCol: { span: 8 },
- wrapperCol: { span: 16 },
- };
- const FormItem = Form.Item;
- const theData = this.props.data;
- return (
- <Form onSubmit={this.handleSubmit} className="hrSituation-form">
- <div className="clearfix">
- <div className="activityCost-title"><span>年份: </span>
- {
- theData.year ? <span>{theData.year}</span> :
- <Select placeholder="请选择年份" style={{ width: 200 }}
- onSelect={(e, n) => { this.state.year = e }}>
- {this.state.yearOption}
- </Select>
- }
- </div>
- </div>
- <p className="hrSituation-title">总体情况</p>
- <div className="clearfix">
- <span className="hrSituation-span">总数(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmTotal', {
- initialValue: this.props.data.firmTotal || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techTotal', {
- initialValue: this.props.data.techTotal || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item" style={{ width: '50%' }}>
- <span>其中科技人员占比
- {(() => {
- if (!this.props.form.getFieldValue('techTotal') || !this.props.form.getFieldValue('firmTotal')) {
- return 0
- }
- return (this.props.form.getFieldValue('techTotal') / this.props.form.getFieldValue('firmTotal') * 100).toFixed(2)
- })()}
- %</span>
- </FormItem>
- <span className="hrSituation-span">在职人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmInService', {
- initialValue: this.props.data.firmInService || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techInService', {
- initialValue: this.props.data.techInService || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <span className="hrSituation-span">兼职人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmPartTime', {
- initialValue: this.props.data.firmPartTime || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techPartTime', {
- initialValue: this.props.data.techPartTime || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <span className="hrSituation-span">临时聘用人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmTemporary', {
- initialValue: this.props.data.firmTemporary || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techTemporary', {
- initialValue: this.props.data.techTemporary || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <span className="hrSituation-span">外籍人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmForeign', {
- initialValue: this.props.data.firmForeign || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techForeign', {
- initialValue: this.props.data.techForeign || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <span className="hrSituation-span">留学归国人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmAbroad', {
- initialValue: this.props.data.firmAbroad || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techAbroad', {
- initialValue: this.props.data.techAbroad || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <span className="hrSituation-span">干人计划人员(人)</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="企业职工"
- >
- {getFieldDecorator('firmCore', {
- initialValue: this.props.data.firmCore || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="科技人员"
- >
- {getFieldDecorator('techCore', {
- initialValue: this.props.data.techCore || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- </div>
- <p className="hrSituation-title">全体人员结构</p>
- <div className="clearfix">
- <span className="hrSituation-span">学历人数</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="博士"
- >
- {getFieldDecorator('doctor', {
- initialValue: this.props.data.doctor || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="硕士"
- >
- {getFieldDecorator('master', {
- initialValue: this.props.data.master || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="本科"
- >
- {getFieldDecorator('undergraduate', {
- initialValue: this.props.data.undergraduate || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="大专及以下"
- >
- {getFieldDecorator('college', {
- initialValue: this.props.data.college || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- </div>
- <div className="clearfix">
- <span className="hrSituation-span">职称人数</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="高级职称"
- >
- {getFieldDecorator('seniorTitle', {
- initialValue: this.props.data.seniorTitle || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="中级职称"
- >
- {getFieldDecorator('intermediateTitle', {
- initialValue: this.props.data.intermediateTitle || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="初级职称"
- >
- {getFieldDecorator('juniorTitle', {
- initialValue: this.props.data.juniorTitle || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="高级技工"
- >
- {getFieldDecorator('seniorMechanic', {
- initialValue: this.props.data.seniorMechanic || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- </div>
- <div className="clearfix">
- <span className="hrSituation-span">年龄人数</span>
- <FormItem className="half-item"
- {...formItemLayout}
- label="30及以下"
- >
- {getFieldDecorator('belowThirty', {
- initialValue: this.props.data.belowThirty || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="31-40"
- >
- {getFieldDecorator('thirtyoneToThirtyfour', {
- initialValue: this.props.data.thirtyoneToThirtyfour || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="41-50"
- >
- {getFieldDecorator('fortyoneToFifty', {
- initialValue: this.props.data.fortyoneToFifty || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem className="half-item"
- {...formItemLayout}
- label="51及以上"
- >
- {getFieldDecorator('aboveFifty', {
- initialValue: this.props.data.aboveFifty || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- </div>
- <p className="hrSituation-title">每年新增员工数</p>
- <div className="clearfix">
- <FormItem
- labelCol={{ span: 16 }}
- wrapperCol={{ span: 8 }}
- label="新增就业人数"
- >
- {getFieldDecorator('newEmployment', {
- initialValue: this.props.data.newEmployment || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- <FormItem
- labelCol={{ span: 16 }}
- wrapperCol={{ span: 8 }}
- label="高校应届毕业生人数"
- >
- {getFieldDecorator('graduateNumber', {
- initialValue: this.props.data.graduateNumber || 0
- })(
- <InputNumber />
- )}
- </FormItem>
- </div>
- <div className="hrSituation-roster">
- <Upload
- name="ratepay"
- action={globalConfig.context + "/api/admin/uploadRoster"}
- data={{ 'sign': 'roster', 'year': (this.state.year || theData.year), 'uid': this.props.uid }}
- beforeUpload={beforeUploadFile}
- fileList={this.state.fileList_roster}
- onChange={(info) => {
- if (info.file.status !== 'uploading') {
- console.log(info.file, info.fileList);
- }
- if (info.file.status === 'done') {
- if (!info.file.response.error.length) {
- message.success(`${info.file.name} 文件上传成功!`);
- } else {
- message.warning(info.file.response.error[0].message);
- return;
- };
- this.state.rosterUrl = info.file.response.data;
- } else if (info.file.status === 'error') {
- message.error(`${info.file.name} 文件上传失败。`);
- };
- this.setState({ fileList_roster: info.fileList.slice(-1) });
- }}
- >
- <Button><Icon type="upload" /> 上传花名册 </Button>
- </Upload>
- <p style={{ marginTop: '10px' }}>{theData.rosterUrl ?
- <span className="download-file">
- <a onClick={newDownloadFile.bind(null, this.props.data.id, 'roster', '/api/admin/downloadHumanResource')}>{theData.rosterDownloadFileName}</a>
- <a onClick={() => {
- var newTab = window.open('about:blank'); getPreview(theData.id, 'humanResource', 'roster', function (data) { newTab.location.href = data; });
- }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
- </span>
- : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
- </div>
- <div className="hrSituation-roster">
- <Upload
- name="ratepay"
- action={globalConfig.context + "/api/admin/uploadSocialSecurity"}
- data={{ 'sign': 'social_security', 'year': (this.state.year || theData.year), 'uid': this.props.uid }}
- beforeUpload={beforeUploadFile}
- fileList={this.state.fileList_social_security}
- onChange={(info) => {
- if (info.file.status !== 'uploading') {
- console.log(info.file, info.fileList);
- }
- if (info.file.status === 'done') {
- if (!info.file.response.error.length) {
- message.success(`${info.file.name} 文件上传成功!`);
- } else {
- message.warning(info.file.response.error[0].message);
- return;
- };
- this.state.socialSecurityUrl = info.file.response.data;
- } else if (info.file.status === 'error') {
- message.error(`${info.file.name} 文件上传失败。`);
- };
- this.setState({ fileList_social_security: info.fileList.slice(-1) });
- }}
- >
- <Button><Icon type="upload" /> 上传社保情况 </Button>
- </Upload>
- <p style={{ marginTop: '10px' }}>{theData.socialSecurityUrl ?
- <span className="download-file">
- <a onClick={newDownloadFile.bind(null, this.props.data.id, 'social_security', '/api/admin/downloadHumanResource')}>{theData.socialSecurityDownloadFileName}</a>
- <a onClick={() => {
- var newTab = window.open('about:blank'); getPreview(theData.id, 'humanResource', 'social_security', function (data) { newTab.location.href = data; });
- }}><Icon style={{ fontSize: '16px' }} type="eye-o" /></a>
- </span>
- : <span><Icon type="exclamation-circle" style={{ color: '#ffbf00', marginRight: '6px' }} />未上传!</span>}</p>
- </div>
- <div>
- <span style={{ color: "red" }}>提示</span>
- <p>1、总体情况的在职人员数、兼职人员数、临时聘用人员数相加小于等于企业职工总数。</p>
- <p>2、科技人员数小于等于企业职工总数。</p>
- <p>3、科技人员各项人数小于等于企业职工各项人数。</p>
- <p>4、全体人员结构中学历一栏人数总和小于等于职工人数。</p>
- <p>5、全体人员结构中年龄一栏人数总和小于等于职工人数。</p>
- <Button style={{ marginTop: "20px" }} className="set-submit" type="primary" htmlType="submit">保存</Button>
- </div>
- </Form >
- );
- },
- }));
- const HrSituationDesc = React.createClass({
- getInitialState() {
- return {
- visible: false,
- loading: false
- };
- },
- componentWillReceiveProps(nextProps) {
- this.state.visible = nextProps.showDesc
- },
- showModal() {
- this.setState({
- visible: true,
- });
- },
- handleOk() {
- this.setState({
- visible: false,
- });
- this.props.closeDesc(false, true);
- },
- handleCancel(e) {
- this.setState({
- visible: false,
- });
- this.props.closeDesc(false);
- },
- spinChange(e) {
- this.setState({
- loading: e
- });
- },
- render() {
- return (
- <div className="patent-addNew">
- <Modal maskClosable={false} title="人力资源状况" visible={this.state.visible}
- onOk={this.handleOk} onCancel={this.handleCancel}
- width='1200px'
- footer=''>
- <Spin spinning={this.state.loading} className='spin-box'>
- <HrSituationDescFrom
- uid={this.props.uid}
- data={this.props.data}
- spinState={this.spinChange}
- visible={this.state.visible}
- closeModal={this.handleCancel}
- clickOk={this.handleOk} />
- </Spin>
- </Modal>
- </div>
- );
- },
- });
- const HrSituation = React.createClass({
- loadData(pageNo) {
- this.state.data = [];
- this.setState({
- loading: true
- });
- $.ajax({
- method: "post",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/orgHumanResource",
- data: {
- pageNo: pageNo || 1,
- pageSize: this.state.pagination.pageSize,
- uid: this.props.data.uid
- }
- }).done((data) => {
- if (data.error.length || !data.data || !data.data.list) {
- message.warning(data.error[0].message);
- return;
- };
- for (let i = 0; i < data.data.list.length; i++) {
- let thisdata = data.data.list[i];
- this.state.data.push({
- key: i,
- id: thisdata.id,
- uid: thisdata.uid,
- year: thisdata.year,
- aboveFifty: thisdata.aboveFifty,
- belowThirty: thisdata.belowThirty,
- college: thisdata.college,
- doctor: thisdata.doctor,
- firmAbroad: thisdata.firmAbroad,
- firmCore: thisdata.firmCore,
- firmForeign: thisdata.firmForeign,
- firmInService: thisdata.firmInService,
- firmPartTime: thisdata.firmPartTime,
- firmTemporary: thisdata.firmTemporary,
- firmTotal: thisdata.firmTotal,
- fortyoneToFifty: thisdata.fortyoneToFifty,
- intermediateTitle: thisdata.intermediateTitle,
- juniorTitle: thisdata.juniorTitle,
- master: thisdata.master,
- seniorMechanic: thisdata.seniorMechanic,
- seniorTitle: thisdata.seniorTitle,
- techAbroad: thisdata.techAbroad,
- techCore: thisdata.techCore,
- techForeign: thisdata.techForeign,
- techInService: thisdata.techInService,
- techPartTime: thisdata.techPartTime,
- techTemporary: thisdata.techTemporary,
- techTotal: thisdata.techTotal,
- thirtyoneToThirtyfour: thisdata.thirtyoneToThirtyfour,
- undergraduate: thisdata.undergraduate,
- rosterUrl: thisdata.rosterUrl,
- rosterDownloadFileName: thisdata.rosterDownloadFileName,
- socialSecurityUrl: thisdata.socialSecurityUrl,
- socialSecurityDownloadFileName: thisdata.socialSecurityDownloadFileName,
- attachment: [thisdata.id, thisdata.rosterDownloadFileName, thisdata.socialSecurityDownloadFileName],
- newEmployment: thisdata.newEmployment,
- graduateNumber: thisdata.graduateNumber
- });
- };
- this.state.pagination.current = data.data.pageNo;
- this.state.pagination.total = data.data.totalCount;
- this.setState({
- dataSource: this.state.data,
- pagination: this.state.pagination
- });
- }).always(function () {
- this.setState({
- loading: false
- });
- }.bind(this));
- let _me = this;
- getProportion(this.props.data.uid, function (data) { _me.setState({ proportion: data }); });
- },
- getInitialState() {
- return {
- selectedRowKeys: [],
- selectedRows: [],
- loading: false,
- pagination: {
- defaultCurrent: 1,
- defaultPageSize: 10,
- showQuickJumper: true,
- pageSize: 10,
- onChange: function (page) {
- this.loadData(page);
- }.bind(this),
- showTotal: function (total) {
- return '共' + total + '条数据';
- }
- },
- columns: [
- {
- title: '年份',
- dataIndex: 'year',
- key: 'year'
- }, {
- title: '总人数',
- dataIndex: 'firmTotal',
- key: 'firmTotal'
- }, {
- title: '科技人员',
- dataIndex: 'techTotal',
- key: 'techTotal'
- }, {
- title: '博士人数',
- dataIndex: 'doctor',
- key: 'doctor',
- }, {
- title: '高级职称人数',
- dataIndex: 'seniorTitle',
- key: 'seniorTitle',
- }, {
- title: '30岁以下人数',
- dataIndex: 'belowThirty',
- key: 'belowThirty',
- }, {
- title: '相关附件',
- dataIndex: 'attachment',
- key: 'attachment',
- render: (text) => {
- return <div>
- <a style={{ marginRight: '10px' }} onClick={newDownloadFile.bind(null, text[0], 'roster', '/api/admin/downloadHumanResource')}>{text[1]}</a>
- <a onClick={newDownloadFile.bind(null, text[0], 'social_security', '/api/admin/downloadHumanResource')}>{text[2]}</a>
- </div>
- }
- }
- ],
- dataSource: []
- };
- },
- componentWillMount() {
- this.loadData();
- },
- tableRowClick(record, index) {
- this.state.RowData = record;
- this.setState({
- showDesc: true
- });
- },
- delectRow() {
- let deletedIds = [];
- for (let idx = 0; idx < this.state.selectedRows.length; idx++) {
- let rowItem = this.state.selectedRows[idx];
- if (rowItem.id) {
- deletedIds.push(rowItem.id)
- }
- }
- this.setState({
- selectedRowKeys: [],
- loading: deletedIds.length > 0
- });
- $.ajax({
- method: "POST",
- dataType: "json",
- crossDomain: false,
- url: globalConfig.context + "/api/admin/deleteHumanResource",
- data: {
- ids: deletedIds
- }
- }).done(function (data) {
- if (!data.error.length) {
- message.success('删除成功!');
- this.setState({
- loading: false,
- });
- } else {
- message.warning(data.error[0].message);
- };
- this.loadData();
- }.bind(this));
- },
- closeDesc(e, s) {
- this.state.showDesc = e;
- if (s) {
- this.loadData();
- };
- },
- render() {
- const rowSelection = {
- selectedRowKeys: this.state.selectedRowKeys,
- onChange: (selectedRowKeys, selectedRows) => {
- this.setState({
- selectedRows: selectedRows,
- selectedRowKeys: selectedRowKeys
- });
- }
- };
- const hasSelected = this.state.selectedRowKeys.length > 0;
- return (
- <div className="user-content" >
- <div className="content-title">
- <span>人力资源状况</span>
- <span className="proportion"> 是否已完成:</span>
- <Switch
- checked={this.state.proportion && this.state.proportion.humanResource == 1 ? true : false}
- checkedChildren={'已完成'}
- unCheckedChildren={'未完成'}
- onChange={(e) => {
- e ? this.state.proportion.humanResource = 1 : this.state.proportion.humanResource = 0;
- saveProportion(this.state.proportion.id, this.props.data.uid, 'humanResource', this.state.proportion.humanResource);
- this.setState({ proportion: this.state.proportion });
- }} />
- </div>
- <div className="user-search">
- <p>
- <Button style={{ background: "#ea0862", border: "none", color: "#fff" }}
- onClick={this.tableRowClick}>添加<Icon type="plus" /></Button>
- <Button style={{ background: "#3fcf9e", border: "none", color: "#fff" }}
- disabled={!hasSelected}
- onClick={this.delectRow}>删除<Icon type="minus" /></Button>
- </p>
- </div>
- <div className="patent-table">
- <Spin spinning={this.state.loading}>
- <Table columns={this.state.columns}
- dataSource={this.state.dataSource}
- pagination={this.state.pagination}
- rowSelection={rowSelection}
- style={{
- cursor: 'pointer',
- }}
- onRowClick={this.tableRowClick} />
- </Spin>
- </div>
- <HrSituationDesc
- uid={this.props.data.uid}
- data={this.state.RowData}
- showDesc={this.state.showDesc} closeDesc={this.closeDesc} />
- </div >
- );
- }
- });
- export default HrSituation;
|