From 2a538033b21296a7b4560579c4fbb84d50e1589a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Tue, 28 May 2024 11:40:53 +0800 Subject: [PATCH] master --- src/layouts/config.js | 1 + src/pages/calcTable/calcFixedTotal.tsx | 17 ++- .../dacheng/salaryDetailTable.tsx | 107 ++++++++++++++++++ src/pages/custom-project/dacheng/sumTotal.tsx | 35 ++++++ src/pages/custom-project/index.less | 93 +++++++++++++++ src/pages/salaryFileTable/index.tsx | 4 +- 6 files changed, 249 insertions(+), 8 deletions(-) create mode 100644 src/pages/custom-project/dacheng/salaryDetailTable.tsx create mode 100644 src/pages/custom-project/dacheng/sumTotal.tsx create mode 100644 src/pages/custom-project/index.less diff --git a/src/layouts/config.js b/src/layouts/config.js index d091876..10d2a2a 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -21,6 +21,7 @@ module.exports = { "/salaryFileTable.*": "blank", "/OCTable.*": "blank", "/unitTable.*": "blank", + "/custom-project.*": "blank", "/manage.*": "manage", "/portal.*": "template", "/passport/oauth-in": "blank", diff --git a/src/pages/calcTable/calcFixedTotal.tsx b/src/pages/calcTable/calcFixedTotal.tsx index 769cdb8..9a00f61 100644 --- a/src/pages/calcTable/calcFixedTotal.tsx +++ b/src/pages/calcTable/calcFixedTotal.tsx @@ -37,17 +37,22 @@ const calcFixedTotal: FunctionComponent = (props) => { const dataSourceUrl = useCallback((payload) => { return API.CalculateService.getAcctResultsum(props.dataSourceUrl, payload); }, [props.dataSourceUrl]); + const debounceFetcher = _.debounce(() => { + debounceFetcher && debounceFetcher.cancel(); + setLoading(true); + dataSourceUrl(props.payload).then(({ data }) => { + setLoading(false); + const { data: result, status } = data; + if (status) setSumRow(result.sumRow || {}); + }); + }, 800); useEffect(() => { 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 || {}); - }); + (props.payload?.updateSum || _.isNil(props.payload?.updateSum)) && debounceFetcher(); } else { setSumRow(props.sumRow); } + return () => debounceFetcher && debounceFetcher.cancel(); }, [props.payload, props.sumRow]); return (<> { diff --git a/src/pages/custom-project/dacheng/salaryDetailTable.tsx b/src/pages/custom-project/dacheng/salaryDetailTable.tsx new file mode 100644 index 0000000..b1b87e7 --- /dev/null +++ b/src/pages/custom-project/dacheng/salaryDetailTable.tsx @@ -0,0 +1,107 @@ +/* + * 大成二开项目 + * 薪酬统计报表-薪资明细表格 + * @Author: 黎永顺 + * @Date: 2024/5/24 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { FunctionComponent, useEffect, useState } from "react"; +import { exceptStr, paginationAction } from "@/utils/common"; +import { PaginationData } from "rc-pagination"; +import { Table, Typography } from "antd"; +import SumTotal from "./sumTotal"; +import styles from "../index.less"; + +const { Text } = Typography; +export type extraType = { + selectedRowKeys: React.Key[]; + i18n: Partial<{}>; + sumRow: Partial<{}>; + scrollHeight: number; + showTotalCell: boolean +} + +interface OwnProps { +} + +type Props = OwnProps; + +const salaryDetailTable: FunctionComponent = (props) => { + const [columns, setColumns] = useState>([]); + const [dataSource, setDataSource] = useState>([]); + const [pageInfo, setPageInfo] = useState>({}); + const [parent, setParent] = useState>({});//参数 + 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 { + i18n, columns, dataSource, pageInfo, showTotalCell, tableScrollHeight: scrollHeight, selectedRowKeys, + sumRow + } = data; + setColumns(_.map(columns, item => ({ + ...item, render: (text: string, record: any) => { + if (record.showRed) { + return ({text}); + } else { + return ({text}); + } + } + }))); + setDataSource(dataSource); + setPageInfo(pageInfo); + setParent({ i18n, showTotalCell, scrollHeight, selectedRowKeys, sumRow }); + } + }; + 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: parent.selectedRowKeys, + renderCell: (value: boolean, record: any, index: number, originNode: React.ReactNode) => (record?.showCheck === "1" ? originNode : null), + onChange: (selectedRowKeys: React.Key[]) => { + setParent({ ...parent, selectedRowKeys: selectedRowKeys }); + window.parent.postMessage( + { type: "turn", payload: { id: "CHECKBOX", params: { selectedRowKeys } } }, "*" + ); + } + }; + return ( it.id), expandIcon: () => null }} + summary={() => (!parent.showTotalCell ? <> : + + + {parent["i18n"]?.["总计"]} + + + + )} + />); +}; + +export default salaryDetailTable; diff --git a/src/pages/custom-project/dacheng/sumTotal.tsx b/src/pages/custom-project/dacheng/sumTotal.tsx new file mode 100644 index 0000000..e71ce8a --- /dev/null +++ b/src/pages/custom-project/dacheng/sumTotal.tsx @@ -0,0 +1,35 @@ +/* + * + * 合计行 + * @Author: 黎永顺 + * @Date: 2024/5/24 + * @Wechat: + * @Email: 971387674@qq.com + * @description: +*/ +import React, { FunctionComponent } from "react"; +import { Table, Typography } from "antd"; +import { ColumnType } from "antd/lib/table"; + +const { Text } = Typography; + +interface OwnProps { + columns: ColumnType[]; + sumRow: any; +} + +type Props = OwnProps; + +const sumTotal: FunctionComponent = (props) => { + return (<> + { + _.map(props.columns, (item: any, index) => { + return + {!_.isEmpty(props?.sumRow) ? props?.sumRow[item.dataIndex] : "-"} + ; + }) + } + ); +}; + +export default sumTotal; diff --git a/src/pages/custom-project/index.less b/src/pages/custom-project/index.less new file mode 100644 index 0000000..0a71435 --- /dev/null +++ b/src/pages/custom-project/index.less @@ -0,0 +1,93 @@ +.DC_table { + background: #fff; + + :global { + + .ant-table-tbody > tr.ant-table-row:hover > td { + background: #e9f7ff; + } + + .anticon-more { + font-size: 16px; + cursor: pointer; + } + + .ant-spin-container { + .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; + line-height: 28px; + border-radius: 6px; + + & > button { + border-radius: 6px; + } + } + + .ant-pagination-item-active { + background: var(--ant-primary-color); + border: none; + + & > a { + color: #FFF; + } + } + + .ant-pagination-options { + .ant-select { + font-size: 12px; + + .ant-select-selector { + height: 28px; + border-radius: 6px; + + .ant-select-selection-search-input { + height: 26px; + line-height: 26px; + } + + .ant-select-selection-item { + line-height: 26px; + } + } + + .ant-select-item { + font-size: 12px; + } + } + + .ant-pagination-options-quick-jumper { + height: 28px; + line-height: 28px; + + & > input { + border-radius: 6px; + height: 28px; + } + } + } + } + } + + .ant-table-thead > tr > th { + background-color: #f7fbfe; + } + + th, td { + font-size: 12px; + + .ant-form-item { + margin-bottom: 0; + + .ant-input-number { + width: 100%; + } + } + } + } +} diff --git a/src/pages/salaryFileTable/index.tsx b/src/pages/salaryFileTable/index.tsx index 7508dd7..6185926 100644 --- a/src/pages/salaryFileTable/index.tsx +++ b/src/pages/salaryFileTable/index.tsx @@ -118,7 +118,7 @@ const Index: FunctionComponent = (props) => { !showDelSalaryFileBtn && (items = _.dropRight(items)); return ( { - _.isNil(DCChiefPermission) ? + (_.isNil(DCChiefPermission) || DCChiefPermission) ? : @@ -147,7 +147,7 @@ const Index: FunctionComponent = (props) => { return ( { - ((_.isNil(DCChiefPermission) && runStatuses === "fixed") || runStatuses === "ext") ? + (((_.isNil(DCChiefPermission) || DCChiefPermission) && runStatuses === "fixed") || runStatuses === "ext") ? :