import request from '@/config/axios'

export interface ProjectPlanningQuarterVO {
  id?: number
  planningId: number
  distributionYear: number
  quarterNo: number
  distributionRatio?: number
  distributionAmount?: number
  createTime?: string
}

export type ProjectPlanningQuarterSaveVO = Omit<
  ProjectPlanningQuarterVO,
  'distributionAmount' | 'createTime'
>

export const getProjectPlanningQuarter = (id: number) => {
  return request.get({ url: '/tjt/planning-quarter/get', params: { id } })
}

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

export const createProjectPlanningQuarter = (data: ProjectPlanningQuarterSaveVO) => {
  return request.post({ url: '/tjt/planning-quarter/create', data })
}

export const updateProjectPlanningQuarter = (data: ProjectPlanningQuarterSaveVO) => {
  return request.put({ url: '/tjt/planning-quarter/update', data })
}

export const deleteProjectPlanningQuarter = (id: number) => {
  return request.delete({ url: '/tjt/planning-quarter/delete', params: { id } })
}

export const deleteProjectPlanningQuarterList = (ids: number[]) => {
  return request.delete({
    url: '/tjt/planning-quarter/delete-list',
    params: { ids: ids.join(',') }
  })
}
