// 订单汇总统计
import { ConnectState } from "@/models/connect";
import { useEffect, useRef, useState } from "react";
import { connect, CurrentUser } from "umi";
import { handeGetGetOnlineOrderSummary, handeGetSaleBillWholeList } from "../service";
import { Button, Col, FormInstance, Row, Tooltip } from "antd";
import ProForm, { ProFormDateRangePicker } from "@ant-design/pro-form";
import ProTable, { ActionType } from "@ant-design/pro-table";
import moment from 'moment'
import './SummaryOfReservation.less'
import addIcon from '@/assets/detail/addIcon.png'
import reduceIcon from '@/assets/detail/reduceIcon.png'
import { handleSetlogSave } from "@/utils/format";
import OrderDetailModal from "../BookingMealOrder/components/orderDetailModal";
import PageTitleBox from "@/components/PageTitleBox";

const SummaryOfReservation: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => {
    const { currentUser } = props
    const actionRef = useRef<ActionType>();
    const formRef = useRef<FormInstance>();
    // 搜索参数
    const [searchParams, setSearchParams] = useState<any>({
        StartDate: moment().startOf('M').format('YYYY-MM-DD'),
        EndDate: moment().format('YYYY-MM-DD')
    })
    // 当前顶部的选择到了第几个
    const [selectTab, setSelectTab] = useState<number>(1)
    // 顶部内容的对象值
    const [topData, setTopData] = useState<any>()

    const [modalVisible, handleModalVisible] = useState<boolean>();
    const [currentRow, setCurrentRow] = useState<any>();
    // 算的列表合计
    const [tableSumDetail, setTableSumDetail] = useState<any>()
    // 选择的tab
    const [selectPageTab, setSelectPageTab] = useState<any>(1)



    const columns: any = [
        {
            dataIndex: 'searchText',
            title: '查询内容',
            hideInTable: true,
        },
        {
            title: '查询时间',
            dataIndex: 'search_date',
            valueType: 'dateRange',
            hideInTable: true,
            hideInDescriptions: true,
            search: {
                transform: (value) => {
                    return {
                        ORDER_DATE_Start: value[0],
                        ORDER_DATE_End: value[1],
                    };
                },
            },
            initialValue: [moment().add(-1, 'M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
        },
        {
            dataIndex: "index",
            title: "序号",
            align: 'center',
            hideInSearch: true,
            valueType: "index",
            width: 120,
            ellipsis: true,
        },
        {
            dataIndex: 'SALEBILL_CODE',
            title: '订单编号',
            align: 'center',
            hideInSearch: true,
            width: 250,
            ellipsis: true,
            render: (_, record) => {
                return record?.SALEBILL_CODE ? record?.SALEBILL_CODE === '合计' ? '合计' : <a onClick={() => {
                    setCurrentRow(record);
                    handleModalVisible(true)
                    handleSetlogSave(`查看编号为【${record?.SALEBILL_CODE}】的订单`)
                }}>{record?.SALEBILL_CODE}</a> : "-"
            }
        },
        {
            dataIndex: 'SHOPNAME',
            title: '门店名称',
            align: 'center',
            hideInSearch: true,
            width: 150,
            ellipsis: true,
        },
        {
            dataIndex: 'ORDER_PERSON',
            title: '下单人员',
            align: 'center',
            hideInSearch: true,
            width: 250,
            ellipsis: true,
        },
        {
            dataIndex: 'TOTAL_COUNT',
            title: '销售数量',
            align: 'center',
            hideInSearch: true,
            width: 250,
            ellipsis: true,
        },
        {
            dataIndex: 'ORDER_AMOUNT',
            title: '订单金额',
            align: 'center',
            hideInSearch: true,
            width: 120,
            ellipsis: true,
        },
        {
            dataIndex: 'COUPON_AMOUNT',
            title: '优惠金额',
            align: 'center',
            hideInSearch: true,
            width: 120,
            ellipsis: true,
        },
        {
            dataIndex: 'PAY_AMOUNT',
            title: '实付金额',
            align: 'center',
            hideInSearch: true,
            width: 120,
            ellipsis: true,
        },
        {
            title: "获得积分",
            dataIndex: "MEMBERSHIP_POINT",
            width: 120,
            hideInSearch: true,
            ellipsis: true,
            align: "center",
        },
        {
            title: "获得成长值",
            dataIndex: "MEMBERGROWTH_VALUE",
            width: 120,
            hideInSearch: true,
            ellipsis: true,
            align: "center",
        },
        {
            dataIndex: 'ORDER_DATE',
            title: '订单时间',
            align: 'center',
            hideInSearch: true,
            width: 170,
            ellipsis: true,
            render: (_, record) => {
                return record?.SALEBILL_CODE === '合计' ? '' : record?.ORDER_DATE ? moment(record?.ORDER_DATE).format('YYYY-MM-DD HH:mm:ss') : ''
            }
        },
        {
            dataIndex: 'SALEBILL_STATE',
            title: '订单状态',
            align: 'center',
            width: 120,
            ellipsis: true,
            valueType: 'select',
            valueEnum: {
                "0": "全部",
                "1005": "订单待支付",
                "1010": "订单待制作",
                "2000": "订单待取餐",
                "3000": "订单已完成",
                "8000": "退款申请中",
                "8900": "订单已退款",
                "9000": "订单已关闭",
                "9999": "订单已撤销",
            },
            initialValue: "0"
        }
    ]

    // 获取顶部的数据
    const handleGetTopData = async (StartDate?: string, EndDate?: string) => {

        const req: any = {
            CalcType: 1,
            OwnerUnitId: currentUser?.OwnerUnitId,
            StartDate: StartDate || searchParams?.StartDate || "",
            EndDate: EndDate || searchParams?.EndDate || "",
            SalebillType: selectPageTab === 1 ? "6000" : "3000,3001,3002",
            MerchantId: ""
        }
        const data = await handeGetGetOnlineOrderSummary(req)
        console.log('datadatadatadata', data);
        if (data && data.length > 0) {
            let obj: any = data[0]
            setTopData(obj)
        } else {
            setTopData(null)
        }
    }
    // 改变顶部的选择
    const handleChangeTab = (value: number) => {
        setSelectTab(value)
        actionRef.current?.reload()
    }
    // 关闭悬浮框
    const handleCloseModal = () => {
        handleModalVisible(false)
        setCurrentRow(undefined);
    }

    useEffect(() => {
        handleGetTopData()
    }, [])

    useEffect(() => {
        // 每当 selectPageTab 改变时执行
        handleGetTopData()
        actionRef.current?.reload()
    }, [selectPageTab])


    return (
        <div className="SummaryOfReservationMain">
            <div className="SummaryOfReservationTop">
                <div className="SummaryOfReservationTitleBox">
                    <div className={selectPageTab === 1 ? 'SummaryOfReservationTitle SummaryOfReservationTitleSelect' : 'SummaryOfReservationTitle'} onClick={() => {
                        setSelectPageTab(1)
                    }}>预约点餐订单汇总</div>
                    <div style={{ marginLeft: '48px' }} className={selectPageTab === 2 ? 'SummaryOfReservationTitle SummaryOfReservationTitleSelect' : 'SummaryOfReservationTitle'} onClick={() => {
                        setSelectPageTab(2)
                    }}>商城订单汇总</div>
                </div>

                <Row style={{ marginTop: "16px" }}>
                    <Col span={18}>
                        <ProForm
                            layout={'horizontal'}
                            formRef={formRef}
                            submitter={false}
                            onFinish={async (values: any) => {
                                console.log('values', values);
                                let [StartDate, EndDate] = ['', '']
                                if (values.searchTime && values.searchTime.length > 0) {
                                    [StartDate, EndDate] = values.searchTime
                                }
                                handleGetTopData(StartDate, EndDate)
                                setSearchParams({
                                    StartDate: StartDate,
                                    EndDate: EndDate
                                })
                                actionRef.current?.reload()
                            }}
                        >
                            <ProFormDateRangePicker
                                label={"查询时间"}
                                name={"searchTime"}
                                // initialValue={[moment().startOf('M').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]}
                                initialValue={[moment().startOf('M'), moment()]}
                                fieldProps={{
                                    ranges: {
                                        "本月": [moment().startOf('M'), moment()],
                                        "上月": [moment().subtract(1, 'M').startOf('M'), moment().subtract(1, 'M').endOf('M')],
                                        "近三月": [moment().subtract(3, 'M').startOf('M'), moment().endOf('M')],
                                        "近半年": [moment().subtract(6, 'M').startOf('M'), moment().endOf('M')],
                                    }
                                }}
                            />
                        </ProForm>
                    </Col>
                    <Col span={6}>
                        <div style={{ display: 'flex', justifyContent: 'flex-end' }}>
                            <Button style={{ marginRight: '8px' }} onClick={() => {
                                formRef.current?.resetFields()
                            }}>重置</Button>
                            <Button type={"primary"} onClick={() => {
                                formRef.current?.submit()
                            }}>查询</Button>
                        </div>
                    </Col>
                </Row>


                <div className="SummaryOfReservationContentBox">

                    <div className="SummaryOfReservationItemOther">
                        <div className={selectTab === 1 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(1)
                            }}>
                            <div className="otherItemTitle">实际销售金额（扣除退款）</div>
                            <div className="otherItemValue">{topData && topData?.TotalActualAmount ? topData?.TotalActualAmount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalActualAmount && topData?.TotalActualAmount.QOQData && topData?.TotalActualAmount.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalActualAmount.summaryData - topData?.TotalActualAmount.QOQData) / topData?.TotalActualAmount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalActualAmount && topData?.TotalActualAmount.QOQData && topData?.TotalActualAmount.summaryData ?
                                        <Tooltip title={`((${topData?.TotalActualAmount.summaryData} - ${topData?.TotalActualAmount.QOQData}) / ${topData?.TotalActualAmount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalActualAmount.summaryData - topData?.TotalActualAmount.QOQData) / topData?.TotalActualAmount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 2 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(2)
                            }}>
                            <div className="otherItemTitle">成交销售金额</div>
                            <div className="otherItemValue">{topData && topData?.TotalSuccAmount ? topData?.TotalSuccAmount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalSuccAmount && topData?.TotalSuccAmount.QOQData && topData?.TotalSuccAmount.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalSuccAmount.summaryData - topData?.TotalSuccAmount.QOQData) / topData?.TotalSuccAmount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalSuccAmount && topData?.TotalSuccAmount.QOQData && topData?.TotalSuccAmount.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalSuccAmount ? topData?.TotalSuccAmount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalSuccAmount.summaryData} - ${topData?.TotalSuccAmount.QOQData}) / ${topData?.TotalSuccAmount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalSuccAmount.summaryData - topData?.TotalSuccAmount.QOQData) / topData?.TotalSuccAmount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 3 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(3)
                            }}>
                            <div className="otherItemTitle">成交订单笔数</div>
                            <div className="otherItemValue">{topData && topData?.TotalSuccTicket ? topData?.TotalSuccTicket.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalSuccTicket && topData?.TotalSuccTicket.QOQData && topData?.TotalSuccTicket.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalSuccTicket.summaryData - topData?.TotalSuccTicket.QOQData) / topData?.TotalSuccTicket.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalSuccTicket && topData?.TotalSuccTicket.QOQData && topData?.TotalSuccTicket.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalSuccTicket ? topData?.TotalSuccTicket.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalSuccTicket.summaryData} - ${topData?.TotalSuccTicket.QOQData}) / ${topData?.TotalSuccTicket.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalSuccTicket.summaryData - topData?.TotalSuccTicket.QOQData) / topData?.TotalSuccTicket.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 4 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(4)
                            }}>
                            <div className="otherItemTitle">成交销售数量</div>
                            <div className="otherItemValue">{topData && topData?.TotalCount ? topData?.TotalCount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalCount && topData?.TotalCount.QOQData && topData?.TotalCount.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalCount.summaryData - topData?.TotalCount.QOQData) / topData?.TotalCount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalCount && topData?.TotalCount.QOQData && topData?.TotalCount.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalCount ? topData?.TotalCount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalCount.summaryData} - ${topData?.TotalCount.QOQData}) / ${topData?.TotalCount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalCount.summaryData - topData?.TotalCount.QOQData) / topData?.TotalCount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 5 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(5)
                            }}>
                            <div className="otherItemTitle">交易失败笔数</div>
                            <div className="otherItemValue">{topData && topData?.TotalFailureTicket ? topData?.TotalFailureTicket.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalFailureTicket && topData?.TotalFailureTicket.QOQData && topData?.TotalFailureTicket.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalFailureTicket.summaryData - topData?.TotalFailureTicket.QOQData) / topData?.TotalFailureTicket.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalFailureTicket && topData?.TotalFailureTicket.QOQData && topData?.TotalFailureTicket.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalFailureTicket ? topData?.TotalFailureTicket.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalFailureTicket.summaryData} - ${topData?.TotalFailureTicket.QOQData}) / ${topData?.TotalFailureTicket.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalFailureTicket.summaryData - topData?.TotalFailureTicket.QOQData) / topData?.TotalFailureTicket.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 6 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(6)
                            }}>
                            <div className="otherItemTitle">退款订单笔数</div>
                            <div className="otherItemValue">{topData && topData?.TotalRefundTicket ? topData?.TotalRefundTicket.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalRefundTicket && topData?.TotalRefundTicket.QOQData && topData?.TotalRefundTicket.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalRefundTicket.summaryData - topData?.TotalRefundTicket.QOQData) / topData?.TotalRefundTicket.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalRefundTicket && topData?.TotalRefundTicket.QOQData && topData?.TotalRefundTicket.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalRefundTicket ? topData?.TotalRefundTicket.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalRefundTicket.summaryData} - ${topData?.TotalRefundTicket.QOQData}) / ${topData?.TotalRefundTicket.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalRefundTicket.summaryData - topData?.TotalRefundTicket.QOQData) / topData?.TotalRefundTicket.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 7 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(7)
                            }}>
                            <div className="otherItemTitle">退款订单金额</div>
                            <div className="otherItemValue">{topData && topData?.TotalRefundAmount ? topData?.TotalRefundAmount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.TotalRefundAmount && topData?.TotalRefundAmount.QOQData && topData?.TotalRefundAmount.summaryData ?
                                        <img className="addIcon" src={((topData?.TotalRefundAmount.summaryData - topData?.TotalRefundAmount.QOQData) / topData?.TotalRefundAmount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.TotalRefundAmount && topData?.TotalRefundAmount.QOQData && topData?.TotalRefundAmount.summaryData ?
                                        // <span className="addValue">{topData && topData?.TotalRefundAmount ? topData?.TotalRefundAmount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.TotalRefundAmount.summaryData} - ${topData?.TotalRefundAmount.QOQData}) / ${topData?.TotalRefundAmount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.TotalRefundAmount.summaryData - topData?.TotalRefundAmount.QOQData) / topData?.TotalRefundAmount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>
                        {/* 
                        <div className={selectTab === 8 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(8)
                            }}>
                            <div className="otherItemTitle">用户访问量</div>
                            <div className="otherItemValue">{topData && topData?.VisitCount ? topData?.VisitCount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.VisitCount && topData?.VisitCount.QOQData && topData?.VisitCount.summaryData ?
                                        <img className="addIcon" src={((topData?.VisitCount.summaryData - topData?.VisitCount.QOQData) / topData?.VisitCount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.VisitCount && topData?.VisitCount.QOQData && topData?.VisitCount.summaryData ?
                                        // <span className="addValue">{topData && topData?.VisitCount ? topData?.VisitCount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.VisitCount.summaryData} - ${topData?.VisitCount.QOQData}) / ${topData?.VisitCount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.VisitCount.summaryData - topData?.VisitCount.QOQData) / topData?.VisitCount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 9 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(9)
                            }}>
                            <div className="otherItemTitle">用户收藏量</div>
                            <div className="otherItemValue">{topData && topData?.CollectionCount ? topData?.CollectionCount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.CollectionCount && topData?.CollectionCount.QOQData && topData?.CollectionCount.summaryData ?
                                        <img className="addIcon" src={((topData?.CollectionCount.summaryData - topData?.CollectionCount.QOQData) / topData?.CollectionCount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.CollectionCount && topData?.CollectionCount.QOQData && topData?.CollectionCount.summaryData ?
                                        // <span className="addValue">{topData && topData?.CollectionCount ? topData?.CollectionCount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.CollectionCount.summaryData} - ${topData?.CollectionCount.QOQData}) / ${topData?.CollectionCount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.CollectionCount.summaryData - topData?.CollectionCount.QOQData) / topData?.CollectionCount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div>

                        <div className={selectTab === 10 ? 'SummaryOfReservationOtherItem SummaryOfReservationOtherItemSelect' : 'SummaryOfReservationOtherItem'}
                            onClick={() => {
                                handleChangeTab(10)
                            }}>
                            <div className="otherItemTitle">商品数量</div>
                            <div className="otherItemValue">{topData && topData?.CommodityCount ? topData?.CommodityCount.summaryData : "-"}</div>
                            <div className="addLabel">环比增长</div>
                            <div className="otherItemAddBox">
                                {
                                    topData && topData?.CommodityCount && topData?.CommodityCount.QOQData && topData?.CommodityCount.summaryData ?
                                        <img className="addIcon" src={((topData?.CommodityCount.summaryData - topData?.CommodityCount.QOQData) / topData?.CommodityCount.QOQData) > 0 ? addIcon : reduceIcon} /> : ""
                                }
                                {
                                    topData && topData?.CommodityCount && topData?.CommodityCount.QOQData && topData?.CommodityCount.summaryData ?
                                        // <span className="addValue">{topData && topData?.CommodityCount ? topData?.CommodityCount.QOQData : "-"}</span>
                                        <Tooltip title={`((${topData?.CommodityCount.summaryData} - ${topData?.CommodityCount.QOQData}) / ${topData?.CommodityCount.QOQData}) * 100`}>
                                            <span className="addValue">{(((topData?.CommodityCount.summaryData - topData?.CommodityCount.QOQData) / topData?.CommodityCount.QOQData) * 100).toFixed(2) + '%'}</span>
                                        </Tooltip>
                                        : "-"
                                }
                            </div>
                        </div> */}

                    </div>
                </div>

            </div>



            <div className="SummaryOfReservationBottom">

                <ProTable
                    scroll={{ x: "100%", y: 'calc(100vh - 500px)' }}
                    rowKey={(record) => `${record?.SALEBILL_CODE}-${record?.ORDER_DATE}`}
                    formRef={formRef}
                    bordered
                    actionRef={actionRef}
                    search={false}
                    options={false}
                    request={async (params, sorter) => {
                        const req = {
                            searchParameter: {
                                SALEBILL_TYPES: selectPageTab === 1 ? 6000 : "3000,3001,3002",
                                OWNERUNIT_ID: currentUser?.OwnerUnitId,
                                ORDER_DATE_Start: searchParams?.StartDate || "",
                                ORDER_DATE_End: searchParams?.EndDate || "",
                                SALEBILL_STATES: selectTab == 1 ? '1010,2000,3000,8000' :
                                    selectTab == 2 ? '1010,2000,3000,8000,8900' :
                                        selectTab == 3 ? '1010,2000,3000,8000,8900' :
                                            selectTab == 4 ? '1010,2000,3000,8000,8900' :
                                                selectTab == 5 ? '9000,9999' :
                                                    selectTab == 6 ? '8900' :
                                                        selectTab == 7 ? '8900' :
                                                            selectTab == 8 ? '' :
                                                                selectTab == 9 ? '' :
                                                                    selectTab == 10 ? '' : '',
                                SearchKeyValue: params?.searchText || ""
                            },
                            PageIndex: 1,
                            PageSize: 999999,
                            SortStr: "ORDER_DATE desc",
                        }
                        const data = await handeGetSaleBillWholeList(req)

                        handleSetlogSave(`点击查询按钮`)
                        console.log('datadatadatadatadata', data);
                        if (data.List && data.List.length > 0) {
                            let PAY_AMOUNTSUM: number = 0
                            let ORDER_AMOUNTSUM: number = 0
                            let COUPON_AMOUNTSUM: number = 0
                            let TOTAL_COUNTSUM: number = 0
                            data.List.forEach((item: any) => {
                                PAY_AMOUNTSUM += item.PAY_AMOUNT
                                ORDER_AMOUNTSUM += item.ORDER_AMOUNT
                                COUPON_AMOUNTSUM += item.COUPON_AMOUNT
                                TOTAL_COUNTSUM += item.TOTAL_COUNT
                            })

                            let sumTotal: any = {
                                PAY_AMOUNT: PAY_AMOUNTSUM.toFixed(2),
                                ORDER_AMOUNT: ORDER_AMOUNTSUM.toFixed(2),
                                COUPON_AMOUNT: COUPON_AMOUNTSUM.toFixed(2),
                                TOTAL_COUNT: TOTAL_COUNTSUM.toFixed(0),
                                SALEBILL_CODE: "合计",
                                ORDER_DATE: 1
                            }

                            let res: any = [{
                                ...sumTotal,
                                children: data.List
                            }]

                            return { data: res, success: true }
                            // , total: data.TotalCount
                        }
                        return { data: [], success: true }
                    }}
                    pagination={false}
                    columns={columns}
                    expandable={{
                        defaultExpandedRowKeys: ["合计-1"],
                        // defaultExpandAllRows: true, // 默认展开所有行（包括合计行）
                        // indentSize: 0, // 可选：调整缩进大小
                    }}
                />
            </div>


            <OrderDetailModal modalVisible={modalVisible} handleCloseModal={handleCloseModal} currentRow={currentRow} />
        </div>
    )
}

export default connect(({ user }: ConnectState) => ({
    currentUser: user.currentUser
}))(SummaryOfReservation);