import { eLevel } from '@/types/level'
import { eUserStatusAction } from '@/types/user'
import baseAxios from '../index'
import { iOutLet, iStaffItem } from './types'

export default class StaffService {
  static instance: StaffService
  static getInstance() {
    if (!StaffService.instance) {
      StaffService.instance = new StaffService()
    }
    return StaffService.instance
  }

  addAcm(data: {
    attr: {
      add_same_level: boolean
    },
    level: number,
    name: string,
    password: string,
    phone: string,
    second_sub_branch: number
  }) {
    return baseAxios<{data: any}>({
      url: '/staff/add/acm',
      method: 'post',
      data
    })
  }

  addNextLevel(data: {
    attr: {
      add_same_level: boolean
    },
    level: number,
    name: string,
    password: string,
    phone: string,
    second_sub_branch: number
  }) {
    return baseAxios<{data: any}>({
      url: '/staff/add/next_level',
      method: 'post',
      data
    })
  }

  addSameLevel(data: {
    attr: {
      add_same_level: boolean
    },
    level: number,
    name: string,
    password: string,
    phone: string,
    second_sub_branch: number
  }) {
    return baseAxios<{data: any}>({
      url: '/staff/add/same_level',
      method: 'post',
      data
    })
  }

  getBranch(data: {
    level: eLevel
    page?: number
    page_size?: number
    parent_id?: number
  }) {
    return baseAxios<{ item: { ID: number; Name: string }[]; total: number }>({
      url: '/staff/branch',
      method: 'get',
      params: data,
    })
  }
  
  deploy(data: {
    level: number,
    second_sub_branch: number,
    uuid: string
  }) {
    return baseAxios<{data: any}>({
      url: '/staff/deploy',
      method: 'put',
      data: data
    })
  }

  import(data: { staffs: iStaffItem[] }) {
    return baseAxios({
      url: '/staff/import',
      method: 'post',
      data,
    })
  }

  modifyStaffStatus(data: { status: eUserStatusAction; uuid: string }) {
    return baseAxios({
      url: '/staff/modifyStatus',
      method: 'PUT',
      data,
    })
  }

  getSelfOutLet() {
    return baseAxios<iOutLet>({
      url: '/staff/outlet',
      method: 'get',
    })
  }

  queryStaff(data: {
    end?: number,
    first_branch?: number,
    first_sub_branch?: number,
    level?: number,
    location?: string,
    page?: number,
    page_size?: number,
    phone?: string,
    second_branch?: number,
    second_sub_branch?: number,
    start?: number,
    user_name?: string,
    role?: string
  }) {
    return baseAxios({
      url: '/staff/query',
      method: 'get',
      params: data
    })
  }

  remarkStaff(data: {
    remark: string,
    uuid: string
  }) {
    return baseAxios({
      url: '/staff/remark/user',
      method: 'put',
      data
    })
  }

  getUserList(data: {
    page: number,
    page_size: number
  }) {
    return baseAxios({
      url: '/staff/self/users',
      method: 'get',
      params: data
    })
  }

  getNextLevel(data: {
    uuid: string,
    role: string
  }) {
    return baseAxios({
      url: '/staff/view',
      method: 'get',
      params: data
    })
  }

  getStaffList(data: {
      page: number,
      page_size: number,
      uuid: string
  }) {
    return baseAxios({
      url: '/staff/query/users',
      method: 'get',
      params: data
    })
  }

  getAcmList(data: {
    end?: number,
    phone?: string,
    user_name?: string,
    start?: number,
    uuid: string
  }) {
    return baseAxios({
      url: '/staff/query/acm/users',
      method: 'get',
      params: data
    })
  }

  deleteStaff(uuid: string) {
    return baseAxios({
      url: '/staff/' + uuid,
      method: 'delete',
    })
  }

  getBankList() {

  }

  

}
