feat(inventory): 販賣機視覺優化、修復匯入日期缺失與倉庫刪除權限錯誤
This commit is contained in:
@@ -133,7 +133,7 @@ export default function WarehouseInventoryPage({
|
||||
</div>
|
||||
|
||||
{/* 操作按鈕 (位於標題下方) */}
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="flex flex-wrap items-center gap-3 mb-6">
|
||||
{/* 安全庫存設定按鈕 */}
|
||||
<Can permission="inventory.safety_stock">
|
||||
<Link href={route('warehouses.safety-stock.index', warehouse.id)}>
|
||||
@@ -231,6 +231,7 @@ export default function WarehouseInventoryPage({
|
||||
open={importDialogOpen}
|
||||
onOpenChange={setImportDialogOpen}
|
||||
warehouseId={warehouse.id}
|
||||
warehouseName={warehouse.name}
|
||||
/>
|
||||
</div>
|
||||
</AuthenticatedLayout>
|
||||
|
||||
@@ -69,18 +69,39 @@ export default function SafetyStockPage({
|
||||
};
|
||||
|
||||
const handleEdit = (updatedSetting: SafetyStockSetting) => {
|
||||
router.put(route('warehouses.safety-stock.update', [warehouse.id, updatedSetting.id]), {
|
||||
safetyStock: updatedSetting.safetyStock,
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
setEditingSetting(null);
|
||||
toast.success(`成功更新 ${updatedSetting.productName} 的安全庫存`);
|
||||
},
|
||||
onError: (errors) => {
|
||||
const firstError = Object.values(errors)[0];
|
||||
toast.error(typeof firstError === 'string' ? firstError : "更新失敗");
|
||||
}
|
||||
});
|
||||
// 如果 ID 包含 temp_,表示這是一個「自動帶入但尚未存入資料庫」的建議項
|
||||
// 這種情況應該呼叫 POST (store) 而非 PUT (update),以避免被後端路由模型綁定報 404
|
||||
if (updatedSetting.id.includes('temp_')) {
|
||||
router.post(route('warehouses.safety-stock.store', warehouse.id), {
|
||||
settings: [{
|
||||
productId: updatedSetting.productId,
|
||||
quantity: updatedSetting.safetyStock
|
||||
}],
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
setEditingSetting(null);
|
||||
toast.success(`成功設定 ${updatedSetting.productName} 的安全庫存`);
|
||||
},
|
||||
onError: (errors) => {
|
||||
const firstError = Object.values(errors)[0];
|
||||
toast.error(typeof firstError === 'string' ? firstError : "設定失敗");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 已存在的項目,正常執行 PUT 更新
|
||||
router.put(route('warehouses.safety-stock.update', [warehouse.id, updatedSetting.id]), {
|
||||
safetyStock: updatedSetting.safetyStock,
|
||||
}, {
|
||||
onSuccess: () => {
|
||||
setEditingSetting(null);
|
||||
toast.success(`成功更新 ${updatedSetting.productName} 的安全庫存`);
|
||||
},
|
||||
onError: (errors) => {
|
||||
const firstError = Object.values(errors)[0];
|
||||
toast.error(typeof firstError === 'string' ? firstError : "更新失敗");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
|
||||
Reference in New Issue
Block a user