import request from '@/utils/request';

// 通过方案ids获取质检项
export async function getQualityTemplateByIds(data) {
  const res = await request.post(
    `/qms/qualitytemplate/getQualityTemplateByIds`,
    data
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 列表

export async function getList(data) {
  let par = new URLSearchParams(data);
  const res = await request.get(`/qms/qualitytemplate/page?` + par, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function getWarehouseList(data) {
  const res = await request.post(`/wms/warehouse/select/warehouseList`, {
    params: { status: 1 }
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 查询工单详情
export async function getDetailById(id) {
  const res = await request.get(`/qms/quality_work_order/getDetailById/${id}`);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 查询计划详情
export async function planDetails(id) {
  const res = await request.get(`/qms/quality_plan/getDetailByld/${id}`);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//转派
export async function transferQualityWork(data) {
  const res = await request.post('/qms/quality_work_order/transfer', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
}
