import request from '@/utils/request'

// 查询维保工单列表
export function listGxtOrder(query) {
  return request({
    url: '/gxt/order/list',
    method: 'get',
    params: query
  })
}

// 查询维保工单详细
export function getGxtOrder(id) {
  return request({
    url: '/gxt/order/' + id,
    method: 'get'
  })
}

// 新增维保工单
export function addGxtOrder(data) {
  return request({
    url: '/gxt/order',
    method: 'post',
    data: data
  })
}

// 修改维保工单
export function updateGxtOrder(data) {
  return request({
    url: '/gxt/order',
    method: 'put',
    data: data
  })
}

// 删除维保工单
export function delGxtOrder(id) {
  return request({
    url: '/gxt/order/' + id,
    method: 'delete'
  })
}

// 派单给班组组长
export function assignToTeamLeader(id, teamLeaderId, teamLeaderName) {
  return request({
    url: '/gxt/order/assignToTeamLeader/' + id,
    method: 'put',
    params: {
      teamLeaderId: teamLeaderId,
      teamLeaderName: teamLeaderName
    }
  })
}

// 班组组长接单
export function acceptByTeamLeader(id) {
  return request({
    url: '/gxt/order/acceptByTeamLeader/' + id,
    method: 'put'
  })
}

// 班组组长派单给工作组成员
export function assignToWorkGroupMember(id, workGroupMemberId, workGroupMemberName) {
  return request({
    url: '/gxt/order/assignToWorkGroupMember/' + id,
    method: 'put',
    params: {
      workGroupMemberId: workGroupMemberId,
      workGroupMemberName: workGroupMemberName
    }
  })
}

// 工作组成员接单
export function acceptByWorkGroupMember(id) {
  return request({
    url: '/gxt/order/acceptByWorkGroupMember/' + id,
    method: 'put'
  })
}

// 挂起工单
export function suspendWorkOrder(id, suspendReason) {
  return request({
    url: '/gxt/order/suspend/' + id,
    method: 'put',
    params: {
      suspendReason: suspendReason
    }
  })
}

// 重启工单
export function restartWorkOrder(id) {
  return request({
    url: '/gxt/order/restart/' + id,
    method: 'put'
  })
}

// 完成工单
export function completeWorkOrder(id) {
  return request({
    url: '/gxt/order/complete/' + id,
    method: 'put'
  })
}

// 查询工单流转记录
export function getWorkOrderFlow(orderId) {
  return request({
    url: '/gxt/order/flow/' + orderId,
    method: 'get'
  })
}

// 接单（支持一次性选择处理人员和检修人员）
export function acceptOrder(id, gxtWorkOrder) {
  return request({
    url: '/gxt/order/accept/' + id,
    method: 'post',
    data: gxtWorkOrder
  })
}
