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

// 查询工单管理列表
export function listWorkOrder(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder/list',
    method: 'get',
    params: query
  })
}

// 查询工单管理列表
export function indexList(query) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder/indexList',
    method: 'get',
    params: query
  })
}

// 查询工单管理详细
export function getWorkOrder(id) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/workOrder/' + id,
    method: 'get'
  })
}

// 修改是否延续
export function setContract(ids, state) {
  request.defaults.baseURL = '/ezhizao-yzbh-crm'
  return request({
    url: '/business/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/workOrder',
    method: 'put',
    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/workOrder/export",
    {
      ...query,
    },
    `合同工单导出_${new Date().getTime()}.xlsx`
  )
}

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


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