import { dataTableProps } from 'naive-ui'
import { type PropType } from 'vue'
import type { SearchFormProps } from './interface'
import { type FormItemOptions } from '@/components/formPro'

export const tableProProps = {
  ...dataTableProps,
  rowKey: {
    type: String as PropType<string>,
    default: 'snowFlakeId',
  },
  tableTitle: {
    type: String as PropType<string>,
    default: '数据列表',
  },
  searchFormProps: {
    type: Object as PropType<SearchFormProps<any>>,
    default: {
      gridProps: {
        cols: '640:1 768:2 1024:4 1280:6 1536:6',
        xGap: 8,
        responsive: 'self',
        itemResponsive: true,
      },
    },
  },
  searchFormOptions: {
    type: Object as PropType<FormItemOptions<any>>,
  },
  requestAuto: {
    type: Boolean as PropType<boolean>,
    default: true,
  },
  requestApi: {
    type: Function as PropType<(params: any) => Promise<any>>,
    default: () => Promise.resolve([]),
  },
  requestError: {
    type: Function as PropType<(errorMsg: any) => void>,
  },
  dataCallback: {
    type: Function as PropType<(data: any[]) => any[]>,
  },
  remote: {
    type: Boolean,
    default: true,
  },
  isPageTable: {
    type: Boolean as PropType<boolean>,
    default: true,
  },
}
