salary-management-front/pc4mobx/hrmSalary/pages/calculate/calcOc/components/salaryCalcOcList.js

127 lines
4.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Author: 黎永顺
* name: 薪资核算-线下对比列表
* Description:
* Date: 2023/9/26
*/
import React, { Component } from "react";
import { WeaLocaleProvider, WeaTable } from "ecCom";
import { Alert } from "antd";
import { comparisonResultList } from "../../../../apis/calculate";
const getLabel = WeaLocaleProvider.getLabel;
class SalaryCalcOcList extends Component {
constructor(props) {
super(props);
this.state = {
loading: false, pageInfo: { current: 1, pageSize: 10, total: 0 },
columns: [], dataSource: [], formulaDesc: ""
};
}
componentDidMount() {
this.comparisonResultList(this.props);
}
componentWillReceiveProps(nextProps, nextContext) {
if (
(nextProps.form.onlyDiffEmployee !== this.props.form.onlyDiffEmployee) ||
(nextProps.form.onlyDiffSalaryItem !== this.props.form.onlyDiffSalaryItem) ||
(nextProps.searchBool !== this.props.searchBool)
) {
this.comparisonResultList(nextProps);
}
}
comparisonResultList = (props) => {
const { form, routeParams: { salaryAcctRecordId } } = props;
const { pageInfo } = this.state;
this.setState({ loading: true });
const payload = { ...pageInfo, ...form, salaryAcctRecordId };
comparisonResultList(payload).then(({ status, data }) => {
this.setState({ loading: false });
if (status) {
const { list: dataSource, columns, pageNum: current, pageSize, total } = data;
this.setState({
dataSource, columns,
pageInfo: { ...pageInfo, current, pageSize, total }
});
}
}).catch(() => this.setState({ loading: false }));
};
render() {
const { dataSource, loading, columns, pageInfo, formulaDesc } = 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.comparisonResultList(this.props));
},
onChange: current => {
this.setState({
pageInfo: { ...pageInfo, current }
}, () => this.comparisonResultList(this.props));
}
};
return (
<React.Fragment>
<Alert message={`${getLabel(18125, "公式")}${formulaDesc}`} type="info"/>
<WeaTable
rowKey="id" pagination={pagination} loading={loading} dataSource={dataSource}
scroll={{ x: 840, y: "calc(100vh - 246px)" }}
columns={_.map(columns, (o, i) => {
if (i > 1) {
if (i > 2) {
return {
...o, width: 180,
render: (__, record) => {
const formulaDesc = record["customParameters"][`${o["dataIndex"]}`];
const showDifference = record[`${o["dataIndex"]}_type`] === "number";
const { acctResultValue, excelResultValue } = record[o["dataIndex"]] || {};
return <div className="comparison-column-item-container"
onClick={() => this.setState({ formulaDesc })}>
<div className="comparison-single-row">
<span>{getLabel(543280, "系统值")}</span>
<span>{acctResultValue}</span>
</div>
<div className="comparison-single-row">
<span>{getLabel(543281, "线下值")}</span>
<span>{excelResultValue}</span>
</div>
{
showDifference &&
<div className="comparison-single-row danger">
<span>{getLabel(543282, "差值")}</span>
<span>{calculateDifference(acctResultValue, excelResultValue)}</span>
</div>
}
</div>;
}
};
}
return { ...o, width: 180 };
}
return { ...o, width: 150, fixed: "left" };
})}
/>
</React.Fragment>
);
}
}
export default SalaryCalcOcList;
// 计算差值
const calculateDifference = (systemValue, excelValue) => {
if (_.isNil(systemValue) || _.isNil(excelValue)) return "";
const systemNum = Number(systemValue);
const excelNum = Number(excelValue);
return (systemNum - excelNum).toFixed(2);
};