import { ref, computed, onMounted } from 'vue'

import type { TableColumn } from '@/types/table'
import { useTable } from '@/hooks/web/useTable'
import { dayjs } from 'element-plus'
import {page, del} from '@/api/new-ai/message'

export default function () {
  const searchParams = ref({})
  const { register, tableObject, methods } = useTable({
    getListApi:page,
    defaultParams: searchParams.value,
    delListApi:del
  })

  const handleSearch = (values: any) => {
    methods.setSearchParams(values)
  }

  const pagination = computed(() => {
    return {
      total: tableObject.total,
      pageSize: tableObject.pageSize,
      currentPage: tableObject.currentPage
    }
  })

  onMounted(() => {
    methods.getList()
  })

  return {
    register,
    handleSearch,
    methods,
    tableObject,
    pagination
  }
}
