48 lines
2.0 KiB
JavaScript
48 lines
2.0 KiB
JavaScript
|
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||
|
|
import {
|
||
|
|
fromEquipForm,
|
||
|
|
fromPageResponse,
|
||
|
|
fromSingleResponse,
|
||
|
|
toEquipForm,
|
||
|
|
toPageQuery,
|
||
|
|
} from "../enterpriseInfo/adapter";
|
||
|
|
import { apiGet, apiPost, apiPostDelete, safeAction, safePageResult } from "../enterpriseInfo/http";
|
||
|
|
|
||
|
|
export const equipInfoList = declareRequest("equipInfoLoading", safePageResult(async (params) => {
|
||
|
|
const query = toPageQuery(params, {
|
||
|
|
likeDeviceName: "deviceName",
|
||
|
|
instrumentType: "instrumentType",
|
||
|
|
deviceType: "deviceType",
|
||
|
|
enableStatus: "enableFlag",
|
||
|
|
});
|
||
|
|
const res = await apiGet("/safety-eval/org-equipment/page", query);
|
||
|
|
return fromPageResponse(res, toEquipForm);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const equipInfoGet = declareRequest("equipInfoLoading", safeAction(async (params) => {
|
||
|
|
const res = await apiGet("/safety-eval/org-equipment/get", { id: params.id });
|
||
|
|
return fromSingleResponse(res, toEquipForm);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const equipInfoAdd = declareRequest("equipInfoLoading", safeAction(async (values) => {
|
||
|
|
const res = await apiPost("/safety-eval/org-equipment/save", fromEquipForm(values));
|
||
|
|
return fromSingleResponse(res, toEquipForm);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const equipInfoEdit = declareRequest("equipInfoLoading", safeAction(async (values) => {
|
||
|
|
const res = await apiPost("/safety-eval/org-equipment/modify", fromEquipForm(values));
|
||
|
|
return fromSingleResponse(res, toEquipForm);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const equipInfoRemove = declareRequest("equipInfoLoading", safeAction(async ({ id }) => {
|
||
|
|
return apiPostDelete("/safety-eval/org-equipment/delete", id);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const equipInfoToggleStatus = declareRequest("equipInfoLoading", safeAction(async ({ id }) => {
|
||
|
|
const detailRes = await apiGet("/safety-eval/org-equipment/get", { id });
|
||
|
|
const current = toEquipForm(detailRes?.data || {});
|
||
|
|
const nextStatus = current.enableStatus === 1 ? 0 : 1;
|
||
|
|
const res = await apiPost("/safety-eval/org-equipment/modify", fromEquipForm({ ...current, id, enableStatus: nextStatus }));
|
||
|
|
return fromSingleResponse(res, toEquipForm);
|
||
|
|
}));
|