import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ServiceMilestoneVO, ServiceMilestoneForm, ContractMilestoneVO, MilestoneDeliverForm } from './types';

// 查询服务包里程碑模板列表
export function listTemplate(packageId: number | string): AxiosPromise<ServiceMilestoneVO[]> {
  return request({ url: '/edu/milestone/template/' + packageId, method: 'get' });
}

// 新增里程碑模板
export function addTemplate(data: ServiceMilestoneForm) {
  return request({ url: '/edu/milestone/template', method: 'post', data });
}

// 修改里程碑模板
export function updateTemplate(data: ServiceMilestoneForm) {
  return request({ url: '/edu/milestone/template', method: 'put', data });
}

// 删除里程碑模板
export function delTemplate(ids: string | number | (string | number)[]) {
  return request({ url: '/edu/milestone/template/' + ids, method: 'delete' });
}

// 查询某合同的里程碑交付进度
export function listContractMilestone(contractId: number | string): AxiosPromise<ContractMilestoneVO[]> {
  return request({ url: '/edu/milestone/contract/' + contractId, method: 'get' });
}

// 推进里程碑交付
export function deliverMilestone(data: MilestoneDeliverForm) {
  return request({ url: '/edu/milestone/deliver', method: 'put', data });
}
