160 lines
6.0 KiB
JavaScript
160 lines
6.0 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name:薪资明细列表
|
|
* Description:
|
|
* Date: 2024/3/26
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { inject, observer } from "mobx-react";
|
|
import { toJS } from "mobx";
|
|
import { WeaLoadingGlobal, WeaLocaleProvider } from "ecCom";
|
|
import { WeaTableNew } from "comsMobx";
|
|
import { message, Spin } from "antd";
|
|
import * as API from "../../../apis/statistics";
|
|
import { getIframeParentHeight } from "../../../util";
|
|
import { sysConfCodeRule } from "../../../apis/ruleconfig";
|
|
import "../index.less";
|
|
|
|
const WeaTableComx = WeaTableNew.WeaTable;
|
|
const { getLabel } = WeaLocaleProvider;
|
|
|
|
@inject("attendanceStore")
|
|
@observer
|
|
class SalaryDetails extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: false, dataSource: [], columns: [], selectedRowKeys: [],
|
|
pageInfo: { current: 1, pageSize: 10, total: 0 }, payload: {},
|
|
showTotalCell: false, updateSum: true
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
this.getSalaryList(this.props);
|
|
window.addEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
componentWillReceiveProps(nextProps, nextContext) {
|
|
if (nextProps.isQuery !== this.props.isQuery) this.setState({
|
|
pageInfo: { ...this.state.pageInfo, current: 1 }, updateSum: true
|
|
}, () => this.getSalaryList(nextProps));
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
window.removeEventListener("message", this.handleReceive, false);
|
|
this.setState(({ selectedRowKeys: [] }));
|
|
}
|
|
|
|
handleReceive = ({ data }) => {
|
|
const { type, payload: { id, params } = {} } = data;
|
|
const { pageInfo } = this.state;
|
|
if (type === "init") {
|
|
this.getColumns();
|
|
} else if (type === "turn") {
|
|
if (id === "PAGEINFO") {
|
|
const { pageNum: current, size: pageSize } = params;
|
|
this.setState({
|
|
pageInfo: { ...pageInfo, current, pageSize },
|
|
updateSum: false
|
|
}, () => this.getSalaryList(this.props));
|
|
} else if (id === "CHECKBOX") {
|
|
const { selectedRowKeys: checkBox } = params;
|
|
this.setState({ selectedRowKeys: checkBox, updateSum: false });
|
|
}
|
|
}
|
|
};
|
|
postMessageToChild = (payload) => {
|
|
const i18n = {
|
|
"共": getLabel(18609, "共"), "条": getLabel(18256, "条"),
|
|
"总计": getLabel(523, "总计")
|
|
};
|
|
const childFrameObj = document.getElementById("atdTable");
|
|
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
|
|
};
|
|
getSalaryList = (props) => {
|
|
const { attendanceStore: { salaryDetailSearchForm, tableStore }, dateRange } = props;
|
|
const [startDateStr, endDateStr] = dateRange;
|
|
const { taxAgentIds, subcompanyIds, departmentIds, ...extra } = salaryDetailSearchForm.getFormParams();
|
|
const { pageInfo } = this.state;
|
|
const payload = {
|
|
taxAgentIds: taxAgentIds ? taxAgentIds.split(",") : [],
|
|
departmentIds: departmentIds ? departmentIds.split(",") : [],
|
|
subcompanyIds: subcompanyIds ? subcompanyIds.split(",") : [],
|
|
...extra, ...pageInfo, startDateStr, endDateStr
|
|
};
|
|
this.setState({ loading: true });
|
|
API.getSalaryList(payload).then(async ({ status, data }) => {
|
|
// API.getSalaryListSum(payload),
|
|
const [{ data: confCode }] = await Promise.all([sysConfCodeRule({ code: "OPEN_ACCT_RESULT_SUM" })]);
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
const { dataKey, pageInfo: pageparams } = data;
|
|
const { list: dataSource, pageNum: current, total, pageSize } = pageparams;
|
|
this.setState({
|
|
dataSource, pageInfo: { ...pageInfo, current, total, pageSize }, payload,
|
|
showTotalCell: confCode === "1"
|
|
}, () => tableStore.getDatas(dataKey.datas));
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
};
|
|
handleExportSalaryList = (key) => {
|
|
const { attendanceStore: { tableStore } } = this.props;
|
|
let { selectedRowKeys, payload } = this.state;
|
|
if (key === "SELECTED" && selectedRowKeys.length === 0) {
|
|
message.warning(getLabel(543345, "请选择需要导出的数据!"));
|
|
return;
|
|
}
|
|
WeaLoadingGlobal.start();
|
|
const promise = API.exportSalaryList({
|
|
...payload, ids: key === "SELECTED" ? selectedRowKeys : [],
|
|
columns: _.map(_.filter(toJS(tableStore.columns), (item) => item.display === "true" && item.dataIndex !== "acctTimes"), o => o.dataIndex)
|
|
});
|
|
};
|
|
getColumns = () => {
|
|
const { attendanceStore: { tableStore } } = this.props;
|
|
const { dataSource, pageInfo, selectedRowKeys, showTotalCell, payload, updateSum } = this.state;
|
|
const columns = _.filter(toJS(tableStore.columns), (item) => item.display === "true" && item.dataIndex !== "acctTimes");
|
|
const sumRowlistUrl = showTotalCell ? "/api/bs/hrmsalary/report/statistics/employee/salaryListSum" : "";
|
|
if (!_.isEmpty(columns)) {
|
|
this.postMessageToChild({
|
|
dataSource, pageInfo, selectedRowKeys, showTotalCell, calcDetail: true, tableScrollHeight: 154,
|
|
sumRowlistUrl, payload: { ...payload, updateSum },
|
|
columns: _.map(columns, (it, idx) => ({
|
|
...it,
|
|
width: (it.dataIndex === "taxAgent" || it.dataIndex === "salarySob") ? 176 : it.oldWidth,
|
|
fixed: (idx === 1 || idx === 0 || idx === 2) ? "left" : "",
|
|
ellipsis: true
|
|
}))
|
|
});
|
|
}
|
|
return [];
|
|
};
|
|
|
|
render() {
|
|
const { loading, dataSource } = this.state;
|
|
const { attendanceStore: { tableStore } } = this.props;
|
|
return (
|
|
<div className="table-layout"
|
|
style={{ height: getIframeParentHeight(".wea-new-top-req-content", dataSource.length, 0) + "px" }}>
|
|
<Spin spinning={loading}>
|
|
<iframe
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
|
// src="http://localhost:7607/#/calcTable"
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/calcTable"
|
|
id="atdTable"
|
|
/>
|
|
</Spin>
|
|
<WeaTableComx
|
|
style={{ display: "none" }}
|
|
comsWeaTableStore={tableStore}
|
|
needScroll={true}
|
|
columns={this.getColumns()}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default SalaryDetails;
|