161 lines
5.4 KiB
JavaScript
161 lines
5.4 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 退差组件
|
|
* Description:
|
|
* Date: 2022/11/22
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { message, Modal } from "antd";
|
|
import RegTop from "./regTop";
|
|
import RegList from "./regList";
|
|
import RegAddEmployee from "./regAddEmployee";
|
|
import RegEditDetial from "./regEditDetial";
|
|
import { convertToUrlString } from "../../../../util/url";
|
|
import { calcPageNo } from "../../../../util";
|
|
import * as API from "../../../../apis/standingBook";
|
|
import "./index.less";
|
|
|
|
class Regression extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
selectKey: [],
|
|
returnPersonModal: {
|
|
title: "添加退差人员",
|
|
visible: false
|
|
},
|
|
returnEditPersonSlide: {
|
|
title: "",
|
|
editId: "",
|
|
visible: false
|
|
},
|
|
loading: { save: false }
|
|
};
|
|
this.regEmmployeeRef = null;
|
|
this.regListRef = null;
|
|
this.regTopRef = null;
|
|
}
|
|
|
|
delRecession = () => {
|
|
const { selectKey } = this.state;
|
|
API.delRecession(selectKey).then(({ status, errormsg }) => {
|
|
if (status) {
|
|
message.success("删除成功");
|
|
const current = calcPageNo(this.regListRef.state.pageInfo.total, this.regListRef.state.pageInfo.current, 10, selectKey.length);
|
|
this.regListRef.recessionList({ current });
|
|
this.regListRef.handleResetSelectRowKeys([]);
|
|
this.setState({ selectKey: [] });
|
|
} else {
|
|
message.error(errormsg || "删除失败");
|
|
}
|
|
});
|
|
};
|
|
handleSave = (params) => {
|
|
const { loading } = this.state;
|
|
const payload = {
|
|
...params, ..._.pick(this.props, ["billMonth", "paymentOrganization"])
|
|
};
|
|
this.setState({ loading: { ...loading, save: true } });
|
|
API.saveRecession(payload).then(({ status, errormsg }) => {
|
|
this.setState({ loading: { ...loading, save: false } });
|
|
if (status) {
|
|
message.success("操作成功。若退差月无核算明细,账单月则无法获取退差数据。");
|
|
this.handleCloseModal();
|
|
} else {
|
|
message.error(errormsg || "操作失败");
|
|
}
|
|
});
|
|
};
|
|
handleChangeOpt = (key) => {
|
|
const { returnPersonModal } = this.state;
|
|
const name = this.regTopRef.state.name;
|
|
const workcode = this.regTopRef.state.workcode;
|
|
const departmentIds = this.regTopRef.state.departmentIds ? this.regTopRef.state.departmentIds.split(",") : [];
|
|
const subCompanyIds = this.regTopRef.state.subCompanyIds ? this.regTopRef.state.subCompanyIds.split(",") : [];
|
|
switch (key) {
|
|
case "add":
|
|
this.setState({ returnPersonModal: { ...returnPersonModal, visible: true } });
|
|
break;
|
|
case "delete":
|
|
Modal.confirm({
|
|
title: "信息确认",
|
|
content: "删除人员本账单月将不包含该人员的退差数据!",
|
|
onOk: () => {
|
|
this.delRecession();
|
|
},
|
|
onCancel: () => {
|
|
}
|
|
});
|
|
break;
|
|
case "export":
|
|
const extraParams = {
|
|
name,
|
|
workcode,
|
|
departmentIds: this.regTopRef.state.departmentIds,
|
|
subCompanyIds: this.regTopRef.state.subCompanyIds
|
|
};
|
|
const url = `/api/bs/hrmsalary/welfare/recession/export?${convertToUrlString({ ..._.pick(this.props, ["billMonth", "paymentOrganization", "creator"]), ...extraParams })}`;
|
|
window.open(url, "_blank");
|
|
break;
|
|
case "search":
|
|
this.regListRef.recessionList({ userName: name, workcode, departmentIds, subCompanyIds, current: 1 });
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
};
|
|
handleCloseModal = (refreshList = false) => {
|
|
const { returnPersonModal, returnEditPersonSlide } = this.state;
|
|
this.setState({
|
|
returnPersonModal: { ...returnPersonModal, visible: false, title: "添加退差人员" },
|
|
returnEditPersonSlide: { ...returnEditPersonSlide, visible: false, title: "", editId: "" }
|
|
}, () => {
|
|
this.regEmmployeeRef.handleReset();
|
|
refreshList && this.regListRef.recessionList();
|
|
});
|
|
};
|
|
handleEdit = (record) => {
|
|
const { userName, id: editId } = record;
|
|
const { returnEditPersonSlide } = this.state;
|
|
this.setState({
|
|
returnEditPersonSlide: { ...returnEditPersonSlide, visible: true, title: userName, editId }
|
|
});
|
|
};
|
|
|
|
render() {
|
|
const { returnPersonModal, returnEditPersonSlide, selectKey, loading } = this.state;
|
|
return (
|
|
<div className="regressionWrapper">
|
|
<RegTop
|
|
{..._.pick(this.props, ["billMonth", "type"])}
|
|
regtopType="regression"
|
|
ref={dom => this.regTopRef = dom}
|
|
onChange={this.handleChangeOpt}
|
|
selectKey={selectKey}
|
|
/>
|
|
<div className="tableWrapper">
|
|
<RegList
|
|
{..._.pick(this.props, ["billMonth", "paymentOrganization", "creator", "type"])}
|
|
regType="regression"
|
|
ref={dom => this.regListRef = dom}
|
|
visible={returnPersonModal.visible}
|
|
onChangeRowkey={(selectKey) => this.setState({ selectKey })}
|
|
onEdit={this.handleEdit}
|
|
/>
|
|
{/*编辑弹框*/}
|
|
<RegEditDetial {...returnEditPersonSlide} onCancel={this.handleCloseModal}/>
|
|
{/* 弹框 */}
|
|
<RegAddEmployee
|
|
ref={dom => this.regEmmployeeRef = dom}
|
|
{...returnPersonModal}
|
|
loading={loading}
|
|
onCancel={this.handleCloseModal}
|
|
onSave={this.handleSave}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Regression; |