import request from '@/utils/request';

// 获取列表
export async function getGroupPage (data) {
  const res = await request.get('/main/categorylevelgroup/page', {
    params: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 新建保存
export async function saveItemGroup (data) {
  const res = await request.post('/main/categorylevelgroup/save', data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}


// 编辑
export async function updateItemGroup(data) {
    const res = await request.put(`/main/categorylevelgroup/update`, data);
    if (res.data.code == 0) {
        return res.data.message;
    }
    return Promise.reject(new Error(res.data.message));
}

// 删除
export async function removeItem (data) {
  const res = await request.delete('/main/categorylevelgroup/delete', { data });
  if (res.data.code == 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

// SAP-物料同步
export async function syncMateriel () {
  const res = await request.get('/sap/sync/syncMateriel');
  if (res.data.code == 0) {
    return res.data.code;
  }
  return Promise.reject(new Error(res.data.message));
}