diff --git a/src/i18n/locales/en/inventory.ts b/src/i18n/locales/en/inventory.ts index bc42ba7..3542126 100644 --- a/src/i18n/locales/en/inventory.ts +++ b/src/i18n/locales/en/inventory.ts @@ -144,6 +144,9 @@ export const inventory: MessageDict = { 'void.confirm': 'Confirm void', 'void.confirmMany': 'Confirm void {n}', + 'adjust.reportsLabel': 'Batch reports', + 'adjust.reportsEmpty': 'No report yet. Use “Upload report”.', + 'batchReport.delFail': 'Failed to delete report', 'adjust.title': 'Adjust available stock', 'adjust.product': 'Product', 'adjust.batch': 'Batch', diff --git a/src/i18n/locales/id/inventory.ts b/src/i18n/locales/id/inventory.ts index e44652c..0154389 100644 --- a/src/i18n/locales/id/inventory.ts +++ b/src/i18n/locales/id/inventory.ts @@ -148,6 +148,9 @@ export const inventory: MessageDict = { 'void.confirm': 'Konfirmasi hapus', 'void.confirmMany': 'Konfirmasi hapus {n}', + 'adjust.reportsLabel': 'Laporan batch', + 'adjust.reportsEmpty': 'Belum ada laporan. Gunakan “Unggah laporan”.', + 'batchReport.delFail': 'Gagal menghapus laporan', 'adjust.title': 'Ubah stok tersedia', 'adjust.product': 'Produk', 'adjust.batch': 'Batch', diff --git a/src/i18n/locales/zh-CN/inventory.ts b/src/i18n/locales/zh-CN/inventory.ts index f2fe800..b058762 100644 --- a/src/i18n/locales/zh-CN/inventory.ts +++ b/src/i18n/locales/zh-CN/inventory.ts @@ -142,6 +142,9 @@ export const inventory: MessageDict = { 'void.confirm': '确认删除', 'void.confirmMany': '确认删除 {n} 条', + 'adjust.reportsLabel': '批次报告', + 'adjust.reportsEmpty': '该批次还没有报告,可点右侧「上传报告」补充', + 'batchReport.delFail': '删除报告失败', 'adjust.title': '修改可用库存', 'adjust.product': '商品', 'adjust.batch': '批次', diff --git a/src/pages/inventory/InventoryManagement.tsx b/src/pages/inventory/InventoryManagement.tsx index 1977c8e..9742e74 100644 --- a/src/pages/inventory/InventoryManagement.tsx +++ b/src/pages/inventory/InventoryManagement.tsx @@ -49,6 +49,10 @@ import { listInventoryManagementApi, listInboundHoldingCostsApi, } from '../../utils/workflowApi'; +import { + fetchInventoryBatchReportsByInventoryApi, + deleteInventoryBatchReportApi, +} from '../../utils/workflowApi'; import { readOperatingBranchCode } from '../../utils/operatingBranch'; import { useAuth } from '../../hooks/useAuth'; import { useFetchGeneration } from '../../hooks/useFetchGeneration'; @@ -218,6 +222,23 @@ export const InventoryManagement: React.FC = () => { created_at: string | null; }> >([]); + useEffect(() => { + if (!adjustItem?.id) { + setAdjustReports([]); + return; + } + let alive = true; + void fetchInventoryBatchReportsByInventoryApi(String(adjustItem.id)) + .then((rows) => { + if (alive) setAdjustReports(Array.isArray(rows) ? rows : []); + }) + .catch(() => { + if (alive) setAdjustReports([]); + }); + return () => { + alive = false; + }; + }, [adjustItem?.id]); const [holdingLoading, setHoldingLoading] = useState(false); const [searchQuery, setSearchQuery] = useState(''); const [expiryFilter, setExpiryFilter] = useState(''); @@ -228,8 +249,32 @@ export const InventoryManagement: React.FC = () => { const [zoneFilter, setZoneFilter] = useState(''); const [zoneOptions, setZoneOptions] = useState([]); const [adjustItem, setAdjustItem] = useState(null); + /** 当前调整批次已绑定的报告(弹窗内可查看/删除/补充;2026-10-20 开发者需求) */ + const [adjustReports, setAdjustReports] = useState< + Array<{ id: string; report_type: string; report_no: string | null; uploaded_at: string | null }> + >([]); const [adjustQty, setAdjustQty] = useState(''); const [adjustRemark, setAdjustRemark] = useState(''); + /** 载入当前批次的已绑定报告(打开/切换批次时;失败静默为空) */ + useEffect(() => { + const inventoryId = adjustItem?.id; + if (!inventoryId) { + setAdjustReports([]); + return; + } + let alive = true; + void fetchInventoryBatchReportsByInventoryApi(String(inventoryId)) + .then((rows) => { + if (alive) setAdjustReports(Array.isArray(rows) ? rows : []); + }) + .catch(() => { + if (alive) setAdjustReports([]); + }); + return () => { + alive = false; + }; + }, [adjustItem?.id]); + const [adjustSaving, setAdjustSaving] = useState(false); const [adjustStorageZone, setAdjustStorageZone] = useState(''); const [adjustShelfLife, setAdjustShelfLife] = useState(''); @@ -1797,6 +1842,49 @@ export const InventoryManagement: React.FC = () => {
+ {/* 报告:该批次已绑定报告可查看/删除,并能直接补充(2026-10-20 开发者需求) */} +
+
+ {t('inventory.adjust.reportsLabel')} + +
+ {adjustReports.length === 0 ? ( +

{t('inventory.adjust.reportsEmpty')}

+ ) : ( +
    + {adjustReports.map((rep) => ( +
  • + + {t(`inventory.batchReport.type.${rep.report_type}` as any) || rep.report_type} + {rep.uploaded_at ? · {rep.uploaded_at} : null} + + +
  • + ))} +
+ )} +
+

{t('inventory.adjust.product')}

{adjustItem.sku_name || adjustItem.sku_code}