import useTable, { ModelType, MultipleResponseType } from '@/hooks/useTable'

import type { EpTableColumn } from 'global-type'

const useUserManageTable = (model?: ModelType<'getUserList'>) => {
  const { data, ...other } = useTable('getUserList', model, { pageSize: 20 })

  const columns: EpTableColumn<MultipleResponseType<'getUserList'>>[] = [
    { type: 'selection', width: 60 },
    { label: 'ID', prop: 'id', minWidth: 50 },
    { label: '姓名', prop: 'name', minWidth: 100 },
    { label: '登录名', prop: 'loginName', minWidth: 100 },
    { label: '单位', prop: 'employer', minWidth: 100 },
    { label: '角色', prop: 'roleName', minWidth: 80 },
    {
      label: '状态',
      prop: 'enable',
      minWidth: 50,
      formatter(row) {
        return row.enable ? '启用' : '禁用'
      },
    },
    { label: '更新人', prop: 'updaterName', minWidth: 100 },
    { label: '更新时间', prop: 'updateTime', minWidth: 130 },
    { label: '操作', slotName: 'operation', showOverflowTooltip: false, minWidth: 180 },
  ]

  return {
    ...other,
    columns,
    data,
  }
}

export default useUserManageTable
