import { declareRequest } from "@cqsjjb/jjb-dva-runtime"; import { fromPageResponse, fromSingleResponse, fromStaffCertForm, toPageQuery, toStaffCertForm, } from "../enterpriseInfo/adapter"; import { apiGet, apiPost, apiPostDelete, safeAction, safePageResult } from "../enterpriseInfo/http"; export const staffCertificateList = declareRequest("staffCertificateLoading", safePageResult(async (params) => { const query = toPageQuery(params, { eqStaffId: "personnelId", likeCertNo: "certNo", }); const res = await apiGet("/safety-eval/org-personnel-cert/page", query); return fromPageResponse(res, toStaffCertForm); })); export const staffCertificateInfo = declareRequest("staffCertificateLoading", safeAction(async (params) => { const res = await apiGet("/safety-eval/org-personnel-cert/get", { id: params.id }); return fromSingleResponse(res, toStaffCertForm); })); export const staffCertificateAdd = declareRequest("staffCertificateLoading", safeAction(async (values) => { const res = await apiPost("/safety-eval/org-personnel-cert/save", fromStaffCertForm(values)); return fromSingleResponse(res, toStaffCertForm); })); export const staffCertificateEdit = declareRequest("staffCertificateLoading", safeAction(async (values) => { const res = await apiPost("/safety-eval/org-personnel-cert/modify", fromStaffCertForm(values)); return fromSingleResponse(res, toStaffCertForm); })); export const staffCertificateRemove = declareRequest("staffCertificateLoading", safeAction(async ({ id }) => { return apiPostDelete("/safety-eval/org-personnel-cert/delete", id); })); export async function fetchStaffCertListByPersonnelId(personnelId) { const query = toPageQuery({ pageIndex: 1, pageSize: 999, eqStaffId: personnelId, }, { eqStaffId: "personnelId", }); const res = await apiGet("/safety-eval/org-personnel-cert/page", query); const page = fromPageResponse(res, toStaffCertForm); return page?.data || []; } export async function fetchStaffCertDetail({ id }) { const res = await apiGet("/safety-eval/org-personnel-cert/get", { id }); return fromSingleResponse(res, toStaffCertForm); }