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

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

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

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

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

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

export function exportNextWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderNext/export",
    {
      ...query,
    },
    `下月工单导出_${new Date().getTime()}.xlsx`
  )
}
