diff --git a/src/layouts/config.js b/src/layouts/config.js index f964fa8..52c0001 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -7,6 +7,7 @@ module.exports = { '/calculateDetail.*': 'blank', '/atdTable.*': 'blank', '/previewTable.*': 'blank', + '/standingbookTable.*': 'blank', '/manage.*': 'manage', '/portal.*': 'template', '/passport/oauth-in': 'blank', diff --git a/src/pages/atdTable/components/index.less b/src/pages/atdTable/components/index.less index e7487d5..010a04f 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -59,7 +59,7 @@ .ant-pagination { font-size: 12px; align-items: center; - + margin-right: 8px; .ant-pagination-item, .ant-pagination-prev, .ant-pagination-next { min-width: 28px; height: 28px; diff --git a/src/pages/previewTable/index.tsx b/src/pages/previewTable/index.tsx index 3bc9bbb..a1c7fc8 100644 --- a/src/pages/previewTable/index.tsx +++ b/src/pages/previewTable/index.tsx @@ -10,6 +10,7 @@ const PreviewTable: FC = (props) => { const [dataSource, setDataSource] = useState>([]); const [pageInfo, setPageInfo] = useState(defaultPage); const [sumRow, setSumRow] = useState>({}); + const [showSumrow, setShowSumrow] = useState(false); useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -21,10 +22,11 @@ const PreviewTable: FC = (props) => { const receiveMessageFromIndex = (event: any) => { const data: any = exceptStr(event.data); if (!_.isEmpty(data)) { - const { columns, dataSource, pageInfo, salaryBillSendSum } = data; + const { columns, dataSource, pageInfo, salaryBillSendSum, showSum } = data; const { current: pageNum, pageSize: size, total } = pageInfo; setDataSource(dataSource); setColumns(columns); + setShowSumrow(showSum); setSumRow(salaryBillSendSum); setPageInfo({ pageNum, size, total }); } @@ -53,7 +55,7 @@ const PreviewTable: FC = (props) => { }} scroll={{ x: 1200, y: "calc(100vh - 193px)" }} summary={() => { - if (_.isEmpty(columns)) return; + if (_.isEmpty(columns) || !showSumrow) return; return ( @@ -63,7 +65,7 @@ const PreviewTable: FC = (props) => { return 总计; } return - {sumRow[item.dataIndex] || "-"} + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} ; }) } diff --git a/src/pages/standingbookTable/index.tsx b/src/pages/standingbookTable/index.tsx new file mode 100644 index 0000000..0a25f50 --- /dev/null +++ b/src/pages/standingbookTable/index.tsx @@ -0,0 +1,133 @@ +import React, { FC, useEffect, useState } from "react"; +import { Button, Table, Typography } from "antd"; +import { exceptStr, paginationFun } from "@/utils/common"; +import { defaultPage, IPage } from "@/common/types"; +import styles from "@/pages/atdTable/components/index.less"; + +const { Text } = Typography; +const StandingbookTable: FC = (props) => { + const [selected, setSelected] = useState>([]); + const [columns, setColumns] = useState>([]); + const [dataSource, setDataSource] = useState>([]); + const [pageInfo, setPageInfo] = useState(defaultPage); + const [sumRow, setSumRow] = 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, pageInfo, showOperates, selectedRowKeys, + showSum, siaccountSum + } = data; + const { current: pageNum, pageSize: size, total } = pageInfo; + const conventColumns = _.map(_.filter(columns, it => it.dataIndex !== "id"), item => { + const { dataIndex } = item; + if (dataIndex === "employeeId") { + return { + title: "姓名", dataIndex, fixed: "left", width: 150, + render: (_: any, record: Partial) => ( + {record?.userName} + ) + }; + } + return { + dataIndex, width: 150, + title: + }; + }); + setDataSource(dataSource); + setColumns( + !showOperates ? conventColumns : + [ + ...conventColumns, + { + title: "操作", + dataIndex: "operate", + fixed: "right", + width: 120, + render: (_: any, record: any) => { + return ( + + ); + } + } + ] + ); + setSelected(selectedRowKeys); + setShowSumrow(showSum); + setSumRow(siaccountSum); + setPageInfo({ pageNum, size, total }); + } + }; + const handleEdit = (record: any) => { + window.parent.postMessage({ type: "turn", payload: { id: "EDIT", params: { ...record } } }, "*"); + }; + const sizeChange = (pageobj: IPage) => { + }; + const onChange = (pageobj: IPage) => { + setPageInfo({ ...pageInfo, ...pageobj }); + window.parent.postMessage( + { + type: "turn", + payload: { id: "PAGEINFO", params: { ...pageInfo, ...pageobj } } + }, + "*" + ); + }; + const rowSelection = { + selectedRowKeys: selected, + onChange: (selectedRowKeys: Array) => { + setSelected(selectedRowKeys); + window.parent.postMessage( + { + type: "turn", + payload: { id: "ROWSELECT", params: { selectedRowKeys } } + }, + "*" + ); + } + }; + return { + if (_.isEmpty(columns) || !showSumrow) return; + return ( + + + { + _.map(columns, (item, index) => { + if (index === 0) { + return 总计; + } + return + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} + ; + }) + } + + + ); + }} + />; +}; + +export default StandingbookTable;