import {get, post, uploadFilePromise} from "@/util/request";
import {Page} from "@/common/consts/CommonConst";

export const uploadOrderFile = async (file) => {
  return await uploadFilePromise("/file/cloud/upload", file, {
    path: "aiot",
    fileType: "工单"
  })
}


export const getMyOrderWork = async ({page = Page.page, size = Page.size, ...params}) => {
  return await post('/orderWork/myPage', {
    page,
    size,
    ...params
  });
}
export const getMyOrderWorkTodo = async ({page = Page.page, size = Page.size, ...params}) => {
  return await post('/orderWork/todoPage', {
    page,
    size,
    ...params
  });
}
export const getWorkOrderDetail = async (id) => {
  return await get(`/orderWork/getDetail/${id}`)
}

export const getWorkOrderSteps = async (id) => {
  return await get(`/orderWork/getHistory/${id}`)
}

/**
 * 提交工单
 * {"name":"CC","type":1,"level":2,"estimatedStartTime":"2024-11-29 00:00:00","estimatedEndTime":"2024-11-30 00:00:00","description":"fffssscccsss","source":3,"problemImg":"[{\"name\":\"login_bg.png\",\"url\":\"http://172.192.10.105:30011/aiot/aiot/202411/aiot/aiot/1732759747878/login_bg.png\",\"uid\":1732759748425,\"status\":\"success\"}]","problemFile":null}
 * @param params
 * @returns {Promise<*>}
 */
export const submitOrderWork = async (params) => {
  return await post('/orderWork/save', params);
}

export const scrapWorkOrder = async (id) => {
  return await get(`/orderWork/scrap/${id}`)
}
export const handleWorkOrder = async (id) => {
  return await get(`/orderWork/handle/${id}`)
}

export const assignWorkOrder = async (param) => {
  return await post(`/orderWork/assign`, param)
}


export const endWorkOrder = async (param) => {
  return await post(`/orderWork/end`, param)
}

