import request from '@/utils/request'

// 查询征用申请列表
export function listRequisition(query) {
  return request({
    url: '/resources/requisitions/list',
    method: 'get',
    params: query
  })
}

// 查询征用申请详细
export function getRequisition(id) {
  return request({
    url: '/resources/requisitions/' + id,
    method: 'get'
  })
}

// 根据队伍ID查询征用申请列表
export function listRequisitionsByTeam(teamId) {
  return request({
    url: '/resources/requisitions/team/' + teamId,
    method: 'get'
  })
}

// 新增征用申请
export function addRequisition(data) {
  return request({
    url: '/resources/requisitions',
    method: 'post',
    data: data
  })
}

// 修改征用申请
export function updateRequisition(data) {
  return request({
    url: '/resources/requisitions',
    method: 'put',
    data: data
  })
}

// 删除征用申请
export function delRequisition(ids) {
  return request({
    url: '/resources/requisitions/' + ids,
    method: 'delete'
  })
}

// 审批通过
export function approveRequisition(id, comment) {
  return request({
    url: '/resources/requisitions/' + id + '/approve',
    method: 'post',
    data: { comment }
  })
}

// 审批驳回
export function rejectRequisition(id, comment) {
  return request({
    url: '/resources/requisitions/' + id + '/reject',
    method: 'post',
    data: { comment }
  })
}

// 开始征用
export function startRequisition(id) {
  return request({
    url: '/resources/requisitions/' + id + '/start',
    method: 'post'
  })
}

// 结束征用
export function endRequisition(id) {
  return request({
    url: '/resources/requisitions/' + id + '/end',
    method: 'post'
  })
}

// 重新提交
export function resubmitRequisition(id) {
  return request({
    url: '/resources/requisitions/' + id + '/resubmit',
    method: 'post'
  })
}

// 查询征用协议列表
export function listRequisitionAgreements(requisitionId, query) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/agreements',
    method: 'get',
    params: query
  })
}

// 查询征用协议详细
export function getRequisitionAgreement(agreementId) {
  return request({
    url: '/resources/requisitions/agreements/' + agreementId,
    method: 'get'
  })
}

// 新增征用协议
export function addRequisitionAgreement(requisitionId, data) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/agreements',
    method: 'post',
    data: data
  })
}

// 修改征用协议
export function updateRequisitionAgreement(requisitionId, agreementId, data) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/agreements/' + agreementId,
    method: 'put',
    data: data
  })
}

// 删除征用协议
export function delRequisitionAgreement(requisitionId, agreementId) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/agreements/' + agreementId,
    method: 'delete'
  })
}

// 查询补偿记录列表
export function listRequisitionCompensations(requisitionId, query) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/compensations',
    method: 'get',
    params: query
  })
}

// 查询补偿记录详细
export function getRequisitionCompensation(compensationId) {
  return request({
    url: '/resources/requisitions/compensations/' + compensationId,
    method: 'get'
  })
}

// 新增补偿记录
export function addRequisitionCompensation(requisitionId, data) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/compensations',
    method: 'post',
    data: data
  })
}

// 修改补偿记录
export function updateRequisitionCompensation(requisitionId, compensationId, data) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/compensations/' + compensationId,
    method: 'put',
    data: data
  })
}

// 删除补偿记录
export function delRequisitionCompensation(requisitionId, compensationId) {
  return request({
    url: '/resources/requisitions/' + requisitionId + '/compensations/' + compensationId,
    method: 'delete'
  })
}

// 结算补偿
export function settleCompensation(compensationId, invoiceNo, paidAt) {
  return request({
    url: '/resources/requisitions/compensations/' + compensationId + '/settle',
    method: 'post',
    data: { invoiceNo, paidAt }
  })
}

