import request from '@/config/axios'

export interface ProjectPlanningVO {
  id?: number
  projectId: number
  ownershipType: string
  calculationMethod: string
  planningContent: string
  planningAmount?: number
  managementFeeRate?: number
  managementFee?: number
  implementationTeam?: string
  planningStartYear?: number
  planningArea?: number
  designStage?: string
  currentDesignStageRatio?: number
  reviewOutsourceFlag?: boolean
  reviewOutsourceRatio?: number
  totalDistributionAmount?: number
  progressRemark?: string
  allocatedAmount?: number
  pendingAmount?: number
  buildingOrUnitCount?: number
  drawingSetFactor?: number
  scaleFactor?: number
  modificationFactor?: number
  complexityFactor?: number
  internalGuidanceUnitPrice?: number
  virtualCalculationMethod?: string
  workingDayCount?: number
  workingDayUnitPrice?: number
  guidanceUnitPrice?: number
  guidanceTotalPrice?: number
  calculationRatio?: number
  contractUnitPrice?: number
  totalAdjustmentFactor?: number
  assessmentArea?: number
  virtualOutputValue?: number
  assessmentOutputValue?: number
  createTime?: string
}

export type ProjectPlanningSaveVO = Omit<
  ProjectPlanningVO,
  | 'allocatedAmount'
  | 'pendingAmount'
  | 'managementFee'
  | 'contractUnitPrice'
  | 'totalAdjustmentFactor'
  | 'assessmentArea'
  | 'virtualOutputValue'
  | 'assessmentOutputValue'
  | 'createTime'
>

export interface ProjectPlanningPageReqVO extends PageParam {
  projectId?: number
  ownershipType?: string
  calculationMethod?: string
  planningContent?: string
  planningStartYear?: number
  createTime?: string[]
}

export const getProjectPlanningPage = (params: ProjectPlanningPageReqVO) => {
  return request.get({ url: '/tjt/planning/page', params })
}

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

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

export const createProjectPlanning = (data: ProjectPlanningSaveVO) => {
  return request.post({ url: '/tjt/planning/create', data })
}

export const updateProjectPlanning = (data: ProjectPlanningSaveVO) => {
  return request.put({ url: '/tjt/planning/update', data })
}

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

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