/*
 * @Author: cclu 1106109051@qq.com
 * @Date: 2024-08-13 18:25:53
 * @LastEditors: cclu 1106109051@qq.com
 * @LastEditTime: 2025-01-02 10:11:42
 * @FilePath: \cloud-platform\src\pages\reports\settlementAccount\component\monthExamine.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { connect } from "umi";
import type { ConnectState } from "@/models/connect";
import ProTable, { ActionType } from "@ant-design/pro-table";
import { useImperativeHandle, useRef, useState } from "react";
import { Col, Drawer, FormInstance, message, Modal, Row, Spin } from "antd";
import moment from 'moment'
import session from "@/utils/session";
import { handleGetAPPROVALROUTEDetail, handleGetGetBUSINESSAPPROVALDetail, handleGetProjectAccountList, handleGetProjectPeriodAccount, handleGetTableRevenueRecognition, } from "../../ShopExpenseDetail/service";
import { handleGetMonthAccountProinst } from "@/pages/examine/examineList/service";
import useRequest from '@ahooksjs/use-request'; // 请求数据的引用
import { handleGetAPPROVALROUTEList } from "@/pages/Setting/serviceConfig/service";
import numeral from 'numeral'
import ProjectEditor from "@/pages/BussinessProject/editor";
import ProjectDetail from '@/pages/BussinessProject/detail'
import CompareList from "../../revenueConfirmation/components/compareList";
import MonthExamineProcess from "./monthExamineProcess";
import ProForm, { ProFormSelect, ProFormTextArea } from "@ant-design/pro-form";
import { handleGetBUSINESSAPPROVALDetail } from "@/pages/examine/monthSettlement/service";
import { handleApproveMAPList } from "../service";
import printIcon from '@/assets/ai/printIcon.png'
import LoadingBox from "../../Finance/businessAnalysis/components/loading";
import { getMoney, handleFormatNumber } from "@/services/options";
import { handleNewPrint, wrapTreeNode } from "@/utils/format";
import PrintContent from "./printContent";
import { handleGetProjectPeriodIncome } from "../../revenueConfirmation/components/service";
import { handleRejectMonthAccountProinst } from "@/pages/examine/reconciliationApproval/base/service";

type DetailProps = {
    searchParams: any
    parentRow: any
    examineState: any
    searchContent: any
    currentUser?: any
    parentRef?: any // 父级表格
    isChangeFile?: any // 判断附件是否能删除
    endReject?: any // 办结后撤回
}
const MonthExamine = ({ searchParams, parentRow, examineState, searchContent, currentUser, parentRef, isChangeFile, endReject }: DetailProps) => {
    const actionRef = useRef<ActionType>();
    const formRef = useRef<FormInstance>();
    const formRejectRef = useRef<any>();

    const batchFormRef = useRef<FormInstance>();
    // 月度状态的对象
    const [monthStateObj, setMonthStateObj] = useState<any>()
    // 默认展开的数据
    const [defaultExpand, setDefaultExpand] = useState<any>()
    // 点击行的数据
    const [currentRow, setCurrentRow] = useState<any>()
    // 显示添加项目功能
    const [modalVisible, handleModalVisible] = useState<boolean>(false) // 是否显示编辑
    // 出来项目详情的抽屉
    const [showProjectDrawer, setShowProjectDrawer] = useState<boolean>(false)
    // 当前状态
    const [currentApprovalstate, setCurrentApprovalstate] = useState<any>()
    // 月度结算抽屉
    const [showDetailDrawer, setShowDetailDrawer] = useState<boolean>(false)
    // 当前月份
    const [monthTime, setMonthTime] = useState<any>()
    // 显示批量审批
    const [batchModal, setBatchModal] = useState<boolean>(false)
    // 批量审批的加载
    const [batchLoading, setBatchLoading] = useState<boolean>(false)
    // 下一状态
    const [currentNextState, setCurrentNextState] = useState<any>()
    // 当前状态
    const [currentNowState, setCurrentNowState] = useState<any>()
    // 导出报表的表格数据
    const [printData, setPrintData] = useState<any>()
    // 导出的合计行数据
    const [exportSumRow, setExportSumRow] = useState<any>()
    // 复核驳回的悬浮框
    const [reviewRejected, setReviewRejected] = useState<boolean>(false)
    // 打印的加载效果
    const [printLoading, setPrintLoading] = useState<boolean>(false)
    // 加载服务区树
    const { loading: stateLoading, data: busninessState = [] } = useRequest(async () => {
        const req: any = {
            SearchParameter: {
                APPROVALROUTE_VALID: 1,
                OPERATION_TYPES: 12
            },
            SortStr: 'APPROVALROUTE_STATE asc',
            PageIndex: 1,
            PageSize: 999999
        }
        const data = await handleGetAPPROVALROUTEList(req)
        if (data && data.length > 0) {
            const list: any = []
            data.forEach((item: any) => {
                list.push({ label: item.APPROVALROUTE_NAME, value: item.APPROVALROUTE_STATE })
            })
            list.push({ label: '已审结', value: 9000 })
            list.push({ label: '已驳回', value: 3000 })
            let str: string = ''
            list.forEach((item: any) => {
                if (item.value === 3000) {

                } else {
                    if (str) {
                        str += `,${item.value}`
                    } else {
                        str = item.value
                    }
                }
            })
            console.log('list22', list);

            if (list && list.length > 0) {
                let obj: any = {}
                list.forEach((item: any) => {
                    obj[item.value] = item.label
                })
                console.log('month', obj);

                setMonthStateObj(obj)
            }
        }
    })

    // 打印的columns
    const exportColumns: any = [
        {
            title: <div style={{ textAlign: 'center' }}>期限</div>,
            dataIndex: 'PeriodDescBig',
            children: [
                {
                    dataIndex: 'IndexStr',
                    title: <div style={{ textAlign: 'center' }}>期数</div>,
                    align: 'center',
                    hideInSearch: true
                },
                {
                    title: <div style={{ textAlign: 'center' }}>期限</div>,
                    dataIndex: 'IndexDesc',
                    align: 'left',
                    hideInSearch: true,
                    // render: (_, record) => {
                    //   return record?.IndexDesc !== '合计' && record?.IndexDesc === '精算数据' ?
                    //     <span>{`${record?.StartDate}-${record?.EndDate}`}</span> :
                    //     <span>{`${record?.IndexDesc}`}</span>
                    // }
                }
            ]
        },
        {
            title: <div style={{ textAlign: 'center' }}>租金信息</div>,
            dataIndex: 'PeriodDescBig',
            hideInSearch: true,
            children: [
                {
                    title: <div style={{ textAlign: 'center' }}>保底/固定租金</div>,
                    dataIndex: 'RENTFEE',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.RENTFEE ? handleFormatNumber(record?.RENTFEE) : '0.00'
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>提成比率</div>,
                    dataIndex: 'GUARANTEERATIO',
                    hideInSearch: true,
                    align: 'right',
                    render: (_, record) => {
                        return record?.GUARANTEERATIO ? `${record?.GUARANTEERATIO}%` : ''
                    }
                }
            ]
        },
        {
            title: <div style={{ textAlign: 'center' }}>营业额</div>,
            dataIndex: 'turnover',
            hideInSearch: true,
            children: [
                {
                    title: <div style={{ textAlign: 'center' }}>现金</div>,
                    dataIndex: 'CASHPAY_AMOUNT',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.CASHPAY_AMOUNT ? handleFormatNumber(record?.CASHPAY_AMOUNT) : '0.00'
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>微支付</div>,
                    dataIndex: 'MOBILEPAY_AMOUNT',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.MOBILEPAY_AMOUNT ? handleFormatNumber(record?.MOBILEPAY_AMOUNT) : '0.00'
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>小计</div>,
                    dataIndex: 'REVENUEDAILY_AMOUNTTotal',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return <span>{record?.REVENUEDAILY_AMOUNTTotal ? handleFormatNumber(record?.REVENUEDAILY_AMOUNTTotal) : '0.00'}</span>
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>提成金额</div>,
                    dataIndex: 'GUARANTEERATIOAMOUNT',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.GUARANTEERATIOAMOUNT ? handleFormatNumber(record?.GUARANTEERATIOAMOUNT) : '0.00'
                    }
                    // render: (_, record) => {
                    //   return record.RevenueAmount * (record.GuaranteeRatio / 100)
                    // }
                },
            ]
        },
        {
            title: <div style={{ textAlign: 'center' }}>业主收款</div>,
            dataIndex: 'BANKACCOUNT_AMOUNT',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            render: (_, record) => {
                return record?.BANKACCOUNT_AMOUNT ? handleFormatNumber(record?.BANKACCOUNT_AMOUNT) : '0.00'
            }
        },
        {
            title: <div style={{ textAlign: 'center' }}>应收租金</div>,
            dataIndex: 'ROYALTYTHEORYMUST',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            render: (_, record) => {
                return record?.ROYALTYTHEORYMUST ? handleFormatNumber(record?.ROYALTYTHEORYMUST) : '0.00'
            }
        },
        {
            title: <div style={{ textAlign: 'center' }}>应收费用</div>,
            dataIndex: 'SHOPEXPENSE_AMOUNT',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            render: (_, record) => {
                return record?.SHOPEXPENSE_AMOUNT ? handleFormatNumber(record?.SHOPEXPENSE_AMOUNT) : '0.00'
            }
            // render: (_, record) => {
            //     return numeral(record?.SHOPEXPENSE_AMOUNT).format('0,0.00')
            // }
        },
        {
            title: <div style={{ textAlign: 'center' }}>已缴费用</div>,
            dataIndex: 'PAID_AMOUNTSum',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            // render: (_, record) => {
            //   return record?.PAID_AMOUNT || ''
            // },
            children: [
                {
                    title: <div style={{ textAlign: 'center' }}>合计</div>,
                    dataIndex: 'PAID_AMOUNT',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.PAID_AMOUNT ? handleFormatNumber(record?.PAID_AMOUNT) : '0.00'
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>水费</div>,
                    dataIndex: 'PAID_AMOUNT_9010',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.PAID_AMOUNT_9010 ?
                            handleFormatNumber(record?.PAID_AMOUNT_9010)
                            : record?.PAID_AMOUNT_9010 === 0 ? <span style={{ color: 'red' }}>0.00</span> : ''
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>电费</div>,
                    dataIndex: 'PAID_AMOUNT_9020',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.PAID_AMOUNT_9020 ?
                            handleFormatNumber(record?.PAID_AMOUNT_9020)
                            : record?.PAID_AMOUNT_9020 === 0 ? <span style={{ color: 'red' }}>0.00</span> : ''
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>房租</div>,
                    dataIndex: 'PAID_AMOUNT_9030',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.PAID_AMOUNT_9030 ? handleFormatNumber(record?.PAID_AMOUNT_9030) : '0.00'
                    }
                },
                {
                    title: <div style={{ textAlign: 'center' }}>物业费</div>,
                    dataIndex: 'PAID_AMOUNT_9050',
                    valueType: 'digit',
                    align: 'right',
                    hideInSearch: true,
                    render: (_, record) => {
                        return record?.PAID_AMOUNT_9050 ?
                            handleFormatNumber(record?.PAID_AMOUNT_9050)
                            : record?.PAID_AMOUNT_9050 === 0 ? <span style={{ color: 'red' }}>0.00</span> : ''
                    }
                }
            ]
        },
        {
            title: <div style={{ textAlign: 'center' }}>退补款</div>,
            dataIndex: 'RefundSupplement',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            render: (_, record) => {
                const number: number = record?.BANKACCOUNT_AMOUNT - record?.RECEIVABLEAMOUNT - record?.SHOPEXPENSE_AMOUNT + record?.PAID_AMOUNT
                return <span>{number ? handleFormatNumber(number) : '0.00'}</span>
            }
        },
        {
            title: <div style={{ textAlign: 'center' }}>备注</div>,
            width: 100,
            dataIndex: 'desc',
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
        }
    ]

    const columns: any = [
        {
            title: '统计时间',
            dataIndex: 'search_date',
            valueType: 'dateRange',
            hideInTable: true,
            hideInDescriptions: true,
            initialValue: [moment(parentRow?.STARTDATE).format("YYYY-MM"), moment(searchParams?.EndDate).format('YYYY-MM')],
            search: {
                transform: (value: any) => {
                    return {
                        StartDate: value[0],
                        EndDate: value[1],
                    };
                },
            },
            fieldProps: {
                picker: "month",
                format: 'YYYY-MM',
                allowClear: true
                // disabledDate: (current: any) => current && current > moment()
            }
        },
        {
            dataIndex: 'CURRENT_PERIOD',
            title: <div style={{ textAlign: 'center' }}>期数</div>,
            align: 'center',
            width: 140,
            hideInSearch: true,
            render: (_, record) => {
                return record?.level === 1 ?
                    record?.CURRENT_PERIOD : record?.SETTLEMENT_DATE
            }
        },
        {
            dataIndex: 'SETTLEMENT_STATE',
            title: <div style={{ textAlign: 'center' }}>结算状态</div>,
            align: 'center',
            width: 120,
            valueType: 'select',
            valueEnum: {
                '3': { text: '全部' },
                '0': { text: '待结算' },
                '1': { text: '已结算' },
                '2': { text: '审批中' },
            },
            hideInSearch: true,
            render: (_, record) => {
                return record?.level === 1 ? record?.SETTLEMENT_STATE : record?.BUSINESSPROJECT_ID ?
                    record?.SETTLEMENT_STATE === 1 ?
                        <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
                            <img style={{ marginRight: '8px', cursor: 'pointer', width: '16px', height: '16px' }} src={printIcon} onClick={() => {
                                console.log('record', record);
                                handlePrintReport(record)
                            }} />
                            <a style={{ color: 'red' }} onClick={() => {
                                console.log('record', record);
                                setCurrentApprovalstate(9)
                                setCurrentRow({
                                    ...record,
                                    Approvalstate: 9,
                                    startTime: record?.STARTDATE,
                                    endTime: record?.ENDDATE,
                                    ShopRoyaltyId: record?.SHOPROYALTY_ID,
                                    BUSINESSPROJECT_ID: record?.BUSINESSPROJECT_ID,
                                    Id: record?.SERVERPARTSHOP_ID,
                                    SERVERPART_ID: record?.SERVERPART_ID,
                                    STATISTICS_MONTH: record?.SETTLEMENT_DATE,
                                })
                                setMonthTime(record?.SETTLEMENT_DATE)
                                setShowDetailDrawer(true)
                            }}>
                                已结算
                            </a>
                        </div>
                        : record?.SETTLEMENT_STATE === 2 ?
                            <a onClick={() => {
                                console.log('record', record);

                                setCurrentApprovalstate(1)
                                setCurrentRow({
                                    ...record,
                                    Approvalstate: 1,
                                    startTime: record?.STARTDATE,
                                    endTime: record?.ENDDATE,
                                    ShopRoyaltyId: record?.SHOPROYALTY_ID,
                                    BUSINESSPROJECT_ID: record?.BUSINESSPROJECT_ID,
                                    Id: record?.SERVERPARTSHOP_ID,
                                    SERVERPART_ID: record?.SERVERPART_ID,
                                    STATISTICS_MONTH: record?.SETTLEMENT_DATE,
                                })
                                console.log('dsad', {
                                    ...record,
                                    Approvalstate: 1,
                                    startTime: record?.STARTDATE,
                                    endTime: record?.ENDDATE,
                                    ShopRoyaltyId: record?.SHOPROYALTY_ID,
                                    BUSINESSPROJECT_ID: record?.BUSINESSPROJECT_ID,
                                    Id: record?.SERVERPARTSHOP_ID,
                                    SERVERPART_ID: record?.SERVERPART_ID,
                                    STATISTICS_MONTH: record?.SETTLEMENT_DATE,
                                });

                                setMonthTime(record?.SETTLEMENT_DATE)
                                setShowDetailDrawer(true)
                            }} style={{ color: '#faad14' }}>
                                审批中
                            </a> :
                            record?.SETTLEMENT_STATE === 0 ?
                                <a onClick={() => {
                                    setCurrentApprovalstate(0)
                                    setCurrentRow({
                                        ...record,
                                        Approvalstate: 0,
                                        startTime: record?.STARTDATE,
                                        endTime: record?.ENDDATE,
                                        ShopRoyaltyId: record?.SHOPROYALTY_ID,
                                        BUSINESSPROJECT_ID: record?.BUSINESSPROJECT_ID,
                                        Id: record?.SERVERPARTSHOP_ID,
                                        SERVERPART_ID: record?.SERVERPART_ID,
                                        STATISTICS_MONTH: record?.SETTLEMENT_DATE,
                                    })
                                    setMonthTime(record?.SETTLEMENT_DATE)
                                    setShowDetailDrawer(true)
                                }}>待结算</a>
                                : '' :
                    <a style={{ color: 'red' }} onClick={async () => {
                        handleModalVisible(true)
                        setCurrentRow({
                            ...record,
                            SERVERPART_IDS: [Number(record?.SERVERPART_ID)],
                            serverpartShopIds: record?.SERVERPARTSHOP_ID ? record?.SERVERPARTSHOP_ID.split(',') : '',
                            projectRangeDate: [record?.PROJECT_STARTDATE, record?.PROJECT_ENDDATE],
                        })
                    }}>添加项目</a>
            }
        },
        {
            dataIndex: 'BUSINESSPROJECT_NAME',
            title: <div style={{ textAlign: 'center' }}>项目名称</div>,
            width: 250,
            hideInSearch: true,
            ellipsis: true,
            render: (_, record) => {
                return record?.level === 1 ?
                    <a onClick={() => {
                        console.log('r', record);
                        setCurrentRow(record)
                        setShowProjectDrawer(true)
                    }}>
                        {record?.BUSINESSPROJECT_NAME}
                    </a>
                    : ''
            }
        },
        {
            title: <div style={{ textAlign: 'center' }}>累计营业额</div>,
            dataIndex: 'REVENUE_AMOUNT',
            width: 120,
            valueType: 'digit',
            align: 'right',
            hideInSearch: true,
            hideInTable: true,
        },
        {
            title: <div style={{ textAlign: 'center' }}>本月营业额</div>,
            dataIndex: 'CURREVENUE_AMOUNT',
            width: 120,
            hideInSearch: true,
            align: 'right',
            valueType: 'digit',
            render: (_, record) => {
                return record.level === 1 ?
                    <>
                        {/* 批量审批的显示条件  这一期必须要已经是完整的一起 且 都是待审核中 且 不是商家 且 全部审批人都是同一个人 才会在这个人进入的时候显示按钮 */}
                        {/* appovedIdList  状态的数组 判断是不是全部是同一个状态 */}
                        {
                            record?.children && record?.children.length >= 12 && (Number(record?.pendingList.toString()) === Number(currentUser.ID)) && record?.appovedIdList && record?.appovedIdList.length === 1 && (Number(record?.appovedIdList.toString()) !== 9000) && (Number(record?.appovedIdList.toString()) !== 1000) ?
                                <a onClick={async () => {
                                    setCurrentRow(record)
                                    setBatchModal(true)
                                }}>批量审核</a> : ''
                        }

                        {
                            record?.children && record?.children.length >= 12 && record?.appovedIdList && record?.appovedIdList.length === 1 && (Number(record?.appovedIdList.toString()) !== 1000)
                                && currentUser?.UserPattern !== 2000 && record?.pendingList && record?.pendingList.length === 1 && (Number(record?.pendingList.toString()) === Number(currentUser.ID))
                                ?
                                '' : ''
                        }

                    </>
                    : <span>{record?.CURREVENUE_AMOUNT ? numeral(record?.CURREVENUE_AMOUNT).format('0,0.00') : ''}</span>
            }
        },
        {
            title: <div style={{ textAlign: 'center' }}>本月应缴费用</div>,
            dataIndex: 'SHOPEXPENSE_AMOUNT',
            width: 120,
            ellipsis: true,
            align: 'right',
            hideInSearch: true,
        },
        {
            dataIndex: 'MERCHANTS_NAME',
            title: <div style={{ textAlign: 'center' }}>经营商户</div>,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.level === 1 ? record?.MERCHANTS_NAME :
                    record?.BusinessProcess_State ?
                        <div>
                            <span>{record?.BusinessProcess_State > 1000 && record?.BusinessProcess_State < 9000 ? `待审核：` : ''}</span>
                            <span style={{ color: '#ada7a7', fontStyle: 'italic' }}>{`${record?.ApproveStaff_Name || ''}【${monthStateObj[record?.BusinessProcess_State]}】`}</span>
                        </div>
                        : ''
            }
        },
        {
            dataIndex: 'SERVERPARTSHOP_NAME',
            title: <div style={{ textAlign: 'center' }}>门店名称</div>,
            hideInSearch: true,
            ellipsis: true,
            render: (_, record) => {
                return record?.level === 1 ? record?.SERVERPARTSHOP_NAME :
                    record?.Staff_Name ?
                        <span>
                            <span>{`发起人：`}</span>
                            <span style={{ color: '#ada7a7', fontStyle: 'italic' }}>{record?.Staff_Name ? record?.Staff_Name : ''}{record?.BusinessProcess_StartDate ? `【${record?.BusinessProcess_StartDate}】` : ''}</span>
                        </span> : ''
            }
        },
        {
            title: '操作',
            hideInTable: !endReject,
            dataIndex: 'option',
            align: 'center',
            render: (_, record) => {
                return record?.level === 1 ? '' : <a onClick={() => {
                    console.log('record', record);
                    setCurrentRow(record)
                    setReviewRejected(true)
                }}>
                    驳回
                </a>
            }
        }
    ]

    // 打印报表的方法
    const handlePrintReport = async (obj: any) => {
        setPrintLoading(true)
        let res: any = []
        const otherReq: any = {
            ServerpartIds: obj?.SERVERPART_ID,
            ShopRoyaltyId: obj?.SHOPROYALTY_ID,
            BusinessProjectId: obj?.BUSINESSPROJECT_ID,
            startDate: obj.SETTLEMENT_DATE ? moment(obj.SETTLEMENT_DATE).format('YYYYMM') : '',
            endDate: obj.SETTLEMENT_DATE ? moment(obj.SETTLEMENT_DATE).format('YYYYMM') : '',
        }
        console.log('otherReq', otherReq);

        const otherData = await handleGetTableRevenueRecognition(otherReq)
        console.log('otherData', otherData);
        if (otherData && otherData.length > 0) {
            const list: any = wrapTreeNode(otherData)
            let newObj: any = {}
            if (list && list.length > 0) {
                newObj = list[0].children[0].children[0]
            }
            console.log('newObj', newObj);
            let [start, end] = newObj.IndexDesc.split('-')
            let newIndexDesc: string = ''
            let newEnd: string = ''
            if (moment(obj.SETTLEMENT_DATE).format('YYYYMM') === moment(end).format('YYYYMM')) {
                newEnd = moment(end).format('YYYY/MM/DD')
            } else {
                newEnd = moment(obj.SETTLEMENT_DATE).endOf('month').format('YYYY/MM/DD')
            }
            newIndexDesc = start + '-' + newEnd
            newObj.IndexDesc = newIndexDesc
            // 取现金 微支付 应收租金  应收费用  已缴费用
            const incomeReq: any = {
                BusinessProjectId: obj?.BUSINESSPROJECT_ID,
                StatisticsMonth: obj?.SETTLEMENT_DATE ? moment(obj?.SETTLEMENT_DATE).format('YYYYMM') : '',
                ShopRoyaltyId: obj?.SHOPROYALTY_ID,
            }
            const income = await handleGetProjectPeriodIncome(incomeReq)
            console.log('income', income);
            let incomObj: any = income[0]
            newObj.CASHPAY_AMOUNT = incomObj.CASHPAY_AMOUNT
            newObj.MOBILEPAY_AMOUNT = incomObj.MOBILEPAY_AMOUNT
            newObj.ROYALTYTHEORYMUST = incomObj.RECEIVABLEAMOUNT
            res = [newObj]
        }
        console.log('res', res);






        setPrintData(res)

        const req: any = {
            BUSINESSAPPROVALId: obj?.BUSINESSAPPROVAL_ID
        }
        const data = await handleGetGetBUSINESSAPPROVALDetail(req)
        // 给导出弄签字
        const signature: any = {
            financeName: '',// 财务部签名
            financeRealName: '',// 财务部签名(只有人名)
            developmentName: '',// 经发部签名
            developmentRealName: '',// 经发部签名(只有人名)
            directorName: '',// 中心主任签名
            directorRealName: '',// 中心主任签名(只有人名)
            centralFinanceName: '',// 中心财务签名
            centralFinanceRealName: '',// 中心财务签名(只有人名)
            operationsSuperName: '',// 中心经营主管签名
            operationsSuperRealName: '',// 中心经营主管签名(只有人名)
            areaManagerName: '',// 服务区经理签名
            areaManagerRealName: '',// 服务区经理签名(只有人名)
            confirmationName: '',// 商户确认签名
            confirmationRealName: '',// 商户确认签名(只有人名)
            developManagerName: data.STAFF_NAME,// 经发人签名
            developManagerRealName: data.STAFF_NAME.split('【')[0] + ` ${data.BUSINESS_STARTDATE || ''}`,// 经发人签名(只有人名)
        }

        if (data.approveList && data.approveList.length > 0) {
            data.approveList.forEach((item: any) => {
                // if (item.APPLYAPPROVE_TYPE === 1000) {
                //     obj.developManagerName = item.STAFF_NAME
                //     obj.developManagerRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                // } else
                if (item.APPLYAPPROVE_TYPE === 2000) {
                    signature.confirmationName = item.STAFF_NAME
                    signature.confirmationRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2010) {
                    signature.areaManagerName = item.STAFF_NAME
                    signature.areaManagerRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2020) {
                    signature.operationsSuperName = item.STAFF_NAME
                    signature.operationsSuperRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2030) {
                    signature.centralFinanceName = item.STAFF_NAME
                    signature.centralFinanceRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2040) {
                    signature.directorName = item.STAFF_NAME
                    signature.directorRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2050) {
                    signature.developmentName = item.STAFF_NAME
                    signature.developmentRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                } else if (item.APPLYAPPROVE_TYPE === 2060) {
                    signature.financeName = item.STAFF_NAME
                    signature.financeRealName = item.STAFF_NAME.split('【')[0] + ` ${item.APPLYAPPROVE_DATE}`
                }
            })
        }

        let printName: string = `${obj?.SERVERPART_NAME}-${obj?.SERVERPARTSHOP_NAME}-${obj?.SETTLEMENT_DATE}月度结算`

        let neckList: any = [
            { label: '管理中心', value: obj?.SPREGIONTYPE_NAME },
            { label: '服务区', value: obj?.SERVERPART_NAME },
            { label: '经营商户', value: obj?.MERCHANTS_NAME },
            { label: '门店名称', value: obj?.SERVERPARTSHOP_NAME },
            { label: '合同期限', value: `${obj?.PROJECT_STARTDATE ? `${moment(obj?.PROJECT_STARTDATE).format('YYYY.MM.DD')}` : ''}${obj?.PROJECT_ENDDATE ? `-${moment(obj?.PROJECT_ENDDATE).format('YYYY.MM.DD')}` : ''}` },
        ]

        const styles = Array.from(document.styleSheets) // 获取页面的CSS样式
            .map((sheet) =>
                Array.from(sheet.cssRules).map((rule) => rule.cssText).join('\n')
            )
            .join('\n');

        let originalTable: any = document.getElementsByClassName('monthExamineTestTable')[0] // 拿到要打印的数据表格
        const clonedTable = originalTable.cloneNode(true) as HTMLElement;// 克隆表格元素，包括其子元素
        // 修改克隆后的表格样式
        clonedTable.style.display = 'block';

        // 遍历克隆表格的 <th> 和 <td> 以及它们的所有子元素，设置字体大小为 16px
        const setFontSizeRecursively = (element: HTMLElement) => {
            element.style.fontSize = '10px'; // 设置字体大小为 16px
            element.style.padding = '4px'; // 设置字体大小为 16px

            Array.from(element.children).forEach((child) =>
                setFontSizeRecursively(child as HTMLElement)
            );
        };

        // 遍历克隆表格的 <th> 和 <td> 单元格，并设置字体大小为 16px
        const tableCells = clonedTable.querySelectorAll('thead th, tbody td,tfoot td');
        tableCells.forEach((cell) => setFontSizeRecursively(cell as HTMLElement));

        // 获取克隆后的 HTML 内容
        const clonedHTML = clonedTable.getElementsByClassName('ant-table-content')[0].innerHTML;
        console.log('clonedHTML', clonedHTML);
        const footer: string = `<div style="width:100%;box-sizing: border-box;padding: 12px 12px 12px 20px;">
                <div style="width: 100%;display: flex;align-items: center;">
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">财务部：</span>
                        <span style="font-size: 12px;">${signature?.financeRealName || ''}</span>
                    </div>
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">经发部：</span>
                        <span style="font-size: 12px;">${signature?.developmentRealName || ''}</span>
                    </div>
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">中心主任：</span>
                        <span style="font-size: 12px;">${signature?.directorRealName || ''}</span>
                    </div>
                </div>
                <div style="width: 100%;display: flex;align-items: center;flex-wrap: wrap;">
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">中心财务：</span>
                        <span style="font-size: 12px;">${signature?.centralFinanceRealName || ''}</span>
                    </div>
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">中心经营主管：</span>
                        <span style="font-size: 12px;">${signature?.operationsSuperRealName || ''}</span>
                    </div>
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">服务区经理：</span>
                        <span style="font-size: 12px;">${signature?.areaManagerRealName || ''}</span>
                    </div>
                </div>
                <div style="width: 100%;display: flex;align-items: center;flex-wrap: wrap;">
                    <div style="width: 66%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">商户确认：</span>
                        <span style="font-size: 12px;">${signature?.confirmationRealName || ''}</span>
                    </div>
                    <div style="width: 33%;box-sizing: border-box;padding-left: 5%">
                        <span style="font-size: 14px;font-weight: 600;margin-right: 2px;">发起人：</span>
                        <span style="font-size: 12px;">${signature?.developManagerRealName || ''}</span>
                    </div>
                </div>
            </div>`
        setPrintLoading(false)
        handleNewPrint(printName, `${obj?.BUSINESSPROJECT_NAME}结算表(${obj?.SETTLEMENT_DATE})月`, neckList, styles, clonedHTML, footer)

    }

    return (
        <div style={{ position: 'relative' }}>
            {
                printLoading ?
                    <div style={{
                        position: 'absolute', width: '100%', height: '100%', background: 'rgba(0,0,0,0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center', zIndex: 5
                    }}>
                        <div style={{
                            display: 'flex',
                            alignItems: 'center',
                            justifyContent: 'center',
                            padding: '15px 20px 10px',
                            background: '#fff',
                            borderRadius: '8px',
                            width: '200px',
                            position: 'absolute',
                            top: '50%',
                            left: '50%',
                            zIndex: 6,
                            transform: 'translate(-50%,-50%)'
                        }}>
                            <Spin />
                            <span style={{ marginLeft: '5px' }}>{'加载打印内容中...'}</span>
                        </div>
                    </div> : ''
            }
            <ProTable
                actionRef={actionRef}
                formRef={formRef}
                columns={columns}
                bordered
                rowKey={(record) => {
                    return `${record?.CURRENT_PERIOD}-${record?.level}-${record?.SETTLEMENT_DATE}`
                }}
                expandable={{
                    expandedRowKeys: defaultExpand,
                    onExpand: (expanded, record) => {
                        console.log('expanded', expanded);
                        console.log('record', record);
                        if (defaultExpand && defaultExpand.length > 0) {
                            // 展开还是闭合
                            if (expanded) {
                                // 展开
                                let old: any = JSON.parse(JSON.stringify(defaultExpand))
                                old.push(`${record?.CURRENT_PERIOD}-1-undefined`)
                                setDefaultExpand(old)
                            } else {
                                // 闭合
                                let old: any = JSON.parse(JSON.stringify(defaultExpand))
                                let newList: any = []
                                old.forEach((item: any) => {
                                    console.log('item', item);
                                    console.log('neew', `${record?.CURRENT_PERIOD}-1-undefined`);


                                    if (item === `${record?.CURRENT_PERIOD}-1-undefined`) {
                                    } else {
                                        newList.push(item)
                                    }
                                })
                                console.log('newList', newList);
                                setDefaultExpand(newList)
                            }
                        } else {
                            // 本身没有 那只能是新增
                            let old: any = []
                            old.push(`${record?.CURRENT_PERIOD}-1-undefined`)
                            setDefaultExpand(old)
                        }
                    }
                }}
                request={async (params) => {
                    const req = {
                        ServerpartId: parentRow?.SERVERPART_ID,
                        ServerpartShopId: parentRow?.SERVERPARTSHOP_ID,
                        StartDate: params?.StartDate ? moment(params?.StartDate).format('YYYYMM') : '',
                        EndDate: params?.EndDate ? moment(params?.EndDate).format('YYYYMM') : '',
                        SettlementMode: parentRow?.SETTLEMENT_MODES || '',
                        SettlementState: examineState === 0 ? '' : examineState,
                        SettlementType: 2,
                        PageIndex: 1,
                        PageSize: 999999,
                        SortStr: '',
                        SearchKeyValue: parentRow?.SERVERPARTSHOP_ID ? '' : parentRow?.MERCHANTS_NAME,
                        SearchKeyName: 'MERCHANTS_NAME'
                    }
                    const data = await handleGetProjectAccountList(req)

                    const stateReq: any = {
                        SearchParameter: {
                            BusinessProcess_StateSearch: "1000,2000,2010,2020,2030,2040,2050,2060,9000",
                            Operation_Type: 12,
                            Serverpart_IDS: parentRow?.SERVERPART_ID,
                            ServerpartShop_ID: parentRow?.SERVERPARTSHOP_ID,
                            PendState: 2
                        },
                        PageIndex: 1,
                        PageSize: 999999
                    }
                    const stateData = await handleGetMonthAccountProinst(stateReq)
                    console.log('stateData', stateData);

                    console.log('month', data);
                    if (data && data.length > 0) {
                        let res: any = []
                        let periodList: any = []
                        data.forEach((item: any) => {
                            if (periodList.indexOf(item.CURRENT_PERIOD) === -1) {
                                periodList.push(item.CURRENT_PERIOD)
                            }
                            if (stateData && stateData.length > 0) {
                                stateData.forEach((subItem: any) => {
                                    if (subItem.BusinessApproval_ID === item.BUSINESSAPPROVAL_ID) {
                                        item.ApproveStaff_Name = subItem.ApproveStaff_Name
                                        item.BusinessProcess_State = subItem.BusinessProcess_State
                                        item.Staff_Name = subItem.Staff_Name
                                        item.Staff_ID = subItem.Staff_ID
                                        item.BusinessProcess_StartDate = subItem.BusinessProcess_StartDate
                                    }
                                })
                            }
                        })
                        console.log('periodList', periodList);
                        let defaultRow: any = []
                        periodList.forEach((item: any) => {
                            let children: any = []
                            let obj: any = {}
                            // 待审批的状态
                            let APPOVED_IDSLIST: any = []
                            // 拿到当前用户可以审批的申请id数组 业务id
                            let idList: any = []
                            // 待审批人数组 只有一个的时候才可以批量审批
                            let pendingList: any = []
                            // 那第一个业务的 作为当前的业务状态
                            let firstState: any = 0

                            data.forEach((subItem: any, subIndex: number) => {
                                if (item === subItem.CURRENT_PERIOD) {
                                    obj = subItem
                                    children.push(subItem)
                                    if (pendingList.indexOf(Number(subItem.APPOVED_IDS)) === -1) {
                                        pendingList.push(Number(subItem.APPOVED_IDS))
                                    }
                                    idList.push(subItem.BUSINESSAPPROVAL_ID)
                                }

                                if (Number(subItem.APPOVED_IDS) === Number(currentUser.ID)) {
                                    if (APPOVED_IDSLIST.indexOf(subItem.BusinessProcess_State) === -1) {
                                        APPOVED_IDSLIST.push(subItem.BusinessProcess_State)
                                    }


                                    if (subIndex === 0) {
                                        firstState = subItem.BusinessProcess_State
                                    }
                                }
                            })
                            console.log('APPOVED_IDSLIST', APPOVED_IDSLIST);
                            console.log('idList', idList);


                            res.push({
                                CURRENT_PERIOD: item,
                                children: children,
                                level: 1,
                                SETTLEMENT_STATE: children.length,
                                BUSINESSPROJECT_NAME: obj.BUSINESSPROJECT_NAME,
                                MERCHANTS_NAME: obj.MERCHANTS_NAME,
                                SERVERPARTSHOP_NAME: obj.SERVERPARTSHOP_NAME,
                                BUSINESSPROJECT_ID: obj.BUSINESSPROJECT_ID,
                                appovedIdList: APPOVED_IDSLIST,
                                SHOPROYALTY_ID: obj.SHOPROYALTY_ID,
                                BUSINESSAPPROVAL_IDS: idList,
                                pendingList: pendingList,// 待审批人列表
                                currentState: firstState,
                                BUSINESSAPPROVAL_ID: obj.BUSINESSAPPROVAL_ID
                            })
                            defaultRow.push(`${item}-1-undefined`)
                        })
                        console.log('defaultRow', defaultRow);
                        console.log('res321312', res);
                        setDefaultExpand(defaultRow)
                        return { data: res, success: true }
                    }
                    return { data: [], success: true }
                }}
            />

            <PrintContent pageName={'monthExamine'} exportColumns={exportColumns} exportData={printData} type={'month'} />

            {/* <ProTable
                style={{ display: "none" }}
                className="testTable"
                columns={exportColumns}
                dataSource={printData}
                pagination={false}
                bordered
                expandable={{
                    defaultExpandAllRows: true
                }}
                summary={() => {
                    return <>
                        <tr>
                            <td colSpan={2} align={'center'}>{exportSumRow?.PeriodIndexStr}</td>
                            <td>{exportSumRow?.MinturnOver ? numeral(exportSumRow?.MinturnOver).format('0,0') : ''}</td>
                            <td></td>
                            <td>{exportSumRow?.CashAmount ? numeral(exportSumRow?.CashAmount).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.MobilePayAmount ? numeral(exportSumRow?.MobilePayAmount).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.RevenueAmount ? numeral(exportSumRow?.RevenueAmount).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.amount ? numeral(exportSumRow?.amount).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.RoyaltyAmount ? numeral(exportSumRow?.RoyaltyAmount).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.GuaranteeFee ? numeral(exportSumRow?.GuaranteeFee).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.accountsReceivable ? numeral(exportSumRow?.accountsReceivable).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.PaidFee ? numeral(exportSumRow?.PaidFee).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.PaidFee_9010 ? numeral(exportSumRow?.PaidFee_9010).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.PaidFee_9020 ? numeral(exportSumRow?.PaidFee_9020).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.PaidFee_9030 ? numeral(exportSumRow?.PaidFee_9030).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.PaidFee_9050 ? numeral(exportSumRow?.PaidFee_9050).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.RefundSupplement ? numeral(exportSumRow?.RefundSupplement).format('0,0.00') : ''}</td>
                            <td>{exportSumRow?.desc}</td>
                        </tr>
                    </>

                }}
            /> */}

            <ProjectEditor parentTableRef={actionRef} currentRecord={currentRow} modalVisible={modalVisible} handleModalVisible={handleModalVisible} come={"examine"} />

            {/* 项目详情抽屉 */}
            <Drawer
                width="80%"
                className="project-drawer"
                visible={showProjectDrawer} // 抽屉弹框是否显示状态
                onClose={() => { // 关闭抽屉 则在清空选中行数据 并 设置抽屉状态为关闭
                    setCurrentRow(undefined);
                    setShowProjectDrawer(false);
                }}
                bodyStyle={{ backgroundColor: "#f9f9f9", padding: 0 }}
                closable={false}
            >
                {/* 抽屉打开时 加载项目详情组件 */}
                {showProjectDrawer && <ProjectDetail id={currentRow?.BUSINESSPROJECT_ID} ></ProjectDetail>}
            </Drawer>


            {/* 月度结算抽屉 */}
            <MonthExamineProcess onShow={showDetailDrawer} setOnShow={setShowDetailDrawer} parentRow={currentRow} setParentRow={setCurrentRow}
                setCurrentApprovalstate={setCurrentApprovalstate} actionRef={actionRef} currentApprovalstate={currentApprovalstate} monthTime={monthTime}
                setMonthTime={setMonthTime} parentRef={parentRef} isChangeFile={isChangeFile} />

            {/* 批量审批 */}
            <Modal
                title="批量审批"
                open={batchModal}
                width={600}
                confirmLoading={batchLoading}
                destroyOnClose
                onOk={() => {
                    batchFormRef.current?.validateFields().then(async (res: any) => {
                        setBatchLoading(true)
                        console.log('currentRow', currentRow);
                        const req: any = {
                            businessApprovalID: currentRow?.BUSINESSAPPROVAL_IDS.toString(),
                            curProinstState: currentNowState,
                            approveedInfo: res?.desc,
                            approveedStaffId: currentUser?.ID,
                            approveedStaffName: currentUser?.Name,
                            nextId: res?.nextPerson
                        }
                        console.log('req', req);
                        const data = await handleApproveMAPList(req)

                        if (data.Result_Code === 100) {
                            message.success(data.Result_Desc)
                            actionRef.current?.reload()
                            setBatchLoading(false)
                            setCurrentRow(undefined)
                            setBatchModal(false)
                            setCurrentNowState(undefined)
                            setCurrentNextState(undefined)
                        } else {
                            message.error(data.Result_Desc)
                            setBatchLoading(false)
                        }
                    })
                }}
                onCancel={() => {
                    setCurrentRow(undefined)
                    setBatchModal(false)
                    setBatchLoading(false)
                }}

            // setBatchLoading
            >
                <ProForm
                    formRef={batchFormRef}
                    submitter={{
                        // 清空表单自带的按钮
                        render: (props, doms) => {
                            return []
                        }
                    }}
                >

                    {
                        currentNextState?.NEXT_STATE !== 9000 ?
                            <Row>
                                <Col span={6}>
                                    <ProFormSelect
                                        name={"nextPerson"}
                                        label={"下一环节审批人"}
                                        rules={[
                                            {
                                                required: true,
                                                message: '请输入备注说明'
                                            }
                                        ]}
                                        request={async () => {
                                            // merchantState 判断哪几个状态是商户的 商户调用拿到 商户下面的全部人列表选择一个  不是商户的 就根据选择了的人去指定一个人
                                            // 接口直接返回就不用判断了
                                            const req: any = {
                                                BUSINESSAPPROVALId: currentRow?.BUSINESSAPPROVAL_ID || currentRow?.BUSINESSAPPROVAL_IDS[0]
                                            }
                                            console.log('req', req);

                                            const data = await handleGetBUSINESSAPPROVALDetail(req)

                                            setCurrentNowState(data.BUSINESSAPPROVAL_STATE)
                                            // 拿到下一环节
                                            const nextReq: any = {
                                                OperationType: 12,
                                                CurState: data.BUSINESSAPPROVAL_STATE,
                                                IsValid: 1
                                            }
                                            const nextData = await handleGetAPPROVALROUTEDetail(nextReq)
                                            setCurrentNextState(nextData)
                                            const list: any = []
                                            if (data.UserList && data.UserList.length > 0) {
                                                data.UserList.forEach((item: any) => {
                                                    if (item.USER_STATUS === 1) {
                                                        list.push({ label: item.USER_NAME, value: item.USER_ID })
                                                    }
                                                })
                                            }
                                            if (list && list.length > 0 && list.length === 1) {
                                                batchFormRef.current?.setFieldsValue({ nextPerson: list[0].value })
                                            }
                                            if (currentUser?.ID === 2785) {
                                                list.push({ label: '严琅杰', value: 2785 })
                                            }
                                            return list
                                        }}
                                    />
                                </Col>
                            </Row>
                            : ''
                    }

                    <ProFormTextArea
                        name="desc"
                        label="审批意见"
                        rules={[
                            {
                                required: true,
                                message: '请输入审批意见'
                            }
                        ]}
                    />
                </ProForm>
            </Modal>


            {/* 办结后的驳回 */}
            <Modal
                title={"复核驳回"}
                destroyOnClose={true}
                width={500}
                visible={reviewRejected}
                afterClose={() => {
                    formRejectRef.current?.resetFields();
                }}
                onCancel={() => {
                    setCurrentRow(undefined)
                    setReviewRejected(false)
                }}
                onOk={(value) => { // 提交框内的数据
                    formRejectRef.current.validateFields().then(async (res: any) => {
                        let req: any = {
                            businessApprovalID: currentRow?.BUSINESSAPPROVAL_ID,
                            approveedStaffId: currentUser?.ID,
                            approveedStaffName: currentUser?.Name,
                            approveedInfo: res.desc,
                            endReject: true,
                            targetProinstState: res.RejectState
                        }
                        const data = await handleRejectMonthAccountProinst(req)
                        if (data.Result_Code === 100) {
                            message.success(data.Result_Desc)
                            setCurrentRow(undefined)
                            setReviewRejected(false)
                            actionRef.current?.reload()
                            if (parentRef) {
                                parentRef.current?.reload()
                            }
                        } else {
                            message.error(data.Result_Desc)
                        }
                    })
                }}
            >
                <ProForm
                    formRef={formRejectRef}
                    submitter={false}
                >
                    <ProFormSelect
                        name="RejectState"
                        label="回退状态"
                        request={async () => {
                            const req: any = {
                                SearchParameter: {
                                    OPERATION_TYPES: '12',
                                    APPROVALROUTE_VALID: 1
                                },
                                PageIndex: 1,
                                PageSize: 999999
                            }
                            const data = await handleGetAPPROVALROUTEList(req)
                            let list: any = []
                            if (data && data.length > 0) {
                                data.forEach((item: any) => {
                                    list.push({ label: item.APPROVALROUTE_NAME, value: item.APPROVALROUTE_STATE })
                                })
                            }
                            console.log('list', list);
                            return list
                        }}
                        required
                    />
                    <ProFormTextArea
                        name="desc"
                        label="备注说明"
                    />
                </ProForm>
            </Modal>
        </div>
    )
}

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