import request from '@/utils/request'

/** 查询工单列表 */
export function listWorkOrder(queryParams, pageNum = 1, pageSize = 10) {
  return request({
    url: '/api/work-order/list',
    method: 'get',
    params: { ...queryParams, pageNum, pageSize }
  })
}

/** 查询工单详情（含操作日志） */
export function getWorkOrderDetail(orderId) {
  return request({
    url: '/api/work-order/' + orderId,
    method: 'get'
  })
}

/** 派单操作 */
export function dispatchWorkOrder(data) {
  return request({
    url: '/api/work-order/dispatch',
    method: 'post',
    data
  })
}

/** 核查操作 */
export function verifyWorkOrder(data) {
  return request({
    url: '/api/work-order/verify',
    method: 'put',
    data
  })
}

/** 接单操作 */
export function acceptWorkOrder(orderId) {
  return request({
    url: '/api/work-order/accept',
    method: 'put',
    params: { orderId }
  })
}

/** 开始处理操作 */
export function startWorkOrder(orderId) {
  return request({
    url: '/api/work-order/start',
    method: 'put',
    params: { orderId }
  })
}

/** 驳回验收 */
export function rejectWorkOrder(data) {
  return request({
    url: '/api/work-order/reject',
    method: 'put',
    data
  })
}

/** 处理操作 */
export function processWorkOrder(data) {
  return request({
    url: '/api/work-order/process',
    method: 'put',
    data
  })
}

/** 完成/提交验收，提交维修后图片 */
export function completeWorkOrder(data) {
  return request({
    url: '/api/work-order/complete',
    method: 'put',
    data
  })
}

/** 新增工单（手动建单） */
export function addWorkOrder(data) {
  return request({
    url: '/api/work-order/add',
    method: 'post',
    data
  })
}

/** 取消工单 */
export function cancelWorkOrder(orderId) {
  return request({
    url: '/api/work-order/' + orderId,
    method: 'delete'
  })
}

/** 验收通过/结案 */
export function closeWorkOrder(data) {
  return request({
    url: '/api/work-order/close',
    method: 'put',
    data
  })
}
