|
|
|
@ -1,22 +1,26 @@
|
|
|
|
|
import React, { FC, useEffect, useState } from "react";
|
|
|
|
|
import { Table } from "antd";
|
|
|
|
|
import { Table, Typography } from "antd";
|
|
|
|
|
import { PaginationData } from "rc-pagination";
|
|
|
|
|
import { exceptStr, paginationAction } from "@/utils/common";
|
|
|
|
|
import { renderCols } from "@/pages/unitTable/renderColsOpts";
|
|
|
|
|
import CaclFixedTotal from "@/pages/calcTable/calcFixedTotal";
|
|
|
|
|
import styles from "./index.less";
|
|
|
|
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
export type extraType = {
|
|
|
|
|
selectedKey: string;
|
|
|
|
|
selectedRowKeys: string[] | number[];
|
|
|
|
|
permission: boolean;
|
|
|
|
|
scrollHeight: number;
|
|
|
|
|
rowKey: string
|
|
|
|
|
rowKey: string;
|
|
|
|
|
showTotalCell: boolean
|
|
|
|
|
}
|
|
|
|
|
const UnitTable: FC = (props) => {
|
|
|
|
|
const [unitTableType, setUnitTableType] = useState<string>("");
|
|
|
|
|
const [columns, setColumns] = useState<Array<any>>([]);
|
|
|
|
|
const [dataSource, setDataSource] = useState<Array<any>>([]);
|
|
|
|
|
const [pageInfo, setPageInfo] = useState<Partial<PaginationData>>({});
|
|
|
|
|
const [sumRow, setSumRow] = useState<Partial<{}>>({});//总计行数据
|
|
|
|
|
const [i18n, setI18n] = useState<any>({});
|
|
|
|
|
const [extraParams, setExtraParams] = useState<Partial<extraType>>({});//额外参数
|
|
|
|
|
|
|
|
|
@ -32,14 +36,15 @@ const UnitTable: FC = (props) => {
|
|
|
|
|
if (!_.isEmpty(data)) {
|
|
|
|
|
const {
|
|
|
|
|
columns, dataSource, pageInfo, scrollHeight, i18n, showOperateBtn: permission, unitTableType = "welfareRecord",
|
|
|
|
|
selectedRowKeys, selectedKey, rowKey
|
|
|
|
|
selectedRowKeys, selectedKey, rowKey, showTotalCell = false, sumDataSource = {}
|
|
|
|
|
} = data;
|
|
|
|
|
setI18n(i18n);
|
|
|
|
|
setColumns(columns);
|
|
|
|
|
setDataSource(dataSource);
|
|
|
|
|
setPageInfo(pageInfo);
|
|
|
|
|
setUnitTableType(unitTableType);
|
|
|
|
|
setExtraParams({ selectedKey, selectedRowKeys, scrollHeight, permission, rowKey });
|
|
|
|
|
setSumRow(sumDataSource);
|
|
|
|
|
setExtraParams({ selectedKey, selectedRowKeys, scrollHeight, permission, rowKey, showTotalCell });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const onChange = (current: number, pageSize: number) => {
|
|
|
|
@ -74,6 +79,16 @@ const UnitTable: FC = (props) => {
|
|
|
|
|
...paginationAction(pageInfo, i18n, onChange),
|
|
|
|
|
size: "default"
|
|
|
|
|
} : false}
|
|
|
|
|
summary={() => (
|
|
|
|
|
!extraParams.showTotalCell ? <></> :
|
|
|
|
|
<Table.Summary fixed={true}>
|
|
|
|
|
<Table.Summary.Row>
|
|
|
|
|
<Table.Summary.Cell index={0} align="center"><Text
|
|
|
|
|
type="danger">{i18n["总计"]}</Text></Table.Summary.Cell>
|
|
|
|
|
<CaclFixedTotal columns={columns.slice(1)} dataSourceUrl="" payload={{}} sumRow={sumRow}/>
|
|
|
|
|
</Table.Summary.Row>
|
|
|
|
|
</Table.Summary>
|
|
|
|
|
)}
|
|
|
|
|
/>;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|