fix(contract-plan): 合同付款预警增加“标记已付”功能
This commit is contained in:
1 parent
5c6ccf9792
commit
ac3fc99883
11 files changed
+231
-19
No files matched your search
@@ -3,12 +3,27 @@
|
||||
* 依赖:统一 requestJson;后端 /api/contract-payment。
|
||||
* 逻辑:台账/合同详情查询、汇总卡统计、待发送摘要、每日扫描入队、周五汇总入队、批次附件下载、失败原因及后台任务状态。
|
||||
* 待确认合同的人工复核提交到 manual-review,通过后合同进入台账。
|
||||
* 带 JSON body 的 POST 必须声明 Content-Type: application/json,否则 Flask 拒绝解析。
|
||||
*/
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
|
||||
/**
|
||||
* 组装带 JSON 正文的 POST。
|
||||
* 核心逻辑:Flask 的 request.get_json 只在 Content-Type 为 application/json 时读取 body。
|
||||
* @param body - 将序列化为 JSON 的请求体。
|
||||
* @returns fetch 的 method、headers 与 body。
|
||||
*/
|
||||
function jsonPost(body: unknown): RequestInit {
|
||||
return {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
}
|
||||
|
||||
export interface PaymentNode {
|
||||
id: number; node_code: string; node_type: string; amount?: string | null; percentage?: string | null;
|
||||
anchor_type?: string | null; anchor_date?: string | null; due_date?: string | null; paid_at?: string | null; status: string;
|
||||
anchor_type?: string | null; anchor_date?: string | null; due_date?: string | null; paid_at?: string | null; paid_source?: string | null; status: string;
|
||||
}
|
||||
export interface PaymentAlert { id: number; node_id: number; alert_round: number; scheduled_at?: string | null; sent_at?: string | null; recipient_user_id?: number | null; status: string; }
|
||||
export interface ContractAttachment {
|
||||
@@ -73,16 +88,23 @@ export interface ManualReviewInput {
|
||||
* @param payload - 采购单号、合同金额和四个付款阶段。
|
||||
* @returns 复核后的合同详情。
|
||||
*/
|
||||
export const submitContractPaymentManualReview = (contractId: number, payload: ManualReviewInput) => requestJson<{ contract: ContractPaymentContract }>(`/api/contract-payment/contracts/${contractId}/manual-review`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
/**
|
||||
* 把未付的预付款或出货款标为已付。
|
||||
* 核心逻辑:只提交这一阶段的付款日期和可选说明;后端关闭尚未发送的预警。
|
||||
* @param contractId - 合同台账主键。
|
||||
* @param nodeId - 付款节点主键。
|
||||
* @param payload.paidDate - 付款日期,YYYY-MM-DD。
|
||||
* @param payload.remark - 可选说明。
|
||||
* @returns 更新后的合同详情。
|
||||
*/
|
||||
export const markContractPaymentNodePaid = (contractId: number, nodeId: number, payload: { paidDate: string; remark?: string }) => requestJson<{ contract: ContractPaymentContract }>(`/api/contract-payment/contracts/${contractId}/nodes/${nodeId}/mark-paid`, jsonPost({ paid_date: payload.paidDate, remark: payload.remark || '' }));
|
||||
export const submitContractPaymentManualReview = (contractId: number, payload: ManualReviewInput) => requestJson<{ contract: ContractPaymentContract }>(`/api/contract-payment/contracts/${contractId}/manual-review`, jsonPost(payload));
|
||||
/** 下载当前登录用户有权限访问的合同原文附件。 */
|
||||
export const downloadContractPaymentAttachment = (contractId: number, attachmentId: number) => requestBlob(`/api/contract-payment/contracts/${contractId}/attachments/${attachmentId}/download`);
|
||||
/** 提交 OA 合同同步;force 为 true 时由后端显式覆盖本次 OA 返回的非空主表字段。 */
|
||||
export const enqueueContractPaymentSync = (force = false) => requestJson<{ job_id: string }>('/api/contract-payment/sync', { method: 'POST', body: JSON.stringify({ force }) });
|
||||
export const enqueueContractPaymentSync = (force = false) => requestJson<{ job_id: string }>('/api/contract-payment/sync', jsonPost({ force }));
|
||||
/** 提交存量合同批量重解析,直接使用已归档附件刷新历史解析结果。 */
|
||||
export const enqueueContractPaymentReparse = () => requestJson<{ job_id: string }>('/api/contract-payment/sync', { method: 'POST', body: JSON.stringify({ reparse_existing: true }) });
|
||||
export const enqueueContractPaymentReparse = () => requestJson<{ job_id: string }>('/api/contract-payment/sync', jsonPost({ reparse_existing: true }));
|
||||
export const enqueueContractPaymentAlertScan = () => requestJson<{ job_id: string }>('/api/contract-payment/alerts/run', { method: 'POST' });
|
||||
export const enqueueContractPaymentWeeklyAlert = () => requestJson<{ job_id: number }>('/api/contract-payment/alerts/weekly-run', { method: 'POST' });
|
||||
export interface ContractPaymentJobResult { batches?: number; sent?: number; failed?: number; alerts?: number; }
|
||||
|
||||
Reference in new issue
Block a user