|
|
|
@ -3,12 +3,13 @@ import { Button, Table, Typography } from "antd";
|
|
|
|
|
import { exceptStr } from "@/utils/common";
|
|
|
|
|
import styles from "@/pages/atdTable/components/index.less";
|
|
|
|
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
const { Text, Paragraph } = Typography;
|
|
|
|
|
const ReportTable: FC = (props) => {
|
|
|
|
|
const [columns, setColumns] = useState<Array<any>>([]);
|
|
|
|
|
const [sumRow, setSumRow] = useState<Partial<{}>>({});
|
|
|
|
|
const [dataSource, setDataSource] = useState<Array<any>>([]);
|
|
|
|
|
const [showSumrow, setShowSumrow] = useState<boolean>(false);
|
|
|
|
|
const [SSHeaderInfo, setSSHeaderInfo] = useState<string>("");
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
window.parent.postMessage({ type: "init" }, "*");
|
|
|
|
@ -20,10 +21,11 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
const receiveMessageFromIndex = (event: any) => {
|
|
|
|
|
const data: any = exceptStr(event.data);
|
|
|
|
|
if (!_.isEmpty(data)) {
|
|
|
|
|
const { columns, dataSource, countResult, showSum } = data;
|
|
|
|
|
const { columns, dataSource, countResult, showSum, SSHeaderInfo = "" } = data;
|
|
|
|
|
setDataSource(dataSource);
|
|
|
|
|
setShowSumrow(showSum);
|
|
|
|
|
setSumRow(countResult);
|
|
|
|
|
setSSHeaderInfo(SSHeaderInfo);
|
|
|
|
|
setColumns(_.map(columns, (item, index: number) => {
|
|
|
|
|
if (index === 0) {
|
|
|
|
|
return { ...item, fixed: "left", ellipsis: true };
|
|
|
|
@ -34,12 +36,12 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
return {
|
|
|
|
|
...child, ellipsis: true,
|
|
|
|
|
render: (text: string, record: any) => {
|
|
|
|
|
if(child.dataIndex?.endsWith("increase")){
|
|
|
|
|
if (child.dataIndex?.endsWith("increase")) {
|
|
|
|
|
let lowerLimitIndex = child.dataIndex.replace("increase", "lowerLimit");
|
|
|
|
|
let upperLimitIndex = child.dataIndex.replace("increase", "upperLimit");
|
|
|
|
|
let rowData = record[child.dataIndex].split(",").join("");
|
|
|
|
|
let rowData = !_.isEmpty(record[child.dataIndex]) ? record[child.dataIndex].split(",").join("") : "";
|
|
|
|
|
if (isNaN(parseFloat(rowData))) {
|
|
|
|
|
return record[child.dataIndex]
|
|
|
|
|
return record[child.dataIndex];
|
|
|
|
|
}
|
|
|
|
|
if (!isNaN(parseFloat(record[lowerLimitIndex])) && parseFloat(rowData) < parseFloat(record[lowerLimitIndex])) {
|
|
|
|
|
return <Button type="link" block onClick={() => {
|
|
|
|
@ -52,7 +54,7 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
);
|
|
|
|
|
}}>
|
|
|
|
|
<Text type="success">{rowData}</Text>
|
|
|
|
|
</Button>
|
|
|
|
|
</Button>;
|
|
|
|
|
}
|
|
|
|
|
if (!isNaN(parseFloat(record[upperLimitIndex])) && parseFloat(rowData) > parseFloat(record[upperLimitIndex])) {
|
|
|
|
|
return <Button type="link" block onClick={() => {
|
|
|
|
@ -65,9 +67,9 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
);
|
|
|
|
|
}}>
|
|
|
|
|
<Text type="danger">{rowData}</Text>
|
|
|
|
|
</Button>
|
|
|
|
|
</Button>;
|
|
|
|
|
} else {
|
|
|
|
|
return `${rowData}`
|
|
|
|
|
return `${rowData}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return <Button type="link" block onClick={() => {
|
|
|
|
@ -94,7 +96,8 @@ const ReportTable: FC = (props) => {
|
|
|
|
|
pagination={false}
|
|
|
|
|
bordered
|
|
|
|
|
size="small"
|
|
|
|
|
scroll={{ x: 1200, y: `calc(100vh - 109px)` }}
|
|
|
|
|
scroll={{ x: 1200, y: `calc(100vh - 148px)` }}
|
|
|
|
|
title={() => <Paragraph ellipsis={true}>{SSHeaderInfo}</Paragraph>}
|
|
|
|
|
summary={() => {
|
|
|
|
|
if (!showSumrow) return;
|
|
|
|
|
let totalColumns: any[] = [];
|
|
|
|
|