溯源系统初版
This commit is contained in:
@@ -0,0 +1,278 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
export namespace TraceabilityApi {
|
||||
export interface Overview {
|
||||
templateCount: number;
|
||||
batchCount: number;
|
||||
publishedCount: number;
|
||||
feedbackCount: number;
|
||||
totalScans: number;
|
||||
}
|
||||
|
||||
export interface FieldDefinition {
|
||||
key: string;
|
||||
label: string;
|
||||
type: string;
|
||||
required: boolean;
|
||||
visible: boolean;
|
||||
placeholder?: string;
|
||||
defaultValue?: any;
|
||||
options?: string[];
|
||||
}
|
||||
|
||||
export interface TemplateNode {
|
||||
id?: string;
|
||||
sort?: number;
|
||||
category: 'business' | 'public' | string;
|
||||
name: string;
|
||||
description: string;
|
||||
locked?: boolean;
|
||||
consumerVisible: boolean;
|
||||
fields: FieldDefinition[];
|
||||
}
|
||||
|
||||
export interface TemplateSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
description: string;
|
||||
productName: string;
|
||||
industryName: string;
|
||||
coverImage: string;
|
||||
themeColor: string;
|
||||
status: string;
|
||||
nodeCount: number;
|
||||
batchCount: number;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface TemplateDetail extends TemplateSummary {
|
||||
nodes: TemplateNode[];
|
||||
}
|
||||
|
||||
export interface BatchStep {
|
||||
id: string;
|
||||
templateNodeId?: string;
|
||||
sort: number;
|
||||
category: string;
|
||||
name: string;
|
||||
description: string;
|
||||
locked?: boolean;
|
||||
consumerVisible: boolean;
|
||||
status: string;
|
||||
operatorName: string;
|
||||
values: Record<string, any>;
|
||||
completedAt: string;
|
||||
fields: FieldDefinition[];
|
||||
}
|
||||
|
||||
export interface BatchSummary {
|
||||
id: string;
|
||||
templateId: string;
|
||||
templateName: string;
|
||||
batchName: string;
|
||||
batchCode: string;
|
||||
productName: string;
|
||||
summary: string;
|
||||
coverImage: string;
|
||||
tags: string[];
|
||||
status: string;
|
||||
currentStep: number;
|
||||
scanCount: number;
|
||||
publicUrl: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface BatchDetail extends BatchSummary {
|
||||
steps: BatchStep[];
|
||||
publishedAt: string;
|
||||
}
|
||||
|
||||
export interface PublicDetail {
|
||||
batch: BatchDetail;
|
||||
companySectionTitle: string;
|
||||
publicSections: BatchStep[];
|
||||
businessSections: BatchStep[];
|
||||
}
|
||||
|
||||
export interface FeedbackItem {
|
||||
id: string;
|
||||
batchId: string;
|
||||
batchCode: string;
|
||||
batchName: string;
|
||||
type: string;
|
||||
contact: string;
|
||||
content: string;
|
||||
source: string;
|
||||
rating: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface OssFileResult {
|
||||
bucketName: string;
|
||||
objectName: string;
|
||||
uploadUrl?: string;
|
||||
tempUrl?: string;
|
||||
contentType?: string;
|
||||
fileName?: string;
|
||||
size?: number;
|
||||
}
|
||||
}
|
||||
|
||||
export function getTraceabilityOverview() {
|
||||
return requestClient.get<TraceabilityApi.Overview>('/traceability/overview');
|
||||
}
|
||||
|
||||
export function getTraceabilityTemplates() {
|
||||
return requestClient.get<TraceabilityApi.TemplateSummary[]>(
|
||||
'/traceability/templates',
|
||||
);
|
||||
}
|
||||
|
||||
export function getTraceabilityTemplate(id: string) {
|
||||
return requestClient.get<TraceabilityApi.TemplateDetail>(
|
||||
`/traceability/templates/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function createTraceabilityTemplate(
|
||||
data: Omit<TraceabilityApi.TemplateDetail, 'batchCount' | 'id' | 'nodeCount' | 'updatedAt'>,
|
||||
) {
|
||||
return requestClient.post('/traceability/templates', data);
|
||||
}
|
||||
|
||||
export function updateTraceabilityTemplate(
|
||||
id: string,
|
||||
data: Omit<TraceabilityApi.TemplateDetail, 'batchCount' | 'id' | 'nodeCount' | 'updatedAt'>,
|
||||
) {
|
||||
return requestClient.put(`/traceability/templates/${id}`, data);
|
||||
}
|
||||
|
||||
export function deleteTraceabilityTemplate(id: string) {
|
||||
return requestClient.delete(`/traceability/templates/${id}`);
|
||||
}
|
||||
|
||||
export function getTraceabilityBatches() {
|
||||
return requestClient.get<TraceabilityApi.BatchSummary[]>(
|
||||
'/traceability/batches',
|
||||
);
|
||||
}
|
||||
|
||||
export function getTraceabilityBatch(id: string) {
|
||||
return requestClient.get<TraceabilityApi.BatchDetail>(
|
||||
`/traceability/batches/${id}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function createTraceabilityBatch(data: {
|
||||
templateId: string;
|
||||
batchName: string;
|
||||
batchCode: string;
|
||||
productName?: string;
|
||||
summary?: string;
|
||||
coverImage?: string;
|
||||
tags?: string[];
|
||||
}) {
|
||||
return requestClient.post('/traceability/batches', data);
|
||||
}
|
||||
|
||||
export function deleteTraceabilityBatch(id: string) {
|
||||
return requestClient.delete(`/traceability/batches/${id}`);
|
||||
}
|
||||
|
||||
export function updateTraceabilityBatchBase(id: string, data: any) {
|
||||
return requestClient.put(`/traceability/batches/${id}/base`, data);
|
||||
}
|
||||
|
||||
export function updateTraceabilityBatchStep(
|
||||
batchId: string,
|
||||
stepId: string,
|
||||
data: {
|
||||
operatorName?: string;
|
||||
status?: string;
|
||||
values?: Record<string, any>;
|
||||
completedAt?: string;
|
||||
},
|
||||
) {
|
||||
return requestClient.put(`/traceability/batches/${batchId}/steps/${stepId}`, data);
|
||||
}
|
||||
|
||||
export function publishTraceabilityBatch(id: string) {
|
||||
return requestClient.post(`/traceability/batches/${id}/publish`);
|
||||
}
|
||||
|
||||
export function getTraceabilityPublicDetail(code: string) {
|
||||
return requestClient.get<TraceabilityApi.PublicDetail>(
|
||||
`/traceability/public/by-code/${code}`,
|
||||
);
|
||||
}
|
||||
|
||||
export function getTraceabilityFeedbackList() {
|
||||
return requestClient.get<TraceabilityApi.FeedbackItem[]>(
|
||||
'/traceability/feedback',
|
||||
);
|
||||
}
|
||||
|
||||
export function submitTraceabilityFeedback(data: {
|
||||
batchCode?: string;
|
||||
batchId?: string;
|
||||
type: string;
|
||||
contact?: string;
|
||||
content: string;
|
||||
source?: string;
|
||||
rating?: number;
|
||||
}) {
|
||||
return requestClient.post('/traceability/public/feedback', data);
|
||||
}
|
||||
|
||||
export function uploadTraceabilityImage(data: FormData) {
|
||||
return requestClient.post<TraceabilityApi.OssFileResult>(
|
||||
'/traceability/files/upload-image',
|
||||
data,
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function getTraceabilityUploadToken(data: {
|
||||
bucketName?: string;
|
||||
objectName: string;
|
||||
expiresMinutes?: number;
|
||||
}) {
|
||||
return requestClient.post<TraceabilityApi.OssFileResult>(
|
||||
'/traceability/files/presigned-put',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export function getTraceabilityTempUrl(data: {
|
||||
bucketName?: string;
|
||||
objectName?: string;
|
||||
objectDir?: string;
|
||||
expiresSeconds?: number;
|
||||
}) {
|
||||
return requestClient.post<TraceabilityApi.OssFileResult>(
|
||||
'/traceability/files/temp-url',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export function moveTraceabilityFile(data: {
|
||||
bucketName?: string;
|
||||
sourceObjectName: string;
|
||||
targetObjectName: string;
|
||||
}) {
|
||||
return requestClient.post<TraceabilityApi.OssFileResult>(
|
||||
'/traceability/files/move',
|
||||
data,
|
||||
);
|
||||
}
|
||||
|
||||
export function deleteTraceabilityFile(data: {
|
||||
bucketName?: string;
|
||||
objectName: string;
|
||||
}) {
|
||||
return requestClient.post<boolean>('/traceability/files/delete', data);
|
||||
}
|
||||
Reference in New Issue
Block a user