From 4380ebb8e8f645fddcef41d3c0e1a7951c8f6368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Wed, 17 Jan 2024 14:32:26 +0800 Subject: [PATCH] master --- src/pages/calcTable/calcFixedTotal.tsx | 7 +++++-- src/pages/calcTable/index.tsx | 12 +++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/calcTable/calcFixedTotal.tsx b/src/pages/calcTable/calcFixedTotal.tsx index cf35fa6..769cdb8 100644 --- a/src/pages/calcTable/calcFixedTotal.tsx +++ b/src/pages/calcTable/calcFixedTotal.tsx @@ -15,6 +15,7 @@ interface OwnProps { columns: ColumnType[]; dataSourceUrl: string; payload: any; + sumRow: Partial<{}>; } type Props = OwnProps; @@ -37,15 +38,17 @@ const calcFixedTotal: FunctionComponent = (props) => { return API.CalculateService.getAcctResultsum(props.dataSourceUrl, payload); }, [props.dataSourceUrl]); useEffect(() => { - if (!_.isEmpty(props.payload)) { + if (!_.isEmpty(props.payload) && !props.sumRow) { setLoading(true); dataSourceUrl(props.payload).then(({ data }) => { setLoading(false); const { data: result, status } = data; if (status) setSumRow(result.sumRow || {}); }); + } else { + setSumRow(props.sumRow); } - }, [props.payload]); + }, [props.payload, props.sumRow]); return (<> { _.map(columns, (item: any, index) => { diff --git a/src/pages/calcTable/index.tsx b/src/pages/calcTable/index.tsx index 4a9b626..761078a 100644 --- a/src/pages/calcTable/index.tsx +++ b/src/pages/calcTable/index.tsx @@ -35,6 +35,7 @@ const index: FunctionComponent = (props) => { const [tableScrollHeight, setTableScrollHeight] = useState(0); const [payload, setPayload] = useState(""); const [fixed, setFixed] = useState(true); + const [sumRow, setSumRow] = useState>({});//总计行数据 useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -49,7 +50,7 @@ const index: FunctionComponent = (props) => { const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail, - fixed = true, tableScrollHeight + fixed = true, tableScrollHeight, sumRow } = data; setSumRowlistUrl(sumRowlistUrl); setShowTotalCell(showTotalCell); @@ -57,6 +58,7 @@ const index: FunctionComponent = (props) => { setI18n(i18nRes); setPayload(payload); setFixed(fixed); + setSumRow(sumRow); setPageInfo(pageInfo); setDataSource(dataSource); setSelectedRowKeys(selectedRowKeys); @@ -137,19 +139,19 @@ const index: FunctionComponent = (props) => { return ( o.dataIndex !== "operate")} footer={() => !isDetailTable ? : null} - pagination={{ + pagination={!_.isNil(pageInfo) ? { ...paginationFun(pageInfo, sizeChange, onChange, i18n), size: "default" - }} + } : false} summary={() => ( !showTotalCell ? <> : {i18n["总计"]} - + )}