feat(shipping-notice): 实现货代发货通知的库存全流程与对话交互
This commit is contained in:
1 parent
a5cc48b6aa
commit
2607f4a9f6
26 files changed
+5013
-256
No files matched your search
@@ -57,4 +57,73 @@ export const getWorkspaceShippingCase = (caseNo: string) =>
|
||||
export const workspaceShippingExportUrl = (caseNo: string) =>
|
||||
`/api/workspace/shipping-cases/${encodeURIComponent(caseNo)}/export`;
|
||||
|
||||
export interface ShippingChatAction {
|
||||
id: string;
|
||||
label: string;
|
||||
message: string;
|
||||
variant: 'primary' | 'secondary' | 'danger';
|
||||
}
|
||||
|
||||
export interface ShippingChatActionsResponse {
|
||||
case_no: string;
|
||||
checkpoint?: string | null;
|
||||
process_status: string;
|
||||
review_status?: string | null;
|
||||
pending_human_reason?: string | null;
|
||||
action_buttons: ShippingChatAction[];
|
||||
}
|
||||
|
||||
export const getShippingChatActions = (caseNo: string) =>
|
||||
getJson<ShippingChatActionsResponse>(
|
||||
`/api/workspace/shipping-cases/${encodeURIComponent(caseNo)}/chat-actions`,
|
||||
);
|
||||
|
||||
export async function uploadWorkspaceShippingInventory(caseNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-cases/${encodeURIComponent(caseNo)}/upload-inventory`,
|
||||
{ method: 'POST', headers, body: form },
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingInventoryUploadResponse & { error?: string };
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryUploadResponse {
|
||||
status: string;
|
||||
message?: string;
|
||||
case_id?: string;
|
||||
checkpoint?: string;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export interface ShippingDecisionResponse {
|
||||
status: string;
|
||||
message?: string;
|
||||
case_id?: string;
|
||||
checkpoint?: string;
|
||||
data?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export async function submitWorkspaceShippingDecision(caseNo: string, decision: string, comment?: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-cases/${encodeURIComponent(caseNo)}/submit-decision`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ decision, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
export const SHIPPING_NOTICE_AGENT_NAME = '货代发货通知 Agent';
|
||||
Reference in new issue
Block a user