From 59497e306b309c88659cf450de2b4a3728a6073b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Mon, 24 Apr 2023 09:37:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=9B=E5=BE=AE=E8=96=AA=E8=B5=84=E6=A0=B8?= =?UTF-8?q?=E7=AE=97iframe=E8=A1=A8=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/config.js | 45 +++++++++++++------------ src/pages/reportTable/index.tsx | 59 +++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 src/pages/reportTable/index.tsx diff --git a/src/layouts/config.js b/src/layouts/config.js index 535553c..86025f5 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -1,25 +1,26 @@ module.exports = { - name: '统一软件开发平台', + name: "统一软件开发平台", layoutConfig: { - '/home': 'blank', - '/manage/design/.*': 'blank', - '/manage/editor': 'blank', - '/calculateDetail.*': 'blank', - '/atdTable.*': 'blank', - '/previewTable.*': 'blank', - '/standingbookTable.*': 'blank', - '/fileTable.*': 'blank', - '/rankMapTable.*': 'blank', - '/manage.*': 'manage', - '/portal.*': 'template', - '/passport/oauth-in': 'blank', - '/passport/openid-in': 'blank', - '/passport/sign-in': 'user', - '/passport/chose-portal': 'user', - '/passport/RegisterResult': 'user', - '/403': 'blank', - '/404': 'blank', - '/500': 'blank', - '/': 'template', - }, + "/home": "blank", + "/manage/design/.*": "blank", + "/manage/editor": "blank", + "/calculateDetail.*": "blank", + "/atdTable.*": "blank", + "/previewTable.*": "blank", + "/standingbookTable.*": "blank", + "/fileTable.*": "blank", + "/rankMapTable.*": "blank", + "/reportTable.*": "blank", + "/manage.*": "manage", + "/portal.*": "template", + "/passport/oauth-in": "blank", + "/passport/openid-in": "blank", + "/passport/sign-in": "user", + "/passport/chose-portal": "user", + "/passport/RegisterResult": "user", + "/403": "blank", + "/404": "blank", + "/500": "blank", + "/": "template" + } }; diff --git a/src/pages/reportTable/index.tsx b/src/pages/reportTable/index.tsx new file mode 100644 index 0000000..41e9c3a --- /dev/null +++ b/src/pages/reportTable/index.tsx @@ -0,0 +1,59 @@ +import React, { FC, useEffect, useState } from "react"; +import { Table, Typography } from "antd"; +import { exceptStr } from "@/utils/common"; +import styles from "@/pages/atdTable/components/index.less"; + +const { Text } = Typography; +const PreviewTable: FC = (props) => { + const [columns, setColumns] = useState>([]); + const [sumRow, setSumRow] = useState>({}); + const [dataSource, setDataSource] = useState>([]); + const [showSumrow, setShowSumrow] = useState(false); + + useEffect(() => { + window.parent.postMessage({ type: "init" }, "*"); + window.addEventListener("message", receiveMessageFromIndex, false); + return () => { + window.removeEventListener("message", receiveMessageFromIndex, false); + }; + }, []); + const receiveMessageFromIndex = (event: any) => { + const data: any = exceptStr(event.data); + if (!_.isEmpty(data)) { + const { columns, dataSource, countResult, showSum } = data; + setDataSource(dataSource); + setColumns(columns); + setShowSumrow(showSum); + setSumRow(countResult); + } + }; + return { + if (!showSumrow) return; + return ( + + + { + _.map(columns, (item, index) => { + if (index === 0) { + return 总计; + } + return + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} + ; + }) + } + + + ); + }} + />; +}; + +export default PreviewTable;