import { postJ, post, get } from "@/utils/request";
import Vue from "vue";


// 工单列表
export async function workorderPage(params) {
  const data = await postJ(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/page`, params, true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}


// 根据工单id获取工序列表

export async function getTaskInstanceList(id) {
  const data = await get(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/getTaskInstanceById/${id}`,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}

// 工单信息
export async function workorderInfo(id) {
  const data = await get(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/getById/${id}`,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}


// 根据工单ids获取工单列表

export async function workorderList(params) {
  const data = await postJ(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/list`, params, true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}


// 父级ID查询分类树
export async function  treeByPid(params) {
  const data = await get(
   Vue.prototype.apiUrl  + `/pda/main/categoryLevel/pdaTreeByPid`, params,  true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}



// 查询库存台账首页列表
export async function  pageeLedgerMain(params) {
  const data = await get(
   Vue.prototype.apiUrl  + `/wms/outin/getRealTimeInventory`, params,  true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}

// 资产台账
export async function  assetPage(params) {
  const data = await get(
   Vue.prototype.apiUrl  + `/main/asset/pdaPage`, params,  true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}




// 生产明细
export async function produceDetail(id) {
  const data = await get(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/produceDetail/${id}`,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}


// 工艺路线
export async function  producerouting(params) {
  const data = await get(
   Vue.prototype.apiUrl  + `/main/producerouting/page`, params,  true,
  );
  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}


// 扫码切换工单

export async function  getByCode(code) {
  const data = await get(
   Vue.prototype.apiUrl  + `/pda/mes/workorder/getByCode/${code}`
  );

  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}

// 扫码 获取台账

export async function  scanLedger(code) {
  const data = await get(
   Vue.prototype.apiUrl  + `/main/asset/getByCode/${code}`
  );

  if (data.code == 0) {
    return data.data;
  }
  return Promise.reject(data.message);
}



