// 车牌管理
import { connect } from "umi";
import type { ConnectState } from "@/models/connect";
import PageTitleBox from "@/components/PageTitleBox";
import ProTable, { ActionType } from "@ant-design/pro-table";
import { useRef } from "react";
import { FormInstance } from "antd";
import { handeGetMemberShipLicenseList } from "../../service";

type DetailProps = {
    parentDetail?: any
}
const LicensePlateManage = ({ parentDetail }: DetailProps) => {
    const actionRef = useRef<ActionType>();
    const formRef = useRef<FormInstance>();

    const columns: any = [
        {
            title: "会员姓名",
            width: 150,
            dataIndex: "MEMBERSHIP_NAME",
            hideInSearch: true,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "车辆类型",
            width: 150,
            dataIndex: "VEHICLE_TYPE",
            hideInSearch: true,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "车牌号码",
            width: 150,
            dataIndex: "PLATE_NUMBER",
            hideInSearch: true,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "手机号码",
            width: 150,
            dataIndex: "MEMBERSHIP_MOBILEPHONE",
            hideInSearch: true,
            align: 'center',
            ellipsis: true,
        },
        {
            title: "会员证件号",
            width: 150,
            dataIndex: "CERTIFICATE_NUMBER",
            hideInSearch: true,
            align: 'center',
            ellipsis: true,
        }
    ]

    return (
        <div>
            <ProTable
                actionRef={actionRef}
                formRef={formRef}
                columns={columns}
                bordered
                expandable={{
                    expandRowByClick: true
                }}
                search={false}
                scroll={{ x: "100%", y: '300px' }}
                // headerTitle={<PageTitleBox props={props} />} // 列表表头
                request={async (params) => {
                    const req: any = {
                        searchParameter: {
                            MEMBERSHIP_ID: parentDetail?.MEMBERSHIP_ID,
                            OWNERUNIT_ID: 911,
                        },
                        PageIndex: 1,
                        PageSize: 20,
                    }
                    const data = await handeGetMemberShipLicenseList(req)
                    console.log('datadatadata', data);
                    if (data.List && data.List.length > 0) {
                        return { data: data.List, success: true, total: data.TotalCount }
                    }
                    return { data: [], success: true }
                }}
            // toolbar={{
            //     actions: [

            //     ]
            // }}
            />


        </div>
    )
}

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