/*
 * @Author: code4eat awesomedema@gmail.com
 * @Date: 2022-12-20 15:24:11
 * @LastEditors: code4eat awesomedema@gmail.com
 * @LastEditTime: 2025-07-09 14:21:59
 * @FilePath: /BudgetManaSystem/src/components/BMSTable/index.tsx
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { deepEqual } from '@/utils/tooljs';
import { ProTable, ProTableProps } from '@ant-design/pro-components';
import { useEffect, useState } from 'react';

// import './style.less';
import './rewrite.less';

export type KCIMTablePropsType<T, U, ValueType> = ProTableProps<
  T,
  U,
  ValueType
> & {};

export const KCIMTablePageDefaultConfig = {
  defaultPageSize: 10,
};

export const KCIMTable = (props: KCIMTablePropsType<any, any, any>) => {
  const { params, options = false, request, ...rest } = props;
  const [prevParams, set_prevParams] = useState<any>(undefined);

  useEffect(() => {
    // console.log({'deepEqual(prevParams,params)':deepEqual(prevParams,params)});
    // console.log({prevParams,params});

    if (deepEqual(prevParams, params)) {
    } else {
    }
    set_prevParams(params);
  }, [params]);

  return (
    <ProTable
      tableClassName="KCIMTable"
      toolBarRender={false}
      options={options}
      pagination={{
        showSizeChanger: true,
        ...KCIMTablePageDefaultConfig,
      }}
      //locale={{emptyText:'暂无数据'}}
      params={{ ...params }}
      bordered={false}
      search={false}
      tableStyle={{}}
      request={
        request
          ? (params, sort, filter) => request({ ...params }, sort, filter)
          : undefined
      }
      {...rest}
    />
  );
};
