index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 fn = data.id ? putJ : postJ;
  7. const res = await fn(url, data);
  8. if (res.code == 0) return res.data;
  9. return Promise.reject(new Error(res.message));
  10. }
  11. // 局部修改(处理)
  12. export async function updatePartial(data) {
  13. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/updatePartial', data);
  14. if (res.code == 0) return res.data;
  15. return Promise.reject(new Error(res.message));
  16. }
  17. // 列表
  18. export async function getList(params) {
  19. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/page', params);
  20. if (res.code == 0) return res.data;
  21. return Promise.reject(new Error(res.message));
  22. }
  23. // 审批通过分页(处理列表)
  24. export async function pageApproved(params) {
  25. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/pageApproved', params);
  26. if (res.code == 0) return res.data;
  27. return Promise.reject(new Error(res.message));
  28. }
  29. // 详情
  30. export async function getById(id) {
  31. const res = await get(Vue.prototype.apiUrl + `/ehs/accidentIncidents/getById/${id}`);
  32. if (res.code == 0) return res.data;
  33. return Promise.reject(new Error(res.message));
  34. }
  35. // 删除
  36. export async function remove(data) {
  37. const res = await postJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/delete', data);
  38. if (res.code == 0) return res.data;
  39. return Promise.reject(new Error(res.message));
  40. }
  41. // 处理(废弃,使用updatePartial)
  42. export async function process(data) {
  43. const res = await putJ(Vue.prototype.apiUrl + '/ehs/accidentIncidents/process', data);
  44. if (res.code == 0) return res.data;
  45. return Promise.reject(new Error(res.message));
  46. }