|
|
|
@ -1,7 +1,8 @@
|
|
|
|
|
import React, { FC, useEffect, useState } from "react";
|
|
|
|
|
import { Button, Table, Typography } from "antd";
|
|
|
|
|
import { exceptStr } from "@/utils/common";
|
|
|
|
|
import { exceptStr, paginationAction } from "@/utils/common";
|
|
|
|
|
import styles from "@/pages/atdTable/components/index.less";
|
|
|
|
|
import { PaginationData } from "rc-pagination";
|
|
|
|
|
|
|
|
|
|
const { Text, Paragraph } = Typography;
|
|
|
|
|
const ReportTable: FC = (props) => {
|
|
|
|
@ -10,6 +11,8 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
const [dataSource, setDataSource] = useState<Array<any>>([]);
|
|
|
|
|
const [showSumrow, setShowSumrow] = useState<boolean>(false);
|
|
|
|
|
const [SSHeaderInfo, setSSHeaderInfo] = useState<string>("");
|
|
|
|
|
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
|
|
|
|
|
const [i18n, setI18n] = useState<any>({});
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.parent.postMessage({ type: "init" }, "*");
|
|
|
|
@ -21,11 +24,13 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
const receiveMessageFromIndex = (event: any) => {
|
|
|
|
|
const data: any = exceptStr(event.data);
|
|
|
|
|
if (!_.isEmpty(data)) {
|
|
|
|
|
const { columns, dataSource, countResult, showSum, SSHeaderInfo = "" } = data;
|
|
|
|
|
const { i18n, columns, dataSource, countResult, showSum, SSHeaderInfo = "", pageInfo } = data;
|
|
|
|
|
setI18n(i18n);
|
|
|
|
|
setDataSource(dataSource);
|
|
|
|
|
setShowSumrow(showSum);
|
|
|
|
|
setSumRow(countResult);
|
|
|
|
|
setSSHeaderInfo(SSHeaderInfo);
|
|
|
|
|
setPageInfo(pageInfo);
|
|
|
|
|
setColumns(_.map(columns, (item, index: number) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
return { ...item, fixed: "left", ellipsis: true };
|
|
|
|
@ -88,16 +93,33 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const onChange = (current: number, pageSize: number) => {
|
|
|
|
|
setPageInfo((prevState) => {
|
|
|
|
|
const { pageSize: size } = prevState;
|
|
|
|
|
window.parent.postMessage(
|
|
|
|
|
{
|
|
|
|
|
type: "turn",
|
|
|
|
|
payload: { id: "PAGEINFO_REPORT", params: { ...pageInfo, current: size === pageSize ? current : 1, pageSize } }
|
|
|
|
|
},
|
|
|
|
|
"*"
|
|
|
|
|
);
|
|
|
|
|
return { ...pageInfo, current: size === pageSize ? current : 1, pageSize };
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return <Table
|
|
|
|
|
rowKey="id"
|
|
|
|
|
className={styles.tableWrapper}
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
pagination={false}
|
|
|
|
|
bordered
|
|
|
|
|
size="small"
|
|
|
|
|
scroll={{ x: 1200, y: `calc(100vh - 148px)` }}
|
|
|
|
|
scroll={{ x: 1200, y: `calc(100vh - 174px)` }}
|
|
|
|
|
title={() => <Paragraph ellipsis={true}>{SSHeaderInfo}</Paragraph>}
|
|
|
|
|
pagination={!_.isNil(pageInfo) ? {
|
|
|
|
|
...paginationAction(pageInfo, i18n, onChange),
|
|
|
|
|
size: "default"
|
|
|
|
|
} : false}
|
|
|
|
|
summary={() => {
|
|
|
|
|
if (!showSumrow) return;
|
|
|
|
|
let totalColumns: any[] = [];
|
|
|
|
|