feat(库存): 修改可用库存弹窗内新增「批次报告」区——可查看/删除已绑定报告并直接上传补充(三语文案)
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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': '批次',
|
||||
|
||||
@@ -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<string[]>([]);
|
||||
const [adjustItem, setAdjustItem] = useState<InventoryItem | null>(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 = () => {
|
||||
</button>
|
||||
</div>
|
||||
<div className="space-y-3 text-sm">
|
||||
{/* 报告:该批次已绑定报告可查看/删除,并能直接补充(2026-10-20 开发者需求) */}
|
||||
<div>
|
||||
<div className="mb-1 flex items-center justify-between">
|
||||
<span className="block text-gray-500 text-xs">{t('inventory.adjust.reportsLabel')}</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setBatchReportOpen(true)}
|
||||
className="text-xs text-indigo-600 hover:underline"
|
||||
>
|
||||
{t('inventory.batchReport.button')}
|
||||
</button>
|
||||
</div>
|
||||
{adjustReports.length === 0 ? (
|
||||
<p className="text-xs text-gray-400">{t('inventory.adjust.reportsEmpty')}</p>
|
||||
) : (
|
||||
<ul className="space-y-1">
|
||||
{adjustReports.map((rep) => (
|
||||
<li key={rep.id} className="flex items-center justify-between gap-2 text-xs">
|
||||
<span className="truncate">
|
||||
{t(`inventory.batchReport.type.${rep.report_type}` as any) || rep.report_type}
|
||||
{rep.uploaded_at ? <span className="text-gray-400"> · {rep.uploaded_at}</span> : null}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={async () => {
|
||||
try {
|
||||
await deleteInventoryBatchReportApi(rep.id);
|
||||
setAdjustReports((prev) => prev.filter((x) => x.id !== rep.id));
|
||||
await fetchInventory();
|
||||
} catch (error: any) {
|
||||
notify(error?.message || t('inventory.batchReport.delFail'));
|
||||
}
|
||||
}}
|
||||
className="text-red-600 hover:underline"
|
||||
>
|
||||
{t('common.delete')}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-gray-500 text-xs">{t('inventory.adjust.product')}</p>
|
||||
<p className="font-medium">{adjustItem.sku_name || adjustItem.sku_code}</p>
|
||||
|
||||
Reference in New Issue
Block a user