import { reactive, ref, computed, watch, inject } from 'vue'
import useTable, { ModelType, MultipleResponseType } from '@/hooks/useTable'
import { ROLE } from '@/constants/dicts'

import type { EpTableProps, EpTableColumn } from 'global-type'

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

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

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

export default useUserManageTable
