From b8d26123df7b8c1575d2b2ed9db443a36bbc3c3f Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 2 Nov 2026 16:00:24 +0800 Subject: [PATCH] =?UTF-8?q?style(=E5=BA=93=E5=AD=98):=20=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=85=A5=E5=8F=A3=E4=B8=8E=E5=85=A8=E9=80=89=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B2=BF=E7=94=A8=E5=8E=9F=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 去掉真实删除单独文案/按钮;单条与全选当前页统一走删除:有可用量先清空,已无可用量移除批次记录。 --- server/tests/inventoryHardDelete.test.ts | 2 +- src/i18n/locales/en/inventory.ts | 14 +-- src/i18n/locales/id/inventory.ts | 14 +-- src/i18n/locales/zh-CN/inventory.ts | 14 +-- src/pages/inventory/InventoryManagement.tsx | 105 +++++--------------- 5 files changed, 32 insertions(+), 117 deletions(-) diff --git a/server/tests/inventoryHardDelete.test.ts b/server/tests/inventoryHardDelete.test.ts index 7b0add9..7ad6eb9 100644 --- a/server/tests/inventoryHardDelete.test.ts +++ b/server/tests/inventoryHardDelete.test.ts @@ -37,6 +37,6 @@ describe('库存批次真实删除(方案 A)', () => { expect(route).toContain('/inventory/batches/:inventoryId/hard-delete'); expect(route).toContain("['inventory_adjust']"); expect(page).toContain('hardDeleteInventoryBatchApi'); - expect(page).toContain('inventory.action.hardDelete'); + expect(page).toContain('setVoidTargets([item])'); }); }); diff --git a/src/i18n/locales/en/inventory.ts b/src/i18n/locales/en/inventory.ts index 7418d9d..c22ef95 100644 --- a/src/i18n/locales/en/inventory.ts +++ b/src/i18n/locales/en/inventory.ts @@ -71,8 +71,6 @@ export const inventory: MessageDict = { inboundDate: 'In {date}', 'action.edit': 'Edit', 'action.editTitle': 'Adjust available stock', - 'action.hardDeleteTitle': 'Permanently delete (no available stock)', - 'action.hardDelete': 'Delete permanently', 'action.delete': 'Delete', 'action.deleteTitle': 'Zero this batch and hide it from the default list', 'pager.inventory': 'batches', @@ -134,19 +132,11 @@ export const inventory: MessageDict = { 'holding.loading': 'Loading…', 'holding.empty': 'No holding cost', - 'hardDelete.title': 'Permanently delete stock batch', - 'hardDelete.body': 'Available stock is 0. This permanently deletes the inventory batch so it no longer blocks product deletion. Stock logs and report files are kept.', - 'hardDelete.confirm': 'Delete permanently', - 'hardDelete.processing': 'Deleting…', - 'hardDelete.done': 'Stock batch permanently deleted', - 'hardDelete.failed': 'Permanent delete failed', - 'hardDelete.reason': 'Consumed cleanup', - 'hardDelete.keepHint': 'Stock logs and report files are kept; this cannot be undone.', 'void.title': 'Void stock batch', 'void.bodyOne': - 'Set this batch available to 0 and hide it from the default list. No hard delete; logs remain. Do not void batches that are still physically in stock.', + 'Delete this batch: available stock is cleared first; batches with no available stock have their batch record removed. Stock logs and report files are kept. This cannot be undone.', 'void.bodyMany': - 'Void {n} batches on this page (other pages untouched). Available set to 0 and hidden from the default list; logs remain.', + 'Delete {n} batches on this page (other pages untouched): available stock is cleared first; batches with no available stock have their batch record removed. Logs and report files are kept.', 'void.product': 'Product', 'void.batch': 'Batch', 'void.currentAvailable': 'Current available {qty}', diff --git a/src/i18n/locales/id/inventory.ts b/src/i18n/locales/id/inventory.ts index 5aaa1b0..0c2f38b 100644 --- a/src/i18n/locales/id/inventory.ts +++ b/src/i18n/locales/id/inventory.ts @@ -74,8 +74,6 @@ export const inventory: MessageDict = { inboundDate: 'Masuk {date}', 'action.edit': 'Ubah', 'action.editTitle': 'Ubah stok tersedia', - 'action.hardDeleteTitle': 'Hapus permanen (tidak ada stok tersedia)', - 'action.hardDelete': 'Hapus permanen', 'action.delete': 'Hapus', 'action.deleteTitle': 'Nolkan batch ini dan sembunyikan dari daftar default', @@ -138,19 +136,11 @@ export const inventory: MessageDict = { 'holding.loading': 'Memuat…', 'holding.empty': 'Tidak ada biaya holding', - 'hardDelete.title': 'Hapus permanen batch stok', - 'hardDelete.body': 'Stok tersedia 0. Batch inventaris akan dihapus permanen dan tidak lagi memblokir penghapusan produk. Log stok dan file laporan tetap disimpan.', - 'hardDelete.confirm': 'Hapus permanen', - 'hardDelete.processing': 'Menghapus…', - 'hardDelete.done': 'Batch stok dihapus permanen', - 'hardDelete.failed': 'Gagal menghapus permanen', - 'hardDelete.reason': 'Pembersihan stok habis', - 'hardDelete.keepHint': 'Log stok dan file laporan tetap disimpan; tidak dapat dibatalkan.', 'void.title': 'Hapus batch stok', 'void.bodyOne': - 'Set tersedia batch ini ke 0 dan sembunyikan dari daftar default. Tidak hapus fisik; log tetap. Jangan void batch yang masih ada di gudang.', + 'Hapus batch ini: stok tersedia dikosongkan lebih dulu; batch tanpa stok tersedia akan dihapus record-nya. Log stok dan file laporan tetap disimpan. Tidak dapat dibatalkan.', 'void.bodyMany': - 'Hapus {n} batch di halaman ini (halaman lain tidak). Tersedia jadi 0 lalu disembunyikan; log tetap.', + 'Hapus {n} batch di halaman ini (halaman lain tidak): stok tersedia dikosongkan lebih dulu; batch tanpa stok tersedia akan dihapus record-nya. Log dan file laporan tetap disimpan.', 'void.product': 'Produk', 'void.batch': 'Batch', 'void.currentAvailable': 'Tersedia sekarang {qty}', diff --git a/src/i18n/locales/zh-CN/inventory.ts b/src/i18n/locales/zh-CN/inventory.ts index eff30b4..ad8a69f 100644 --- a/src/i18n/locales/zh-CN/inventory.ts +++ b/src/i18n/locales/zh-CN/inventory.ts @@ -70,8 +70,6 @@ export const inventory: MessageDict = { inboundDate: '入库 {date}', 'action.edit': '修改', 'action.editTitle': '修改可用库存', - 'action.hardDeleteTitle': '可真实删除(已无可用库存)', - 'action.hardDelete': '真实删除', 'action.delete': '删除', 'action.deleteTitle': '将本批次可用清零并从默认列表隐藏', 'pager.inventory': '条库存', @@ -132,19 +130,11 @@ export const inventory: MessageDict = { 'holding.loading': '加载中…', 'holding.empty': '暂无在库存货(账外进仓台账)', - 'hardDelete.title': '真实删除库存批次', - 'hardDelete.body': '该批次可用库存已为 0。真实删除后会物理删除库存批次,商品不再被它引用;库存流水和报告文件保留。', - 'hardDelete.confirm': '确认真实删除', - 'hardDelete.processing': '删除中…', - 'hardDelete.done': '库存批次已真实删除', - 'hardDelete.failed': '真实删除失败', - 'hardDelete.reason': '已用完清理', - 'hardDelete.keepHint': '不会删除库存流水/报告文件,删除后不可恢复。', 'void.title': '删除库存批次', 'void.bodyOne': - '将本批次可用改为 0,默认列表不再显示。不物理删库,流水保留。请勿把真实在库批次一并删掉。', + '删除本批次:有可用量的先清空可用量;已无可用量的批次移除批次记录。库存流水和报告文件保留,删除后不可恢复。', 'void.bodyMany': - '将删除当前页 {n} 条批次(不含其它页)。可用改为 0 后默认列表不再显示,流水保留。', + '删除当前页 {n} 条批次(不含其它页):有可用量的先清空可用量;已无可用量的批次移除批次记录。流水和报告文件保留。', 'void.product': '商品', 'void.batch': '批次', 'void.currentAvailable': '当前可用 {qty}', diff --git a/src/pages/inventory/InventoryManagement.tsx b/src/pages/inventory/InventoryManagement.tsx index f596503..ec6d59d 100644 --- a/src/pages/inventory/InventoryManagement.tsx +++ b/src/pages/inventory/InventoryManagement.tsx @@ -413,8 +413,6 @@ export const InventoryManagement: React.FC = () => { const [unitChoices, setUnitChoices] = useState>([]); const [voidTargets, setVoidTargets] = useState([]); const [voidSaving, setVoidSaving] = useState(false); - const [hardDeleteTarget, setHardDeleteTarget] = useState(null); - const [hardDeleting, setHardDeleting] = useState(false); const [voidProgress, setVoidProgress] = useState(''); const [stockCoverEnabled, setStockCoverEnabled] = useState(true); const [stockImportOpen, setStockImportOpen] = useState(false); @@ -596,25 +594,6 @@ export const InventoryManagement: React.FC = () => { }; }, []); - const submitHardDeleteBatch = async () => { - if (!hardDeleteTarget || hardDeleting) return; - setHardDeleting(true); - try { - await hardDeleteInventoryBatchApi({ - inventoryId: hardDeleteTarget.id, - reason: t('inventory.hardDelete.reason'), - operatingBranchCode: operatingBranchCode || readOperatingBranchCode(), - }); - notify.success(t('inventory.hardDelete.done')); - setHardDeleteTarget(null); - await Promise.all([fetchInventory(), fetchInventoryLogs()]); - } catch (error: any) { - notify.error(error?.message || t('inventory.hardDelete.failed')); - } finally { - setHardDeleting(false); - } - }; - const closeVoidModal = () => { if (voidSaving) return; setVoidTargets([]); @@ -623,12 +602,7 @@ export const InventoryManagement: React.FC = () => { const submitVoidBatch = async () => { if (!voidTargets.length || voidSaving) return; - const targets = voidTargets.filter((item) => (Number(item.available_qty) || 0) > 0); - if (!targets.length) { - notify.error(t('inventory.toast.noVoidable')); - setVoidTargets([]); - return; - } + const targets = voidTargets; setVoidSaving(true); const branch = operatingBranchCode || readOperatingBranchCode(); let ok = 0; @@ -638,12 +612,20 @@ export const InventoryManagement: React.FC = () => { const item = targets[i]; setVoidProgress(`${i + 1}/${targets.length}`); try { - await adjustInventoryAvailableApi({ - inventoryId: item.id, - availableQty: 0, - remark: INVENTORY_VOID_REMARK, - operatingBranchCode: branch, - }); + if (Number(item.available_qty) > 1e-9) { + await adjustInventoryAvailableApi({ + inventoryId: item.id, + availableQty: 0, + remark: INVENTORY_VOID_REMARK, + operatingBranchCode: branch, + }); + } else { + await hardDeleteInventoryBatchApi({ + inventoryId: item.id, + reason: INVENTORY_VOID_REMARK, + operatingBranchCode: branch, + }); + } ok += 1; } catch (err: unknown) { const msg = err instanceof Error ? err.message : t('inventory.toast.deleteFail'); @@ -1413,12 +1395,11 @@ export const InventoryManagement: React.FC = () => { type="button" disabled={loading || voidSaving || sortedInventory.length === 0} onClick={() => { - const rows = sortedInventory.filter((item) => (Number(item.available_qty) || 0) > 0); - if (!rows.length) { + if (!sortedInventory.length) { notify.error(t('inventory.toast.pageNoVoidable')); return; } - setVoidTargets(rows); + setVoidTargets(sortedInventory); }} className="inline-flex items-center px-3 py-2 text-sm font-medium text-red-700 border border-red-200 rounded-md hover:bg-red-50 disabled:opacity-50 whitespace-nowrap" title={t('inventory.bulkVoidTitle')} @@ -1792,25 +1773,14 @@ export const InventoryManagement: React.FC = () => { > {t('inventory.action.edit')} - {Number(item.available_qty) <= 1e-9 ? ( - - ) : ( - - )} + ); @@ -2215,31 +2185,6 @@ export const InventoryManagement: React.FC = () => { )} - {hardDeleteTarget && ( - (hardDeleting ? undefined : setHardDeleteTarget(null))}> -
e.stopPropagation()}> -
-

{t('inventory.hardDelete.title')}

- -
-

{t('inventory.hardDelete.body')}

-
-

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

{hardDeleteTarget.sku_name || hardDeleteTarget.sku_code}

-

{t('inventory.void.batch')}

{hardDeleteTarget.batch_no}

-

{t('inventory.hardDelete.keepHint')}

-
-
- - -
-
-
- )} - {adjustItem && (