import request from '@/utils/request';

// 一键报工，新增或修改填写表单类型的执行记录，并修改状态为已执行
export async function saveOrUpdateAndSubmit(body) {
  const res = await request.post(
    '/mes/producetaskrulerecord/saveOrUpdateAndSubmit',
    body
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 缓存，新增或修改填写表单类型的执行记录
export async function saveOrUpdate(body) {
  const res = await request.post(
    '/mes/producetaskrulerecord/saveOrUpdate',
    body
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 一键报工，新增或修改填写表单类型的执行记录，并修改状态为已执行
export async function logicDelete(id) {
  const res = await request.delete(
    '/mes/producetaskrulerecord/logicDeleteById/' + id
  );
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function getById(id) {
  const res = await request.get('/mes/producetaskrulerecord/getById/' + id);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
