import request from '@/config/axios'

// 生产班组 VO
export interface WorkTeamVO {
  id: number // ID
  teamName: string // 班组名称
  teamLeaderId: number // 组长ID
  teamType: string // 工序类型
  startTime: Date
  endTime: Date
  remark: string // 备注
  isEnable: boolean // 是否启用
}

// 生产班组 API
export const WorkTeamApi = {
  // 查询生产班组分页
  getWorkTeamPage: async (params: any) => {
    return await request.get({ url: `/mes/work-team/page`, params })
  },

  // 查询生产班组详情
  getWorkTeam: async (id: number) => {
    return await request.get({ url: `/mes/work-team/get?id=` + id })
  },

  // 新增生产班组
  createWorkTeam: async (data: WorkTeamVO) => {
    return await request.post({ url: `/mes/work-team/create`, data })
  },

  // 修改生产班组
  updateWorkTeam: async (data: WorkTeamVO) => {
    return await request.put({ url: `/mes/work-team/update`, data })
  },

  // 删除生产班组
  deleteWorkTeam: async (id: number) => {
    return await request.delete({ url: `/mes/work-team/delete?id=` + id })
  },

  // 导出生产班组 Excel
  exportWorkTeam: async (params) => {
    return await request.download({ url: `/mes/work-team/export-excel`, params })
  },

// ==================== 子表（班组成员） ====================

  // 获得班组成员分页
  getWorkTeamDetailPage: async (params) => {
    return await request.get({ url: `/mes/work-team/work-team-detail/page`, params })
  },
  // 新增班组成员
  createWorkTeamDetail: async (data) => {
    return await request.post({ url: `/mes/work-team/work-team-detail/create`, data })
  },

  // 修改班组成员
  updateWorkTeamDetail: async (data) => {
    return await request.put({ url: `/mes/work-team/work-team-detail/update`, data })
  },

  // 删除班组成员
  deleteWorkTeamDetail: async (id: number) => {
    return await request.delete({ url: `/mes/work-team/work-team-detail/delete?id=` + id })
  },

  // 获得班组成员
  getWorkTeamDetail: async (id: number) => {
    return await request.get({ url: `/mes/work-team/work-team-detail/get?id=` + id })
  },
  // 获得班组成员
  getUserList: async (processType: string, groupType:string) => {
    return await request.get({ url: `/mes/work-team/work-team-detail/getUserList?processType=` + processType+`&&groupType=`+groupType })
  },
  // 获得班组成员
  getUserList2: async (orgId: number, groupType:string) => {
    return await request.get({ url: `/mes/work-team/work-team-detail/getUserList2?orgId=` + orgId+`&&groupType=`+groupType })
  },
}
