import request from '@/utils/request'

export async function getProcessTypePageAPI(data) {
  const res = await request.post('/bpm/processtype/page', data);
  if (res.data.code == 0) {
    return res.data.data
  }
  return Promise.reject(new Error(res.data.message));
}

export async function processTypeSaveAPI(data) {
  const res = await request.post('/bpm/processtype/save', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function processTypeUpdateAPI(data) {

  const res = await request.put('/bpm/processtype/update', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function getProcessTypeGetByIdAPI(id) {
  const res = await request.get(`/bpm/processtype/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function processTypeDeleteAPI(data) {
  const res = await request.delete(`/bpm/processtype/delete`, {data});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function getProduceTreeByCode(code) {
  const res = await request.get(
    `/main/categoryLevel/getProduceTreeByPid?code=${code}`,
    {}
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
