import { PropType } from 'vue';
import { PropTypes } from '/nerv-lib/util/type';
import { tableConfig } from '/nerv-base/config/table.config';
import { AxiosRequestConfig } from 'axios';
import { tableProps as TableProps } from 'ant-design-vue/es/table/Table';

export const tableProps = {
  ...TableProps(),
  api: {
    type: [String, Object, Function] as PropType<string | Function | AxiosRequestConfig>,
    default: undefined,
  },
  params: PropTypes.object.def(() => ({})),
  dynamicParams: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.array,
    PropTypes.object,
    PropTypes.func,
  ]),
  requiredParams: PropTypes.oneOfType([
    PropTypes.string,
    PropTypes.array,
    PropTypes.object,
    PropTypes.bool,
  ]),
  rowSelection: PropTypes.oneOfType([PropTypes.object.def(() => ({})), PropTypes.bool]).def({}),
  pagination: PropTypes.oneOfType([PropTypes.object.def(() => ({})), PropTypes.bool]).def(true), //分页
  headerActions: PropTypes.array.def(() => []), //顶部操作栏
  footerActions: PropTypes.array.def(() => []), //顶部操作栏
  columnActions: PropTypes.oneOfType([
    PropTypes.object.def(() => tableConfig.columnActions),
    PropTypes.bool,
  ]).def(false), //操作栏
  scroll: PropTypes.object.def(() => tableConfig.scroll), //操作栏
  size: PropTypes.string.def('middle'),
  showBack: PropTypes.bool.def(false),
  bordered: PropTypes.bool.def(true),
  pageField: PropTypes.string.def(tableConfig.pageField),
  pageCountField: PropTypes.string.def(tableConfig.pageCount),
  listField: PropTypes.string.def(tableConfig.listField),
  totalField: PropTypes.string.def(tableConfig.totalField),
  pageFieldOffset: PropTypes.number.def(tableConfig.pageFieldOffset),
  sizeField: PropTypes.string.def(tableConfig.sizeField),
  pageSizeOptions: PropTypes.array.def(tableConfig.pageSizeOptions),
  defaultPageSize: PropTypes.number.def(tableConfig.defaultPageSize),
  paramsPageSizeField: PropTypes.string.def(tableConfig.paramsPageSizeField),
  paramsPageField: PropTypes.string.def(tableConfig.paramsPageField),
  paramsOrderField: PropTypes.string.def(tableConfig.paramsOrderField),

  formConfig: PropTypes.object, //查询表单
  tableTitle: PropTypes.string,

  treeConfig: PropTypes.object.def(() => ({})), //树型菜单
  editable: PropTypes.bool.def(false),
  ediRowData: PropTypes.object.def(() => ({})),
  value: PropTypes.array.def(() => []),
  rowKey: PropTypes.oneOfType([PropTypes.func, PropTypes.string]).def('key'),
  refreshTime: PropTypes.number.def(0),
  enableTableSession: PropTypes.bool.def(false),
  expand: PropTypes.bool.def(true), // 默认是否展开
  showExpand: PropTypes.bool.def(false), // 是否展示右下角的收起展开
  // 收起全部
  expandAll: PropTypes.bool.def(true), // 默认是否全部展开
  showExpandAll: PropTypes.bool.def(true), // 是否展示右上角的全部收起展开
};
