124 lines
3.9 KiB
JavaScript
124 lines
3.9 KiB
JavaScript
/*
|
|
* Author: 黎永顺
|
|
* name: 薪资核算-列表数据
|
|
* Description:
|
|
* Date: 2023/9/14
|
|
*/
|
|
import React, { Component } from "react";
|
|
import { WeaLocaleProvider } from "ecCom";
|
|
import { inject, observer } from "mobx-react";
|
|
import { Spin } from "antd";
|
|
import { acctResultList } from "../../../../../apis/calculate";
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
@inject("calculateStore")
|
|
@observer
|
|
class EditCalcTable extends Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = {
|
|
loading: false, pageInfo: { current: 1, pageSize: 10, total: 0 },
|
|
selectedRowKeys: []
|
|
};
|
|
}
|
|
|
|
componentDidMount() {
|
|
window.addEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
handleReceive = async ({ data }) => {
|
|
const { type, payload: { id, params } = {} } = data;
|
|
if (type === "init") {
|
|
this.queryCalcResultList();
|
|
} else if (type === "turn") {
|
|
switch (id) {
|
|
case "PAGEINFO":
|
|
const { size: pageSize, pageNum: current } = params;
|
|
this.setState({ pageInfo: { ...this.state.pageInfo, current, pageSize } }, () => this.queryCalcResultList());
|
|
break;
|
|
case "CHECKBOX":
|
|
const { selectedRowKeys } = params;
|
|
this.setState({ selectedRowKeys });
|
|
break;
|
|
case "FORMULA":
|
|
const { dataIndex } = params;
|
|
this.props.onShowFormulaTd(dataIndex);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
componentWillUnmount() {
|
|
window.removeEventListener("message", this.handleReceive, false);
|
|
}
|
|
|
|
postMessageToChild = (payload = {}) => {
|
|
const childFrameObj = document.getElementById("atdTable");
|
|
childFrameObj.contentWindow.postMessage(JSON.stringify(payload), "*");
|
|
};
|
|
queryCalcResultList = () => {
|
|
const { pageInfo } = this.state;
|
|
const { calculateStore: { ECSearchForm }, routeParams: { salaryAcctRecordId } } = this.props;
|
|
const { subcompanyIds, departmentIds, positionIds, statuses, ...extra } = ECSearchForm.getFormParams();
|
|
const payload = {
|
|
salaryAcctRecordId, ...pageInfo, ...extra,
|
|
departmentIds: !_.isEmpty(departmentIds) ? departmentIds.split(",") : [],
|
|
positionIds: !_.isEmpty(positionIds) ? positionIds.split(",") : [],
|
|
subcompanyIds: !_.isEmpty(subcompanyIds) ? subcompanyIds.split(",") : [],
|
|
statuses: !_.isEmpty(statuses) ? statuses.split(",") : []
|
|
};
|
|
this.setState({ loading: true });
|
|
acctResultList(payload).then(({ status, data }) => {
|
|
this.setState({ loading: false });
|
|
if (status) {
|
|
const { columns, pageInfo: list } = data;
|
|
const { list: dataSource, pageNum: current, pageSize, total } = list;
|
|
this.setState({ pageInfo: { ...pageInfo, current, pageSize, total } }, () => {
|
|
const { pageInfo, selectedRowKeys } = this.state;
|
|
this.postMessageToChild({
|
|
dataSource, pageInfo, selectedRowKeys,
|
|
columns: _.map(traverse(columns), (it, idx) => ({ ...it, fixed: idx < 2 ? "left" : false }))
|
|
});
|
|
});
|
|
}
|
|
}).catch(() => this.setState({ loading: false }));
|
|
};
|
|
|
|
render() {
|
|
const { loading } = this.state;
|
|
return (
|
|
<div className="editCalcTable-layout">
|
|
<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>
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default EditCalcTable;
|
|
|
|
const traverse = (arr) => {
|
|
return _.map(arr, item => {
|
|
if (!_.isEmpty(item.children)) {
|
|
return {
|
|
title: item.text, width: item.width + "px", ellipsis: true,
|
|
dataIndex: item.column, children: traverse(item.children)
|
|
};
|
|
} else {
|
|
return {
|
|
title: item.text, width: item.width + "px",
|
|
dataIndex: item.column, ellipsis: true, lockStatus: item.lockStatus
|
|
};
|
|
}
|
|
});
|
|
};
|