diff --git a/package.json b/package.json index 4eae9e3..0824865 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "@types/react": "^17.0.2", "@types/react-dom": "^17.0.2", "@umijs/plugin-access": "2.4.2", - "umi-plugin-authorize": "^2.8.12", "@umijs/plugin-dva": "^0.13.0", "@umijs/plugin-initial-state": "^2.4.0", "@umijs/plugin-locale": "^0.15.0", @@ -70,6 +69,7 @@ "prettier": "^2.2.0", "typescript": "^4.3.5", "umi": "^3.5.20", + "umi-plugin-authorize": "^2.8.12", "yorkie": "^2.0.0" } } diff --git a/src/api/calculate.service.ts b/src/api/calculate.service.ts index 0de7712..29a29b9 100644 --- a/src/api/calculate.service.ts +++ b/src/api/calculate.service.ts @@ -35,6 +35,26 @@ class CalculateService extends BasicService { getRankInfo = async () => { return this.get(`/api/ais/tupu/getRankInfo`); }; + //获取社保福利台账-正常缴纳合计行数据 + siaccountDetailCommonListSum = async (data: any) => { + return this.post(`/api/bs/hrmsalary/siaccount/detail/common/list/sum`, data); + }; + //获取社保福利台账-正常缴纳合计行数据 + siaccountDetailSupplementaryListSum = async (data: any) => { + return this.post(`/api/bs/hrmsalary/siaccount/detail/supplementary/list/sum`, data); + }; + //获取社保福利台账-社保福利台账退差合计接口 + siaccountDetailRecessionListSum = async (data: any) => { + return this.post(`/api/bs/hrmsalary/siaccount/detail/recession/list/sum`, data); + }; + //获取社保福利台账-社保福利台账补差合计接口 + siaccountDetailBalanceListSum = async (data: any) => { + return this.post(`/api/bs/hrmsalary/siaccount/detail/balance/list/sum`, data); + }; + //工资单发放-查看详情页面列表合计行数据 + salaryBillSendSum = async (data: any) => { + return this.post(`/api/bs/hrmsalary/salaryBill/send/sum`, data); + }; //合计行 getAcctresultsum = async (params: any) => { const { departmentIds = "", positionIds = "", subcompanyIds = "", ...extraParams } = params || {}; diff --git a/src/pages/atdTable/components/antdTable.tsx b/src/pages/atdTable/components/antdTable.tsx index a1cb4ce..0b42fe4 100644 --- a/src/pages/atdTable/components/antdTable.tsx +++ b/src/pages/atdTable/components/antdTable.tsx @@ -1,7 +1,7 @@ import React, { FC, useEffect, useState } from "react"; import { exceptStr, paginationFun } from "@/utils/common"; import { defaultPage, ILoading, IPage } from "@/common/types/page"; -import { message, Spin, Table, Typography } from "antd"; +import { Button, message, Spin, Table, Typography } from "antd"; import { LockOutlined, UnlockOutlined } from "@ant-design/icons"; import API from "@/api"; import styles from "./index.less"; @@ -97,19 +97,19 @@ const AntdTable: FC = (props) => { title: "操作", render: (text: string, record: any) => { return ( - { - window.parent.postMessage( - { - type: "PC", - data: { id: "DELETE", data: record } - }, - "*" - ); - }} + ); } }]; @@ -299,7 +299,7 @@ const AntdTable: FC = (props) => { width: "100px", fixed: "right", render: (text: string, record: any) => { - return { + return ; } }); return [ @@ -393,7 +393,7 @@ const AntdTable: FC = (props) => { _.isEmpty(sumRow) ? : _.map([{}, ...totalColumns], (item, index) => { if (index === 0) { - return 总计; + return 总计; } return {sumRow[item.dataIndex] || "-"} diff --git a/src/pages/payrollFilesTable/index.tsx b/src/pages/payrollFilesTable/index.tsx index e2dedf6..dd02c76 100644 --- a/src/pages/payrollFilesTable/index.tsx +++ b/src/pages/payrollFilesTable/index.tsx @@ -1,7 +1,7 @@ import React, { FC, useEffect, useState } from "react"; import { Button, Dropdown, Menu, Space, Spin, Table, Typography } from "antd"; import { DownOutlined } from "@ant-design/icons"; -import { exceptStr, paginationFun } from "@/utils/common"; +import { convertColumns, exceptStr, paginationFun } from "@/utils/common"; import styles from "@/pages/atdTable/components/index.less"; import { defaultPage, IPage } from "@/common/types"; import cs from "classnames"; @@ -158,7 +158,7 @@ const payrollFilesTable: FC = (props) => { } }; } - return { ...item }; + return _.omitBy({ ...item }, item => !item); })); setShowSumrow(showSum); setSumRow(_.isEmpty(countResult) ? { [new Date().getTime()]: new Date().getTime() } : countResult); @@ -202,26 +202,14 @@ const payrollFilesTable: FC = (props) => { ); } }; + return { - return (pageInfo.pageNum - 1) * pageInfo.size + index + 1; - } - }, - ...columns - ] - } + columns={!_.isEmpty(columns) && convertColumns(columns, _.findIndex(columns, ["dataIndex", "operate"]), Object.keys(columns).length)} dataSource={dataSource} size="small" rowSelection={rowSelection} diff --git a/src/pages/previewTable/index.tsx b/src/pages/previewTable/index.tsx index a1c7fc8..2a14459 100644 --- a/src/pages/previewTable/index.tsx +++ b/src/pages/previewTable/index.tsx @@ -1,8 +1,9 @@ import React, { FC, useEffect, useState } from "react"; -import { Table, Typography } from "antd"; +import { Spin, Table, Typography } from "antd"; import styles from "@/pages/atdTable/components/index.less"; import { exceptStr, paginationFun } from "@/utils/common"; import { defaultPage, IPage } from "@/common/types"; +import API from "@/api"; const { Text } = Typography; const PreviewTable: FC = (props) => { @@ -19,16 +20,30 @@ const PreviewTable: FC = (props) => { window.removeEventListener("message", receiveMessageFromIndex, false); }; }, []); - const receiveMessageFromIndex = (event: any) => { + const receiveMessageFromIndex = async (event: any) => { const data: any = exceptStr(event.data); if (!_.isEmpty(data)) { - const { columns, dataSource, pageInfo, salaryBillSendSum, showSum } = data; + const { columns, dataSource, pageInfo, sumpayload } = data; const { current: pageNum, pageSize: size, total } = pageInfo; setDataSource(dataSource); setColumns(columns); - setShowSumrow(showSum); - setSumRow(salaryBillSendSum); setPageInfo({ pageNum, size, total }); + const confCode: any = await API.CalculateService.getSysconfcode({ code: "OPEN_ACCT_RESULT_SUM" }); + setShowSumrow(confCode.data.status && confCode.data.data === "1"); + if (confCode.data.status && confCode.data.data === "1") { + const sumRowlist: any = await API.CalculateService.salaryBillSendSum(sumpayload); + if (sumRowlist.data.status) { + if (!_.isEmpty(sumRowlist.data.data.sumRow)) { + const tmpVSumRow= _.reduce(_.keys(sumRowlist.data.data.sumRow), (pre, cur) => (_.assign(pre, { [`${cur}_salaryItem`]: sumRowlist.data.data.sumRow[cur] })), {}) + setSumRow(tmpVSumRow); + } else { + setSumRow({ [new Date().getTime()]: new Date().getTime() }); + } + } + if (sumRowlist.data.status && _.isNil(sumRowlist.data.data.sumRow)) { + setSumRow({ [new Date().getTime()]: new Date().getTime() }); + } + } } }; const sizeChange = (pageobj: IPage) => { @@ -60,14 +75,16 @@ const PreviewTable: FC = (props) => { { - _.map(columns, (item, index) => { - if (index === 0) { - return 总计; - } - return - {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} - ; - }) + _.isEmpty(sumRow) ? : + _.map(columns, (item, index) => { + if (index === 0) { + return 总计; + } + return + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} + ; + }) } diff --git a/src/pages/rankMapTable/index.tsx b/src/pages/rankMapTable/index.tsx index 66c0c79..468671a 100644 --- a/src/pages/rankMapTable/index.tsx +++ b/src/pages/rankMapTable/index.tsx @@ -19,6 +19,7 @@ const RankMapTable: React.FC = () => { ...item, align: "center", className: colsIndex === "1" ? "bg_1_Cols" : colsIndex === "2" ? "bg_2_Cols" : "", + width: colsIndex === "1" && "60px", render: (text: string, _: any) => { return { children: {text}, @@ -63,6 +64,7 @@ const RankMapTable: React.FC = () => { _.forEach(_.reduce(columns, (pre: any, cur: any) => ([...pre, cur["dataIndex"]]), []), item => { tmpV = changeData(list, item); }); + console.log(columns); setCols(columns); setDataSource(tmpV); } diff --git a/src/pages/reportTable/index.tsx b/src/pages/reportTable/index.tsx new file mode 100644 index 0000000..fd3859c --- /dev/null +++ b/src/pages/reportTable/index.tsx @@ -0,0 +1,90 @@ +import React, { FC, useEffect, useState } from "react"; +import { Button, Table, Typography } from "antd"; +import { exceptStr } from "@/utils/common"; +import styles from "@/pages/atdTable/components/index.less"; + +const { Text } = Typography; +const ReportTable: FC = (props) => { + const [columns, setColumns] = useState>([]); + const [sumRow, setSumRow] = useState>({}); + const [dataSource, setDataSource] = useState>([]); + const [showSumrow, setShowSumrow] = 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, countResult, showSum } = data; + setDataSource(dataSource); + setShowSumrow(showSum); + setSumRow(countResult); + setColumns(_.map(columns, item => { + return { + ...item, + children: _.map(item.children, child => { + return { + ...child, + render: (text: string, record: any) => { + return ; + } + }; + }) + }; + })); + } + }; + return
{ + if (!showSumrow) return; + let totalColumns: any[] = []; + _.forEach(columns, it => { + if (!it.children) { + totalColumns.push(it); + } else { + totalColumns = [...totalColumns, ...it.children]; + } + }); + return ( + + + { + _.map([{}, ...totalColumns], (item, index) => { + if (index === 0) { + return 总计; + } + return + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} + ; + }) + } + + + ); + }} + />; +}; + +export default ReportTable; diff --git a/src/pages/standingbookTable/index.tsx b/src/pages/standingbookTable/index.tsx index 0a25f50..56275fb 100644 --- a/src/pages/standingbookTable/index.tsx +++ b/src/pages/standingbookTable/index.tsx @@ -1,8 +1,9 @@ import React, { FC, useEffect, useState } from "react"; -import { Button, Table, Typography } from "antd"; +import { Button, Spin, Table, Typography } from "antd"; import { exceptStr, paginationFun } from "@/utils/common"; import { defaultPage, IPage } from "@/common/types"; import styles from "@/pages/atdTable/components/index.less"; +import API from "@/api"; const { Text } = Typography; const StandingbookTable: FC = (props) => { @@ -20,12 +21,12 @@ const StandingbookTable: FC = (props) => { window.removeEventListener("message", receiveMessageFromIndex, false); }; }, []); - const receiveMessageFromIndex = (event: any) => { + const receiveMessageFromIndex = async (event: any) => { const data: any = exceptStr(event.data); if (!_.isEmpty(data)) { const { columns, dataSource, pageInfo, showOperates, selectedRowKeys, - showSum, siaccountSum + sumpayload, selectedKey } = data; const { current: pageNum, pageSize: size, total } = pageInfo; const conventColumns = _.map(_.filter(columns, it => it.dataIndex !== "id"), item => { @@ -61,10 +62,31 @@ const StandingbookTable: FC = (props) => { } ] ); - setSelected(selectedRowKeys); - setShowSumrow(showSum); - setSumRow(siaccountSum); setPageInfo({ pageNum, size, total }); + setSelected(selectedRowKeys); + const confCode: any = await API.CalculateService.getSysconfcode({ code: "OPEN_ACCT_RESULT_SUM" }); + setShowSumrow(confCode.data.status && confCode.data.data === "1"); + if (confCode.data.status && confCode.data.data === "1") { + const sumRowlist: any = selectedKey === "1" ? await API.CalculateService.siaccountDetailCommonListSum(sumpayload) : + selectedKey === "3" ? await API.CalculateService.siaccountDetailSupplementaryListSum(sumpayload) : + selectedKey === "regression" ? await API.CalculateService.siaccountDetailRecessionListSum(sumpayload) : + selectedKey === "difference" ? await API.CalculateService.siaccountDetailBalanceListSum(sumpayload) : { + data: { + status: false, + data: { sumRow: {} } + } + }; + if (sumRowlist.data.status) { + if (!_.isEmpty(sumRowlist.data.data.sumRow)) { + setSumRow(sumRowlist.data.data.sumRow); + } else { + setSumRow({ [new Date().getTime()]: new Date().getTime() }); + } + } + if (sumRowlist.data.status && _.isNil(sumRowlist.data.data.sumRow)) { + setSumRow({ [new Date().getTime()]: new Date().getTime() }); + } + } } }; const handleEdit = (record: any) => { @@ -84,6 +106,7 @@ const StandingbookTable: FC = (props) => { }; const rowSelection = { selectedRowKeys: selected, + columnWidth: 80, onChange: (selectedRowKeys: Array) => { setSelected(selectedRowKeys); window.parent.postMessage( @@ -113,15 +136,16 @@ const StandingbookTable: FC = (props) => { { - _.map(columns, (item, index) => { - if (index === 0) { - return 总计; - } - return - {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} - ; - }) + _.isEmpty(sumRow) ? : + _.map([{}, ...columns], (item, index) => { + if (index === 0) { + return 总计; + } + return + {!_.isNil(sumRow[item.dataIndex]) ? sumRow[item.dataIndex] : "-"} + ; + }) } diff --git a/src/utils/common.js b/src/utils/common.js index 13c0b0e..be7dc7c 100644 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -49,6 +49,15 @@ export const getPicSuffix = () => { return config.get("picSuffix"); }; +/** + * 数组中某项移至数组末尾 + * @returns {array} + */ +export const convertColumns = (array, fromIndex, toIndex) => { + array.splice(toIndex, 1, array.splice(fromIndex, 1)[0]); + return array; +}; + /** * 判断是否为JSON字符串 * @returns {string} @@ -76,8 +85,8 @@ export const paginationFun = (tableListPageObj, sizeChange, onChange) => { onChange({ pageNum: page, size, - total, + total }); - }, + } }; };