import request from '@/utils/request';



// 保存or更新
export async function save(data) {
  const res = await request.post(`/eam/management_template/` + (data.id ? 'update' : 'add'), data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 列表
 */
export async function getList(data) {
  const res = await request.post('/eam/management_template/page', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 保存or更新
export async function saveTemplate(data) {
  const res = await request.post(`/eam/disposal_template_list/` + (data.id ? 'update' : 'add'), data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//删除
export async function remove(data) {
  const res = await request.delete(`/eam/management_template/remove`, { data });
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 列表
 */
export async function getDisposalList(data) {
  const res = await request.post('/eam/disposal_management_template/page', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 保存or更新
export async function saveDisposal(data) {
  const res = await request.post(`/eam/disposal_management_template/` + (data.id ? 'update' : 'add'), data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//删除
export async function removeDisposal(data) {
  const res = await request.delete(`/eam/disposal_management_template/remove`, { data });
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// // 详情
export async function detailsId(id) {
  const res = await request.get(`/eam/spare_parts_apply/detailsId/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 模板列表
 */
export async function templateList(data) {
  const res = await request.post('/eam/disposal_template_list/page', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
//模板删除
export async function removeTemplate(data) {
  const res = await request.delete(`/eam/disposal_template_list/remove`, { data });
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 流程列表
 */
export async function bpmPage(params) {
  const res = await request.get('/bpm/model/page', { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 提交
 */
 export async function submit (data) {
  const res = await request.post('/bpm/disposalManagement/submit', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


