From 156b3288b05ca5fdcc1dfe4ce7ca4188d2fb817c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Fri, 5 Jan 2024 10:32:13 +0800 Subject: [PATCH 1/4] master --- src/api/calculate.service.ts | 4 +--- src/pages/calcTable/calcFixedTotal.tsx | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index 27ec01a..d7d843b 100644 --- a/src/api/calculate.service.ts +++ b/src/api/calculate.service.ts @@ -73,9 +73,7 @@ class CalculateService extends BasicService { return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, queryParams); }; //合计行 - getAcctResultsum = async (params: any) => { - return this.post(`/api/bs/hrmsalary/salaryacct/acctresult/sum`, params); - }; + getAcctResultsum = async (url: string, params: any) => (this.post(url, params)); //社保合计行 getSyMixSum = async (params: any) => { return this.post(`/api/bs/hrmsalary/siaccount/detail/list/syMixSum`, params); diff --git a/src/pages/calcTable/calcFixedTotal.tsx b/src/pages/calcTable/calcFixedTotal.tsx index b23504b..cf35fa6 100644 --- a/src/pages/calcTable/calcFixedTotal.tsx +++ b/src/pages/calcTable/calcFixedTotal.tsx @@ -34,7 +34,7 @@ const calcFixedTotal: FunctionComponent = (props) => { return !_.isEmpty(props.columns) ? flattenFn(props.columns) : []; }, [props.columns]); const dataSourceUrl = useCallback((payload) => { - return API.CalculateService.getAcctResultsum(payload); + return API.CalculateService.getAcctResultsum(props.dataSourceUrl, payload); }, [props.dataSourceUrl]); useEffect(() => { if (!_.isEmpty(props.payload)) { 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 2/4] 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; 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 3/4] 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 (
Date: Wed, 17 Jan 2024 14:32:26 +0800 Subject: [PATCH 4/4] 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["总计"]} - + )}