(null);
@@ -98,21 +128,63 @@ export function PriceQtyRequestsPage() {
const loadInbox = useCallback(async () => {
setInboxLoading(true);
try {
- const [pending, all] = await Promise.all([
- listMainSystemActualQtyRequestsApi({ status: 'pending', limit: 100 }),
- // 历史:一次取回后在本地按状态拆分(后端只支持单状态过滤)
- listMainSystemActualQtyRequestsApi({ limit: 100 }),
+ // 服务端分页:待审 / 已处理两区各自取一页(不再一次拉全量)
+ const [pending, processed] = await Promise.all([
+ listMainSystemActualQtyRequestsApi({
+ scope: 'pending',
+ page: inboxPage,
+ pageSize: INBOX_PAGE_SIZE,
+ }),
+ listMainSystemActualQtyRequestsApi({
+ scope: 'processed',
+ page: historyPage,
+ pageSize: INBOX_PAGE_SIZE,
+ }),
]);
setInboxRows(Array.isArray(pending?.data) ? pending.data : []);
- setInboxHistoryRows(
- (Array.isArray(all?.data) ? all.data : []).filter((row) => row.status !== 'pending')
- );
+ setInboxTotal(Number(pending?.total) || 0);
+ setInboxHistoryRows(Array.isArray(processed?.data) ? processed.data : []);
+ setHistoryTotal(Number(processed?.total) || 0);
+ if (processed?.counts) setInboxCounts(processed.counts);
+ else if (pending?.counts) setInboxCounts(pending.counts);
} catch (error: any) {
notify.error(error?.message || t('orders.priceQty.inboxEmpty'));
} finally {
setInboxLoading(false);
}
- }, [t]);
+ }, [t, inboxPage, historyPage]);
+
+ /**
+ * **提交前重取**(2026-10-12,开发者要求):主系统对"未处理"的申请是**原地更新为最新**,
+ * 而本页不轮询 ⇒ 审核人屏幕上可能是**旧值**。若拿旧值审批(尤其手填了旧值),
+ * 会把旧值写回去(对方那道基值守卫挡不住,因为它比对的是"期间是否被改",而 before/proposed 是一起刷新的)。
+ * ⇒ 决策前先重取一次:值变了 / 已不是待审 ⇒ **拦下并要求重新确认**。
+ */
+ const isInboxRowStale = (
+ shown: MainSystemActualQtyRequestDto,
+ fresh: MainSystemActualQtyRequestDto
+ ): boolean => {
+ const sameNum = (a: unknown, b: unknown) => {
+ const x = a === null || a === undefined || a === '' ? null : Number(a);
+ const y = b === null || b === undefined || b === '' ? null : Number(b);
+ if (x === null && y === null) return true;
+ if (x === null || y === null) return false;
+ return Math.abs(x - y) < 1e-9;
+ };
+ const sameTime = (a: unknown, b: unknown) => {
+ const x = a ? new Date(String(a)).getTime() : null;
+ const y = b ? new Date(String(b)).getTime() : null;
+ if (x === null && y === null) return true;
+ if (x === null || y === null) return false;
+ return x === y;
+ };
+ return (
+ !sameNum(shown.proposed_value, fresh.proposed_value) ||
+ !sameNum(shown.before_value, fresh.before_value) ||
+ String(shown.unit ?? '') !== String(fresh.unit ?? '') ||
+ !sameTime(shown.applied_at, fresh.applied_at)
+ );
+ };
const decideInbox = async (row: MainSystemActualQtyRequestDto, decision: 'approved' | 'rejected') => {
const draft = inboxDraft[row.id] || { finalValue: '', reason: '' };
@@ -122,6 +194,31 @@ export function PriceQtyRequestsPage() {
notify.error(t('orders.priceQty.inboxField'));
return;
}
+ // ⚠️ 顺序很重要:**先重取、后置 busy**。若先 setActingId 再 return,按钮会永远停在忙碌态。
+ try {
+ const freshList = await listMainSystemActualQtyRequestsApi({ status: 'pending', limit: 100 });
+ const fresh = (Array.isArray(freshList?.data) ? freshList.data : []).find((r) => r.id === row.id);
+ if (!fresh) {
+ notify.error(t('orders.priceQty.inboxStaleGone'));
+ await loadInbox();
+ return;
+ }
+ if (isInboxRowStale(row, fresh)) {
+ const shownValue = row.field === 'unit' ? row.unit : row.proposed_value;
+ const freshValue = fresh.field === 'unit' ? fresh.unit : fresh.proposed_value;
+ notify.error(
+ t('orders.priceQty.inboxStaleRefreshed', {
+ from: `${shownValue ?? '—'}`,
+ to: `${freshValue ?? '—'}`,
+ })
+ );
+ await loadInbox();
+ return;
+ }
+ } catch (error: any) {
+ // 重取失败不阻断审核(保守:宁可让人审,也不因为一次查询失败卡死流程),但要把原因说清楚
+ console.error('提交前重取实收申请失败:', error);
+ }
setActingId(row.id);
try {
const result = await decideMainSystemActualQtyRequestApi(row.id, {
@@ -129,7 +226,17 @@ export function PriceQtyRequestsPage() {
final_value: decision === 'approved' ? finalValue : null,
reason: draft.reason.trim() || null,
});
- notify.success(result?.reason || t('common.save'));
+ /**
+ * ⚠️ 结果可能是 **suspended**(没有落成)——最常见的是版本过期:
+ * 主系统在我方审核期间把该申请**原地刷新**了,它会返回 409 且**不写任何值**,
+ * 后端已把最新值拉回来刷新本行并给出「请重新确认」的说明。
+ * 这种情况**不能**报成功(否则审核人以为审完了,实际什么都没发生)。
+ */
+ if (result?.status === 'suspended') {
+ notify.error(result?.reason || t('common.save'));
+ } else {
+ notify.success(result?.reason || t('common.save'));
+ }
await loadInbox();
void load();
} catch (error: any) {
@@ -267,7 +374,7 @@ export function PriceQtyRequestsPage() {
{t('orders.priceQty.inboxTitle')}
- {inboxRows.length ? `(${inboxRows.length})` : ''}
+ {inboxCounts.pending ? `(${inboxCounts.pending})` : ''}
{t('orders.priceQty.inboxReviewNote')}
@@ -301,6 +408,7 @@ export function PriceQtyRequestsPage() {
) : null}
{inboxRows.map((row, index) => {
const draft = inboxDraft[row.id] || { finalValue: '', reason: '' };
+ const refreshTrail = readRefreshHistory(row);
const nodeKey =
row.node === 'picking_check'
? 'orders.priceQty.nodePickingCheck'
@@ -341,9 +449,38 @@ export function PriceQtyRequestsPage() {
{row.unit && row.field === 'unit' ? row.unit : row.proposed_value}
+ {refreshTrail.length ? (
+
+ `${formatTime(entry.at)} ${formatRefreshPair(entry)}(${
+ entry.source === 'reconcile'
+ ? t('orders.priceQty.refreshSourceReconcile')
+ : t('orders.priceQty.refreshSourceWebhook')
+ })`
+ )
+ .join('\n')}
+ >
+ {t('orders.priceQty.refreshHint', {
+ pair: formatRefreshPair(refreshTrail[refreshTrail.length - 1]),
+ at: formatTime(refreshTrail[refreshTrail.length - 1].at),
+ })}
+ {refreshTrail.length > 1
+ ? ` ${t('orders.priceQty.refreshHintMore', { count: refreshTrail.length })}`
+ : ''}
+
+ ) : null}
-
- {row.applied_at ? formatTime(row.applied_at) : '—'}
+ |
+ {row.applied_at ? formatTime(row.applied_at) : '—'}
+ {/* 版本徽标(主系统第七批 §12.3):纯数字,v3 = 你审的是第 3 版;对方"原地刷新"后数字会跳 */}
+ {typeof row.request_version === 'number' ? (
+
+ v{row.request_version}
+
+ ) : null}
|
{formatTime(row.created_at)}
@@ -396,6 +533,43 @@ export function PriceQtyRequestsPage() {
})}
+
+
+ {t('orders.priceQty.pageInfo', { page: inboxPage, total: Math.max(1, Math.ceil(inboxTotal / INBOX_PAGE_SIZE)) })}
+
+
+
+
+
+
{/* 已处理历史(2026-10-11 口径):事实登记 + 双方留痕 —— 主系统实际值/生效时间、
@@ -404,7 +578,7 @@ export function PriceQtyRequestsPage() {
{t('orders.priceQty.historyTitle')}
- {inboxHistoryRows.length ? `(${inboxHistoryRows.length})` : ''}
+ {inboxCounts.processed ? `(${inboxCounts.processed})` : ''}
@@ -457,13 +631,15 @@ export function PriceQtyRequestsPage() {
const nodeKey =
row.node === 'picking_check'
? 'orders.priceQty.nodePickingCheck'
- : row.node === 'inbound'
- ? 'orders.priceQty.nodeInbound'
- : row.node === 'admin_received_qty'
- ? 'orders.priceQty.nodeAdminReceivedQty'
- : row.node === 'post_complete_price'
- ? 'orders.priceQty.nodePostCompletePrice'
- : '';
+ : row.node === 'picking_check_revert'
+ ? 'orders.priceQty.nodePickingCheckRevert'
+ : row.node === 'inbound'
+ ? 'orders.priceQty.nodeInbound'
+ : row.node === 'admin_received_qty'
+ ? 'orders.priceQty.nodeAdminReceivedQty'
+ : row.node === 'post_complete_price'
+ ? 'orders.priceQty.nodePostCompletePrice'
+ : '';
const fieldKey =
row.field === 'qty'
? 'orders.priceQty.fieldQty'
@@ -471,11 +647,16 @@ export function PriceQtyRequestsPage() {
? 'orders.priceQty.fieldUnit'
: 'orders.priceQty.fieldPrice';
const synced = row.status === 'approved';
+ // 2026-10-12:对方可在未审前撤回/作废(结果事件关闭该行)⇒ 单独一档展示
+ const withdrawn = row.status === 'withdrawn' || row.status === 'superseded';
const applyNote = row.payload?.apply?.note || '';
+ const historyTrail = readRefreshHistory(row);
return (
| {index + 1} |
- {row.item_name || row.prep_id || '-'} |
+
+ {row.item_name || row.sku_code || row.prep_id || '-'}
+ |
{row.our_order_code || '-'} |
- {synced ? t('orders.priceQty.statusSynced') : t('orders.priceQty.statusRejectedNoSync')}
+ {synced
+ ? t('orders.priceQty.statusSynced')
+ : row.status === 'withdrawn'
+ ? t('orders.priceQty.statusWithdrawn')
+ : row.status === 'superseded'
+ ? t('orders.priceQty.statusSuperseded')
+ : t('orders.priceQty.statusRejectedNoSync')}
|
@@ -512,12 +699,55 @@ export function PriceQtyRequestsPage() {
|
{applyNote || row.decision_reason || '—'}
+ {historyTrail.length ? (
+
+ {t('orders.priceQty.refreshHintMore', { count: historyTrail.length })}:
+ {historyTrail.map((entry) => formatRefreshPair(entry)).join(' / ')}
+
+ ) : null}
|
);
})}
+
+
+ {t('orders.priceQty.pageInfo', { page: historyPage, total: Math.max(1, Math.ceil(historyTotal / INBOX_PAGE_SIZE)) })}
+
+
+
+
+
+
diff --git a/src/pages/orders/orderManagement/OrderManagementPage.tsx b/src/pages/orders/orderManagement/OrderManagementPage.tsx
index ec4ba8e..b54454c 100644
--- a/src/pages/orders/orderManagement/OrderManagementPage.tsx
+++ b/src/pages/orders/orderManagement/OrderManagementPage.tsx
@@ -87,7 +87,6 @@ import {
reportOrderItemStockoutApi,
listOrdersManagementApi,
listOrderTrashApi,
- submitOrderItemPriceQtyRequestApi,
saveOrderItemsWithFulfillmentApi,
updateOrderDeliveryDateApi,
updateOrderDeliveryAddressApi,
@@ -1730,16 +1729,19 @@ export const OrderManagement: React.FC = () => {
const ORDER_ITEM_NUMBER_EPS = 1e-6;
/**
- * 跨系统改价/改量分流(设计 20261011 §4 C2/C6,2026-10-11 开发者口径):
- * 主系统分配行的 price/quantity 变化**不走既有明细保存**,逐行提交申请;
- * - 免审项(补价/改低/减量)提交后立即生效 ⇒ 回填最终生效值;
- * - 涨价/加量 ⇒ pending 等主系统审核 ⇒ 回填原值(本地不落未审核的价/量);
- * - 功能未开启(503 price_qty_disabled,当前默认关)⇒ **静默整批回退**:改动带回编辑值走既有链路
- * (后端守卫在开关关闭时同样放行,回退安全),不弹提示;
- * - 其它失败(主系统未就绪/暂不可用/被拒)⇒ 回填原值(该行价/量不落地)+ 逐条汇总原因。
+ * 跨系统改价/改量:**不再在界面上分流**(开发者 2026-10-12 口径:**先改后通知**)。
*
- * 注意:这些行**不能从保存载荷里剔除** —— 明细保存是整单全量语义,后端把缺席的明细 id 判为
- * 「删除行」并 409(main_system_item_locked),故一律保留行、只回填价/量后再交回既有链路。
+ * 为什么保留这个空壳而不是删掉调用点:调用点牵连保存主流程的三处 notify 汇总与
+ * `itemsToSave` 变量,改结构属于范围外;这里只把"分流"行为取消,返回值恒等于"未改动",
+ * 于是 `itemsToSave === itemsToPersist`(用户编辑值原样交给既有保存链路)。
+ *
+ * 旧行为(2026-10-11"先审后改")为什么必须取消:
+ * - 涨价/加量 pending ⇒ **回填原值** ⇒ 用户改完保存后界面又变回旧值(正是"改不动");
+ * - 免审项 ⇒ 走单独的 `price-qty-request` 接口,与明细保存**两个写入者**,谁后写谁赢。
+ * 新链路:明细保存照常写库 ⇒ 后端在 **COMMIT 之后**异步通知主系统
+ * (`orderManageItemsService` 的 `notifyMainSystemPriceQtyChanges`),对方同意/驳回都不回改我方值。
+ * 自采列表的改销售价同理(`purchaseLinkedSalePriceService`)。
+ * 见 docs/design/20261011-跨系统改价改量审核.md §10。
*/
const routeMainSystemPriceQtyChanges = async (params: {
order: Order;
@@ -1749,105 +1751,20 @@ export const OrderManagement: React.FC = () => {
items: OrderItem[];
applied: number;
pending: number;
- /** 主系统已生效但本地落地失败(`applied_locally=false`):本地保持原值,等后端自动重试 */
+ /** 保留字段:新口径下恒为 0(本地落地由后端写入,不存在"主系统已生效但本地没落") */
notLanded: number;
notLandedNotes: string[];
failures: string[];
- }> => {
- const unchanged = {
+ }> =>
+ // 保留行、不改值:明细保存是整单全量语义,缺席的明细 id 会被后端判为「删除行」并 409。
+ ({
items: params.items,
applied: 0,
pending: 0,
notLanded: 0,
notLandedNotes: [] as string[],
failures: [] as string[],
- };
- const originalById = new Map(params.originals.map((row) => [row.id, row]));
- const candidates = params.items.filter((item) => {
- if (item.is_returned || isTempOrderItemId(item.id)) return false;
- const original = originalById.get(item.id);
- if (!original) return false;
- if (!isMainSystemOrderLine(params.order, item)) return false;
- return (
- Math.abs((Number(original.price) || 0) - (Number(item.price) || 0)) >
- ORDER_ITEM_NUMBER_EPS ||
- Math.abs((Number(original.quantity) || 0) - (Number(item.quantity) || 0)) >
- ORDER_ITEM_NUMBER_EPS
- );
});
- if (!candidates.length) return unchanged;
-
- const overrideById = new Map();
- let applied = 0;
- let pending = 0;
- let notLanded = 0;
- let featureDisabled = false;
- const notLandedNotes: string[] = [];
- const failures: string[] = [];
- for (const item of candidates) {
- const original = originalById.get(item.id) as OrderItem;
- const beforePrice = Number(original.price) || 0;
- const beforeQty = Number(original.quantity) || 0;
- const nextPrice = Number(item.price) || 0;
- const nextQty = Number(item.quantity) || 0;
- const priceChanged = Math.abs(beforePrice - nextPrice) > ORDER_ITEM_NUMBER_EPS;
- const qtyChanged = Math.abs(beforeQty - nextQty) > ORDER_ITEM_NUMBER_EPS;
- const label = String(item.item_name || item.sku_name || '').trim() || item.id;
- try {
- const result = await submitOrderItemPriceQtyRequestApi(params.order.order_code, item.id, {
- proposed_price: priceChanged ? nextPrice : undefined,
- proposed_qty: qtyChanged ? nextQty : undefined,
- });
- if (result.status === 'applied') {
- if (result.applied_locally === false) {
- // ⚠️ 主系统已生效、本地落地失败(如订单已结案/并发改动):本地**必须保持原值**,
- // 否则等于"没落地却按新值保存",两边彻底错位;后端已把台账退回 pending 自动重试。
- notLanded += 1;
- notLandedNotes.push(`${label}: ${result.apply_note || '本地待同步'}`);
- overrideById.set(item.id, { price: beforePrice, quantity: beforeQty });
- } else {
- applied += 1;
- overrideById.set(item.id, {
- price: Number(result.final_price ?? nextPrice),
- quantity: Number(result.final_qty ?? nextQty),
- });
- }
- } else {
- pending += 1;
- overrideById.set(item.id, { price: beforePrice, quantity: beforeQty });
- }
- } catch (err) {
- const code = String((err as { code?: unknown } | null)?.code || '');
- // 功能未开启(默认关):整批静默回退到既有保存链路,不再逐行试提交
- if (code === 'price_qty_disabled') {
- featureDisabled = true;
- break;
- }
- // 目标值已等于主系统侧现值(重复保存/上一轮已生效)⇒ 编辑值本来就在库里,无需提交
- if (code === 'no_change') continue;
- // 后端判定该行不属于主系统分配 ⇒ 老链路本来就是对的(真属于则由后端守卫再拦)
- if (code === 'not_main_system_item') continue;
- overrideById.set(item.id, { price: beforePrice, quantity: beforeQty });
- failures.push(`${label}: ${err instanceof Error ? err.message : '提交失败'}`);
- }
- }
- const items = params.items.map((item) => {
- const override = overrideById.get(item.id);
- if (!override) return item;
- const next = { ...item, ...override };
- next.amount = Math.round(Number(next.quantity) * Number(next.price) * 100) / 100;
- return next;
- });
- // 功能未开启:不报错(正常状态),已提交成功的少数行仍按其生效值回填
- return {
- items,
- applied,
- pending,
- notLanded,
- notLandedNotes,
- failures: featureDisabled ? [] : failures,
- };
- };
/** 提交结果一次性汇总(沿用页面既有 notify 提示):N 项已生效 / M 项待审核 / K 项提交失败 */
const buildPriceQtySubmitSummary = (result: {
@@ -1926,7 +1843,7 @@ export const OrderManagement: React.FC = () => {
);
}
- // 跨系统改价/改量:主系统来源行的价/量变化先走申请,其余行照旧(设计 20261011 C6)
+ // 跨系统改价/改量:**先改后通知**,界面不再分流(2026-10-12 口径,见函数注释)
const priceQtyRouting = itemsEditable
? await routeMainSystemPriceQtyChanges({
order: selectedOrder,
diff --git a/src/pages/orders/orderManagement/orderManagementPage.priceQtyLocalFirst.test.ts b/src/pages/orders/orderManagement/orderManagementPage.priceQtyLocalFirst.test.ts
new file mode 100644
index 0000000..804e6cc
--- /dev/null
+++ b/src/pages/orders/orderManagement/orderManagementPage.priceQtyLocalFirst.test.ts
@@ -0,0 +1,41 @@
+import { readFileSync } from 'node:fs';
+import { describe, expect, it } from 'vitest';
+
+/**
+ * 订单明细页:跨系统改价/改量的**界面分流必须保持关闭**(开发者 2026-10-12 口径:先改后通知)。
+ *
+ * 事故背景(这条钉子的由来):2026-10-11 的"先审后改"在界面做了一次分流 ——
+ * 主系统来源行的价/量改动**不走明细保存**,改走高一个 `price-qty-request` 接口,
+ * 并把"待审核"的行**回填成原值**。表现就是用户改完保存后**值又变回去了("改不动")**,
+ * 而且与明细保存形成**两个写入者**(谁后写谁赢)。
+ *
+ * 新口径下:明细保存照常写库,后端在 **COMMIT 之后**异步通知主系统;
+ * 因此界面必须**原样把用户编辑值交给保存链路**(`itemsToSave === itemsToPersist`)。
+ */
+const src = readFileSync(new URL('./OrderManagementPage.tsx', import.meta.url), 'utf8');
+
+describe('订单明细页:主系统行改价/改量不再被界面回填/拦截', () => {
+ it('分流函数恒为"未改动":不回填原值、不计数、不报失败', () => {
+ const start = src.indexOf('const routeMainSystemPriceQtyChanges = async');
+ expect(start).toBeGreaterThan(0);
+ const body = src.slice(start, src.indexOf('const buildPriceQtySubmitSummary'));
+ expect(body).toContain('items: params.items');
+ expect(body).toContain('applied: 0');
+ expect(body).toContain('pending: 0');
+ expect(body).toContain('notLanded: 0');
+ expect(body).toContain('failures: [] as string[]');
+ // 不得再出现"回填"逻辑与逐行提交
+ expect(body).not.toContain('overrideById');
+ expect(body).not.toContain('beforePrice');
+ expect(body).not.toContain('submitOrderItemPriceQtyRequestApi');
+ });
+
+ it('页面不再导入/调用改价改量申请接口(通知由后端在 COMMIT 后发)', () => {
+ expect(src).not.toContain('submitOrderItemPriceQtyRequestApi');
+ });
+
+ it('保存链路仍以分流结果为输入(结构未动,便于后续再切回)', () => {
+ expect(src).toContain('const itemsToSave = priceQtyRouting.items;');
+ expect(src).toContain('priceQtySummary = buildPriceQtySubmitSummary(priceQtyRouting);');
+ });
+});
diff --git a/src/utils/workflowApi.ts b/src/utils/workflowApi.ts
index 0ff7009..08fa0a6 100644
--- a/src/utils/workflowApi.ts
+++ b/src/utils/workflowApi.ts
@@ -778,6 +778,17 @@ export async function submitOrderItemPriceQtyRequestApi(
/** 跨系统改价/改量申请列表(只读台账);`enabled` 为功能总开关,关闭时列表恒空 */
/** 对方(主系统)发起、**我方审核**的实收/单位/完结后成本价申请 */
+/** 主系统把**未处理**的申请原地刷新为最新值时留下的痕迹(from → to,含时间与来源) */
+export interface MainSystemActualQtyRefreshEntry {
+ at?: string | null;
+ from_value?: number | null;
+ from_unit?: string | null;
+ to_value?: number | null;
+ to_unit?: string | null;
+ /** webhook=事件到达时刷新;reconcile=Q6 对账刷新 */
+ source?: string | null;
+}
+
export interface MainSystemActualQtyRequestDto {
id: string;
request_id: string;
@@ -793,7 +804,7 @@ export interface MainSystemActualQtyRequestDto {
unit: string | null;
operator: string | null;
reason: string | null;
- status: 'pending' | 'approved' | 'rejected' | 'superseded';
+ status: 'pending' | 'approved' | 'rejected' | 'superseded' | 'withdrawn';
final_value: number | null;
reviewer: string | null;
decided_at: string | null;
@@ -802,21 +813,53 @@ export interface MainSystemActualQtyRequestDto {
fact_registered: boolean;
/** 主系统实际值在其侧生效的时刻(新口径"事实登记"的时间锚点) */
applied_at: string | null;
+ /**
+ * 主系统台账行的**权威整数版本**(原地刷新 +1;主系统第七批 §12.3)。
+ * 审核回执会把它原样回带(`decided_basis_version`);对方发现版本不一致 ⇒ 409 且不写值,
+ * 后端会把最新值拉回来刷新本行并提示"请重新确认"。`null` = 对方未提供(旧版载荷)。
+ */
+ request_version?: number | null;
/** 我方落值结论(审核同意时由后端写入:status/note/at) */
- payload?: { apply?: { status?: string; note?: string; at?: string } } | null;
+ payload?: {
+ apply?: { status?: string; note?: string; at?: string };
+ /** 单次刷新痕迹(最近一次,兼容旧数据) */
+ refresh?: MainSystemActualQtyRefreshEntry;
+ reconcile_refresh?: MainSystemActualQtyRefreshEntry;
+ /** **完整刷新历史**:主系统"未处理就地更新为最新"时逐次追加,审核页可追溯 */
+ refresh_history?: MainSystemActualQtyRefreshEntry[];
+ } | null;
/** 台账 LEFT JOIN 出来的商品名 */
item_name?: string | null;
created_at: string;
}
-export async function listMainSystemActualQtyRequestsApi(params?: { status?: string; limit?: number }) {
+/**
+ * 实收申请列表(**服务端分页**,2026-10-12):
+ * · `scope`:`pending` 待我审核 / `processed` 已处理历史 / `all`;
+ * · `status` 精确值优先于 `scope`;
+ * · 返回 `total`(当前过滤的总行数)与 `counts`(两区各自总数,供区标题显示)。
+ */
+export async function listMainSystemActualQtyRequestsApi(params?: {
+ status?: string;
+ scope?: 'pending' | 'processed' | 'all';
+ page?: number;
+ pageSize?: number;
+ limit?: number;
+}) {
const query = new URLSearchParams();
if (params?.status) query.set('status', params.status);
+ if (params?.scope) query.set('scope', params.scope);
+ if (params?.page) query.set('page', String(params.page));
+ if (params?.pageSize) query.set('page_size', String(params.pageSize));
if (params?.limit) query.set('limit', String(params.limit));
const suffix = query.toString() ? `?${query.toString()}` : '';
- return workflowFetch<{ data: MainSystemActualQtyRequestDto[] }>(
- `/main-system/actual-qty-requests${suffix}`
- );
+ return workflowFetch<{
+ data: MainSystemActualQtyRequestDto[];
+ total: number;
+ page: number;
+ page_size: number;
+ counts: { pending: number; processed: number };
+ }>(`/main-system/actual-qty-requests${suffix}`);
}
/** 审核结论回传主系统(成功后才改本地台账):通过 / 改值后通过 / 驳回 */
@@ -824,6 +867,7 @@ export async function decideMainSystemActualQtyRequestApi(
id: string,
body: { decision: 'approved' | 'rejected'; final_value?: number | null; reason?: string | null }
) {
+ // status: done=已落结论;ignored=已是终态/不存在;**suspended=未落结论**(如版本过期 409、回执失败)
return workflowFetch<{ data: { status: string; reason: string; duplicate: boolean } }>(
`/main-system/actual-qty-requests/${encodeURIComponent(id)}/decision`,
{ method: 'POST', body: JSON.stringify(body) }
|