141 lines
6.4 KiB
JavaScript
141 lines
6.4 KiB
JavaScript
|
|
import { declareRequest } from "@cqsjjb/jjb-dva-runtime";
|
||
|
|
import {
|
||
|
|
fromFilingBasicForm,
|
||
|
|
fromFilingCommitmentForm,
|
||
|
|
fromPageResponse,
|
||
|
|
fromSingleResponse,
|
||
|
|
toChangeHistory,
|
||
|
|
toFilingDetail,
|
||
|
|
toFilingListRow,
|
||
|
|
toFilingPageQuery,
|
||
|
|
} from "./adapter";
|
||
|
|
import { apiGet, apiPost, apiPostDelete, safeAction, safePageResult } from "../enterpriseInfo/http";
|
||
|
|
import { asId } from "../enterpriseInfo/idUtil";
|
||
|
|
import { resolveUploadFileId } from "../../utils/mockUpload";
|
||
|
|
|
||
|
|
const APPLY_TYPE_APPLICATION = 1;
|
||
|
|
|
||
|
|
export async function fetchQualFilingDetail(id) {
|
||
|
|
const res = await apiGet("/safety-eval/qual-filing/detail", { id: asId(id) });
|
||
|
|
return fromSingleResponse(res, toFilingDetail);
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function fetchQualFilingChangeHistory(originFilingId) {
|
||
|
|
const res = await apiGet("/safety-eval/qual-filing-change/history", {
|
||
|
|
originFilingId: asId(originFilingId),
|
||
|
|
});
|
||
|
|
return fromSingleResponse(res, toChangeHistory);
|
||
|
|
}
|
||
|
|
|
||
|
|
export const qualFilingPage = declareRequest("qualFilingLoading", safePageResult(async (params) => {
|
||
|
|
const query = toFilingPageQuery(params, { applyTypeCode: APPLY_TYPE_APPLICATION });
|
||
|
|
const res = await apiGet("/safety-eval/qual-filing/page", query);
|
||
|
|
return fromPageResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingFiledPage = declareRequest("qualFilingLoading", safePageResult(async (params) => {
|
||
|
|
const query = toFilingPageQuery(params);
|
||
|
|
const res = await apiGet("/safety-eval/qual-filing/filed/page", query);
|
||
|
|
return fromPageResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingChangePage = declareRequest("qualFilingLoading", safePageResult(async (params) => {
|
||
|
|
const query = toFilingPageQuery(params);
|
||
|
|
const res = await apiGet("/safety-eval/qual-filing/change/page", query);
|
||
|
|
return fromPageResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingDraft = declareRequest("qualFilingLoading", safeAction(async () => {
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing/draft?applyTypeCode=1", {});
|
||
|
|
return fromSingleResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingFiledDraft = declareRequest("qualFilingLoading", safeAction(async () => {
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing/filed/draft", {});
|
||
|
|
return fromSingleResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingSaveDraft = declareRequest("qualFilingLoading", safeAction(async (values) => {
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing/save-draft", fromFilingBasicForm(values));
|
||
|
|
return fromSingleResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingSubmit = declareRequest("qualFilingLoading", safeAction(async ({ id }) => {
|
||
|
|
const res = await apiPost(`/safety-eval/qual-filing/submit?id=${encodeURIComponent(asId(id))}`, {});
|
||
|
|
return fromSingleResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingDelete = declareRequest("qualFilingLoading", safeAction(async ({ id }) => {
|
||
|
|
return apiPostDelete("/safety-eval/qual-filing/delete", id);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingMaterialInitTemplate = declareRequest("qualFilingLoading", safeAction(async ({ filingId }) => {
|
||
|
|
return apiPost(`/safety-eval/qual-filing-material/init-template?filingId=${encodeURIComponent(asId(filingId))}`, {});
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingMaterialUpload = declareRequest("qualFilingLoading", safeAction(async ({ id, attachmentUrl, files }) => {
|
||
|
|
const url = attachmentUrl || resolveUploadFileId(files);
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-material/upload", { id: asId(id), attachmentUrl: url });
|
||
|
|
return fromSingleResponse(res);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingUploadAttachment = declareRequest("qualFilingLoading", safeAction(async ({ id, attachmentUrl, files }) => {
|
||
|
|
const url = attachmentUrl || resolveUploadFileId(files);
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing/upload-attachment", { id: asId(id), attachmentUrl: url });
|
||
|
|
return fromSingleResponse(res, toFilingListRow);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingCommitmentSaveOrUpdate = declareRequest("qualFilingLoading", safeAction(async (values) => {
|
||
|
|
const payload = fromFilingCommitmentForm(values, values.filingId);
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-commitment/save-or-update", payload);
|
||
|
|
return fromSingleResponse(res);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingCommitmentUploadSignature = declareRequest("qualFilingLoading", safeAction(async ({ id, attachmentUrl, files }) => {
|
||
|
|
const url = attachmentUrl || resolveUploadFileId(files);
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-commitment/upload-signature", { id: asId(id), attachmentUrl: url });
|
||
|
|
return fromSingleResponse(res);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingPersonnelBatchAdd = declareRequest("qualFilingLoading", safeAction(async ({ filingId, sourcePersonnelIds }) => {
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-personnel/batch-add-from-org", {
|
||
|
|
filingId: asId(filingId),
|
||
|
|
sourcePersonnelIds: (sourcePersonnelIds || []).map(asId),
|
||
|
|
});
|
||
|
|
return res;
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingPersonnelDelete = declareRequest("qualFilingLoading", safeAction(async ({ id }) => {
|
||
|
|
return apiPostDelete("/safety-eval/qual-filing-personnel/delete", id);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingEquipmentBatchAdd = declareRequest("qualFilingLoading", safeAction(async ({ filingId, sourceEquipmentIds }) => {
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-equipment/batch-add-from-org", {
|
||
|
|
filingId: asId(filingId),
|
||
|
|
sourceEquipmentIds: (sourceEquipmentIds || []).map(asId),
|
||
|
|
});
|
||
|
|
return res;
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingEquipmentUploadCalibration = declareRequest("qualFilingLoading", safeAction(async ({ id, attachmentUrl, files }) => {
|
||
|
|
const url = attachmentUrl || resolveUploadFileId(files);
|
||
|
|
const res = await apiPost("/safety-eval/qual-filing-equipment/upload-calibration", { id: asId(id), attachmentUrl: url });
|
||
|
|
return fromSingleResponse(res);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingEquipmentDelete = declareRequest("qualFilingLoading", safeAction(async ({ id }) => {
|
||
|
|
return apiPostDelete("/safety-eval/qual-filing-equipment/delete", id);
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingChangeStart = declareRequest("qualFilingLoading", safeAction(async ({ originFilingId }) => {
|
||
|
|
const res = await apiPost(
|
||
|
|
`/safety-eval/qual-filing-change/start?originFilingId=${encodeURIComponent(asId(originFilingId))}`,
|
||
|
|
{},
|
||
|
|
);
|
||
|
|
return fromSingleResponse(res, (data) => ({ draftFilingId: asId(data) }));
|
||
|
|
}));
|
||
|
|
|
||
|
|
export const qualFilingChangeSubmit = declareRequest("qualFilingLoading", safeAction(async ({ draftFilingId }) => {
|
||
|
|
return apiPost("/safety-eval/qual-filing-change/submit", { draftFilingId: asId(draftFilingId) });
|
||
|
|
}));
|