From 699d3323c4be2c376cfb3b71beedd72e173864ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Fri, 19 Jul 2024 11:06:46 +0800 Subject: [PATCH] master --- src/pages/reportTable/index.tsx | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/pages/reportTable/index.tsx b/src/pages/reportTable/index.tsx index 40d9066..25efc36 100644 --- a/src/pages/reportTable/index.tsx +++ b/src/pages/reportTable/index.tsx @@ -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>([]); const [showSumrow, setShowSumrow] = useState(false); const [SSHeaderInfo, setSSHeaderInfo] = useState(""); + const [pageInfo, setPageInfo] = useState>({}); + const [i18n, setI18n] = useState({}); 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 {SSHeaderInfo}} + pagination={!_.isNil(pageInfo) ? { + ...paginationAction(pageInfo, i18n, onChange), + size: "default" + } : false} summary={() => { if (!showSumrow) return; let totalColumns: any[] = [];