import request from '@/utils/request'
const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
import { download, downloadPdf } from '@/utils/request'

// 查询外协结算列表
export function listBalanceAccount(query) {
  return request({
    url: baseUrl + '/business/balanceAccount/list',
    method: 'get',
    params: query
  })
}

// 查询外协结算详细
export function getBalanceAccount(id) {
  return request({
    url: baseUrl + '/business/balanceAccount/' + id,
    method: 'get'
  })
}

// 新增外协结算
export function addBalanceAccount(data) {
  return request({
    url: baseUrl + '/business/balanceAccount',
    method: 'post',
    data: data
  })
}

// 修改外协结算
export function updateBalanceAccount(data) {
  return request({
    url: baseUrl + '/business/balanceAccount',
    method: 'put',
    data: data
  })
}

// 删除外协结算
export function delBalanceAccount(id) {
  return request({
    url: baseUrl + '/business/balanceAccount/' + id,
    method: 'delete'
  })
}
// 结算
export function checkout(data) {
  return request({
    url: baseUrl + '/business/balanceAccount/confirm',
    method: 'post',
    data: data
  })
}
// 取消结算
export function discheckout(data) {
  return request({
    url: baseUrl + '/business/balanceAccount/cancel',
    method: 'post',
    data: data
  })
}
export function saveBatchBalanceAccount(data) {
  return request({
    url: baseUrl + '/business/balanceAccount/saveBatch',
    method: 'post',
    data: data
  })
}

// 导出
export function exportBalanceAccount(data) {
  download(
    baseUrl + "/business/balanceAccount/export",
    {
      ...data,
    },
    `外协结算_${new Date().getTime()}.xlsx`
  )
}
