import { get, put, putJ, postJ, deleteApi } from "@/utils/request"; import Vue from "vue"; // 保存或更新(根据是否有id) export async function save(data) { const url = Vue.prototype.apiUrl + '/ehs/invhazard/' + (data.id ? 'update' : 'save'); const fn = data.id ? putJ : postJ; const res = await fn(url, data); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 整改 export async function rectify(data) { const res = await putJ(Vue.prototype.apiUrl + '/ehs/invhazard/rectify', data); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 验收 export async function accept(data) { const res = await putJ(Vue.prototype.apiUrl + '/ehs/invhazard/accept', data); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 分页列表 export async function getList(params) { const res = await get(Vue.prototype.apiUrl + '/ehs/invhazard/page', params); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 详情 export async function getById(id) { const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/getById/${id}`); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 删除 export async function remove(data) { const res = await deleteApi(Vue.prototype.apiUrl + '/ehs/invhazard/delete', data); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 校验当前登录人是否为验收人 export async function checkAcceptor(id) { const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/checkAcceptor/${id}`); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); } // 校验当前登录人是否为整改人 export async function checkRectifier(id) { const res = await get(Vue.prototype.apiUrl + `/ehs/invhazard/checkRectifier/${id}`); if (res.code == 0) { return res.data; } return Promise.reject(new Error(res.message)); }