From a24ff111a33b414fb1901b09e09421f15612eca7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 20 Oct 2026 14:39:01 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=BA=93=E5=AD=98):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E5=BA=93=E5=AD=98=E5=BC=B9=E7=AA=97=E5=86=85?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=8C=E6=89=B9=E6=AC=A1=E6=8A=A5=E5=91=8A?= =?UTF-8?q?=E3=80=8D=E5=8C=BA=E2=80=94=E2=80=94=E5=8F=AF=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?/=E5=88=A0=E9=99=A4=E5=B7=B2=E7=BB=91=E5=AE=9A=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E5=B9=B6=E7=9B=B4=E6=8E=A5=E4=B8=8A=E4=BC=A0=E8=A1=A5?= =?UTF-8?q?=E5=85=85=EF=BC=88=E4=B8=89=E8=AF=AD=E6=96=87=E6=A1=88=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en/inventory.ts | 3 + src/i18n/locales/id/inventory.ts | 3 + src/i18n/locales/zh-CN/inventory.ts | 3 + src/pages/inventory/InventoryManagement.tsx | 88 +++++++++++++++++++++ 4 files changed, 97 insertions(+) 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}