import request from '@/utils/httpRequest'

export default class CwFinanceInvoiceService {
  list (params) {
    return request({
      url: '/cw_finance/invoice/list',
      method: 'get',
      params: params
    })
  }
  queryById (id) {
    return request({
      url: '/cw_finance/invoice/queryById',
      method: 'get',
      params: {id: id}
    })
  }
  queryByNumber (number, id) {
    return request({
      url: '/cw_finance/invoice/queryByNumber',
      method: 'get',
      params: {number: number, id: id}
    })
  }
  save (inputForm) {
    return request({
      url: `/cw_finance/invoice/save`,
      method: 'post',
      data: inputForm
    })
  }
  delete (ids) {
    return request({
      url: '/cw_finance/invoice/delete',
      method: 'delete',
      params: {ids: ids}
    })
  }
  updateStatusById (data) {
    return request({
      url: '/cw_finance/invoice/updateStatusById',
      method: 'post',
      data: data
    })
  }
  isReceivables (data) {
    return request({
      url: '/cw_finance/invoice/isReceivables',
      method: 'post',
      data: data
    })
  }
  saveForm (inputForm) {
    return request({
      url: `/cw_finance/invoice/saveForm`,
      method: 'post',
      data: inputForm
    })
  }
  saveFormInvalid (inputForm) {
    return request({
      url: `/cw_finance/invoice/saveFormInvalid`,
      method: 'post',
      data: inputForm
    })
  }
  queryIdByInvalidId (id) {
    return request({
      url: '/cw_finance/invoice/queryIdByInvalidId',
      method: 'get',
      params: {id: id}
    })
  }
  importDetail (data) {
    return request({
      url: '/cw_finance/invoice/importDetail',
      method: 'post',
      data: data
    })
  }
  exportTemplate () {
    return request({
      url: '/cw_finance/invoice/importDetail/template',
      method: 'get',
      responseType: 'blob'
    })
  }
  getByIds (projectId, invoiceForm) {
    return request({
      url: '/cw_finance/invoice/getByIds',
      method: 'get',
      params: {projectId: projectId, ...invoiceForm}
    })
  }
  getByContractId (contractId, invoiceForm) {
    return request({
      url: '/cw_finance/invoice/getByContractId',
      method: 'get',
      params: {contractId: contractId, ...invoiceForm}
    })
  }
  getIdByClientId (clientId, invoiceForm) {
    return request({
      url: '/cw_finance/invoice/getIdByClientId',
      method: 'get',
      params: {clientId: clientId, ...invoiceForm}
    })
  }
  exportFile (params) {
    return request({
      url: '/cw_finance/invoice/export',
      method: 'get',
      params: params,
      responseType: 'blob'
    })
  }
}
