index.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { get, put, putJ, postJ, deleteApi } from "@/utils/request";
  2. import Vue from "vue";
  3. // 保存或更新(根据是否有id)
  4. export async function save(data) {
  5. const url = Vue.prototype.apiUrl + '/ehs/invhazard/' + (data.id ? 'update' : 'save');
  6. const fn = data.id ? putJ : postJ;
  7. const res = await fn(url, data);
  8. if (res.code == 0) {
  9. return res.data;
  10. }
  11. return Promise.reject(new Error(res.message));
  12. }
  13. // 整改
  14. export async function rectify(data) {
  15. const res = await putJ(Vue.prototype.apiUrl + '/ehs/invhazard/rectify', data);
  16. if (res.code == 0) {
  17. return res.data;
  18. }
  19. return Promise.reject(new Error(res.message));
  20. }
  21. // 验收
  22. export async function accept(data) {
  23. const res = await putJ(Vue.prototype.apiUrl + '/ehs/invhazard/accept', data);
  24. if (res.code == 0) {
  25. return res.data;
  26. }
  27. return Promise.reject(new Error(res.message));
  28. }
  29. // 分页列表
  30. export async function getList(params) {
  31. const res = await get(Vue.prototype.apiUrl + '/ehs/invhazard/page', params);
  32. if (res.code == 0) {
  33. return res.data;
  34. }
  35. return Promise.reject(new Error(res.message));
  36. }
  37. // 详情
  38. export async function getById(id) {
  39. const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/getById/${id}`);
  40. if (res.code == 0) {
  41. return res.data;
  42. }
  43. return Promise.reject(new Error(res.message));
  44. }
  45. // 删除
  46. export async function remove(data) {
  47. const res = await deleteApi(Vue.prototype.apiUrl + '/ehs/invhazard/delete', data);
  48. if (res.code == 0) {
  49. return res.data;
  50. }
  51. return Promise.reject(new Error(res.message));
  52. }
  53. // 校验当前登录人是否为验收人
  54. export async function checkAcceptor(id) {
  55. const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/checkAcceptor/${id}`);
  56. if (res.code == 0) {
  57. return res.data;
  58. }
  59. return Promise.reject(new Error(res.message));
  60. }
  61. // 校验当前登录人是否为整改人
  62. export async function checkRectifier(id) {
  63. const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/checkRectifier/${id}`);
  64. if (res.code == 0) {
  65. return res.data;
  66. }
  67. return Promise.reject(new Error(res.message));
  68. }