import request from '@/utils/request'
import { download } from '@/utils/request'
export function listInvoice(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice/list',
    method: 'get',
    params: query
  })
}

export function getInvoice(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice/' + id,
    method: 'get'
  })
}

export function addInvoice(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice',
    method: 'post',
    data: data
  })
}

export function updateInvoice(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice',
    method: 'put',
    data: data
  })
}

export function delInvoice(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-sys'
  return request({
    url: '/business/invoice/' + id,
    method: 'delete'
  })
}
export function getCollectionToAmount(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice/getCollectionToAmount/' + id,
    method: 'get'
  })
}


export function getInfoByName(name) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  return request({
    url: '/business/invoice/getInfoByName/' + name,
    method: 'get'
  })
}


export function exportInfo(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-financial'
  download(
    "business/invoice/export",
    {
      ...query,
    },
    `发票数据导出_${new Date().getTime()}.xlsx`
  )
}