From 58152f05288ef40bdd76142ab66b5085eebe284c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 11 Jan 2024 14:52:52 +0800 Subject: [PATCH] master --- src/pages/calcTable/index.tsx | 6 +- src/pages/salaryFileTable/index.tsx | 118 ++++++++++++++++++++++++++-- 2 files changed, 114 insertions(+), 10 deletions(-) diff --git a/src/pages/calcTable/index.tsx b/src/pages/calcTable/index.tsx index 4343872..4a9b626 100644 --- a/src/pages/calcTable/index.tsx +++ b/src/pages/calcTable/index.tsx @@ -32,6 +32,7 @@ const index: FunctionComponent = (props) => { const [showTotalCell, setShowTotalCell] = useState(false); const [isDetailTable, setIsDetailTable] = useState(false); const [sumRowlistUrl, setSumRowlistUrl] = useState(""); + const [tableScrollHeight, setTableScrollHeight] = useState(0); const [payload, setPayload] = useState(""); const [fixed, setFixed] = useState(true); @@ -48,7 +49,7 @@ const index: FunctionComponent = (props) => { const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail, - fixed = true + fixed = true, tableScrollHeight } = data; setSumRowlistUrl(sumRowlistUrl); setShowTotalCell(showTotalCell); @@ -59,6 +60,7 @@ const index: FunctionComponent = (props) => { setPageInfo(pageInfo); setDataSource(dataSource); setSelectedRowKeys(selectedRowKeys); + setTableScrollHeight(tableScrollHeight); setColumns([...convertColumns(_.map(columns, o => ({ ...o, i18n: i18nRes }))), { title: i18nRes["操作"], dataIndex: "operate", fixed: "right", width: 120, render: (__, record) => () @@ -135,7 +137,7 @@ const index: FunctionComponent = (props) => { return ( o.dataIndex !== "operate")} footer={() => !isDetailTable ? : null} pagination={{ diff --git a/src/pages/salaryFileTable/index.tsx b/src/pages/salaryFileTable/index.tsx index 4611757..52f96f8 100644 --- a/src/pages/salaryFileTable/index.tsx +++ b/src/pages/salaryFileTable/index.tsx @@ -9,7 +9,8 @@ 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"; +import { Button, Dropdown, MenuProps, Space, Table } from "antd"; +import { MoreOutlined } from "@ant-design/icons"; interface OwnProps { } @@ -24,6 +25,7 @@ const Index: FunctionComponent = (props) => { const [i18n, setI18n] = useState({}); const [runStatuses, setRunStatuses] = useState(""); const [showOperateBtn, setShowOperateBtn] = useState(false); + const [showDelSalaryFileBtn, setShowDelSalaryFileBtn] = useState(false);//待定薪、停薪员工 是否允许删除薪资档案 useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -38,15 +40,16 @@ const Index: FunctionComponent = (props) => { if (!_.isEmpty(data)) { const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, - runStatuses, showOperateBtn + selectedKey, showOperateBtn, showDelSalaryFileBtn } = data; setShowOperateBtn(showOperateBtn); - setRunStatuses(runStatuses); + setRunStatuses(selectedKey); setI18n(i18nRes); setPageInfo(pageInfo); setDataSource(dataSource); setSelectedRowKeys(selectedRowKeys); setColumns(columns); + setShowDelSalaryFileBtn(showDelSalaryFileBtn); } }; const onChange = (current: number, pageSize: number) => { @@ -70,13 +73,13 @@ const Index: FunctionComponent = (props) => { window.parent.postMessage( { type: "turn", - payload: { id: "CHECKBOX", params: { selectedRowKeys } } + payload: { id: "ROWSELECTION", params: { selectedRowKeys } } }, "*" ); } }; - const handleWelfareOperate = (type: string, record: any, interfaceParams?: any) => { + const handleSalaryFileOperate = (type: string, record: any, interfaceParams?: any) => { window.parent.postMessage( { type: "turn", @@ -86,10 +89,109 @@ const Index: FunctionComponent = (props) => { ); }; const cols: any = useMemo(() => { - return showOperateBtn ? [...columns] : [...columns]; - }, [columns, runStatuses, i18n, showOperateBtn]); + if (!_.isEmpty(columns)) { + let opts: any = _.find(columns, o => o.dataIndex === "operate"); + switch (runStatuses) { + case "pending": + opts = { + ...opts, + render: (__: any, record: any) => { + let items: MenuProps["items"] = [ + { + key: "DeleteTodoList", + label: i18n["删除待办"], + onClick: () => handleSalaryFileOperate("DEL-PENDITNG-TO-DO", record, [record?.id]) + }, + { + key: "DeleteFiles", + label: i18n["删除档案"], + onClick: () => handleSalaryFileOperate("DEL-SALARY-FILES", record, [record?.id]) + } + ]; + !showDelSalaryFileBtn && (items = _.dropRight(items)); + return ( + + + + ) + }; + break; + case "suspend": + opts = { + ...opts, + render: (__: any, record: any) => { + const downsizingItems: MenuProps["items"] = [ + { + key: "DeleteTodoList", + label: i18n["删除待办"], + onClick: () => handleSalaryFileOperate("DEL-SUSPEND-TO-DO", record, [record?.id]) + } + ]; + return ( + + + + + + { + !_.isEmpty(stopItems) && + + ) + }]; + } else { + return []; + } + }, [columns, runStatuses, i18n, showOperateBtn, showDelSalaryFileBtn]); return (