import React, { useState, useEffect, useContext } from 'react';
import { Button, Divider, Tooltip, Row, Col, Popover, Form, Drawer, message, Modal } from 'antd'; //
import {
    SearchOutlined,
    ReloadOutlined,
    DownOutlined,
    MinusCircleOutlined,
    PlusCircleOutlined,
    ExclamationCircleOutlined
} from '@ant-design/icons'
import { MyContext } from '../../utils/contextManage';
import GForm from '../../components/GForm';
import GTableWithReferenceRule from "../../components/GTableWithReferenceRule";
import { ActiveTableProps } from '../../index.d'
import './index.less'
// @ts-ignore
import { handleModelFormDetail, modelFormDetailToBoolean } from "../../utils/common.js"


// export interface PageContentProps {
//     [propsName: string]: any
// }
const PageContent: React.FC<ActiveTableProps> = (props) => {
    console.log('PageContent的props', props);
    const { tableRrn, tableSelectType = 'radio', drawerOperateBtns = [], toolBtns = [] } = props
    const { state } = useContext(MyContext);
    const [searchForm] = Form.useForm()
    const [editForm] = Form.useForm()
    const [tableInfo, setTableInfo] = useState<any>({})
    const [fieldList1, setFieldList1] = useState<any[]>([])
    const [fieldList2, setFieldList2] = useState<any[]>([])
    const [referRuleInfo, setReferRuleInfo] = useState<any>({})
    const [popoverVisible, setPopoverVisible] = useState<any>(false)
    const [serachParam1, setSerachParam1] = useState<any>({})
    const [serachParam2, setSerachParam2] = useState<any>({})
    const [columns, setColumns] = useState<any[]>([])
    const [fields, setFields] = useState<any[]>([])
    const [dataList, setDataList] = useState<any[]>([])
    const [loading, setLoading] = useState<boolean>(false)
    const [tableWidth, setTableWidth] = useState<number>(0)
    const [total, setTotal] = useState<number>(0)
    const [current, setCurrent] = useState<number>(1)
    const [pageSize, setPageSize] = useState<number>(20)
    const [tableSelectDetail, setTableSelectDetail] = useState<any>({})
    const [drawerVisible, setDrawerVisible] = useState<any>(false)
    const [selectedRowKeys, setSelectedRowKeys] = useState<(string | number)[]>([]);
    // @ts-ignore
    const [selectedRows, setSelectedRows] = useState<any[]>([]);

    // 右上方按钮,支持插入特定顺序
    let toolButtons: any = [
        {
            key: 'create',
            name: '新建',
            icon: <PlusCircleOutlined />,
            btnType: 'primary',
            click: function ({ tableInfo, selectedRowKeys, dataList, freshTable }: any) {
                console.log('传给外部的参数', tableInfo, selectedRowKeys, dataList, freshTable);
                onCreate()
            }
        },
        {
            key: 'delete',
            name: '删除',
            icon: <MinusCircleOutlined />,
            display: false,
            disabled: true,
            click: function ({ tableInfo, tableSelectDetail, editForm }: any) {
                console.log('传给外部的参数', tableInfo, tableSelectDetail, editForm);
            }
        }
    ]
    if (toolBtns && toolBtns.length > 0) {
        const tempToolButtons = [...toolBtns]
        const tempBtns = []
        for (let v of tempToolButtons) {
            if (toolButtons.some((it: any) => it.key === v.key)) {
                let btnIndex = toolButtons.findIndex((item: any) => Object.is(item.key, v.key))
                const newBtn = { ...toolButtons[btnIndex], ...v }
                toolButtons.splice(btnIndex, 1, newBtn)
            } else {
                if (v.before) {
                    // before 代表外部传入按钮的插入位置
                    let beforeIndex = toolButtons.findIndex((item: any) => item.key === v.before)
                    if (beforeIndex === -1) {
                        tempBtns.push(v)
                    } else {
                        toolButtons.splice(beforeIndex, 0, v)
                    }
                } else {
                    tempBtns.push(v)
                }
            }
        }
        toolButtons = tempBtns.concat(toolButtons)
    }
    // 表格右侧按钮，按传入顺序排列
    const tableRowButtons: any = [
        // {
        //     key: 'detail',
        //     name: '详情',
        //     click: function ({ record }: any) {
        //         tableRowDetail(record)
        //     }
        // }
    ]
    // 抽屉下方按钮，支持插入特定位置
    let drawerBtns: any = [
        {
            key: 'save',
            name: '保存',
            icon: null,
            btnType: 'primary',
            display: true,
            disabled: false,
            click: function ({ tableInfo, tableSelectDetail, editForm, freshTable }: any) {
                console.log('传给外部的参数', tableInfo, tableSelectDetail, editForm, 'freshTable', freshTable);
                onDrawerOk()
            }
        },
        {
            key: 'delete',
            name: '删除',
            icon: null,
            display: true,
            disabled: !(tableSelectDetail.OBJECTRRN),
            click: function ({ tableInfo, tableSelectDetail, editForm }: any) {
                console.log('传给外部的参数', tableInfo, tableSelectDetail, editForm);
                onDrawerDelete()
            }
        }
    ]
    // 处理外部传入的操作按钮
    if (drawerOperateBtns && drawerOperateBtns.length > 0) {
        const drawerOperateButtons = [...drawerOperateBtns]
        const tempBtns = []
        for (let v of drawerOperateButtons) {
            if (drawerBtns.some((it: any) => it.key === v.key)) {
                let btnIndex = drawerBtns.findIndex((item: any) => Object.is(item.key, v.key))
                const newBtn = { ...drawerBtns[btnIndex], ...v }
                drawerBtns.splice(btnIndex, 1, newBtn)
            } else {
                if (v.before) {
                    // before 代表外部传入按钮的插入位置
                    let beforeIndex = drawerBtns.findIndex((item: any) => item.key === v.before)
                    if (beforeIndex === -1) {
                        tempBtns.push(v)
                    } else {
                        drawerBtns.splice(beforeIndex, 0, v)
                    }
                } else {
                    tempBtns.push(v)
                }
            }
        }
        drawerBtns = tempBtns.concat(drawerBtns)
    }

    useEffect(() => {
        if (tableRrn && state.getEntity) {
            // 获取动态表信息tableInfo
            getTableInfo()
        }
    }, [tableRrn, state.getEntity])

    useEffect(() => {
        if (fields) {
            const isZh = state.lang === 'zh-CN'
            let totalWidth = 0
            const list = fields.length > 0 ? fields.filter((x: any) => x.ISMAIN).map((item: any) => {
                const title = (isZh ? item.LABELZH : item.LABEL) || ''
                const width = Math.max(title.length * 18, 100)
                totalWidth += width;
                return {
                    title: title,
                    width,
                    dataIndex: item.NAME.toUpperCase()
                }
            }) : []
            if (tableRowButtons.length > 0) {
                const operateCol = {
                    title: '操作',
                    width: 100,
                    dataIndex: 'operation',
                    align: 'center',
                    render: (text: any, record: any) =>
                        tableRowButtons.map((it: any, index: number) => {
                            return (<>
                                <a onClick={() => { it.click({ text, record }) }}>{it.name}</a>
                                {(index !== (tableRowButtons.length - 1)) ? <Divider type="vertical" /> : null}
                            </>)
                        })
                }
                list.push(operateCol)
                totalWidth += 100
            }
            setColumns(list)
            setTableWidth(totalWidth)
        }
    }, [fields])
    useEffect(() => {
        if (state.getEntityListAsPage && Object.keys(tableInfo).length > 0) {
            getFieldListData('init')
        }
    }, [state.getEntityListAsPage, tableInfo])
    // 获取编辑表格数据，带分页
    const getFieldListData = (type: string, current = 1, pageSize = 20, serachVal?: object) => {
        console.log('开始请求编辑表格分页数据')
        const { MODELCLASS, ORDERBYCLAUSE, INITWHERECLAUSE, WHERECLAUSE } = tableInfo
        setLoading(true)
        const params = {
            ENTITYMODEL: MODELCLASS,
            ORDERBYCLAUSE,
            page: current,
            pageSize: pageSize,
            queryParams: {},
            WHERECLAUSE: ''
        }
        if (type === 'init') {
            params.queryParams = {}
            params.WHERECLAUSE = INITWHERECLAUSE
        } else {
            params.queryParams = {}
            params.WHERECLAUSE = WHERECLAUSE
        }
        if (serachVal) {
            params.queryParams = serachVal
        }
        console.log('请求参数', params)
        state.getEntityListAsPage(params)
            .then((res: any) => {
                setLoading(false)
                console.log('返回的数据', res);

                if (res) {
                    setDataList(res.list.map((t: any, i: number) => {
                        t.key = t.OBJECTRRN || i
                        return t
                    }))
                    setTotal(res.total)
                }
            })
            .catch((err: any) => {
                console.log('请求失败，todo解锁加载中', err)
            })
    }
    const pageChange = (page: number, pageSize: number) => {
        const serachParams = { ...serachParam1, ...serachParam2 }
        getFieldListData('', page, pageSize, serachParams)
        setCurrent(page)
        setPageSize(pageSize)
    }
    const getTableInfo = () => {
        const params = {
            ENTITYMODEL: state.entityModel,
            OBJECTRRN: `${tableRrn}`
        }
        state.getEntity(params)
            .then((res: any) => {
                if (res.Header.RESULT === 'SUCCESS') {
                    const tableInfo = res.Body.DATA
                    console.log('最大动态表的信息', tableInfo);
                    setTableInfo(tableInfo)
                    setFields(tableInfo.ADFIELDLIST)
                    // 搜索表单里只显示ISQUERY的字段
                    const adFieldList = tableInfo.ADFIELDLIST.filter((x: any) => x.ISQUERY)
                    console.log('adFieldList', adFieldList);

                    // 拆成2个数组
                    let fieldList1: any = []
                    let fieldList2: any = []
                    adFieldList.forEach((item: any, index: number) => {
                        if (index <= 2) {
                            fieldList1.push(item)
                        } else {
                            fieldList2.push(item)
                        }
                    })
                    setFieldList1(fieldList1)
                    setFieldList2(fieldList2)
                    // 获取子表单的级联信息 referRuleInfo
                    const obj = {} as any
                    tableInfo.ADFIELDLIST?.filter((x: any) => x.REFERENCERULE && /[a-zA-Z0-9]+.[a-zA-Z0-9]+/g.test(x.REFERENCERULE))
                        .forEach((x: any) => {
                            const arr = x.REFERENCERULE.toUpperCase().split('.')
                            const key = arr[0]
                            const value = arr[1]
                            if (obj[key]) {
                                obj[key].push({ name: x.NAME, value })
                            } else {
                                obj[key] = [{ name: x.NAME, value }]
                            }
                        })
                    setReferRuleInfo(obj)
                }
            })
            .catch((err: any) => {
                console.log('getTableInfo 请求失败，todo解锁加载中', err)
            })
    }

    // 搜索
    const handleFormSubmit1 = () => {
        // 只校验外部的表单
        const validateFieldList = fieldList1.map(item => item.NAME)
        searchForm.validateFields([...validateFieldList]).then((values: any) => {
            console.log('表单校验1', values);
            // values设置到state里保存起来，用于分页刷新数据
            setSerachParam1(values)
            setSerachParam2({})
            getFieldListData('', 1, pageSize, values)
            setCurrent(1)
            setSelectedRowKeys([])
            setSelectedRows([])
        }).catch(err => console.log('校验失败', err))
    }
    const handleFormSubmit2 = () => {
        searchForm.validateFields().then((values: any) => {
            console.log('表单校验2', values);
            setSerachParam2(values)
            getFieldListData('', 1, pageSize, values)
            setCurrent(1)
            setSelectedRowKeys([])
            setSelectedRows([])
            setPopoverVisible(false)
        }).catch(err => console.log('校验失败', err))
    }

    const changeFormDetail = (detail: any) => {
        if (props.changeFormDetail) {
            setTableSelectDetail(props.changeFormDetail(detail))
        }
        console.log('查询到的formDetail,已转换‘Y’', detail)
        setTableSelectDetail(detail)
        setDrawerVisible(true)
    }
    const handleBooleanField = (record: any) => {
        let detail = { ...record }
        const booleanFieldList = tableInfo.ADFIELDLIST.filter((x: any) => x.DISPLAYTYPE === 'boolean')
        Object.keys(record).forEach(function (key) {
            if (booleanFieldList.some((x: any) => x.NAME.toUpperCase() === key)) {
                // @ts-ignore
                detail[key] = detail[key] === 'Y' || detail[key] === true
            }
        })
        changeFormDetail(detail)
    }
    const tableRowDetail = (record: any) => {
        // 点击表格行详情,改为双击表格某行
        console.log('当前行数据record', record);
        // 根据这一行的OBJECTRRN查询出formDetail
        if (!record.OBJECTRRN) {
            handleBooleanField(JSON.parse(JSON.stringify(record)))
        } else {
            const params = {
                ENTITYMODEL: tableInfo.MODELCLASS,
                OBJECTRRN: record.OBJECTRRN
            }
            state.getEntity(params).then((res: any) => {
                if (res.Header.RESULT === 'SUCCESS') {
                    handleBooleanField(res.Body.DATA)
                }
            })
        }
    }

    // 刷新
    const onRefresh = () => {
        searchForm.resetFields()
        setSerachParam1({})
        setSerachParam2({})
        getFieldListData('', 1, 20)
        setCurrent(1)
        setPageSize(20)
        setSelectedRowKeys([])
        setSelectedRows([])
        setTableSelectDetail({})
    }
    // 新建
    const onCreate = () => {
        setSelectedRowKeys([])
        setSelectedRows([])
        setTableSelectDetail({})
        setDrawerVisible(true)
    }
    const onDrawerCancel = () => {
        setDrawerVisible(false)
    }
    const onDrawerOk = () => {
        // 保存
        editForm.validateFields().then((values: any) => {
            console.log('抽屉弹窗表单校验', values);
            const data = handleModelFormDetail(values)
            // console.log('转换过布尔值的data', data);
            const formData = { ...tableSelectDetail, ...data }
            const saveType = formData.OBJECTRRN ? 'UPDATEENTITY' : 'SAVEENTITY'
            const xModelData = JSON.stringify({
                ...values,
                OBJECTRRN: formData.OBJECTRRN,
                ADTABLERRN: tableInfo.OBJECTRRN,
            })
            const params = {
                ACTIONTYPE: saveType,
                ENTITYMODEL: tableInfo.MODELCLASS,
                XMODELDATA: xModelData
            }
            console.log('保存参数', params);
            state.cudEntity(params).then((res: any) => {
                if (res.Header.RESULT === 'SUCCESS') {
                    //   console.log('保存成功', res)
                    message.success('保存成功')
                    if (saveType === 'SAVEENTITY') {
                        setDrawerVisible(false)
                    }
                    // 更新弹层表单数据
                    const resData = { ...res.Body.DATA }
                    setTableSelectDetail(modelFormDetailToBoolean(resData))
                    // 保存之后的刷新逻辑
                    const serachParams = { ...serachParam1, ...serachParam2 }
                    getFieldListData('', current, pageSize, serachParams)

                } else {
                    console.log('保存失败');
                }
            }).catch((err: any) => {
                console.log('保存失败，todo解锁加载中', err)
            })
        }).catch(err => console.log('校验失败', err))
    }
    const onDrawerDelete = () => {
        // 删除
        Modal.confirm({
            title: 'warning',
            icon: <ExclamationCircleOutlined />,
            style: { top: 20 },
            content: '确认删除吗?',
            okText: '确认',
            cancelText: '取消',
            onOk() {
                certainDelete(tableInfo)
            },
            onCancel() {
            }
        })
    }
    // 确认删除
    const certainDelete = (tableInfo: any) => {
        const params = {
            ACTIONTYPE: 'DELETEENTITY',
            ENTITYMODEL: tableInfo.MODELCLASS,
            OBJECTRRN: `${tableSelectDetail.OBJECTRRN}`
        }
        console.log('删除参数', params)
        state.cudEntity(params).then((res: any) => {
            if (res.Header.RESULT === 'SUCCESS') {
                message.success('删除成功')
                setDrawerVisible(false)
                // 清空弹层表单数据
                editForm.resetFields()
                setTableSelectDetail({})
                // 删除后的刷新逻辑
                setSelectedRowKeys([])
                setSelectedRows([])
                if (dataList.length > 1) {
                    const serachParams = { ...serachParam1, ...serachParam2 }
                    getFieldListData('', current, pageSize, serachParams)
                } else {
                    getFieldListData('init', 1, 20)
                    setCurrent(1)
                    setPageSize(20)
                }
            } else {
                console.log('删除失败');
            }
        })
            .catch((err: any) => {
                console.log('请求失败，todo解锁加载中', err)
            })
    }
    // 传给外层组件的刷新方法
    const freshTable = (param: { cleanSearchRefresh: boolean; isCurrentPage: boolean; cleanSelected: boolean }) => {
        // console.log(param);
        if (param.cleanSearchRefresh) {
            // 不带搜索条件的刷新
            if (param.isCurrentPage) {
                // 刷新后留着当前页
                getFieldListData('init', current, pageSize)
            } else {
                // 刷新后回到第一页
                getFieldListData('init', 1, 20)
                setCurrent(1)
                setPageSize(20)
            }
            if (param.cleanSelected) {
                // 刷新后清空左侧表格勾选
                setSelectedRowKeys([])
            }
        } else {
            // 带搜索条件刷新
            const serachParams = { ...serachParam1, ...serachParam2 }
            if (param.isCurrentPage) {
                // 刷新后留着当前页
                getFieldListData('', current, pageSize, serachParams)
            } else {
                // 刷新后回到第一页
                getFieldListData('', 1, 20, serachParams)
                setCurrent(1)
                setPageSize(20)
            }
            if (param.cleanSelected) {
                // 刷新后清空左侧表格勾选
                setSelectedRowKeys([])
            }
        }
    }

    const text = <span>更多查询</span>;
    const content = (
        <div className="popoverContent">
            <GForm
                key={2}
                form={searchForm}
                fieldData={fieldList2}
                fieldRefRule={referRuleInfo}
                layout="horizontal"
                formType="searchForm" >
            </GForm>
            <Divider />
            <div className="popoverBtn">
                <Button
                    type="primary"
                    onClick={() => {
                        handleFormSubmit2()
                    }}>确认</Button>&nbsp;
                <Button onClick={() => { setPopoverVisible(false) }}>取消</Button>
            </div>
        </div>
    );
    const renderTopForm = () => {
        return (
            <div className="topForm">
                <Row justify="center" gutter={24}>
                    <Col span={18}>
                        <Row gutter={16}>
                            <Col className="topForm-col">
                                <GForm
                                    key={1}
                                    form={searchForm}
                                    fieldData={fieldList1}
                                    fieldRefRule={referRuleInfo}
                                    layout="inline"
                                    formType="searchForm" >
                                </GForm>
                            </Col>
                            <Col>
                                <Tooltip title="搜索">
                                    <Button
                                        type="primary"
                                        shape="circle"
                                        icon={<SearchOutlined />}
                                        onClick={() => {
                                            handleFormSubmit1()
                                        }}
                                    />
                                </Tooltip>
                            </Col>
                            {fieldList2.length > 0 ?
                                <Col>
                                    <Popover
                                        visible={popoverVisible}
                                        onVisibleChange={(v) => { setPopoverVisible(v) }}
                                        placement="bottomRight"
                                        title={text}
                                        content={content}
                                        trigger="click">
                                        <Button type="link" >更多查询<DownOutlined /></Button>
                                    </Popover>
                                </Col> : null}
                        </Row>
                    </Col>
                    <Col span={6} className="toolTipCol">
                        {toolButtons && toolButtons.length > 0
                            ? toolButtons.map((it: any) => {
                                const display = it.hasOwnProperty('display') ? (typeof (it.display) === 'function' ? it.display(tableSelectDetail) : it.display) : true
                                return display ? (<Button
                                    key={it.key}
                                    icon={it.icon}
                                    type={it.btnType ? it.btnType : 'default'}
                                    disabled={typeof (it.disabled) === 'function' ? it.disabled(tableSelectDetail) : it.disabled}
                                    style={{ marginLeft: 8 }}
                                    onClick={() => {
                                        it.click({
                                            tableInfo,
                                            selectedRowKeys,
                                            dataList,
                                            freshTable
                                        })
                                    }}
                                >{it.name}</Button>) : null
                            }) : null
                        }
                        {/* <Button type="primary" icon={<PlusCircleOutlined />} onClick={() => { onCreate() }}>新建</Button>&nbsp; */}
                        {/* <Button icon={<MinusCircleOutlined />} >删除</Button> */}
                        <Tooltip title="刷新">
                            <Button className="tooltipBtn" icon={<ReloadOutlined />} onClick={() => { onRefresh() }} />
                        </Tooltip>
                    </Col>
                </Row>
            </div>
        )
    }

    const renderBottomTable = () => {
        const height = document.documentElement.clientHeight - 100
        return <GTableWithReferenceRule
            fields={fields}
            columns={columns}
            dataSource={dataList}
            loading={loading}
            bordered={true}
            style={{ height: `${height}px` }}
            scroll={{ y: `${height - 170}px`, x: `${tableWidth}px` }}
            resizable
            total={total}
            rowSelection={{
                selectedRowKeys,
                columnWidth: 15, // '20px'
                hideSelectAll: tableSelectType === 'radio',
                onChange: (srks: any, srs: any) => {
                    if (tableSelectType === 'radio') {
                        if (selectedRowKeys && selectedRowKeys.length > 0) {
                            const tempSelectedRowKeys = [...selectedRowKeys]
                            const selectRowKeys = srks.filter((k: any) => !tempSelectedRowKeys.includes(k))
                            const selectRows = srs.filter((item: any) => !tempSelectedRowKeys.includes(item.OBJECTRRN))
                            console.log('selectRowKeys', selectRowKeys, 'selectRows', selectRows)
                            setSelectedRowKeys(selectRowKeys)
                        } else {
                            console.log('selectRowKeys', srks, 'selectRows', srs)
                            setSelectedRowKeys(srks)
                            setSelectedRows(srs)
                        }
                    } else {
                        console.log('srks', srks, 'srs', srs)
                        setSelectedRowKeys(srks)
                        setSelectedRows(srs)
                    }
                }
            }}
            onRow={(record: any) => {
                return {
                    onDoubleClick: () => {
                        tableRowDetail(record)
                    },
                    onClick: () => {
                        if (tableSelectType === 'radio') {
                            console.log('selectRowKeys', [record.OBJECTRRN], 'selectRows', [record])
                            setSelectedRowKeys([record.OBJECTRRN])
                            setSelectedRows([record])
                        } else {
                            // 还可以单击行实现多选效果
                            const selectRowKeys = [...selectedRowKeys]
                            const selectRows = [...selectedRows]
                            if (selectRowKeys.indexOf(record.OBJECTRRN) >= 0) {
                                // 已被勾选，取消勾选
                                selectRowKeys.splice(selectRowKeys.indexOf(record.OBJECTRRN), 1)
                                selectRows.splice(selectRows.findIndex(it => it.OBJECTRRN === record.OBJECTRRN), 1)
                            } else {
                                selectRowKeys.push(record.OBJECTRRN)
                                selectRows.push(record)
                            }
                            console.log('srks', selectRowKeys, 'srs', selectRows)
                            setSelectedRowKeys(selectRowKeys)
                            setSelectedRows(selectRows)
                        }
                    }
                };
            }}
            pagination={{
                size: "small",
                showSizeChanger: true,
                showQuickJumper: true,
                defaultPageSize: 20,
                total,
                pageSizeOptions: ['10', '20', '30', '50', '100'],
                showTotal: () => state.lang === 'zh-CN' ? `共 ${total} 条` : `Total ${total} Items`,
                onChange: pageChange,
                onShowSizeChange: pageChange,
                current: current,
                pageSize: pageSize
            }}
        />
    }
    const renderOperateDrawer = () => {
        return (
            <>
                <Drawer
                    title="详细信息"
                    width={920}
                    onClose={() => { onDrawerCancel() }}
                    visible={drawerVisible}
                    maskClosable={false}
                    destroyOnClose={false}
                    bodyStyle={{ paddingBottom: 80 }}
                    footer={
                        <div style={{ textAlign: 'left' }}>
                            {drawerBtns && drawerBtns.length > 0
                                ? drawerBtns.map((it: any) => {
                                    const display = it.hasOwnProperty('display') ? (typeof (it.display) === 'function' ? it.display(tableSelectDetail) : it.display) : true
                                    return display ? (<Button
                                        key={it.key}
                                        icon={it.icon}
                                        type={it.btnType ? it.btnType : 'default'}
                                        disabled={typeof (it.disabled) === 'function' ? it.disabled(tableSelectDetail) : it.disabled}
                                        style={{ marginLeft: 8 }}
                                        onClick={() => {
                                            it.click({
                                                tableInfo,
                                                tableSelectDetail,
                                                dataList,
                                                editForm,
                                                freshTable
                                            })
                                        }}
                                    >{it.name}</Button>) : null
                                }) : null
                            }
                            {/* <Button onClick={() => { onDrawerOk() }} type="primary">保存</Button> */}
                            {/* <Button disabled={!(tableSelectDetail.OBJECTRRN)} onClick={() => { onDrawerDelete() }} style={{ marginLeft: 8 }}>删除</Button> */}
                        </div>
                    }
                >
                    <GForm
                        key={3}
                        fieldData={fields}
                        fieldRefRule={referRuleInfo}
                        adTableList={tableInfo.ADTABLIST}
                        formDetail={tableSelectDetail}
                        form={editForm}
                        layout="horizontal"
                        formType="form" >
                    </GForm>
                </Drawer>
            </>
        )
    }

    return (
        <div className="operateTable">
            {renderTopForm()}
            {renderBottomTable()}
            {renderOperateDrawer()}
        </div>
    )
}

export default PageContent;