feat(入库列表): 仅展示需加工徽标不改加工流程
后端只返回 needs_processing_badge(订单行仓内加工/未完工加工需求单);前端徽标与筛选用新字段,needs_processing 仍只驱动原加工/入库流程。
This commit is contained in:
@@ -194,7 +194,9 @@ export async function listInspectionsForManagement(
|
||||
LEFT JOIN skus sk ON sk.sku_code = i.sku_code
|
||||
LEFT JOIN suppliers sup ON sup.supplier_code = i.supplier_code
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT oi2.item_name, oi2.category_code, oi2.unit, oi2.category_name
|
||||
SELECT oi2.item_name, oi2.category_code, oi2.unit, oi2.category_name,
|
||||
oi2.processing_method AS line_processing_method,
|
||||
oi2.processing_owner AS line_processing_owner
|
||||
FROM order_items oi2
|
||||
WHERE oi2.order_code = i.order_code
|
||||
AND (oi2.sku_code = i.sku_code OR i.sku_code IS NULL)
|
||||
@@ -308,6 +310,17 @@ export async function listInspectionsForManagement(
|
||||
demand_sheet.demand_material_qty,
|
||||
demand_sheet.demand_net_weight,
|
||||
demand_sheet.demand_loss_qty,
|
||||
-- 仅用于入库列表「需加工」徽标,不驱动任何入库/加工流程。
|
||||
(CASE
|
||||
WHEN LOWER(TRIM(COALESCE(oi.line_processing_owner, ''))) IN
|
||||
('warehouse', 'warehouse_processing', '仓内加工')
|
||||
AND COALESCE(NULLIF(TRIM(oi.line_processing_method), ''), '原材料') <> '原材料'
|
||||
THEN TRUE
|
||||
WHEN demand_sheet.demand_material_qty IS NOT NULL
|
||||
OR demand_sheet.demand_net_weight IS NOT NULL
|
||||
THEN TRUE
|
||||
ELSE FALSE
|
||||
END) AS needs_processing_badge,
|
||||
${LAST_INBOUND_ZONE_SELECT},
|
||||
${inboundPriceSql} AS inbound_unit_price
|
||||
${listFromSql}
|
||||
@@ -330,6 +343,7 @@ export async function listInspectionsForManagement(
|
||||
demand_material_qty: row.demand_material_qty == null ? null : Number(row.demand_material_qty),
|
||||
demand_net_weight: row.demand_net_weight == null ? null : Number(row.demand_net_weight),
|
||||
demand_loss_qty: row.demand_loss_qty == null ? null : Number(row.demand_loss_qty),
|
||||
needs_processing_badge: row.needs_processing_badge === true,
|
||||
}));
|
||||
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const service = readFileSync(new URL('../src/services/inspectionQueryService.ts', import.meta.url), 'utf8');
|
||||
const page = readFileSync(new URL('../../src/pages/inspection/InspectionManagement.tsx', import.meta.url), 'utf8');
|
||||
|
||||
describe('入库列表「需加工」仅展示徽标', () => {
|
||||
it('后端返回独立的 needs_processing_badge,不返回 needs_processing 流程字段', () => {
|
||||
expect(service).toContain('AS needs_processing_badge');
|
||||
expect(service).toContain('needs_processing_badge: row.needs_processing_badge === true');
|
||||
expect(service).toContain('oi2.processing_method AS line_processing_method');
|
||||
expect(service).toContain('oi2.processing_owner AS line_processing_owner');
|
||||
expect(service).not.toContain('AS needs_processing,');
|
||||
});
|
||||
|
||||
it('前端徽标/筛选使用 badge 字段,加工流程仍使用 needs_processing', () => {
|
||||
expect(page).toContain('needs_processing_badge?: boolean');
|
||||
expect(page).toContain('needs_processing_badge: Boolean(item.needs_processing_badge)');
|
||||
expect(page).toContain('task.needs_processing_badge');
|
||||
expect(page).toContain("processingFilter === 'needs' && !t.needs_processing_badge");
|
||||
expect(page).toContain('selectedTask?.needs_processing === true');
|
||||
expect(page).toContain('needsProcessing: task.needs_processing === true');
|
||||
});
|
||||
});
|
||||
@@ -318,6 +318,8 @@ interface InspectionTask {
|
||||
unit?: string | null;
|
||||
source_type?: 'supplier' | 'purchase' | string;
|
||||
needs_processing?: boolean;
|
||||
/** 仅列表展示「需加工」徽标;不触发加工明细/入库流程。 */
|
||||
needs_processing_badge?: boolean;
|
||||
status: number;
|
||||
temperature?: number;
|
||||
humidity?: number;
|
||||
@@ -970,6 +972,7 @@ export const InspectionManagement: React.FC = () => {
|
||||
processing_details: item.processing_details || [],
|
||||
purchase_price: item.purchase_price,
|
||||
needs_processing: Boolean(item.needs_processing),
|
||||
needs_processing_badge: Boolean(item.needs_processing_badge),
|
||||
demand_material_qty: item.demand_material_qty == null ? null : Number(item.demand_material_qty),
|
||||
demand_net_weight: item.demand_net_weight == null ? null : Number(item.demand_net_weight),
|
||||
demand_loss_qty: item.demand_loss_qty == null ? null : Number(item.demand_loss_qty),
|
||||
@@ -1501,8 +1504,8 @@ export const InspectionManagement: React.FC = () => {
|
||||
if (gradeFilter) {
|
||||
if (formatInspectionResultLabel(t.quality_rating) !== gradeFilter) return false;
|
||||
}
|
||||
if (processingFilter === 'needs' && !t.needs_processing) return false;
|
||||
if (processingFilter === 'none' && t.needs_processing) return false;
|
||||
if (processingFilter === 'needs' && !t.needs_processing_badge) return false;
|
||||
if (processingFilter === 'none' && t.needs_processing_badge) return false;
|
||||
// 日期区间已由 management-list 按配送日/下单日过滤,此处不再按建单日二次筛
|
||||
return true;
|
||||
};
|
||||
@@ -2248,7 +2251,7 @@ export const InspectionManagement: React.FC = () => {
|
||||
? t('inspection.type.purchase')
|
||||
: t('inspection.type.supplier')}
|
||||
</span>
|
||||
{task.needs_processing && (
|
||||
{task.needs_processing_badge && (
|
||||
<span className="ml-1 inline-flex px-2 py-0.5 rounded text-xs bg-purple-50 text-purple-700 dark:bg-purple-950/50 dark:text-purple-300">
|
||||
{t('inspection.needProcess')}
|
||||
</span>
|
||||
|
||||
Reference in New Issue
Block a user