import { getBillInvoiceList, updateBillNameAndBillExplainAndEndDate, getBillByIdInfo, deleteBillInvoiceById, billInvoiceOfflinePayment, updateBillInvoiceStatus, addTempBillInvoice, getTempBillInvoice, deleteTempBillInvoice, updateBillInvoiceIdPayPrice, exportExcel, billInvoiceGetInvoiceInvalid, updateBillInvoiceIdBillInvoiceExplain } from '@/api/billInvoice'

const billInvoice = {
  state: {

  },
  mutations: {

  },
  actions: {
    GetBillInvoiceList({ commit }, data) { // // 查询缴费单
      return new Promise((resolve, reject) => {
        getBillInvoiceList(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    UpdateBillNameAndBillExplainAndEndDate({ commit }, data) { // 修改缴费项 收费项名称,缴费项说明,截止时间
      return new Promise((resolve, reject) => {
        updateBillNameAndBillExplainAndEndDate(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    GetBillByIdInfo({ commit }, id) { // 根据 id 查询 缴费项信息
      return new Promise((resolve, reject) => {
        getBillByIdInfo(id).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    DeleteBillInvoiceById({ commit }, data) { // 根据 id 集合批量删除
      return new Promise((resolve, reject) => {
        deleteBillInvoiceById(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    BillInvoiceOfflinePayment({ commit }, data) { // 设置线下缴费
      return new Promise((resolve, reject) => {
        billInvoiceOfflinePayment(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    UpdateBillInvoiceStatus({ commit }, data) { // 由前台批量添加收费单, 默认定为 作废
      return new Promise((resolve, reject) => {
        updateBillInvoiceStatus(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    AddTempBillInvoice({ commit }, data) { // 由前台批量添加收费单, 进行统一的提交, 修改为有效
      return new Promise((resolve, reject) => {
        addTempBillInvoice(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    GetTempBillInvoice({ commit }, billId) { // 查询前台批量添加的收费单, 状态是作废
      return new Promise((resolve, reject) => {
        getTempBillInvoice(billId).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    DeleteTempBillInvoice({ commit }, billId) { // 根据id删除收费单, 只能删除作废的
      return new Promise((resolve, reject) => {
        deleteTempBillInvoice(billId).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    UpdateBillInvoiceIdPayPrice({ commit }, data) { // 根据缴费单id, 修改金额
      return new Promise((resolve, reject) => {
        updateBillInvoiceIdPayPrice(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    ExportBillInvoiceExcel({ commit }, billId) { // 下载excel
      return new Promise((resolve, reject) => {
        exportExcel(billId).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    BillInvoiceGetInvoiceInvalid({ commit }, data) { // 根据缴费项id, 查询草稿
      return new Promise((resolve, reject) => {
        billInvoiceGetInvoiceInvalid(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    UpdateBillInvoiceIdBillInvoiceExplain({ commit }, data) { // 根据收费单id, 修改收费说明
      return new Promise((resolve, reject) => {
        updateBillInvoiceIdBillInvoiceExplain(data).then(response => {
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default billInvoice
