index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { get, postJ, putJ, deleteApi } from "@/utils/request";
  2. import Vue from "vue";
  3. // 保存或更新
  4. export async function save(data) {
  5. const url = Vue.prototype.apiUrl + '/ehs/accidentIncidents/' + (data.id ? 'update' : 'save');
  6. const res = await postJ(url, data);
  7. if (res.code == 0) return res.data;
  8. return Promise.reject(new Error(res.message));
  9. }
  10. // 局部修改(处理)
  11. export async function updatePartial(data) {
  12. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/updatePartial', data);
  13. if (res.code == 0) return res.data;
  14. return Promise.reject(new Error(res.message));
  15. }
  16. // 列表
  17. export async function getList(params) {
  18. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/page', params);
  19. if (res.code == 0) return res.data;
  20. return Promise.reject(new Error(res.message));
  21. }
  22. // 审批通过分页(处理列表)
  23. export async function pageApproved(params) {
  24. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/pageApproved', params);
  25. if (res.code == 0) return res.data;
  26. return Promise.reject(new Error(res.message));
  27. }
  28. // 详情
  29. export async function getById(id) {
  30. const res = await get(Vue.prototype.apiUrl + `/ehs/accidentIncidents/getById/${id}`);
  31. if (res.code == 0) return res.data;
  32. return Promise.reject(new Error(res.message));
  33. }
  34. // 删除
  35. export async function remove(data) {
  36. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/delete', data);
  37. if (res.code == 0) return res.data;
  38. return Promise.reject(new Error(res.message));
  39. }
  40. // 处理(废弃,使用updatePartial)
  41. export async function process(data) {
  42. const res = await putJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/process', data);
  43. if (res.code == 0) return res.data;
  44. return Promise.reject(new Error(res.message));
  45. }