2023-02-17 17:21:05 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* name: 数据采集-列表
|
|
|
|
|
* Description:
|
|
|
|
|
* Date: 2023/2/17
|
|
|
|
|
*/
|
|
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import { getTableDate } from "../../apis/cumDeduct";
|
2024-10-30 16:23:58 +08:00
|
|
|
import { Spin } from "antd";
|
2024-02-23 10:13:43 +08:00
|
|
|
import { WeaLocaleProvider } from "ecCom";
|
|
|
|
|
|
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
2023-02-17 17:21:05 +08:00
|
|
|
|
|
|
|
|
class DataTables extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
2024-10-30 10:20:43 +08:00
|
|
|
loading: { query: false }, dataSource: [], columns: [], selectedRowKeys: [],
|
|
|
|
|
pageInfo: { current: 1, pageSize: 10, total: 0 }
|
2023-02-17 17:21:05 +08:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
2024-10-30 10:20:43 +08:00
|
|
|
window.addEventListener("message", this.handleReceive, false);
|
2023-02-17 17:21:05 +08:00
|
|
|
}
|
|
|
|
|
|
2024-10-30 10:20:43 +08:00
|
|
|
componentWillUnmount() {
|
|
|
|
|
window.removeEventListener("message", this.handleReceive, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleReceive = async ({ data }) => {
|
|
|
|
|
const { type, payload: { id, params } = {} } = data;
|
|
|
|
|
if (type === "init") {
|
|
|
|
|
this.getTableDate();
|
|
|
|
|
} else if (type === "turn") {
|
|
|
|
|
switch (id) {
|
|
|
|
|
case "PAGEINFO":
|
|
|
|
|
this.setState({ pageInfo: { ...this.state.pageInfo, ...params } }, () => this.getTableDate());
|
|
|
|
|
break;
|
|
|
|
|
case "CHECKBOX":
|
|
|
|
|
const { selectedRowKeys } = params;
|
|
|
|
|
this.setState({ selectedRowKeys });
|
|
|
|
|
break;
|
|
|
|
|
case "DEL":
|
2024-10-30 16:23:58 +08:00
|
|
|
this.props.onTableOperate({ key: "deleteSelectAddUpDeduction" }, params);
|
2024-10-30 10:20:43 +08:00
|
|
|
break;
|
|
|
|
|
case "EDIT":
|
2024-10-30 16:23:58 +08:00
|
|
|
this.props.onTableOperate({ key: "handleAddData" }, params);
|
|
|
|
|
break;
|
|
|
|
|
case "VIEW":
|
|
|
|
|
this.props.onViewDetails(params);
|
|
|
|
|
break;
|
|
|
|
|
case "log":
|
|
|
|
|
this.props.onTableOperate({ key: "log" }, params);
|
2024-10-30 10:20:43 +08:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-20 14:28:08 +08:00
|
|
|
getTableDate = (extraPayload = {}) => {
|
2024-10-30 10:20:43 +08:00
|
|
|
const { loading, pageInfo, selectedRowKeys } = this.state;
|
2024-10-30 16:23:58 +08:00
|
|
|
const { url, payload, isSpecial } = this.props;
|
2024-03-15 09:19:59 +08:00
|
|
|
const module = {
|
|
|
|
|
...pageInfo, url, ...payload, ...extraPayload,
|
|
|
|
|
departmentIds: extraPayload.departmentIds ? extraPayload.departmentIds.split(",") : []
|
|
|
|
|
};
|
2023-02-17 17:21:05 +08:00
|
|
|
this.setState({ loading: { ...loading, query: true } });
|
|
|
|
|
getTableDate(module).then(({ status, data }) => {
|
|
|
|
|
this.setState({ loading: { ...loading, query: false } });
|
|
|
|
|
if (status) {
|
|
|
|
|
const { columns, list: dataSource, pageNum: current, pageSize, total } = data;
|
|
|
|
|
this.setState({
|
2024-10-30 10:20:43 +08:00
|
|
|
pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, columns
|
|
|
|
|
}, () => this.postMessageToChild({
|
2024-10-31 10:22:16 +08:00
|
|
|
dataSource: this.state.dataSource, scrollHeight: 103, selectedRowKeys, isSpecial,
|
2024-10-30 10:20:43 +08:00
|
|
|
pageInfo: this.state.pageInfo, unitTableType: "dataAcquisition",
|
|
|
|
|
columns: this.state.columns
|
|
|
|
|
}));
|
2023-02-17 17:21:05 +08:00
|
|
|
}
|
|
|
|
|
}).catch(() => this.setState({ loading: { ...loading, query: false } }));
|
|
|
|
|
};
|
2023-02-20 10:24:40 +08:00
|
|
|
/*
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
* Description: 清空所选
|
|
|
|
|
* Params:
|
|
|
|
|
* Date: 2023/2/20
|
|
|
|
|
*/
|
|
|
|
|
handleClearRows = () => this.setState({ selectedRowKeys: [] });
|
2024-10-30 10:20:43 +08:00
|
|
|
postMessageToChild = (payload = {}) => {
|
|
|
|
|
const i18n = {
|
|
|
|
|
"操作": getLabel(30585, "操作"), "编辑": getLabel(111, "编辑"), "共": getLabel(18609, "共"),
|
2024-10-30 16:23:58 +08:00
|
|
|
"条": getLabel(18256, "条"), "删除": getLabel(111, "删除"), "查看明细": getLabel(111, "查看明细"),
|
|
|
|
|
"操作日志": getLabel(545781, "操作日志")
|
2024-10-30 10:20:43 +08:00
|
|
|
};
|
|
|
|
|
const childFrameObj = document.getElementById("unitTable");
|
|
|
|
|
childFrameObj && childFrameObj.contentWindow.postMessage(JSON.stringify({ ...payload, i18n }), "*");
|
|
|
|
|
};
|
2023-02-17 17:21:05 +08:00
|
|
|
|
|
|
|
|
render() {
|
2024-10-30 16:23:58 +08:00
|
|
|
const { dataSource, loading } = this.state;
|
2024-10-31 10:22:16 +08:00
|
|
|
const dom = document.querySelector(".dataContent");
|
2024-10-30 10:20:43 +08:00
|
|
|
let height = 280;
|
2024-10-31 10:22:16 +08:00
|
|
|
if (dataSource.length > 0 && dom) {
|
|
|
|
|
const tableHeight = dataSource.length * 46 + 124;
|
|
|
|
|
height = dom.offsetHeight > tableHeight ? tableHeight : dom.offsetHeight;
|
|
|
|
|
}
|
2024-10-30 10:20:43 +08:00
|
|
|
return (<div style={{ height: height + "px" }}>
|
|
|
|
|
<Spin spinning={loading.query}>
|
|
|
|
|
<iframe
|
|
|
|
|
style={{ border: 0, width: "100%", height: "100%" }}
|
2024-10-31 10:22:16 +08:00
|
|
|
// src="http://localhost:7607/#/unitTable"
|
|
|
|
|
src="/spa/hrmSalary/hrmSalaryCalculateDetail/index.html#/unitTable"
|
2024-10-30 10:20:43 +08:00
|
|
|
id="unitTable"
|
|
|
|
|
/>
|
|
|
|
|
</Spin>
|
|
|
|
|
</div>);
|
2023-02-17 17:21:05 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DataTables;
|