feat: 優化採購單操作紀錄與統一刪除確認 UI

- 優化採購單更新與刪除的活動紀錄邏輯 (PurchaseOrderController)
  - 整合更新異動為單一紀錄,包含品項差異
  - 刪除時記錄當下品項快照
- 統一採購單刪除確認介面,使用 AlertDialog 取代原生 confirm (PurchaseOrderActions)
- Refactor: 將 ActivityDetailDialog 移至 Components/ActivityLog 並優化樣式與大數據顯示
- 調整 UI 文字:將「總金額」統一為「小計」
- 其他模型與 Controller 的活動紀錄支援更新
This commit is contained in:
2026-01-19 15:32:41 +08:00
parent 18edb3cb69
commit a8091276b8
20 changed files with 1114 additions and 482 deletions

View File

@@ -80,11 +80,12 @@ class Product extends Model
{
$properties = $activity->properties;
$attributes = $properties['attributes'] ?? [];
$snapshot = $properties['snapshot'] ?? [];
// Handle Category Name Snapshot
if (isset($attributes['category_id'])) {
$category = Category::find($attributes['category_id']);
$attributes['category_name'] = $category ? $category->name : null;
$snapshot['category_name'] = $category ? $category->name : null;
}
// Handle Unit Name Snapshots
@@ -93,14 +94,15 @@ class Product extends Model
if (isset($attributes[$field])) {
$unit = Unit::find($attributes[$field]);
$nameKey = str_replace('_id', '_name', $field);
$attributes[$nameKey] = $unit ? $unit->name : null;
$snapshot[$nameKey] = $unit ? $unit->name : null;
}
}
// Always snapshot self name for context (so logs always show "Cola")
$attributes['name'] = $this->name;
$snapshot['name'] = $this->name;
$properties['attributes'] = $attributes;
$properties['snapshot'] = $snapshot;
$activity->properties = $properties;
}