diff --git a/src/layouts/config.js b/src/layouts/config.js index 2761b0d..37ef1b4 100644 --- a/src/layouts/config.js +++ b/src/layouts/config.js @@ -17,6 +17,7 @@ module.exports = { "/payrollFilesTable.*": "blank", "/employeeDeclareTable.*": "blank", "/welfareArchiveTable.*": "blank", + "/OCTable.*": "blank", "/manage.*": "manage", "/portal.*": "template", "/passport/oauth-in": "blank", diff --git a/src/pages/OCTable/index.tsx b/src/pages/OCTable/index.tsx new file mode 100644 index 0000000..ab8d780 --- /dev/null +++ b/src/pages/OCTable/index.tsx @@ -0,0 +1,103 @@ +/* + * Author: 黎永顺 + * name: 薪酬系统-线下对比 + * Description: + * Date: 2023/11/28 + */ +import React, { FC, useEffect, useState } from "react"; +import { Table } from "antd"; +import { exceptStr, paginationFun } from "@/utils/common"; +import styles from "@/pages/atdTable/components/index.less"; +import { defaultPage, IPage } from "@/common/types"; +import cs from "classnames"; + +const OCTable: FC = (props) => { + const [columns, setColumns] = useState>([]); + const [pageInfo, setPageInfo] = useState(defaultPage); + const [dataSource, setDataSource] = useState>([]); + const [i18n, setI18n] = 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 { columns, dataSource, pageInfo, i18n: i18nRes = {} } = data; + const { current: pageNum, pageSize: size, total } = pageInfo; + setDataSource(dataSource); + setI18n(i18nRes); + setPageInfo({ pageNum, size, total }); + setColumns(convertColumns(columns, i18nRes)); + } + }; + const convertColumns: any = (cols: any[], lanObj: any) => { + return _.map(cols, item => { + if (_.isNaN(parseInt(item.dataIndex))) { + return { ...item }; + } else { + return { + ...item, children: convertColumns(item.children, lanObj), + render: (__: any, record: any) => { + const formulaDesc = record["customParameters"][`${item["dataIndex"]}`]; + const showDifference = record[`${item["dataIndex"]}_type`] === "number"; + const { acctResultValue, excelResultValue } = record[item["dataIndex"]] || {}; + return
console.log(formulaDesc)}> +
+ {lanObj["系统值"]}: + {acctResultValue} +
+
+ {lanObj["线下值"]}: + {excelResultValue} +
+ { + showDifference && +
+ {lanObj["差值"]}: + {calculateDifference(acctResultValue, excelResultValue)} +
+ } +
; + } + }; + } + }); + }; + // 计算差值 + const calculateDifference = (systemValue: string, excelValue: string) => { + if (_.isNil(systemValue) || _.isNil(excelValue)) return ""; + const systemNum = Number(systemValue); + const excelNum = Number(excelValue); + return (systemNum - excelNum).toFixed(2); + }; + + const sizeChange = (pageobj: IPage) => { + }; + const onChange = (pageobj: IPage) => { + setPageInfo({ ...pageInfo, ...pageobj }); + window.parent.postMessage( + { + type: "turn", + payload: { id: "PAGEINFO", params: { ...pageInfo, ...pageobj } } + }, + "*" + ); + }; + return ; +}; + +export default OCTable; diff --git a/src/pages/atdTable/components/index.less b/src/pages/atdTable/components/index.less index 9b3859f..7577694 100644 --- a/src/pages/atdTable/components/index.less +++ b/src/pages/atdTable/components/index.less @@ -153,6 +153,18 @@ } } + .comparison-column-item-container { + cursor: pointer; + + .comparison-single-row { + margin: 4px 0; + } + + .danger { + color: #ff4d4f; + } + } + :global { .ant-btn-link { height: inherit !important;