F4: add report list contracts to web client
This commit is contained in:
@@ -8,6 +8,25 @@ export type InspectionReportFollowUpType =
|
|||||||
| 'VERIFICATION'
|
| 'VERIFICATION'
|
||||||
| 'OTHER';
|
| 'OTHER';
|
||||||
|
|
||||||
|
export interface PageMetaF4 {
|
||||||
|
page: number;
|
||||||
|
pageSize: number;
|
||||||
|
total: number;
|
||||||
|
totalPages: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InspectionReportQueryF4 {
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
search?: string;
|
||||||
|
year?: number | string;
|
||||||
|
companyId?: string;
|
||||||
|
areaId?: string;
|
||||||
|
inspectorId?: string;
|
||||||
|
dateFrom?: string;
|
||||||
|
dateTo?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface InspectionReportDetailF4 {
|
export interface InspectionReportDetailF4 {
|
||||||
id: string;
|
id: string;
|
||||||
visitId: string;
|
visitId: string;
|
||||||
@@ -47,6 +66,22 @@ export interface InspectionReportDetailF4 {
|
|||||||
findingCount: number;
|
findingCount: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PendingInspectionReportF4 {
|
||||||
|
actId: string;
|
||||||
|
visitId: string;
|
||||||
|
actCode: string;
|
||||||
|
actTitle: string;
|
||||||
|
actYear: number;
|
||||||
|
occurredAt: string;
|
||||||
|
sealedAt: string;
|
||||||
|
closureSha256: string;
|
||||||
|
visitCode: string;
|
||||||
|
visitTitle: string;
|
||||||
|
companies: Array<{ id: string; code: string; name: string }>;
|
||||||
|
areas: Array<{ id: string; code: string; name: string }>;
|
||||||
|
findingCount: number;
|
||||||
|
}
|
||||||
|
|
||||||
export interface InspectionReportFollowUp {
|
export interface InspectionReportFollowUp {
|
||||||
id: string;
|
id: string;
|
||||||
reportId: string;
|
reportId: string;
|
||||||
@@ -84,6 +119,32 @@ export interface InspectionReportWorkflowView {
|
|||||||
followUps: InspectionReportFollowUp[];
|
followUps: InspectionReportFollowUp[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function queryString(query: InspectionReportQueryF4): string {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
const add = (key: string, value: string | number | undefined) => {
|
||||||
|
if (value === undefined || value === '') return;
|
||||||
|
params.set(key, String(value));
|
||||||
|
};
|
||||||
|
add('page', query.page ?? 1);
|
||||||
|
add('pageSize', query.pageSize ?? 25);
|
||||||
|
add('search', query.search?.trim() || undefined);
|
||||||
|
add('year', query.year);
|
||||||
|
add('companyId', query.companyId);
|
||||||
|
add('areaId', query.areaId);
|
||||||
|
add('inspectorId', query.inspectorId);
|
||||||
|
add('dateFrom', query.dateFrom);
|
||||||
|
add('dateTo', query.dateTo);
|
||||||
|
return params.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listInspectionReportsF4(query: InspectionReportQueryF4) {
|
||||||
|
return apiRequest<{ data: InspectionReportDetailF4[]; meta: PageMetaF4 }>(`/inspection-reports?${queryString(query)}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function listPendingInspectionReportsF4(query: InspectionReportQueryF4) {
|
||||||
|
return apiRequest<{ data: PendingInspectionReportF4[]; meta: PageMetaF4 }>(`/inspection-reports/pending?${queryString(query)}`);
|
||||||
|
}
|
||||||
|
|
||||||
export function getInspectionReportF4(id: string) {
|
export function getInspectionReportF4(id: string) {
|
||||||
return apiRequest<InspectionReportDetailF4>(`/inspection-reports/${id}`);
|
return apiRequest<InspectionReportDetailF4>(`/inspection-reports/${id}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user