// 商家信息管理
import React, { useRef, useState, Suspense } from 'react';
import moment from 'moment'; // 时间相关引用，没有使用可以删除
import numeral from "numeral"; // 数字相关引用，没有使用可以删除
import { connect } from 'umi';

import useRequest from '@ahooksjs/use-request'; // 请求数据的引用
import Draggable from 'react-draggable';
import SubMenu from "antd/lib/menu/SubMenu";
import ProTable from '@ant-design/pro-table';
import ProDescriptions from '@ant-design/pro-descriptions';
import ProForm, { ProFormDatePicker, ProFormDateTimePicker, ProFormMoney, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect, ProFormUploadButton } from '@ant-design/pro-form';
import { MenuFoldOutlined, PlusOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-layout';
import { Button, Col, Drawer, message, Row, Popconfirm, Space, Image, Modal, Form, Switch, Upload, Tooltip, Descriptions, TreeSelect, Divider, Tabs, Select, Input, Tree } from 'antd';

import type { CurrentUser } from "umi";
import type { ConnectState } from '@/models/connect';
import type { ActionType, ProColumns } from '@ant-design/pro-table';
import type { ProDescriptionsItemProps } from '@ant-design/pro-descriptions';
import type { FormInstance } from 'antd';
import { handleDeleteSERVERPARTSELLER, handleGetMEMBERADDRESSList, handleGetRelateShopToSeller, handleGetSERVERPARTSELLERDetail, handleGetSERVERPARTSHOPList, handleRemoveShopFromSeller, handleSynchroSERVERPARTSELLER } from '../service';
import LeftSelectTree from '@/pages/reports/settlementAccount/component/leftSelectTree';
import session from '@/utils/session';
import PageTitleBox from '@/components/PageTitleBox';
import { handeGetCOMMENTList, handeGetPictureList, handeGetRevenueReport } from '@/pages/travelMember/service';
import { deletePicture, uploadPicture } from '@/services/picture';
import { handleGetServerPartShopNewList } from '@/pages/basicManage/serviceArea/service';
import { handleGetServerpartShopList } from '@/pages/DataVerification/service';
import ModalFooter from '@/pages/travelMember/scenicSpotConfig/component/modalFooter';

const beforeUpload = (file: any) => {
    const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
    if (!isJpgOrPng) {
        message.error('请上传JPEG、jpg、png格式的图片文件!');
    }
    const isLt2M = file.size / 1024 / 1024 < 5;
    if (!isLt2M) {
        message.error('图片大小不超过 5MB!');
    }
    return isJpgOrPng && isLt2M;
}

const MerchantInformation: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => {
    const { confirm } = Modal;
    const { currentUser } = props
    const actionRef = useRef<ActionType>();
    const formRef = useRef<FormInstance>();
    const formMerchantRef = useRef<FormInstance>();
    const associationActionRef = useRef<ActionType>();
    const [currentRow, setCurrentRow] = useState<any>();
    const [showDetail, setShowDetail] = useState<boolean>();
    const [modalVisible, handleModalVisible] = useState<boolean>();
    const [confirmLoading, handleConfirmLoading] = useState<boolean>(false) // 弹出框的内容表单是否在提交
    const [searchParams, setSearchParams] = useState<any>();
    // 树相关的属性和方法
    const [selectedId, setSelectedId] = useState<string>()
    const [collapsible, setCollapsible] = useState<boolean>(false)
    // 新增关联选择的方法
    const [selectedRowKeys, setSelectRowKeys] = useState<any>();
    const [selectedRowDetail, setSelectRowDetail] = useState<any>();
    // 在关联编辑页里面的tab选择
    const [selectTab, setSelectTab] = useState<string>("1")
    // 当前编辑商家的关联门店数据
    const [currentShopData, setCurrentShopData] = useState<any>()
    // 当前编辑商家的详情
    const [currentRowDetail, setCurrentRowDetail] = useState<any>()
    // 选择的 要关联的服务区
    const [selectAssociationServerpart, setSelectAssociationServerpart] = useState<any>()
    // 文件列表
    const [fileList, setFileList] = useState<any>([])
    const [imagePreviewVisible, setImagePreviewVisible] = useState<boolean>(false) // 预览图片
    // 商家logo图片列表
    const [MerchantLogoList, setMerchantLogoList] = useState<any>([])
    // 门头图片列表
    const [DoorImageList, setDoorImageList] = useState<any>([])
    // 内景图片列表
    const [InteriorImage, setInteriorImageList] = useState<any>([])
    // 营收的加载效果
    const [revenueLoading, setRevenueLoading] = useState<boolean>(false)


    let SHOPTRADEObj = session.get('SHOPTRADEObj')
    let SHOPTRADEList = session.get('SHOPTRADEList')
    // 云南 门店业态
    let BUSINESSTRADEYNTree = session.get('BUSINESSTRADEYNTree')
    console.log('BUSINESSTRADEYNTree', BUSINESSTRADEYNTree);

    let shopregionObj = session.get('shopregionObj')
    let businessStateObj = session.get('businessStateObj')
    let SERVERPARTTree = session.get('SERVERPARTTree')
    let serverpartList = session.get('serverpartList')
    let MEMBERSHIP_TYPEObj = session.get('MEMBERSHIP_TYPEObj');


    // 弹出框拖动效果
    const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置
    const [disabled, setDraggleDisabled] = useState<boolean>() // 是否拖动
    const draggleRef = React.createRef<any>()
    // 显示新增门店功能悬浮框
    const [showAddModal, setShowAddModal] = useState<boolean>(false)
    // 评论列表
    const [commentFileList, setCommentFileList] = useState<any>()
    const [imageCommentPreviewVisible, setImageCommentPreviewVisible] = useState<boolean>(false) // 预览图片

    const onDraggaleStart = (event, uiData) => {
        const { clientWidth, clientHeight } = window.document.documentElement;
        const targetRect = draggleRef.current?.getBoundingClientRect();
        if (!targetRect) {
            return;
        }
        setBounds({
            left: -targetRect.left + uiData.x,
            right: clientWidth - (targetRect.right - uiData.x),
            top: -targetRect.top + uiData.y,
            bottom: clientHeight - (targetRect.bottom - uiData.y),
        });
    };
    // 拖动结束
    const formatTreeData = (data: any) => {
        return data.map((item: any) => ({
            ...item,
            value: String(item.value), // 数字转字符串
            children: item.children ? formatTreeData(item.children) : undefined,
        }));
    };


    // 定义列表字段内容
    const columns: any = [
        {
            dataIndex: 'SELLER_NAME',
            title: '商家名称',
            width: 300,
            align: 'center',
            hideInSearch: true,
            ellipsis: true,
            render: (_, record) => {
                return record?.SELLER_NAME ? <a onClick={() => {
                    setCurrentRow({ ...record });
                    handleModalVisible(true);
                }}>{`${record?.SERVERPART_NAME || ""}${record?.SELLER_NAME}`}</a> : "-"
            }
        },
        {
            dataIndex: 'SHOPTRADE',
            title: '经营业态',
            align: 'center',
            width: 120,
            valueType: 'treeSelect',
            ellipsis: true,
            fieldProps: {
                treeData: formatTreeData(BUSINESSTRADEYNTree),  // 设置树形数据源
                showSearch: true,               // 启用搜索
                treeNodeFilterProp: 'label',    // 按 label 过滤
                treeDefaultExpandAll: true,
                filterTreeNode: (input: any, treeNode: any) => {
                    return String(treeNode.label).toLowerCase().includes(input.toLowerCase());
                },
            },
        },
        {
            dataIndex: 'SCANCODE_ORDER',
            title: '预约点餐',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.SCANCODE_ORDER === 1 ? '是' : '否'
            }
        },
        {
            dataIndex: 'ShopList',
            title: '门店数量',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.ShopList && record?.ShopList.length > 0 ? <a onClick={() => {
                    console.log('recordrecordrecordrecord', record);
                    setCurrentRow({ ...record });
                    handleModalVisible(true);
                }}>{record?.ShopList.length}</a> : '-'
            }
        },
        {
            dataIndex: 'IconList',
            title: '商家logo',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.IconList && record?.IconList.length > 0 ? <a onClick={() => {
                    console.log('recordrecordrecordrecord', record);
                    setCurrentRow({ ...record });
                    handleModalVisible(true);
                }}>{record?.IconList.length}</a> : '-'
            }
        },
        {
            dataIndex: 'DoorImgList',
            title: '门头图片',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.DoorImgList && record?.DoorImgList.length > 0 ? <a onClick={() => {
                    console.log('recordrecordrecordrecord', record);
                    setCurrentRow({ ...record });
                    handleModalVisible(true);
                }}>{record?.DoorImgList.length}</a> : '-'
            }
        },
        {
            dataIndex: 'InsideImgList',
            title: '内景图片',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            render: (_, record) => {
                return record?.InsideImgList && record?.InsideImgList.length > 0 ? <a onClick={() => {
                    console.log('recordrecordrecordrecord', record);
                    setCurrentRow({ ...record });
                    handleModalVisible(true);
                }}>{record?.InsideImgList.length}</a> : '-'
            }
        },
        // {
        //     dataIndex: 'MONTHLYSALES',
        //     title: '月销售量',
        //     align: 'center',
        //     width: 120,
        //     ellipsis: true,
        //     hideInSearch: true,
        // },
        // {
        //     dataIndex: 'PERCAPITA',
        //     title: '人均消费',
        //     align: 'center',
        //     width: 120,
        //     ellipsis: true,
        //     hideInSearch: true,
        // },
        // {
        //     dataIndex: 'SELLER_SCORE',
        //     title: '评价分数',
        //     align: 'center',
        //     width: 120,
        //     ellipsis: true,
        //     hideInSearch: true,
        // },
        // {
        //     dataIndex: 'COMMENT_COUNT',
        //     title: '评价数量',
        //     align: 'center',
        //     width: 120,
        //     ellipsis: true,
        //     hideInSearch: true,
        // },
        {
            dataIndex: 'ISSHOW',
            title: '小程序呈现',
            align: 'center',
            width: 120,
            ellipsis: true,
            hideInSearch: true,
            valueType: "select",
            valueEnum: {
                "-1": "全部",
                "0": "否",
                "1": "是"
            }
        },

        {
            dataIndex: 'SERVERPARTSELLER_DESC',
            title: '备注说明',
            width: 150,
            ellipsis: true,
            align: 'center',
            hideInSearch: true,
        },
        // {
        //     dataIndex: 'option',
        //     title: '操作',
        //     valueType: 'option',
        //     width: 120,
        //     align: 'center',
        //     fixed: 'right',
        //     hideInSearch: true,
        //     render: (_, record) => {
        //         return (
        //             <Space>
        //                 <a
        //                     onClick={() => {
        //                         console.log('recordrecordrecordrecord', record);
        //                         setCurrentRow({ ...record });
        //                         handleModalVisible(true);
        //                     }}
        //                 >
        //                     编辑
        //                 </a>
        //                 <Popconfirm
        //                     title="确认删除该服务区商家信息列表信息吗?"
        //                     onConfirm={async () => {
        //                         await handelDelete(record.SELLER_ID);
        //                     }}
        //                 >
        //                     <a>删除</a>
        //                 </Popconfirm>
        //             </Space>
        //         );
        //     },
        // },
    ];

    // 关联商家的表格
    const merchantColumns: any = [
        {
            dataIndex: 'SERVERPART_NAME',
            title: '服务区名称',
            align: 'center',
            width: 150,
            ellipsis: true,
            hideInSearch: true,
        },
        {
            dataIndex: 'SHOPNAME',
            title: '门店名称',
            align: 'center',
            width: 150,
            ellipsis: true,
            hideInSearch: true,
        },
        {
            dataIndex: 'SHOPREGION',
            title: '所属方位',
            align: 'center',
            width: 120,
            hideInSearch: true,
            valueType: "select",
            valueEnum: shopregionObj
        },
        // {
        //     dataIndex: 'SCANCODE_ORDER',
        //     title: '扫码点餐',
        //     align: 'center',
        //     width: 120,
        //     hideInSearch: true,
        //     valueType: "select",
        //     valueEnum: {
        //         "0": "禁用",
        //         "1": "启用"
        //     }
        // },
        {
            dataIndex: 'BUSINESS_STATE',
            title: '经营状态',
            align: 'center',
            width: 120,
            valueType: "select",
            hideInSearch: true,
            valueEnum: businessStateObj
        },
        // {
        //     dataIndex: 'SHOPDIRECTION',
        //     title: '门店方向',
        //     align: 'center',
        //     width: 120,
        //     ellipsis: true,
        //     hideInSearch: true,
        // },
        // {
        //     dataIndex: 'ISVALID',
        //     title: '门店状态',
        //     align: 'center',
        //     width: 120,
        //     valueEnum: {
        //         "0": "无效",
        //         "1": "有效"
        //     },
        //     initialValue: "1"
        // },
        {
            dataIndex: 'SERVERPARTSHOP_DESC',
            title: '介绍说明',
            align: 'center',
            width: 150,
            ellipsis: true,
            hideInSearch: true,
        }
    ]

    // 门店信息的表格
    const shopColumns: any = [
        {
            title: "序号",
            dataIndex: "index",
            valueType: "index",
            align: 'center',
            width: 80
        },
        {
            title: "门店",
            dataIndex: "SHOPNAME",
            width: 150,
            align: 'center'
        },
        {
            title: "门店简称",
            dataIndex: "SHOPSHORTNAME",
            width: 150,
            align: 'center'
        },
        {
            title: "门店方向",
            dataIndex: "SHOPDIRECTION",
            width: 150,
            align: 'center',
            render: (_, record) => {
                return <Input defaultValue={record?.SHOPDIRECTION} onBlur={(e) => {
                    if (e.target.value !== record?.SHOPDIRECTION) {
                        let list: any = JSON.parse(JSON.stringify(currentShopData))
                        if (list && list.length > 0) {
                            list.forEach((item: any) => {
                                if (item.SERVERPARTSHOP_ID === record?.SERVERPARTSHOP_ID) {
                                    item.SHOPDIRECTION = e.target.value
                                }
                            })
                        }
                        setCurrentShopData(list)
                    }
                }} />
            }
        },
        {
            title: "扫码点餐",
            dataIndex: "SCANCODE_ORDER",
            width: 150,
            align: 'center',
            render: (_, record) => {
                return <Select
                    value={record?.SCANCODE_ORDER || 0}
                    options={[{ label: "启用", value: 1 }, { label: "禁用", value: 0 }]}
                    onChange={(e: any) => {
                        let list: any = JSON.parse(JSON.stringify(currentShopData))
                        if (list && list.length > 0) {
                            list.forEach((item: any) => {
                                if (item.SERVERPARTSHOP_ID === record?.SERVERPARTSHOP_ID) {
                                    item.SCANCODE_ORDER = e
                                }
                            })
                        }
                        setCurrentShopData(list)
                    }}
                ></Select>
            }
        },
        {
            title: "联系人名称",
            dataIndex: "SHOP_LINKMAN",
            width: 150,
            align: 'center'
        },
        {
            title: "联系电话",
            dataIndex: "SHOP_TELEPHONE",
            width: 150,
            align: 'center'
        },
        // {
        //     title: "操作",
        //     dataIndex: "option",
        //     width: 120,
        //     align: 'center',
        //     render: (_, record) => {
        //         return <Space>
        //             <Popconfirm
        //                 title="确认解除关联?"
        //                 onConfirm={async () => {
        //                     await handleRemoveSeller(record)
        //                 }}
        //             >
        //                 <a>解除关联</a>
        //             </Popconfirm>

        //         </Space>
        //     }
        // }
    ]

    // 评论信息表格
    const commentColumns: any = [
        {
            title: "序号",
            dataIndex: "index",
            valueType: "index",
            width: 80,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "评价时间",
            dataIndex: "CREATE_DATE",
            width: 150,
            align: 'center',
            ellipsis: true,
            render: (_, record) => {
                return record?.CREATE_DATE ? moment(record?.CREATE_DATE).format('YYYY-MM-DD HH:mm:ss') : "-"
            }
        },
        {
            title: "评价人员",
            dataIndex: "MEMBERSHIP_NAME",
            width: 120,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "会员类型",
            dataIndex: "MEMBERSHIP_TYPE",
            width: 120,
            align: 'center',
            ellipsis: true,
            valueType: 'select',
            valueEnum: {
                ...MEMBERSHIP_TYPEObj,
            },
        },
        {
            title: "匿名评价",
            dataIndex: "ISANONYMOUS",
            width: 120,
            align: 'center',
            ellipsis: true,
            valueType: 'select',
            valueEnum: {
                "0": "否",
                "1": "是",
            },
        },
        {
            title: "评分",
            dataIndex: "COMMENT_SCORE",
            align: 'center',
            ellipsis: true,
            width: 120
        },
        {
            title: "评价内容",
            dataIndex: "COMMENT_CONTENT",
            align: 'center',
            ellipsis: true,
            width: 200
        },
        {
            title: "图片信息",
            dataIndex: "ImageList",
            align: 'center',
            ellipsis: true,
            width: 200,
            render: (_, record) => {
                return record?.ImageList && record?.ImageList.length > 0 ?
                    <img style={{ width: '60px', height: '60px', cursor: 'pointer', borderRadius: '8px' }} src={record?.ImageList[0].ImageUrl} onClick={() => {
                        let list: any = []
                        record?.ImageList.forEach((item: any) => {
                            list.push({ url: item.ImageUrl })
                        })
                        setCommentFileList(list)
                        handleChangePreview2(true)
                    }} /> : "-"
            }
        }
    ]

    const handelDelete = async (id: number) => {
        const req: any = {
            SERVERPARTSELLERId: id
        }
        const result = await handleDeleteSERVERPARTSELLER(req)
        if (result.Result_Code !== 100) {
            message.error(`${result.Result_Desc}` || `${result.Result_Code}:删除失败`);
        } else {
            message.success('删除成功！');
            actionRef.current?.reload()

            setShowAddModal(false)
            setSelectRowKeys(null)
            setSelectRowDetail(null)
            setSelectAssociationServerpart(null)
        }
    };

    const handleAddUpdate = async (res: any) => {
        let req: any = {}
        if (currentRow?.SELLER_ID) {
            req = {
                ...currentRowDetail,
                ...res,
                UPDATE_STAFF_ID: currentUser?.ID,
                UPDATE_STAFF_NAME: currentUser?.Name,
                UPDATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
            }
        } else {
            req = {
                ...res,
                PROVINCE_CODE: currentUser?.ProvinceCode,
                ISVALID: 1,
                CREATE_STAFF_ID: currentUser?.ID,
                CREATE_STAFF_NAME: currentUser?.Name,
                CREATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
            }
        }

        console.log('resresresres', res);

        const data = await handleSynchroSERVERPARTSELLER(req)
        handleConfirmLoading(false)
        if (data.Result_Code === 100) {
            await handleUploadAllImage(res, data)
            message.success(data.Result_Desc)
            formRef?.current?.resetFields()
            handleConfirmLoading(false)
            handleModalVisible(false)
            setCurrentRowDetail(null)
            setCurrentRow(undefined)
            setMerchantLogoList([])
            setDoorImageList([])
            setInteriorImageList([])
            setCurrentShopData([])
            actionRef.current?.reload()
        } else {
            message.error(data.Result_Desc)
        }

    };

    // 上传三个图片的方法
    // MerchantLogoList imageType 3000 TableType 1204
    // DoorImageList  imageType 1000  TableType 1204
    // InteriorImage  imageType 2000  TableType 1204
    const handleUploadAllImage = async (formValue: any, result: any) => {
        // formValue  表单的数据  result 商家的数据
        // 上传商家logo
        if (formValue.MerchantLogo && formValue.MerchantLogo.length > 0) {
            const formData = new FormData();
            formValue.MerchantLogo.forEach((file: any) => {
                formData.append('files[]', file.originFileObj);
                formData.append('ImageName', typeof file !== 'string' ? file?.name : '');
            });
            formData.append('TableId', result?.Result_Data.SELLER_ID);
            formData.append('imageType', "1000");
            formData.append('TableType', "1204");

            let res = await uploadPicture(formData)
        }

        if (formValue.DoorImage && formValue.DoorImage.length > 0) {
            const formData = new FormData();
            formValue.DoorImage.forEach((file: any) => {
                formData.append('files[]', file.originFileObj);
                formData.append('ImageName', typeof file !== 'string' ? file?.name : '');
            });
            formData.append('TableId', result?.Result_Data.SELLER_ID);
            formData.append('imageType', "2000");
            formData.append('TableType', "1204");

            let res = await uploadPicture(formData)
        }

        if (formValue.InteriorImage && formValue.InteriorImage.length > 0) {
            const formData = new FormData();
            formValue.InteriorImage.forEach((file: any) => {
                formData.append('files[]', file.originFileObj);
                formData.append('ImageName', typeof file !== 'string' ? file?.name : '');
            });
            formData.append('TableId', result?.Result_Data.SELLER_ID);
            formData.append('imageType', "3000");
            formData.append('TableType', "1204");

            let res = await uploadPicture(formData)
        }
    }

    // 移除门店关联
    const handleRemoveSeller = async (obj: any) => {
        const req: any = {
            SellerId: obj.SELLER_ID,
            ShopIds: obj?.SERVERPARTSHOP_ID
        }
        const result = await handleRemoveShopFromSeller(req)
        if (result.Result_Code !== 100) {
            message.error(`${result.Result_Desc}` || `${result.Result_Code}:删除失败`);
        } else {
            message.success('删除成功！');
            // formRef.current?.resetFields()
            await handleGetMemberDetail()
        }
    }

    // 服务区商家的详情信息
    const handleGetMemberDetail = async () => {
        if (currentRow?.SELLER_ID) {
            const data = await handleGetSERVERPARTSELLERDetail({ SERVERPARTSELLERId: currentRow?.SELLER_ID })

            setCurrentShopData(data.ShopList)
            setCurrentRowDetail(data)
            formRef.current?.setFieldsValue(data)
            return {
                ...data,
                SHOPTRADE: currentRow?.SHOPTRADE ? Number(currentRow?.SHOPTRADE) : ""
            }
        } else {
            return {
                ISSHOW: 1
            }
        }
    }

    // 预览上传后的图片
    const handlePreview = async (value: number) => {
        setFileList(value === 1 ? MerchantLogoList : value === 2 ? DoorImageList : value === 3 ? InteriorImage : '')
        setImagePreviewVisible(true)
    };
    const handleChangePreview = (val: any) => {
        setImagePreviewVisible(val)
    }

    const handleChangePreview2 = (val: any) => {
        setImageCommentPreviewVisible(val)
    }

    // 获取营收数据
    const handleGetRevenueData = async () => {
        const req: any = {
            DataType: 1,
            DataSourceType: 1,
            ServerpartIds: currentRow?.SERVERPART_ID || "",
            ServerpartShopIds: currentRow?.SERVERPARTSHOP_IDS || "",
            StartDate: moment().subtract(1, 'M').startOf('M').format('YYYY-MM-DD'),
            EndDate: moment().subtract(1, 'M').endOf('M').format('YYYY-MM-DD'),
        }
        setRevenueLoading(true)
        console.log('req', req);

        const data = await handeGetRevenueReport(req)
        setRevenueLoading(false)
        console.log('datadata', data);
        if (data && data.length > 0) {
            message.success('获取成功！')
            let obj: any = data[0]
            formRef.current?.setFieldsValue({
                MONTHLYSALES: obj.TotalRevenue.Ticket_Count || "0",
                CASHPAY: obj.TotalRevenue.Revenue_Amount || "0",
                PERCAPITA: obj.TotalRevenue.Ticket_Count ? (obj.TotalRevenue.Revenue_Amount / obj.TotalRevenue.Ticket_Count).toFixed(2) : "0",
            })

        }
    }


    const processTreeData = (data: any) => {
        return data.map((item: any) => {
            if (item.children && item.children.length > 0) {
                return {
                    ...item,
                    disabled: true,  // 有子节点的节点禁用
                    children: processTreeData(item.children)
                };
            }
            return item;
        });
    };


    // 新增的确认按钮的方法
    const handleModalOk = async () => {
        // 判断是新增 还是关联 看看有没有 SELLER_ID 有就是关联 没有就是新增
        if (currentRow?.SELLER_ID) {
            if (!(selectedRowKeys && selectedRowKeys.length > 0)) {
                message.error('请选择要关联的门店！')
                return
            }
            // 关联 接口
            const req: any = {
                SellerId: currentRow?.SELLER_ID,
                ShopIds: selectedRowKeys.toString()
            }
            const data = await handleGetRelateShopToSeller(req)
            if (data.Result_Code === 100) {
                message.success(data.Result_Desc)
                setShowAddModal(false)
                setSelectRowKeys(null)
                setSelectRowDetail(null)
                // formRef.current?.resetFields()
                handleGetMemberDetail()
                setSelectAssociationServerpart(null)
            } else {
                message.error(data.Result_Desc)
            }
        } else {
            if (!(selectedRowKeys && selectedRowKeys.length > 0)) {
                setShowAddModal(false)
                setSelectRowKeys(null)
                setSelectRowDetail(null)
                setSelectAssociationServerpart(null)
            } else {
                console.log('selectedRowDetailselectedRowDetailselectedRowDetailselectedRowDetail', selectedRowDetail);
                // 必须要是同一商户的 才能进去
                let sellIdList: any = []
                let SHOPTRADEList: any = []
                let serverpartList: any = []
                let SERVERPARTSHOP_IDS: string = ''
                selectedRowDetail.forEach((item: any) => {
                    if (sellIdList.indexOf(item.SELLER_ID) === -1) {
                        sellIdList.push(item.SELLER_ID)
                    }
                    if (SHOPTRADEList.indexOf(item.SHOPTRADE) === -1) {
                        SHOPTRADEList.push(item.SHOPTRADE)
                    }
                    if (serverpartList.indexOf(item.SERVERPART_ID) === -1) {
                        serverpartList.push(item.SERVERPART_ID)
                    }
                    if (item.SERVERPARTSHOP_ID) {
                        if (SERVERPARTSHOP_IDS) {
                            SERVERPARTSHOP_IDS += `,${item.SERVERPARTSHOP_ID}`
                        } else {
                            SERVERPARTSHOP_IDS = `${item.SERVERPARTSHOP_ID}`
                        }
                    }
                })

                console.log('sellIdListsellIdListsellIdList', sellIdList);
                console.log('SHOPTRADEListSHOPTRADEListSHOPTRADEList', SHOPTRADEList);
                if (sellIdList && sellIdList.length > 1) {
                    message.error("仅支持选择一个商家！")
                    return
                }

                if (SHOPTRADEList && SHOPTRADEList.length > 1) {
                    message.error("仅支持选择一种业态！")
                    return
                }

                if (serverpartList && serverpartList.length > 1) {
                    message.error("仅支持选择一个服务区！")
                    return
                }
                let obj: any = selectedRowDetail[0]

                // 调用商家详情
                const req: any = {
                    SERVERPARTSELLERId: sellIdList[0]
                }
                const detail: any = await handleGetSERVERPARTSELLERDetail(req)
                setShowAddModal(false)
                setSelectRowKeys(null)
                setSelectRowDetail(null)
                setSelectAssociationServerpart(null)
                setCurrentShopData(selectedRowDetail)

                setCurrentRow({
                    ...detail,
                    SHOPTRADE: obj.SHOPTRADE,
                    SERVERPART_ID: Number(obj.SERVERPART_ID),
                    SERVERPARTSHOP_IDS: SERVERPARTSHOP_IDS,
                    SERVERPART_NAME: obj.SERVERPART_NAME
                })
                handleModalVisible(true)

            }
        }
    }


    return (
        <div>
            <div style={{ backgroundColor: '#fff', display: 'flex' }}>
                <LeftSelectTree setSelectedId={setSelectedId} setCollapsible={setCollapsible} collapsible={collapsible} />
                <div style={{
                    width: !collapsible ? 'calc(100% - 300px)' : 'calc(100% - 60px)',
                    paddingTop: 0,
                    paddingBottom: 0,
                    paddingRight: 0
                }}>
                    <ProTable
                        style={{ height: 'calc(100vh - 135px)', background: '#fff' }}
                        scroll={{ y: 'calc(100vh - 410px)' }}
                        rowKey={(record) => {
                            return `${record?.SERVERPARTSELLER_ID}`
                        }}
                        bordered
                        // formRef={formRef}
                        headerTitle={<PageTitleBox props={props} />} // 列表表头
                        actionRef={actionRef}
                        search={{ span: 6, labelWidth: 'auto' }}
                        // 请求数据
                        request={async (params, sorter) => {
                            if (!selectedId) {
                                return
                            }
                            const req = {
                                searchParameter: {
                                    SERVERPART_IDS: selectedId,
                                    SHOPTRADES: params?.SHOPTRADES,
                                    ISVALID: 1,
                                    ISSHOW: params?.ISSHOW === "-1" ? "" : params?.ISSHOW
                                },
                                PageIndex: params.current,
                                PageSize: params.pageSize,
                            }
                            console.log('reqreqreqreq', req);
                            const data = await handleGetMEMBERADDRESSList(req);
                            console.log('datadatadatadatadata', data);
                            if (data.List && data.List.length > 0) {
                                return { data: data.List, success: true, total: data.TotalCount }
                            }
                            return { data: [], success: true }
                        }}
                        columns={columns}
                        toolbar={{
                            actions: [
                                // 新增按钮
                                <Button
                                    key="new"
                                    icon={<PlusOutlined />}
                                    type="primary"
                                    onClick={() => {
                                        setShowAddModal(true)
                                        // handleModalVisible(true);
                                    }}
                                >
                                    服务区商家信息
                                </Button>,
                            ],
                        }}
                        pagination={{ defaultPageSize: 20 }}
                    />
                </div>
            </div>

            {/* 图片预览组件 */}
            {fileList && fileList.length > 0 && <div style={{ display: 'none' }}>
                <Image.PreviewGroup
                    preview={{
                        visible: imagePreviewVisible,
                        onVisibleChange: vis => {
                            handleChangePreview(vis)
                        }
                    }}>
                    {
                        fileList.map((n) => <Image src={n.url} key={n.url} />)
                    }
                </Image.PreviewGroup>
            </div>}

            {/* 图片预览组件 */}
            {commentFileList && commentFileList.length > 0 && <div style={{ display: 'none' }}>
                <Image.PreviewGroup
                    preview={{
                        visible: imageCommentPreviewVisible,
                        onVisibleChange: vis => {
                            handleChangePreview2(vis)
                        }
                    }}>
                    {
                        commentFileList.map((n) => <Image src={n.url} key={n.url} />)
                    }
                </Image.PreviewGroup>
            </div>}


            {/* 添加服务区商家信息表 */}
            <Modal
                title={'新建服务区商家信息'}
                destroyOnClose
                width={1200}
                visible={showAddModal}
                afterClose={() => {
                }}
                bodyStyle={{
                    height: '700px', // 你可以根据需要调整高度
                    overflowY: 'auto',
                }}
                onCancel={() => {
                    setShowAddModal(false)
                    setSelectRowKeys(null)
                    setSelectRowDetail(null)
                    setSelectAssociationServerpart(null)
                }}
                okText={currentRow?.SELLER_ID ? "关联" : "确认"}
                onOk={async () => { // 提交框内的数据
                    handleModalOk()
                }}
                // footer={<ModalFooter
                //     hideDelete={!currentRow?.SELLER_ID}
                //     handleDelete={async () => {
                //         await handelDelete(currentRow?.SELLER_ID)
                //     }}
                //     handleCancel={() => {
                //         setShowAddModal(false)
                //         setSelectRowKeys(null)
                //         setSelectRowDetail(null)
                //         setSelectAssociationServerpart(null)
                //     }}
                //     handleOK={() => {
                //         handleModalOk()
                //     }} />}
            >
                <div style={{ display: 'flex', alignItems: 'flex-start' }}>
                    <LeftSelectTree setSelectedId={setSelectAssociationServerpart} />
                    <div style={{ width: 'calc(100% - 300px)' }}>
                        <ProTable
                            actionRef={associationActionRef}
                            columns={merchantColumns}
                            scroll={{ x: '100%', y: '400px' }}
                            bordered
                            rowKey={"SERVERPARTSHOP_ID"}
                            request={async (params) => {
                                if (!selectAssociationServerpart) {
                                    return
                                }
                                const req: any = {
                                    SearchParameter: {
                                        SERVERPART_IDS: selectAssociationServerpart,
                                        ISVALID: 1
                                    },
                                    PageIndex: 1,
                                    PageSize: 999999,
                                    SortStr: "SHOPTRADE,SHOPSHORTNAME,SHOPREGION,SERVERPART_CODE",
                                }
                                const data = await handleGetServerpartShopList(req)
                                console.log('datadatadatadatadata', data);
                                if (data && data.length > 0) {
                                    let list: any = []
                                    data.forEach((item: any) => {
                                        if (item.SELLER_ID && item.SHOPTRADE) {
                                            list.push(item)
                                        }
                                    })
                                    return { data: list, success: true }
                                }
                                return { data: [], success: true }

                                // if (!selectAssociationServerpart) {
                                //     return
                                // }
                                // const req: any = {
                                //     searchParameter: {
                                //         SERVERPART_IDS: selectAssociationServerpart,
                                //         ISVALID: params?.ISVALID,
                                //         BUSINESS_STATE: params?.BUSINESS_STATE
                                //     },
                                //     PageIndex: 1,
                                //     PageSize: 999999,
                                //     SortStr: "SHOPTRADE,SHOPREGION,SHOPSHORTNAME,SHOPCODE"
                                // }
                                // const data = await handleGetSERVERPARTSHOPList(req)
                                // if (data.List && data.List.length > 0) {
                                //     let list: any = []
                                //     data.List.forEach((item: any) => {
                                //         if (!item.SELLER_ID) {
                                //             list.push(item)
                                //         }
                                //     })
                                //     return { data: list, success: true }
                                // }
                                // return { data: [], success: true }
                            }}
                            pagination={false}
                            rowSelection={{
                                type: 'checkbox',
                                onChange: (rowKeys, rowDetail) => {
                                    setSelectRowKeys(rowKeys)
                                    setSelectRowDetail(rowDetail)
                                },
                            }}
                        />
                    </div>
                </div>


            </Modal>

            <Modal
                className="MerchantInformationModal"
                title={
                    <div
                        style={{
                            width: '100%',
                            cursor: 'move',
                        }}
                        onMouseOver={() => {
                            if (disabled) {
                                setDraggleDisabled(false)
                            }
                        }}
                        onMouseOut={() => {
                            setDraggleDisabled(true)
                        }}

                        onFocus={() => { }}
                        onBlur={() => { }}
                    >
                        {currentRow ? '更新服务区商家信息' : '新建服务区商家信息'}
                    </div>
                }
                destroyOnClose={true}
                bodyStyle={{
                    height: '700px', // 你可以根据需要调整高度
                    overflowY: 'auto',
                }}
                width={1200}
                visible={modalVisible}
                confirmLoading={confirmLoading}
                afterClose={() => {
                    formRef.current?.resetFields();
                    setCurrentRow(undefined);
                }}
                onCancel={() => {
                    handleConfirmLoading(false)
                    handleModalVisible(false)
                    setCurrentRowDetail(null)
                    setCurrentRow(null)
                    setMerchantLogoList([])
                    setDoorImageList([])
                    setInteriorImageList([])
                    setCurrentShopData([])
                }}
                // onOk={async () => { // 提交框内的数据
                //     formRef?.current?.validateFields().then(() => {
                //         handleConfirmLoading(true)
                //         formRef?.current?.submit()
                //     })
                // }}
                modalRender={(modal) => {
                    return <Draggable
                        disabled={disabled}
                        bounds={bounds}
                        onStart={(event, uiData) => onDraggaleStart(event, uiData)}
                        handle=".MerchantInformationModal"
                    >
                        <div ref={draggleRef}>{modal}</div>
                    </Draggable>
                }}
                footer={<div style={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}>
                    {
                        // currentRow?.SELLER_ID ?
                        currentRow?.SERVERPART_ID ?
                            <div>
                                {/* <Button type={"primary"} onClick={() => {
                                    setShowAddModal(true)
                                }}>关联门店</Button> */}
                                <Button type={"primary"} loading={revenueLoading} onClick={() => {
                                    handleGetRevenueData()
                                }}>获取营收</Button>
                            </div>
                            : <div></div>
                    }

                    <div>
                        <Button onClick={() => {
                            handleConfirmLoading(false)
                            handleModalVisible(false)
                            setCurrentRowDetail(null)
                            setCurrentRow(null)
                        }}>取消</Button>
                        <Button type={"primary"} loading={confirmLoading} onClick={() => {
                            formRef?.current?.validateFields().then(() => {
                                handleConfirmLoading(true)
                                formRef?.current?.submit()
                            })
                        }}>保存</Button>
                    </div>
                </div>}

            >
                <ProForm
                    layout={'horizontal'}
                    formRef={formRef}
                    autoFocusFirstInput
                    submitter={false}
                    preserve={false}
                    labelCol={{ style: { width: 100 } }}
                    request={async () => {
                        const data = await handleGetMemberDetail()
                        let list1: any = []
                        let list2: any = []
                        let list3: any = []
                        console.log('currentRowcurrentRowcurrentRowcurrentRow', currentRow);


                        if (currentRow?.IconList && currentRow?.IconList.length > 0) {
                            currentRow?.IconList.forEach((item: any) => {
                                let obj = JSON.parse(JSON.stringify(item))
                                obj.url = obj.ImageUrl
                                obj.name = obj.ImageName
                                obj.uid = item.ImageId
                                obj.status = 'done'
                                list1.push(obj)
                            })
                        }
                        setMerchantLogoList(list1);

                        if (currentRow?.DoorImgList && currentRow?.DoorImgList.length > 0) {
                            currentRow?.DoorImgList.forEach((item: any) => {
                                let obj = JSON.parse(JSON.stringify(item))
                                obj.url = obj.ImageUrl
                                obj.name = obj.ImageName
                                obj.uid = item.ImageId
                                obj.status = 'done'
                                list2.push(obj)
                            })
                        }
                        setDoorImageList(list2);

                        if (currentRow?.InsideImgList && currentRow?.InsideImgList.length > 0) {
                            currentRow?.InsideImgList.forEach((item: any) => {
                                let obj = JSON.parse(JSON.stringify(item))
                                obj.url = obj.ImageUrl
                                obj.name = obj.ImageName
                                obj.uid = item.ImageId
                                obj.status = 'done'
                                list3.push(obj)
                            })
                        }
                        setInteriorImageList(list3);


                        // if (currentRow?.SELLER_ID) {
                        //     let req: any = {
                        //         TableId: currentRow?.SELLER_ID,
                        //         // TableName:  '',
                        //         TableType: "1204",
                        //         ImageType: "1000",
                        //     }
                        //     const MerchantLogoData = await handeGetPictureList(req)

                        //     if (MerchantLogoData.List && MerchantLogoData.List.length > 0) {
                        //         if (MerchantLogoData.List && MerchantLogoData.List.length > 0) {
                        //             MerchantLogoData.List.forEach((item: any) => {
                        //                 let obj = JSON.parse(JSON.stringify(item))
                        //                 obj.url = obj.ImageUrl
                        //                 obj.name = obj.ImageName
                        //                 obj.uid = item.ImageId
                        //                 obj.status = 'done'
                        //                 list1.push(obj)
                        //             })
                        //         }

                        //         setMerchantLogoList(list1);
                        //     }

                        //     let req2: any = {
                        //         TableId: currentRow?.SELLER_ID,
                        //         // TableName:  '',
                        //         TableType: "1204",
                        //         ImageType: "2000",
                        //     }
                        //     const DoorImageData = await handeGetPictureList(req2)
                        //     if (DoorImageData.List && DoorImageData.List.length > 0) {
                        //         if (DoorImageData.List && DoorImageData.List.length > 0) {
                        //             DoorImageData.List.forEach((item: any) => {
                        //                 let obj = JSON.parse(JSON.stringify(item))
                        //                 obj.url = obj.ImageUrl
                        //                 obj.name = obj.ImageName
                        //                 obj.uid = item.ImageId
                        //                 obj.status = 'done'
                        //                 list2.push(obj)
                        //             })
                        //         }

                        //         setDoorImageList(list2);
                        //     }
                        //     let req3: any = {
                        //         TableId: currentRow?.SELLER_ID,
                        //         // TableName:  '',
                        //         TableType: "1204",
                        //         ImageType: "3000",
                        //     }
                        //     const InteriorImageData = await handeGetPictureList(req3)
                        //     if (InteriorImageData.List && InteriorImageData.List.length > 0) {
                        //         if (InteriorImageData.List && InteriorImageData.List.length > 0) {
                        //             InteriorImageData.List.forEach((item: any) => {
                        //                 let obj = JSON.parse(JSON.stringify(item))
                        //                 obj.url = obj.ImageUrl
                        //                 obj.name = obj.ImageName
                        //                 obj.uid = item.ImageId
                        //                 obj.status = 'done'
                        //                 list3.push(obj)
                        //             })
                        //         }

                        //         setInteriorImageList(list3);
                        //     }
                        // }

                        return {
                            ...data,
                            SHOPTRADE: currentRow?.SHOPTRADE ? Number(currentRow?.SHOPTRADE) : "",
                            SERVERPART_ID: currentRow?.SERVERPART_ID ? Number(currentRow?.SERVERPART_ID) : "",
                            // MerchantLogo: list1,
                            // DoorImage: list2,
                            // InteriorImage: list3,
                        }
                        // if (currentRow?.SELLER_ID) {
                        //     const data = await handleGetSERVERPARTSELLERDetail({ SERVERPARTSELLERId: currentRow?.SELLER_ID })

                        //     setCurrentShopData(data.ShopList)
                        //     setCurrentRowDetail(data)
                        //     return {
                        //         ...data,
                        //         SHOPTRADE: currentRow?.SHOPTRADE ? Number(currentRow?.SHOPTRADE) : ""
                        //     }
                        // } else {
                        //     return {
                        //         ISSHOW: 1
                        //     }
                        // }
                    }}
                    // initialValues={{
                    //     ...currentRow,
                    //     SHOPTRADE: currentRow?.SHOPTRADE ? Number(currentRow?.SHOPTRADE) : ""
                    // }}
                    onFinish={async (values) => {
                        let newValue: any = { ...values };
                        if (currentRow) {
                            // 编辑数据
                            newValue = {
                                ...values,
                                SERVERPARTSELLER_ID: currentRow.SERVERPARTSELLER_ID,
                                ShopList: currentShopData
                            };
                        }
                        await handleAddUpdate(newValue);
                    }}
                >
                    <Row gutter={8}>
                        <Col span={8}>
                            <ProFormText
                                name="SELLER_NAME"
                                label="商家名称"
                                rules={[
                                    {
                                        required: true,
                                        message: '请输入商家名称！'
                                    }
                                ]}
                                disabled={currentRow?.SELLER_NAME}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormTreeSelect
                                name="SHOPTRADE"
                                label="门店业态"
                                request={() => {
                                    return processTreeData(BUSINESSTRADEYNTree)
                                }}
                                fieldProps={{
                                    treeDefaultExpandAll: true,  // 默认展开所有节点
                                    showSearch: true,            // 可选：添加搜索功能
                                    treeNodeFilterProp: 'label', // 可选：按标签搜索
                                }}
                                rules={[
                                    {
                                        required: true,
                                        message: '请选择门店业态！'
                                    }
                                ]}
                                disabled={currentRow?.SHOPTRADE}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="SELLER_INDEX"
                                label="排序索引"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="BUS_STARTDATE"
                                label="营业时间"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormSelect
                                name="SERVERPART_ID"
                                label="服务区名"
                                options={serverpartList}
                                rules={[
                                    {
                                        required: true,
                                        message: '请选择服务区！'
                                    }
                                ]}
                                fieldProps={{
                                    showSearch: true,
                                    filterOption: (input, option) =>
                                        (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
                                }}
                                disabled={currentRow?.SERVERPART_ID}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormSelect
                                name="ISSHOW"
                                label="小程序呈现"
                                options={[
                                    { label: "是", value: 1 },
                                    { label: "否", value: 0 },
                                ]}
                                rules={[
                                    {
                                        required: true,
                                        message: '请选择是否在小程序呈现'
                                    }
                                ]}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="MONTHLYSALES"
                                label="上月销量"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="CASHPAY"
                                label="月销售额"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="PERCAPITA"
                                label="人均价格"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="SELLER_LINKMAN"
                                label="联系人员"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="SELLER_TELEPHONE"
                                label="商家电话"
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                name="SELLER_ADDRESS"
                                label="商家地址"
                            />
                        </Col>
                        <Col span={24}>
                            <ProFormText
                                name="SELF_COMMENT"
                                label="掌柜寄语"
                            />
                        </Col>
                        <Col span={24}>
                            <ProFormTextArea
                                name="SELLER_DESC"
                                label="商家介绍"
                            />
                        </Col>


                    </Row>



                    <Tabs
                        onChange={(e: any) => {
                            setSelectTab(e)
                        }}
                        activeKey={selectTab}
                        type="card"
                        items={[
                            { label: "门店信息", key: "1" },
                            { label: "评论信息", key: "2" },
                        ]}
                    />

                    <ProTable
                        search={false}
                        options={false}
                        columns={shopColumns}
                        bordered
                        style={{ display: selectTab === '1' ? 'block' : 'none' }}
                        dataSource={currentShopData}
                    />

                    <div style={{ display: selectTab === '1' ? 'block' : 'none' }}>
                        <Row gutter={8}>
                            <Col span={8}>
                                <ProFormUploadButton
                                    label={"商家Logo"}
                                    name={"MerchantLogo"}
                                    listType="picture-card"
                                    accept="image/*"
                                    fieldProps={{
                                        beforeUpload,
                                        onPreview: () => handlePreview(1),
                                        fileList: MerchantLogoList, // 绑定 fileList
                                        onChange: async (info: any) => {
                                            if (info.file.status === 'removed') {
                                                const index = MerchantLogoList.findIndex(n => n.uid === info.file.uid);
                                                confirm({
                                                    title: '确认删除该文件吗？',
                                                    icon: <ExclamationCircleOutlined />,
                                                    async onOk() {
                                                        if (info.file.ImageId) {
                                                            const deleteLoading = message.loading('正在删除...')
                                                            const success = await deletePicture(info.file?.ImagePath, info.file?.uid, '', '6000')
                                                            deleteLoading()

                                                            if (success) {
                                                                const files = [...MerchantLogoList]
                                                                files.splice(index, 1)
                                                                setMerchantLogoList(files)
                                                                message.success("删除成功")
                                                            }
                                                            else {
                                                                message.error("删除失败")
                                                            }
                                                        } else {
                                                            const files = [...fileList];
                                                            files.splice(index, 1);
                                                            setMerchantLogoList(files);
                                                        }
                                                    },
                                                    onCancel() {
                                                    },
                                                });
                                            } else {
                                                setMerchantLogoList(info.fileList)
                                            }
                                        }
                                    }}
                                />
                            </Col>

                            <Col span={8}>
                                <ProFormUploadButton
                                    label={"门头图片"}
                                    name={"DoorImage"}
                                    listType="picture-card"
                                    accept="image/*"
                                    fieldProps={{
                                        beforeUpload,
                                        onPreview: () => handlePreview(2),
                                        fileList: DoorImageList, // 绑定 fileList
                                        onChange: async (info: any) => {
                                            if (info.file.status === 'removed') {
                                                const index = DoorImageList.findIndex(n => n.uid === info.file.uid);
                                                confirm({
                                                    title: '确认删除该文件吗？',
                                                    icon: <ExclamationCircleOutlined />,
                                                    async onOk() {
                                                        if (info.file.ImageId) {
                                                            const deleteLoading = message.loading('正在删除...')
                                                            const success = await deletePicture(info.file?.ImagePath, info.file?.uid, '', '6000')
                                                            deleteLoading()

                                                            if (success) {
                                                                const files = [...DoorImageList]
                                                                files.splice(index, 1)
                                                                setDoorImageList(files)
                                                                message.success("删除成功")
                                                            }
                                                            else {
                                                                message.error("删除失败")
                                                            }
                                                        } else {
                                                            const files = [...fileList];
                                                            files.splice(index, 1);
                                                            setDoorImageList(files);
                                                        }
                                                    },
                                                    onCancel() {
                                                    },
                                                });
                                            } else {
                                                setDoorImageList(info.fileList)
                                            }
                                        }
                                    }}
                                />
                            </Col>

                            <Col span={8}>
                                <ProFormUploadButton
                                    label={"内景图片"}
                                    name={"InteriorImage"}
                                    listType="picture-card"
                                    accept="image/*"
                                    fieldProps={{
                                        beforeUpload,
                                        onPreview: () => handlePreview(3),
                                        fileList: InteriorImage, // 绑定 fileList
                                        onChange: async (info: any) => {
                                            if (info.file.status === 'removed') {
                                                const index = InteriorImage.findIndex(n => n.uid === info.file.uid);
                                                confirm({
                                                    title: '确认删除该文件吗？',
                                                    icon: <ExclamationCircleOutlined />,
                                                    async onOk() {
                                                        if (info.file.ImageId) {
                                                            const deleteLoading = message.loading('正在删除...')
                                                            const success = await deletePicture(info.file?.ImagePath, info.file?.uid, '', '6000')
                                                            deleteLoading()

                                                            if (success) {
                                                                const files = [...InteriorImage]
                                                                files.splice(index, 1)
                                                                setInteriorImageList(files)
                                                                message.success("删除成功")
                                                            }
                                                            else {
                                                                message.error("删除失败")
                                                            }
                                                        } else {
                                                            const files = [...fileList];
                                                            files.splice(index, 1);
                                                            setInteriorImageList(files);
                                                        }
                                                    },
                                                    onCancel() {
                                                    },
                                                });
                                            } else {
                                                setInteriorImageList(info.fileList)
                                            }
                                        }
                                    }}
                                />
                            </Col>
                        </Row>
                    </div>



                    <ProTable
                        search={false}
                        options={false}
                        bordered
                        columns={commentColumns}
                        style={{ display: selectTab === '2' ? 'block' : 'none' }}
                        request={async () => {
                            if (!currentRow?.SELLER_ID) {
                                return { data: [], success: true }
                            }
                            const req: any = {
                                searchParameter: {
                                    MERCHANTS_ID: currentRow?.SELLER_ID
                                },
                                PageIndex: 1,
                                PageSize: 999999,
                            }
                            const data = await handeGetCOMMENTList(req)
                            console.log('评论数据', data);
                            if (data.List && data.List.length > 0) {
                                return { data: data.List, success: true, total: data.TotalCount }
                            }
                            return { data: [], success: true }
                        }}
                    />
                </ProForm>
            </Modal>
        </div>
    );
};
export default connect(({ user }: ConnectState) => ({
    currentUser: user.currentUser
}))(MerchantInformation);
