index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {
  2. get,
  3. put,
  4. putJ,
  5. postJ,
  6. deleteApi
  7. } from "@/utils/request";
  8. import Vue from "vue";
  9. // 随手拍分页列表
  10. export async function getList(params) {
  11. const res = await get(Vue.prototype.apiUrl + '/ehs/safetyquickshot/page', params);
  12. if (res.code == 0) {
  13. return res.data;
  14. }
  15. return Promise.reject(new Error(res.message));
  16. }
  17. // 随手拍详情
  18. export async function getById(id) {
  19. const res = await get(Vue.prototype.apiUrl + `/ehs/safetyquickshot/getById/${id}`);
  20. if (res.code == 0) {
  21. return res.data;
  22. }
  23. return Promise.reject(new Error(res.message));
  24. }
  25. // 保存随手拍
  26. export async function save(data) {
  27. const res = await postJ(Vue.prototype.apiUrl + '/ehs/safetyquickshot/save', data);
  28. if (res.code == 0) {
  29. return res.data;
  30. }
  31. return Promise.reject(new Error(res.message));
  32. }
  33. // 更新随手拍
  34. export async function update(data) {
  35. const url = Vue.prototype.apiUrl + '/ehs/safetyquickshot/' + (data.id ? 'update' : 'save');
  36. const fn = data.id ? putJ : postJ;
  37. const res = await fn(url, data);
  38. if (res.code == 0) {
  39. return res.data;
  40. }
  41. return Promise.reject(new Error(res.message));
  42. }
  43. // 删除随手拍
  44. export async function remove(data) {
  45. const res = await deleteApi(Vue.prototype.apiUrl + '/ehs/safetyquickshot/delete', data);
  46. if (res.code == 0) {
  47. return res.data;
  48. }
  49. return Promise.reject(new Error(res.message));
  50. }
  51. // 处理/下发整改
  52. export async function handle(data) {
  53. const res = await postJ(Vue.prototype.apiUrl + '/ehs/safetyquickshot/handle', data);
  54. if (res.code == 0) {
  55. return res.data;
  56. }
  57. return Promise.reject(new Error(res.message));
  58. }
  59. // 废弃
  60. export async function discard(data) {
  61. const res = await postJ(Vue.prototype.apiUrl + '/ehs/safetyquickshot/discard', data);
  62. if (res.code == 0) {
  63. return res.data;
  64. }
  65. return Promise.reject(new Error(res.message));
  66. }