125 lines
4.8 KiB
JavaScript
125 lines
4.8 KiB
JavaScript
/*
|
|
* 杭州五院二开
|
|
* 差异对比表
|
|
* @Author: 黎永顺
|
|
* @Date: 2025/4/29
|
|
* @Wechat:
|
|
* @Email: 971387674@qq.com
|
|
* @description:
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLoadingGlobal, WeaLocaleProvider } from "ecCom";
|
|
import { Spin } from "antd";
|
|
import EditCalcAdvanceSearchPannel from "../salaryEditCalc/editCalcAdvanceSearchPannel";
|
|
import { postExportFetch, postFetch } from "../../../../../util/request";
|
|
import { traverse } from "../salaryEditCalc/editCalcTable";
|
|
import cs from "classnames";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
class Index extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
showSearchAd: false, showTotalCell: false, pageInfo: { current: 1, pageSize: 10, total: 0 },
|
|
loading: false, payload: {}
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
window.addEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
window.removeEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
handleReceive = async ({ data }) => {
|
|
const { type, payload: { id, params } = {} } = data;
|
|
if (type === "init") {
|
|
this.getCompareDifferentList();
|
|
} else if (type === "turn") {
|
|
switch (id) {
|
|
case "PAGEINFO":
|
|
const { size: pageSize, pageNum: current } = params;
|
|
this.setState({
|
|
pageInfo: { ...this.state.pageInfo, current, pageSize }
|
|
}, () => this.getCompareDifferentList());
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
getCompareDifferentList = () => {
|
|
const { pageInfo } = this.state,
|
|
{ calculateStore: { ECSearchForm, otherConditions }, routeParams: { salaryAcctRecordId } } = this.props;
|
|
this.setState({ loading: true });
|
|
const { subcompanyIds, departmentIds, positionIds, statuses, ...extra } = ECSearchForm.getFormParams();
|
|
const payload = {
|
|
salaryAcctRecordId, ...pageInfo, ...extra, otherConditions,
|
|
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
|
|
positionIds: !_.isEmpty(positionIds) ? positionIds.split(",") : [],
|
|
subcompanyIds: !_.isEmpty(subcompanyIds) ? subcompanyIds.split(",") : [],
|
|
statuses: !_.isEmpty(statuses) ? statuses.split(",") : []
|
|
};
|
|
postFetch("/api/bs/hrmsalary/salaryArchive/wy/compareDifferentList", payload)
|
|
.then(({ status, data }) => {
|
|
this.setState({ loading: false, payload });
|
|
if (status && !_.isEmpty(data)) {
|
|
const { columns, pageInfo: { pageNum: current, pageSize, total, list: dataSource } } = data;
|
|
this.setState({ pageInfo: { current, pageSize, total } }, () => {
|
|
const { pageInfo } = this.state;
|
|
this.postMessageToChild({
|
|
dataSource, pageInfo, showTotalCell: false, sumRowlistUrl: "", calcDetail: true, tableScrollHeight: 120,
|
|
columns: _.every(traverse(columns, true), (it, idx) => !it.fixed) ? _.map(traverse(columns, true), (it, idx) => ({
|
|
...it, fixed: idx < 2 ? "left" : false
|
|
})) : traverse(columns, true)
|
|
});
|
|
});
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
};
|
|
openAdvanceSearch = () => this.setState({ showSearchAd: !this.state.showSearchAd });
|
|
onAdSearch = (bool = true) => {
|
|
this.getCompareDifferentList();
|
|
bool && this.openAdvanceSearch();
|
|
};
|
|
postMessageToChild = (payload = {}) => {
|
|
const i18n = {
|
|
"共": getLabel(18609, "共"), "条": getLabel(18256, "条"),
|
|
"总计": getLabel(523, "总计")
|
|
};
|
|
const childFrameObj = document.getElementById("diffenceTable");
|
|
childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
|
|
};
|
|
exportDifferenctList = () => {
|
|
WeaLoadingGlobal.start();
|
|
const promise = postExportFetch("/api/bs/hrmsalary/salaryArchive/wy/exportCompareDifferentList", this.state.payload);
|
|
};
|
|
|
|
render() {
|
|
const { showSearchAd, loading, pageInfo } = this.state, { routeParams: { salaryAcctRecordId } } = this.props;
|
|
const { pageSize, total } = pageInfo;
|
|
const columnNum = total > pageSize ? pageSize : total;
|
|
return (<div className="salary-edit-calc-content">
|
|
<div className={cs("searchAdvanced-condition-container", { "searchAdvanced-condition-hide": !showSearchAd })}>
|
|
<EditCalcAdvanceSearchPannel
|
|
salaryAcctRecordId={salaryAcctRecordId}
|
|
onToggleSwitch={this.openAdvanceSearch}
|
|
onAdSearch={this.onAdSearch}/>
|
|
</div>
|
|
<div style={{ height: `calc((39px * ${columnNum}) + 188.53px)`, minHeight: "287px" }}>
|
|
<Spin spinning={loading}>
|
|
<iframe
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/calcTable"
|
|
id="diffenceTable"
|
|
/>
|
|
</Spin>
|
|
</div>
|
|
</div>);
|
|
}
|
|
}
|
|
|
|
export default Index; |