import request from '@/utils/request'
import { download, downloadPdf } from '@/utils/request'

// 查询工资列表
export function listSalary(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/list',
    method: 'get',
    params: query
  })
}

// 导出工资详细
export function exportSalary(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  download(
    "business/salaryZero/export",
    {
      ...data,
    },
    `工资导出_${new Date().getTime()}.xlsx`
  )
}

// 下载工资模板
export function exportSalaryTemplate() {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  download(
    "business/salary/exportSalaryTemplate",
    {
    },
    `工资零申报导入模板_${new Date().getTime()}.xlsx`
  )
}

// 查询工资详细
export function getSalary(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/' + id,
    method: 'get'
  })
}

// 新增工资
export function addSalary(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero',
    method: 'post',
    data: data
  })
}

export function exportSalaryEmployee(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  download(
    "business/salary/exportDetailExcel",
    {
      id: id
    },
    `工资表${new Date().getTime()}.xlsx`
  )
}

// 修改工资
export function updateSalary(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero',
    method: 'put',
    data: data
  })
}

// 删除工资
export function delSalary(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/' + id,
    method: 'delete'
  })
}

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

export function saveDetail(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/saveDetail',
    method: 'post',
    data: data
  })
}
export function updateDetail(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/updateDetail',
    method: 'post',
    data: data
  })
}

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


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

export function exportSalaryPdf(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  downloadPdf(
    "business/salary/printDetailPdf",
    {
      id: id
    },
    `工资表${new Date().getTime()}.pdf`
  )
}

export function delSalarys(ids) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salaryZero/physical/' + ids,
    method: 'delete'
  })
}