import request from '@/config/axios'

export interface SpecialtyRolePersonVO {
  employeeId?: number
  employeeName?: string
  personRatio?: number
  personAmount?: number
}

export interface SpecialtyRoleSplitVO {
  id?: number
  outputSplitId?: number
  planningId?: number
  projectName?: string
  planningContent?: string
  specialtyCode: string
  specialtyName?: string
  specialtyAmount?: number
  roleCode: string
  roleName?: string
  roleRatio: number
  roleAmount?: number
  persons?: SpecialtyRolePersonVO[]
  sortNo?: number
}

export interface SpecialtyRoleSplitSaveItemVO {
  specialtyCode: string
  roleCode: string
  roleRatio: number
  persons: SpecialtyRolePersonVO[]
}

export interface SpecialtyRoleSplitBatchSaveVO {
  planningId: number
  items: SpecialtyRoleSplitSaveItemVO[]
}

export const getSpecialtyRoleSplitListByPlanningId = (planningId: number) => {
  return request.get({ url: '/tjt/specialty-role-split/list-by-planning', params: { planningId } })
}

export const saveSpecialtyRoleSplitBatch = (data: SpecialtyRoleSplitBatchSaveVO) => {
  return request.put({ url: '/tjt/specialty-role-split/save-batch', data })
}
