diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index c1e2dcf..e0f5c1b 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/layouts/config.js b/src/layouts/config.js index 7e96181..f26707a 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -21,6 +21,7 @@ module.exports = { "/employeeDeclareTable.*": "blank", "/taxDeclareTable.*": "blank", "/welfareArchiveTable.*": "blank", + "/salaryFileTable.*": "blank", "/OCTable.*": "blank", "/manage.*": "manage", "/portal.*": "template", diff --git a/src/pages/calcTable/calcFixedTotal.tsx b/src/pages/calcTable/calcFixedTotal.tsx index b23504b..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; @@ -34,18 +35,20 @@ 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)) { + 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 6440b92..6377755 100644 --- a/src/pages/calcTable/index.tsx +++ b/src/pages/calcTable/index.tsx @@ -33,8 +33,10 @@ 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); + const [sumRow, setSumRow] = useState>({});//总计行数据 useEffect(() => { window.parent.postMessage({ type: "init" }, "*"); @@ -49,7 +51,7 @@ const index: FunctionComponent = (props) => { const { columns, dataSource, pageInfo, selectedRowKeys, i18n: i18nRes = {}, showTotalCell = false, sumRowlistUrl = "", payload = {}, calcDetail, - fixed = true + fixed = true, tableScrollHeight, sumRow } = data; setSumRowlistUrl(sumRowlistUrl); setShowTotalCell(showTotalCell); @@ -57,9 +59,11 @@ const index: FunctionComponent = (props) => { setI18n(i18nRes); setPayload(payload); setFixed(fixed); + setSumRow(sumRow); 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) => () @@ -148,19 +152,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["总计"]} - + )} diff --git a/src/pages/salaryFileTable/index.tsx b/src/pages/salaryFileTable/index.tsx new file mode 100644 index 0000000..52f96f8 --- /dev/null +++ b/src/pages/salaryFileTable/index.tsx @@ -0,0 +1,204 @@ +/* + * 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 { Button, Dropdown, MenuProps, Space, Table } from "antd"; +import { MoreOutlined } from "@ant-design/icons"; + +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); + const [showDelSalaryFileBtn, setShowDelSalaryFileBtn] = 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 = {}, + selectedKey, showOperateBtn, showDelSalaryFileBtn + } = data; + setShowOperateBtn(showOperateBtn); + setRunStatuses(selectedKey); + setI18n(i18nRes); + setPageInfo(pageInfo); + setDataSource(dataSource); + setSelectedRowKeys(selectedRowKeys); + setColumns(columns); + setShowDelSalaryFileBtn(showDelSalaryFileBtn); + } + }; + 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: "ROWSELECTION", params: { selectedRowKeys } } + }, + "*" + ); + } + }; + const handleSalaryFileOperate = (type: string, record: any, interfaceParams?: any) => { + window.parent.postMessage( + { + type: "turn", + payload: { id: type, params: { record, interfaceParams } } + }, + "*" + ); + }; + const cols: any = useMemo(() => { + 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 (
); +}; + +export default Index;