From b9846d5abd40769f69cc061801cd1dabed3c4150 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, 8 Jan 2024 18:04:32 +0800 Subject: [PATCH] master --- src/layouts/config.js | 1 + src/pages/salaryFileTable/index.tsx | 102 ++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 src/pages/salaryFileTable/index.tsx diff --git a/src/layouts/config.js b/src/layouts/config.js index 873e8fe..4b582b2 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -18,6 +18,7 @@ module.exports = { "/employeeDeclareTable.*": "blank", "/taxDeclareTable.*": "blank", "/welfareArchiveTable.*": "blank", + "/salaryFileTable.*": "blank", "/OCTable.*": "blank", "/manage.*": "manage", "/portal.*": "template", diff --git a/src/pages/salaryFileTable/index.tsx b/src/pages/salaryFileTable/index.tsx new file mode 100644 index 0000000..4611757 --- /dev/null +++ b/src/pages/salaryFileTable/index.tsx @@ -0,0 +1,102 @@ +/* + * Author: 黎永顺 + * name: 薪资档案重构-档案列表 + * Description: + * Date: 2024/1/8 + */ +import React, { FunctionComponent, useEffect, useMemo, useState } from "react"; +import { ColumnType } from "antd/lib/table"; +import { PaginationData } from "rc-pagination"; +import styles from "@/pages/atdTable/components/index.less"; +import { exceptStr, paginationAction } from "@/utils/common"; +import { Table } from "antd"; + +interface OwnProps { +} + +type Props = OwnProps; + +const Index: FunctionComponent = (props) => { + const [columns, setColumns] = useState[]>([]); + const [dataSource, setDataSource] = useState([]); + const [selectedRowKeys, setSelectedRowKeys] = useState([]); + const [pageInfo, setPageInfo] = useState>({}); + const [i18n, setI18n] = useState({}); + const [runStatuses, setRunStatuses] = useState(""); + const [showOperateBtn, setShowOperateBtn] = 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, selectedRowKeys, i18n: i18nRes = {}, + runStatuses, showOperateBtn + } = data; + setShowOperateBtn(showOperateBtn); + setRunStatuses(runStatuses); + setI18n(i18nRes); + setPageInfo(pageInfo); + setDataSource(dataSource); + setSelectedRowKeys(selectedRowKeys); + setColumns(columns); + } + }; + const onChange = (current: number, pageSize: number) => { + setPageInfo((prevState) => { + const { pageSize: size } = prevState; + window.parent.postMessage( + { + type: "turn", + payload: { id: "PAGEINFO", params: { ...pageInfo, current: size === pageSize ? current : 1, pageSize } } + }, + "*" + ); + return { ...pageInfo, current: size === pageSize ? current : 1, pageSize }; + }); + }; + const rowSelection = { + columnWidth: 60, + selectedRowKeys: selectedRowKeys, + onChange: (selectedRowKeys: React.Key[]) => { + setSelectedRowKeys(selectedRowKeys); + window.parent.postMessage( + { + type: "turn", + payload: { id: "CHECKBOX", params: { selectedRowKeys } } + }, + "*" + ); + } + }; + const handleWelfareOperate = (type: string, record: any, interfaceParams?: any) => { + window.parent.postMessage( + { + type: "turn", + payload: { id: type, params: { record, interfaceParams } } + }, + "*" + ); + }; + const cols: any = useMemo(() => { + return showOperateBtn ? [...columns] : [...columns]; + }, [columns, runStatuses, i18n, showOperateBtn]); + return (); +}; + +export default Index;