import request from '@/utils/request'
import { download } from '@/utils/request'
// 查询本月委托
export function listOnceWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/list',
    method: 'get',
    params: query
  })
}

// 查询本月委托
export function listFactoryOnceWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/listForFactory',
    method: 'get',
    params: query
  })
}
// 判断是否设定当期
export function checkCurrent() {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/checkCurrent',
    method: 'get'
  })
}

// 初始化当期
export function initCurrentMonth(params) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/initCurrent',
    method: 'get',
    params: params
  })
}

// 添加委托
export function addEntrust(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/addEntrust',
    method: 'post',
    data: data
  })
}

// 删除委托
export function delEntrust(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/delEntrust',
    method: 'post',
    data: data
  })
}

export function getFactories() {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/getFactories',
    method: 'get'
  })
}

export function exportOnceWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderOnce/export",
    {
      ...query,
    },
    `单次任务导出_${new Date().getTime()}.xlsx`
  )
}

export function transNext() {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderOnce/transNext',
    method: 'get'
  })
}