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

// 查询工单管理列表
export function listWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder/list',
    method: 'get',
    params: query
  })
}
export function OrderDisable(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder/OrderDisable',
    method: 'post',
    data: query
  })
}
// 查询工单管理列表
export function indexList(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder/indexList',
    method: 'get',
    params: query
  })
}
export function completeUpgrade() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/upgrade/crm/order/completeUpgrade',
    method: 'post',
    timeout: 1000000,
  })
}
export function checkWorkOrder() {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/upgrade/crm/order/checkWorkOrder',
    method: 'post'
  })
}
// 查询工单管理详细
export function getWorkOrder(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder/' + id,
    method: 'get'
  })
}

// 修改是否延续
export function setContract(ids, state) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder' + ids + "/" + state,
    method: 'post'
  })
}

// 新增工单管理
export function addWorkOrder(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder',
    method: 'post',
    data: data
  })
}

// 修改工单管理
export function updateWorkOrder(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/upgrade/workorder/updatestartmonth',
    method: 'post',
    data: data
  })
}

// 删除工单管理
export function delWorkOrder(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder/' + id,
    method: 'delete'
  })
}

export function exportWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  download(
    "/business/upgrade/workorder/export",
    {
      ...query,
    },
    `合同工单导出_${new Date().getTime()}.xlsx`
  )
}

export function exportNoContract(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  download(
    "/business/upgrade/workorder/export",
    {
      ...query,
    },
    `未匹配工单.xlsx`
  )
}


export function setWorkOrderService(data) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder/setService',
    method: 'post',
    data: data
  })
}
