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

// 查询本月委托
export function listCurrentWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderCurrent/list',
    method: 'get',
    params: query
  })
}

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

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

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

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

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

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

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

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



export function listHistory(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  return request({
    url: '/business/workOrderCurrent/history/list',
    method: 'get',
    params: query
  })
}
export function exportStore(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderCurrent/exportStore",
    {
      ...query,
    },
    `本月工单导出_${new Date().getTime()}.xlsx`
  )
}
export function exportNextStore(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderCurrent/exportNextStore",
    {
      ...query,
    },
    `下月工单导出_${new Date().getTime()}.xlsx`
  )
}
export function exportFactory(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderCurrent/exportFactory",
    {
      ...query,
    },
    `本月工单导出_${new Date().getTime()}.xlsx`
  )
}
export function exportNextFactory(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-entrust'
  download(
    "business/workOrderCurrent/exportNextFactory",
    {
      ...query,
    },
    `下月工单导出_${new Date().getTime()}.xlsx`
  )
}