|
|
|
@ -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, Table, Typography } from "antd";
|
|
|
|
|
import { message, Spin, Table, Typography } from "antd";
|
|
|
|
|
import { LockOutlined, UnlockOutlined } from "@ant-design/icons";
|
|
|
|
|
import API from "@/api";
|
|
|
|
|
import styles from "./index.less";
|
|
|
|
@ -20,6 +20,7 @@ const AntdTable: FC<ITableProps> = (props) => {
|
|
|
|
|
const [columns, setColumns] = useState<any[]>([]);
|
|
|
|
|
const [dataSource, setDataSource] = useState<any[]>([]);
|
|
|
|
|
const [sumRow, setSumRow] = useState<Partial<{}>>({});//薪资核算总计行数据
|
|
|
|
|
const [showSumrow, setShowSumrow] = useState<boolean>(false);//薪资核算总计行是否隐藏
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.parent.postMessage(
|
|
|
|
|
{
|
|
|
|
@ -40,7 +41,7 @@ const AntdTable: FC<ITableProps> = (props) => {
|
|
|
|
|
setLoading({ query: true });
|
|
|
|
|
setTab(type);
|
|
|
|
|
setUsertab(listType);
|
|
|
|
|
API.CalculateService.getPCDataList(extraParams).then(({ success, data, errorMsg }) => {
|
|
|
|
|
API.CalculateService.getPCDataList(extraParams).then(async ({ success, data, errorMsg }) => {
|
|
|
|
|
setLoading({ query: false });
|
|
|
|
|
if (success) {
|
|
|
|
|
const { data: dataCopy } = data;
|
|
|
|
@ -57,12 +58,19 @@ const AntdTable: FC<ITableProps> = (props) => {
|
|
|
|
|
setPageParams({ ...pageParams, total, size, pageNum });
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
const { columns = [], pageInfo = {}, sumRow = {} } = dataCopy;
|
|
|
|
|
const { columns = [], pageInfo = {} } = dataCopy;
|
|
|
|
|
const { list = [], total, pageSize: size, pageNum } = pageInfo;
|
|
|
|
|
setColumns(getColumns(columns));
|
|
|
|
|
setDataSource(list);
|
|
|
|
|
setSumRow(sumRow);
|
|
|
|
|
setPageParams({ ...pageParams, total, size, pageNum });
|
|
|
|
|
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.getAcctresultsum({ salaryAcctRecordId: extraParams.queryParams.salaryAcctRecordId });
|
|
|
|
|
if (sumRowlist.data.status && !_.isEmpty(sumRowlist.data.data.sumRow)) {
|
|
|
|
|
setSumRow(sumRowlist.data.data.sumRow);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message.error(errorMsg || "");
|
|
|
|
@ -290,7 +298,7 @@ const AntdTable: FC<ITableProps> = (props) => {
|
|
|
|
|
y: tab !== "PR" ? "calc(100vh - 96px)" : !_.isEmpty(sumRow) ? "calc(100vh - 192px)" : "calc(100vh - 156px)"
|
|
|
|
|
}}
|
|
|
|
|
summary={() => {
|
|
|
|
|
if (tab !== "PR" || _.isEmpty(sumRow)) return;
|
|
|
|
|
if (tab !== "PR" || !showSumrow) return;
|
|
|
|
|
let totalColumns: any[] = [];
|
|
|
|
|
_.forEach(columns, it => {
|
|
|
|
|
if (!it.children) {
|
|
|
|
@ -303,14 +311,16 @@ const AntdTable: FC<ITableProps> = (props) => {
|
|
|
|
|
<Table.Summary fixed>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
{
|
|
|
|
|
_.map([{},...totalColumns], (item, index) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
return <Table.Summary.Cell index={0}><Text type="danger">总计</Text></Table.Summary.Cell>;
|
|
|
|
|
}
|
|
|
|
|
return <Table.Summary.Cell index={index} key={index}>
|
|
|
|
|
<Text type="danger">{sumRow[item.dataIndex] || "-"}</Text>
|
|
|
|
|
</Table.Summary.Cell>;
|
|
|
|
|
})
|
|
|
|
|
_.isEmpty(sumRow) ? <Spin tip="加载中"/> :
|
|
|
|
|
_.map([{}, ...totalColumns], (item, index) => {
|
|
|
|
|
console.log(sumRow[item.dataIndex]);
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
return <Table.Summary.Cell index={0}><Text type="danger">总计</Text></Table.Summary.Cell>;
|
|
|
|
|
}
|
|
|
|
|
return <Table.Summary.Cell index={index} key={index}>
|
|
|
|
|
<Text type="danger">{sumRow[item.dataIndex] || "-"}</Text>
|
|
|
|
|
</Table.Summary.Cell>;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
</Table.Summary>
|
|
|
|
|