/*
 * @Author: cclu 1106109051@qq.com
 * @Date: 2024-07-05 16:06:11
 * @LastEditors: cclu 1106109051@qq.com
 * @LastEditTime: 2024-09-05 18:21:41
 * @FilePath: \cloud-platform\src\pages\basicManage\serviceArea\component\detail.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 ProForm, { ProFormDatePicker, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form";
import { useEffect, useImperativeHandle, useRef, useState } from "react";
import { Button, Col, Divider, Drawer, FormInstance, message, Modal, Radio, Row } from "antd";
import './detail.less'
import { getFieldEnumTree, getServerpartTree } from "@/services/options";
import session from "@/utils/session";
import { handleGetServerPartShopNewDetail, handleModifyShopState, handleServerPartShopNewSaveState } from "../service";
import ProTable, { ActionType } from "@ant-design/pro-table";
import moment from 'moment'
import MerchatsTable from "../../Merchats";
import SelectPerson from "./selectPerson";

type DetailProps = {
    currentUser?: any;
    currentRow: any;
    type?: string;
    showDrawer?: boolean;
    closeDrawer?: any;
    onRef?: any;
}
const Detail = ({ currentUser, currentRow, type, showDrawer, closeDrawer, onRef }: DetailProps) => {
    const actionRef = useRef<ActionType>();
    const tableFormRef = useRef<FormInstance>();
    const formRef = useRef<FormInstance>();
    const modalRef = useRef<FormInstance>();
    const formSecondRef = useRef<FormInstance>();
    const MerchatsTableRef = useRef<any>()
    const SelectPersonRef = useRef<any>()


    // 单选框的选择值
    const [radioValue, setRadioValue] = useState<number>(2)
    // 表格的值
    const [tableData, setTableData] = useState<any>()
    // 查到的详情值
    const [detailData, setDetailData] = useState<any>()
    // 点击设置状态 出现的悬浮框
    const [showConfigStateModal, setShowConfigStateModal] = useState<boolean>(false)
    // 判断点击的设置状态是哪个
    const [configType, setConfigType] = useState<any>()
    // 点击设置状态选中的门店id
    const [selectShopId, setSelectShopId] = useState<any>()
    // 显示选择经营单位的抽屉
    const [showBUSINESSUNIT, setShowBUSINESSUNIT] = useState<boolean>(false)
    // 经营商户选中之后出现选人的modal
    const [selectPersonModal, setSelectPersonModal] = useState<boolean>(false)
    // 选中的商户详情
    const [selectRowDetail, setSelectRowDetail] = useState<any>()
    // 当前经营状态
    const [currentBusinessState, setCurrentBusinessState] = useState<any>()

    const columns: any = [
        {
            title: '序号',
            dataIndex: "index",
            valueType: 'index',
            hideInSearch: true
        },
        {
            title: '门店名称',
            dataIndex: 'ShopName',
            hideInSearch: true
        },
        {
            title: '开业时间',
            dataIndex: 'BusinessDate',
            hideInSearch: true,
            render: (_, record) => {
                return record?.BusinessDate || ''
            }
        },
        {
            title: '停业时间',
            dataIndex: 'BusinessEndDate',
            hideInSearch: true,
            render: (_, record) => {
                return record?.BusinessEndDate || ''
            }
        },
        {
            title: '操作人员',
            dataIndex: 'StaffName',
            hideInSearch: true
        },
        {
            title: '操作时间',
            dataIndex: 'OperateDate',
            hideInSearch: true,
            render: (_, record) => {
                return record?.OperateDate ? moment(record?.OperateDate).format('YYYY-MM-DD') : ''
            }
        },
    ]

    // 拿到详情数据
    const handleGetDetail = async () => {
        const req: any = {
            serverPartShopId: currentRow?.SERVERPARTSHOP_ID
        }
        const data = await handleGetServerPartShopNewDetail(req)
        console.log('data', data);
        setDetailData(data)
        // 底部表格的值
        if (data.RtServerPartShopList && data.RtServerPartShopList.length > 0) {
            setTableData(data.RtServerPartShopList)
        }
        // 设置是选择了四种里面的哪个
        let obj: any = data.ServerPartShop
        // 顶部表单的数据
        formRef.current?.setFieldsValue(obj)

        setRadioValue(obj?.BUSINESS_REGION === 1000 ? 2 : obj?.BUSINESS_REGION === 1010 ? 1 : obj?.BUSINESS_REGION === 2000 ? 4 : obj?.BUSINESS_REGION === 2010 ? 3 : 0)

        // 中间表单的赋值
        if (data.ShopBusinessStateList && data.ShopBusinessStateList.length > 0) {
            if (data.ShopBusinessStateList.length === 1) {
                formSecondRef.current?.setFieldsValue(data.ShopBusinessStateList[0])
            } else {
                let first = data.ShopBusinessStateList[0]
                let obj = data.ShopBusinessStateList[1]
                let second = {
                    ShopRegionSecond: obj.ShopRegion,
                    SHOPNAMESecond: obj.ShopName,
                    BUSINESS_TYPESecond: obj.BusinessType,
                    BUSINESS_STATESecond: obj.BusinessState,
                    BusinessDateSecond: obj.BusinessDate,
                    BusinessEndDateSecond: obj.BusinessEndDate,
                    ServerPartShopIdSecond: obj.ServerPartShopId
                }
                formSecondRef.current?.setFieldsValue({
                    ...first,
                    ...second
                })
            }
        }
    }

    useEffect(async () => {
        if (showDrawer) {
            if (type === 'edit') {
                handleGetDetail()
            }
        }
    }, [showDrawer])

    useImperativeHandle(onRef, () => ({
        formRef,
        formSecondRef,
        tableData,
        detailData,
        radioValue,
        setSelectRowDetail
    }));



    return (
        <div className="detailBox">
            <ProForm
                layout={'horizontal'}
                formRef={formRef}
                submitter={{
                    render: (props, doms) => {
                        return []
                    }
                }}
            >
                <Divider orientation="left">门店信息设定</Divider>
                <Row gutter={16}>
                    <Col span={16}>
                        <ProFormText
                            label={"经营单位"}
                            name={"BUSINESS_UNIT"}
                            disabled={true}
                            fieldProps={{
                                addonAfter: (<div onClick={() => {
                                    if (type === 'edit') {

                                    } else {
                                        setShowBUSINESSUNIT(true)
                                    }
                                }} style={{
                                    width: '10px', height: '30px', borderRadius: '8px', background: '#f9f9f9',
                                    display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer'
                                }} >+</div>)
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormSelect
                            label={"服务区名"}
                            name={"SERVERPART_ID"}
                            disabled={type === 'edit'}
                            request={async () => {
                                const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true)
                                console.log('data', data);
                                let list: any = []
                                if (data && data.length > 0) {
                                    data.forEach((item: any) => {
                                        if (item.children && item.children.length > 0) {
                                            item.children.forEach((subItem: any) => {
                                                list.push(subItem)
                                            })
                                        }
                                        if (item.value === 424 || item.value === 586) {
                                            list.push(item)
                                        }
                                    })
                                }
                                return list
                            }}
                            fieldProps={{
                                showSearch: true,
                                filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
                            }}
                        />
                    </Col>

                    <Col span={8}>
                        <ProFormText
                            label={"统一信用代码"}
                            name={"TAXPAYER_IDENTIFYCODE"}
                            disabled={type === 'edit'}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"开户支行"}
                            name={"BANK_NAME"}
                            disabled={type === 'edit'}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"返款账户"}
                            name={"BANK_ACCOUNT"}
                            disabled={type === 'edit'}
                        />
                    </Col>

                    <Col span={8}>
                        <ProFormText
                            label={"负责人员"}
                            name={"TOPPERSON"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"联系电话"}
                            name={"LINKMAN_MOBILE"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"显示索引"}
                            name={"SERVERPARTSHOP_INDEX"}
                        />
                    </Col>
                </Row>
                <Divider></Divider>
                <Row gutter={16}>
                    <Col span={16}>
                        <ProFormText
                            label={"合同名称"}
                            name={"REGISTERCOMPACT_NAME"}
                            // fieldProps={{
                            //     addonAfter: (<div style={{
                            //         width: '10px', height: '30px', borderRadius: '8px', background: '#f9f9f9',
                            //         display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer'
                            //     }} >+</div>)
                            // }}
                            disabled={type === 'edit'}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormSelect
                            label={"商品业态"}
                            name={"SHOPTRADE"}
                            disabled={type === 'edit'}
                            request={async () => {
                                let list = session.get('BUSINESSTYPETree')
                                if (list && list.length > 0) {
                                    list.forEach((item: any) => {
                                        item.value = item.value.toString()
                                    })
                                }
                                console.log('商品业态', list);
                                return list
                            }}
                            fieldProps={{
                                placeholder: '请选择'
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormTreeSelect
                            label={"经营业态"}
                            name={"BUSINESS_TRADE"}
                            rules={[
                                {
                                    required: true,
                                    message: '请选择经营业态',
                                },
                            ]}
                            request={async () => {
                                const data = await getFieldEnumTree({ FieldExplainField: 'BusinessTradeIds', sessionName: 'BusinessTradeIds' })
                                if (data && data.length > 0) {
                                    data.forEach((item: any) => {
                                        item.disabled = true
                                    })
                                }
                                console.log('data', data);
                                return data
                            }}
                            fieldProps={{
                                showSearch: true,
                                treeDefaultExpandAll: true,
                                filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormTreeSelect
                            label={"经营品牌"}
                            rules={[
                                {
                                    required: true,
                                    message: '请选择经营品牌',
                                },
                            ]}
                            name={"BUSINESS_BRAND"}
                            request={async () => {
                                const data = await getFieldEnumTree({ FieldExplainField: 'BusinessBrandIds', FieldEnumPID: null, noStorge: true })
                                if (data && data.length > 0) {
                                    data.forEach((item: any) => {
                                        // item.disabled = true
                                    })
                                }
                                console.log('经营品牌', data);
                                return data
                            }}
                            fieldProps={{
                                showSearch: true,
                                treeDefaultExpandAll: true,
                                filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"门店简称"}
                            rules={[
                                {
                                    required: true,
                                    message: '请输入门店简称',
                                },
                            ]}
                            name={"SHOPSHORTNAME"}
                        />
                    </Col>
                    <Col span={24}>
                        <ProFormTextArea
                            label={"备注说明"}
                            name={"SERVERPARTSHOP_DESC"}
                        />
                    </Col>
                </Row>
                <Divider orientation="left">收银稽核配置</Divider>
                <Row gutter={16}>
                    <Col span={8}>
                        <ProFormText
                            label={"销售数量上限"}
                            name={"SALECOUNT_LIMIT"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"金额上限"}
                            name={"SALEAMOUNT_LIMIT"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormSelect
                            label={"优惠折扣"}
                            name={"RECORD_DISCOUNT"}
                            request={() => {
                                return [{ label: '不记异常稽核', value: 0 }, { label: '记录异常稽核', value: 1 }]
                            }}
                        />
                    </Col>

                    <Col span={8} style={{ display: 'none' }}>
                        <ProFormText
                            label={"商户内码"}
                            name={"SELLER_ID"}
                        />
                    </Col>
                </Row>
            </ProForm>
            <ProForm
                layout={'horizontal'}
                formRef={formSecondRef}
                submitter={{
                    render: (props, doms) => {
                        return []
                    }
                }}
            >
                <Divider orientation="left">收银稽核配置</Divider>
                <div style={{ marginBottom: '16px' }}>
                    <Radio.Group onChange={(e: any) => {
                        setRadioValue(e.target.value)
                    }} value={radioValue}>
                        <Radio value={1}>服务区单侧</Radio>
                        <Radio value={2}>服务区双侧</Radio>
                        <Radio value={3}>加油站单侧</Radio>
                        <Radio value={4}>加油站双侧</Radio>
                    </Radio.Group>
                </div>
                <Row gutter={16}>
                    <Col span={8}>
                        <ProFormSelect
                            label={"门店方位"}
                            name={"ShopRegion"}
                            rules={[
                                {
                                    required: true,
                                    message: '请选择门店方位',
                                },
                            ]}
                            request={() => {
                                let list: any = session.get('shopregionList')
                                if (list && list.length > 0) {
                                    list.forEach((item: any) => {
                                        item.value = Number(item.value)
                                    })
                                }
                                return list
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormText
                            label={"门店名称"}
                            rules={[
                                {
                                    required: true,
                                    message: '请输入门店名称',
                                },
                            ]}
                            name={"ShopName"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormSelect
                            label={"经营模式"}
                            name={"BusinessType"}
                            rules={[
                                {
                                    required: true,
                                    message: '请选择经营模式',
                                },
                            ]}
                            request={() => {
                                return session.get('BUSINESS_TYPETree')
                            }}
                        />
                    </Col>
                    <Col span={8}>
                        {
                            type === 'edit' ?
                                <Row gutter={16}>
                                    <Col span={18}>
                                        <ProFormSelect
                                            label={"经营状态"}
                                            name={"BusinessState"}
                                            request={() => {
                                                return session.get('businessStateList')
                                            }}
                                            disabled={type === 'edit'}
                                            initialValue={1000}
                                        />
                                    </Col>
                                    <Col span={6}>
                                        <Button type='primary' onClick={() => {
                                            setConfigType('BusinessState')
                                            let res: any = formSecondRef.current?.getFieldsValue()
                                            setCurrentBusinessState(res.BusinessState)
                                            setSelectShopId(res.ServerPartShopId)
                                            setShowConfigStateModal(true)
                                        }}>设置状态</Button>
                                    </Col>
                                </Row> :
                                <ProFormSelect
                                    label={"经营状态"}
                                    name={"BusinessState"}
                                    request={() => {
                                        return session.get('businessStateList')
                                    }}
                                    disabled={type === 'edit'}
                                    initialValue={1000}
                                />
                        }
                    </Col>
                    <Col span={8}>
                        <ProFormDatePicker
                            fieldProps={{
                                style: {
                                    width: '100%'
                                },
                            }}
                            label={"开业时间"}
                            name={"BusinessDate"}
                        />
                    </Col>
                    <Col span={8}>
                        <ProFormDatePicker
                            fieldProps={{
                                style: {
                                    width: '100%'
                                },
                            }}
                            label={"停业时间"}
                            name={"BusinessEndDate"}
                        />
                    </Col>
                    <Col span={8} style={{ display: 'none' }}>
                        <ProFormText
                            label={"门店id"}
                            name={"ServerPartShopId"}
                        />
                    </Col>
                </Row>
                {
                    radioValue === 2 || radioValue === 4 ?
                        <>
                            <Divider orientation="left">对向经营状态</Divider>
                            <Row gutter={16}>
                                <Col span={8}>
                                    <ProFormSelect
                                        label={"门店方位"}
                                        name={"ShopRegionSecond"}
                                        rules={[
                                            {
                                                required: true,
                                                message: '请选择门店方位',
                                            },
                                        ]}
                                        request={() => {
                                            let list: any = session.get('shopregionList')
                                            if (list && list.length > 0) {
                                                list.forEach((item: any) => {
                                                    item.value = Number(item.value)
                                                })
                                            }
                                            return list
                                        }}
                                    />
                                </Col>
                                <Col span={8}>
                                    <ProFormText
                                        label={"门店名称"}
                                        rules={[
                                            {
                                                required: true,
                                                message: '请输入门店名称',
                                            },
                                        ]}
                                        name={"SHOPNAMESecond"}
                                    />
                                </Col>
                                <Col span={8}>
                                    <ProFormSelect
                                        label={"经营模式"}
                                        rules={[
                                            {
                                                required: true,
                                                message: '请选择经营模式',
                                            },
                                        ]}
                                        name={"BUSINESS_TYPESecond"}
                                        request={() => {
                                            return session.get('BUSINESS_TYPETree')
                                        }}
                                    />
                                </Col>
                                <Col span={8}>
                                    {
                                        type === 'edit' ?
                                            <Row gutter={16}>
                                                <Col span={18}>
                                                    <ProFormSelect
                                                        label={"经营状态"}
                                                        name={"BUSINESS_STATESecond"}
                                                        request={() => {
                                                            return session.get('businessStateList')
                                                        }}
                                                        disabled={type === 'edit'}
                                                        initialValue={1000}
                                                    />
                                                </Col>
                                                <Col span={6}>
                                                    <Button type='primary' onClick={() => {
                                                        setConfigType('BUSINESS_STATESecond')
                                                        let res: any = formSecondRef.current?.getFieldsValue()
                                                        console.log('res', res);
                                                        setCurrentBusinessState(res.BUSINESS_STATESecond)
                                                        setSelectShopId(res.ServerPartShopIdSecond)
                                                        setShowConfigStateModal(true)
                                                    }}>设置状态</Button>
                                                </Col>
                                            </Row> :
                                            <ProFormSelect
                                                label={"经营状态"}
                                                name={"BUSINESS_STATESecond"}
                                                request={() => {
                                                    return session.get('businessStateList')
                                                }}
                                                disabled={type === 'edit'}
                                                initialValue={1000}
                                            />
                                    }
                                </Col>
                                <Col span={8}>
                                    <ProFormDatePicker
                                        label={"开业时间"}
                                        fieldProps={{
                                            style: {
                                                width: '100%'
                                            },
                                        }}
                                        name={"BusinessDateSecond"}
                                    />
                                </Col>
                                <Col span={8}>
                                    <ProFormDatePicker
                                        label={"停业时间"}
                                        name={"BusinessEndDateSecond"}
                                        fieldProps={{
                                            style: {
                                                width: '100%'
                                            },
                                        }}
                                    />
                                </Col>
                                <Col span={8} style={{ display: 'none' }}>
                                    <ProFormText
                                        label={"门店id"}
                                        name={"ServerPartShopIdSecond"}
                                    />
                                </Col>
                            </Row>
                        </> : ''
                }
            </ProForm>

            {
                type === 'edit' ?
                    <div>
                        <Divider orientation="left">门店经营信息</Divider>
                        <ProTable
                            actionRef={actionRef}
                            formRef={tableFormRef}
                            columns={columns}
                            dataSource={tableData}
                            search={false}
                        />
                    </div> : ''
            }


            <Modal
                width={600}
                open={showConfigStateModal}
                destroyOnClose={true}
                onCancel={() => {
                    setSelectShopId(undefined)
                    setShowConfigStateModal(false)
                    setConfigType(undefined)
                }}
                onOk={async () => {
                    let obj: any = modalRef.current?.getFieldsValue()

                    console.log('selectShopId', selectShopId);

                    let res: any = formSecondRef.current?.getFieldsValue()
                    let bigFormRes: any = formRef.current?.getFieldsValue()
                    console.log('res', res);
                    console.log('bigFormRes', bigFormRes);
                    let req: any = {}
                    if (configType === 'BusinessState') {
                        req = {
                            SERVERPARTSHOP_ID: res?.ServerPartShopId,
                            SHOPNAME: res?.ShopName,
                            BUSINESS_DATE: currentBusinessState === 1000 ? (obj?.BusinessDate ? moment(obj?.BusinessDate).format('YYYY-MM-DD') : '') : '',
                            BUSINESS_ENDDATE: currentBusinessState === 1000 ? '' : (obj?.BusinessDate ? moment(obj?.BusinessDate).format('YYYY-MM-DD') : ''),
                            BUSINESS_STATE: obj?.BusinessState,
                            BUSINESS_ORISTATE: res?.BusinessState,
                            STAFF_ID: currentUser?.ID,
                            STAFF_NAME: currentUser?.Name,
                            OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss')
                        }
                    } else {
                        req = {
                            SERVERPARTSHOP_ID: res?.ServerPartShopIdSecond,
                            SHOPNAME: res?.SHOPNAMESecond,
                            BUSINESS_DATE: currentBusinessState === 1000 ? (obj?.BusinessDate ? moment(obj?.BusinessDate).format('YYYY-MM-DD') : '') : '',
                            BUSINESS_ENDDATE: currentBusinessState === 1000 ? '' : (obj?.BusinessDate ? moment(obj?.BusinessDate).format('YYYY-MM-DD') : ''),
                            BUSINESS_STATE: obj?.BusinessState,
                            BUSINESS_ORISTATE: res?.BUSINESS_STATESecond,
                            STAFF_ID: currentUser?.ID,
                            STAFF_NAME: currentUser?.Name,
                            OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss')
                        }
                    }
                    let oldObj: any = formSecondRef.current?.getFieldsValue()

                    if (configType === 'BusinessState') {
                        formSecondRef.current?.setFieldsValue({
                            BusinessState: obj?.BusinessState,
                            BusinessDate: currentBusinessState === 1000 ?  obj?.BusinessDate : oldObj?.BusinessDate,
                            BusinessEndDate: currentBusinessState === 1000 ? oldObj?.BusinessEndDate :obj?.BusinessDate,
                        })
                    } else {
                        formSecondRef.current?.setFieldsValue({
                            BusinessStateSecond: obj?.BusinessState,
                            BusinessDateSecond: currentBusinessState === 1000 ?  obj?.BusinessDate : oldObj?.BusinessDateSecond,
                            BusinessEndDateSecond: currentBusinessState === 1000 ? oldObj?.BusinessEndDateSecond: obj?.BusinessDate
                        })
                    }
                    console.log('req', req);
                    const data = await handleModifyShopState([req])
                    if (data.Result_Code === 100) {
                        message.success(data.Result_Desc)
                        setSelectShopId(undefined)
                        setShowConfigStateModal(false)
                        setConfigType(undefined)
                        handleGetDetail()
                    } else {
                        message.error(data.Result_Desc)
                    }
                }}
            >
                <ProForm
                    formRef={modalRef}
                    submitter={{
                        // 清空表单自带的按钮
                        render: (props, doms) => {
                            return []
                        }
                    }}
                    request={() => {
                        console.log('configType', configType);
                        let obj: any = formSecondRef.current?.getFieldsValue()
                        let res: any = obj[configType]
                        console.log('res', res);
                        return {
                            BusinessState: res,
                            BusinessDate: res === 1000 ? (configType === 'BusinessState' ? obj?.BusinessDate : obj?.BusinessDateSecond) : (configType === 'BusinessState' ? obj?.BusinessEndDate : obj?.BusinessEndDateSecond)
                        }
                    }}
                >
                    <ProFormSelect
                        label={"经营状态"}
                        name={"BusinessState"}
                        request={() => {
                            let list: any = session.get('businessStateList')
                            console.log('list', list);
                            let res: any = []
                            if (list && list.length > 0) {
                                list.forEach((item: any) => {
                                    if (item.value !== 1010 && item.label !== "待运营") {
                                        res.push(item)
                                    }
                                })
                            }
                            return res
                        }}
                        fieldProps={{
                            onChange: (e: any) => {
                                setCurrentBusinessState(e)
                            }
                        }}
                    />
                    <ProFormDatePicker
                        fieldProps={{
                            style: {
                                width: '100%'
                            },
                        }}
                        label={currentBusinessState === 1000 ? "开业时间" : '停业时间'}
                        name={"BusinessDate"}
                    />
                </ProForm>
            </Modal>

            {/* 选择经营单位 */}
            <Drawer
                width="80%"
                visible={showBUSINESSUNIT} // 抽屉弹框是否显示状态
                onClose={() => { // 关闭抽屉 设置抽屉状态为关闭
                    setShowBUSINESSUNIT(false)
                }}
                destroyOnClose
                closable={false}
                bodyStyle={{ padding: '16px' }}
                footer={<div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
                    <Button type={"primary"} onClick={() => {
                        let selectRowDetail = MerchatsTableRef.current?.selectRowDetail
                        if (selectRowDetail && selectRowDetail.length > 0) {
                            let obj: any = selectRowDetail[0]
                            setSelectRowDetail(obj)
                            setSelectPersonModal(true)
                        } else {
                            message.error('请选择商户！')
                        }
                    }}>确认</Button>
                </div>}
            >
                <MerchatsTable isComponent={true} onRef={MerchatsTableRef} />
            </Drawer>

            <Modal
                title="选择负责人"
                width={500}
                destroyOnClose={true}
                open={selectPersonModal}
                onCancel={() => {
                    setSelectPersonModal(false)
                }}
                onOk={() => {
                    let selectPerson: any = SelectPersonRef.current?.selectPersonDetail
                    if (selectPerson && selectPerson.length > 0) {
                        let obj: any = selectPerson[0]
                        formRef.current?.setFieldsValue({
                            BUSINESS_UNIT: selectRowDetail?.COOPMERCHANTS_NAME,
                            TAXPAYER_IDENTIFYCODE: selectRowDetail?.TAXPAYER_IDENTIFYCODE,
                            BANK_NAME: selectRowDetail?.BANK_NAME,
                            BANK_ACCOUNT: selectRowDetail?.BANK_ACCOUNT,
                            TOPPERSON: obj?.LINKER_NAME,
                            LINKMAN_MOBILE: obj?.LINKER_MOBILEPHONE,
                            SELLER_ID: selectRowDetail?.COOPMERCHANTS_ID
                        })
                        setSelectPersonModal(false)
                        setShowBUSINESSUNIT(false)
                    }
                }}
            >
                <SelectPerson selectRowDetail={selectRowDetail} onRef={SelectPersonRef} />
            </Modal>



        </div >
    )
}

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