import request from '@/utils/request';



// 查询仓库下拉列表
export async function getWarehouseList() {
    const res = await request.post(`/wms/warehouse/getWarehouseList`, {});
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  
 

// 根据当前用户id查询他的负责工序
  export async function listTask(data) {
    const res = await request.get('/main/producetask/listTaskByUserId', {
      params: data
    });
    if (res.data.code == 0) {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  


  // bom 信息

  export async function getByTaskId(data) {
    const res = await request.get(`/main/categoryparam/getByTaskId`, { params: data });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  
  export async function pcCheckOutsource(data) {
    const res = await request.get(`/mes/applyoutsource/pcCheckOutsource`, { params: data });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  
  export async function getTaskInstanceById(data) {
    const res = await request.get(`/pda/mes/workorder/getTaskInstanceById/${data}`);
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  

  export async function checkOutsourceMaterial(data) {
    const res = await request.get(`/mes/applyoutsource/checkOutsourceMaterial`, { params: data });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  

  export async function pdaTreeByPid(data) {
    const res = await request.get(`/api/main/asset/pdaPage`, { params: data });
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }

  export async function applyoutsourceSave(data) {
    const res = await request.post(`/mes/applyoutsource/save`, data );
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }

  export async function outInDetailPdaPage(data) {
    const res = await request.get(`/main/asset/pdaPage`, { params: data });
    if (res.data.code == '0') {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }



  export async function producerouting(data) {
    const res = await request.get(`/main/producerouting/page`, { params: data });
    if (res.data.code == '0') {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  
  export async function categoryGetList(data) {
    const res = await request.get(`/main/category/getList`, { params: data });
    if (res.data.code == '0') {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  export async function factoryworkstationPage(data) {
    const res = await request.get(`/main/factoryworkstation/page`, { params: data });
    if (res.data.code == '0') {
      return res.data.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  
  export async function nextTask(data) {
    const res = await request.post(`/mes/workorder/nextTask`, data );
    if (res.data.code == 0) {
      return res.data;
    }
    return Promise.reject(new Error(res.data.message));
  }
  // http://localhost:8084/api/main/asset/pdaPage?categoryLevelId=9&keyWord=&pageNum=1&size=100&taskId=1894207928134549506