salary-management-front/pc4mobx/hrmSalary/pages/employeedeclareDetail/components/deductionListConfirmDialog.js

113 lines
4.6 KiB
JavaScript

/*
* 扣除名单确认
* @Author: 黎永顺
* @Date: 2025/3/26
* @Wechat:
* @Email: 971387674@qq.com
* @description:
*/
import React, { Component } from "react";
import { WeaButtonIcon, WeaDialog, WeaLocaleProvider, WeaTable, WeaTools } from "ecCom";
import { message, Modal } from "antd";
import DeductionListConfirmEmployeeDialog from "./deductionListConfirmEmployeeDialog";
import * as API from "../../../apis/declare";
const { getLabel } = WeaLocaleProvider, { getUrlParams } = WeaTools;
class DeductionListConfirmDialog extends Component {
constructor(props) {
super(props);
this.state = {
pageInfo: { current: 1, pageSize: 10, total: 0 }, loading: false, columns: [], dataSource: [], visible: false,
selectedRowKeys: []
};
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) this.getDeductionAmountList(nextProps);
if (nextProps.visible !== this.props.visible && !nextProps.visible) this.setState({
pageInfo: { current: 1, pageSize: 10, total: 0 }, loading: false, dataSource: [], selectedRowKeys: []
});
}
getDeductionAmountList = (props) => {
const { pageInfo } = this.state, { id: taxAgentId } = getUrlParams(), { year } = props || this.props;
const payload = { ...pageInfo, taxAgentId, year };
this.setState({ loading: true });
API.getDeductionAmountList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
this.setState({
columns, dataSource,
pageInfo: { ...pageInfo, current, pageSize, total }
});
}
}).catch(() => this.setState({ loading: false }));
};
handleDelete = () => {
Modal.confirm({
title: getLabel(111, "信息确认"),
content: getLabel(111, "确认删除本条数据吗?"),
onOk: () => {
API.deleteDeductionAmount({ ids: this.state.selectedRowKeys }).then(({ status, errormsg }) => {
if (status) {
message.success(getLabel(111, "操作成功"));
this.getDeductionAmountList();
} else {
message.error(errormsg);
}
});
}
});
};
render() {
const { loading, columns, dataSource, pageInfo, visible, selectedRowKeys } = this.state;
const pagination = {
...pageInfo,
showTotal: total => `${getLabel(18609, "共")} ${total} ${getLabel(18256, "条")}`,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
this.setState({
pageInfo: { ...pageInfo, current, pageSize }
}, () => this.getDeductionAmountList());
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.getDeductionAmountList());
}
};
const rowSelection = {
selectedRowKeys, onChange: v => this.setState({ selectedRowKeys: v })
};
const height = this.refs.employeeRef ? this.refs.employeeRef.state.height : 400;
return (
<WeaDialog {...this.props} hasScroll initLoadCss title={getLabel(111, "扣除名单确认")} ref="confirmRef"
style={{
width: 1150, height: 606.6, minHeight: 200, minWidth: 380, maxHeight: "90%",
maxWidth: "90%", overflow: "hidden", transform: "translate(0px, 0px)"
}}>
<div className="confirmationDialogContent">
<div className="tableBtns">
<WeaButtonIcon buttonType="add" type="primary" title={getLabel(111, "添加")}
onClick={() => this.setState({ visible: true })}/>
<WeaButtonIcon buttonType="del" type="primary" title={getLabel(111, "删除")} onClick={this.handleDelete}
disabled={_.isEmpty(selectedRowKeys)}/>
</div>
<WeaTable columns={columns} dataSource={dataSource} loading={loading} pagination={pagination} rowKey="id"
rowSelection={rowSelection} scroll={{ y: `calc(${height}px - 113px)` }}/>
<DeductionListConfirmEmployeeDialog visible={visible} onSuccess={this.getDeductionAmountList}
year={this.props.year} payload={this.props.payload}
onCancel={(callback) => this.setState({ visible: false }, () => callback && callback())}/>
</div>
</WeaDialog>
);
}
}
export default DeductionListConfirmDialog;