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/salary/list',
    method: 'get',
    params: query
  })
}

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

// 查询工资详细
export function exportSalary(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  download(
    "business/salary/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 exportSalaryTemplateNotCompany() {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  download(
    "business/salary/exportSalaryTemplateNotCompany",
    {
    },
    `工资导入模板_${new Date().getTime()}.xlsx`
  )
}
// 新增工资
export function addSalary(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salary',
    method: 'post',
    data: data
  })
}

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

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

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

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

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


export function turnBackDetail(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-production'
  return request({
    url: '/business/salary/turnBackDetail',
    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 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/salary/physical/' + ids,
    method: 'delete'
  })
}