import request from '@/utils/request';

export async function getCBomAPI(params) {
  const res = await request.get('/main/bomCategory/cBom', { params });
  console.log(res);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 动态表头
export async function fieldModelAPI(params) {
  const res = await request.get(`/main/fieldmodel/list`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.resolve([]);
}
//获取设备台账
export async function assetPageAPI(params) {
  const res = await request.get('/main/asset/page', { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//条件查询工厂
export async function getFactoryarea(params) {
  const res = await request.get('/main/factoryarea/page', { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 参数设置
 * @param params 查询条件
 */
export async function parameterPageList(params) {
  const res = await request.get('/sys/parameter/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//获取系统参数
export async function parameterGetByCode(data) {
  const res = await request.post('/sys/parameter/getByCode', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 首页统计

 */
export async function indexGroup() {
  const res = await request.get('/eom/saleorder/indexGroup');
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
