/*
 * @Author: your name
 * @Date: 2022-03-09 10:08:00
 * @LastEditTime: 2022-03-09 14:13:03
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /MedicalWisdomCheckSys/src/components/MccsTable/index.tsx
 */

import React,{useImperativeHandle,useRef} from 'react'
import ProTable, {  } from '@ant-design/pro-table';
import type { ActionType } from '@ant-design/pro-table';
import type { ProFormInstance } from '@ant-design/pro-form';

import './index.less';




const MccsTable=React.forwardRef<MccsTable.MccsTableRef,MccsTable.MccsTable>((props,ref)=>{

    const {columns=[],serach,request,searchNode,...rest} = props;
    const formRef = useRef<ProFormInstance>();
    const tableRef =useRef<ActionType>(); 

    const processColumns = (colums:MccsTable.Columns[])=>{
         return colums.map((item,index)=>{
                return {
                     ...item,
                    //  ellipsis:true
                }
         })
    }

    useImperativeHandle(ref,()=>{
        // getFormRef 就是暴露给父组件的方法
        const getFormRef = ()=>{
            return formRef;
        }
        const getTableRef = ()=>{
            return tableRef;
        }
        return {getFormRef,getTableRef}
    });

    return (
        <React.Fragment >
            <div className='container'>
            <ProTable
                  columns={processColumns(columns)}
                  toolBarRender={false}
                  formRef={formRef}
                  actionRef={tableRef}
                  request={request}
                  pagination={{ defaultPageSize: 10 }}
                  {...rest}
            />
            </div>
        </React.Fragment>
    )
})

export default MccsTable

