[FIX] 優化 B009 同步機制、庫存排序與修正管理後台 UI 遮擋問題

1. 實作 B009 貨道全量同步與拆除 (decommission) 紀錄機制。
2. 優化機台庫存概覽排序邏輯,優先顯示低填充率 (需補貨) 之機台。
3. 修正新增機台 Modal 的 z-index 層級與 overflow 限制,解決下拉選單被蓋住的問題。
4. 修復機台庫存分頁中的 JS 語法錯誤並新增貨道拆除狀態標籤。
This commit is contained in:
sky121113 2026-05-07 15:08:01 +08:00
parent 1739dc6625
commit 6decba6cb6
6 changed files with 25 additions and 13 deletions

View File

@ -25,15 +25,14 @@ class MachineStockMovement extends Model
'reference_type',
'reference_id',
'note',
'context',
'created_by',
];
protected $appends = [
'translated_note',
'translated_type',
];
/**
* 動態翻譯備註
*/
public function getTranslatedNoteAttribute(): ?string
{
if (empty($this->note)) {
@ -43,6 +42,14 @@ class MachineStockMovement extends Model
return __($this->note, $this->context ?? []);
}
/**
* 動態翻譯類型
*/
public function getTranslatedTypeAttribute(): string
{
return __("movement.type.{$this->type}");
}
protected $casts = [
'quantity' => 'integer',
'before_qty' => 'integer',

View File

@ -246,7 +246,7 @@ class MachineService
MachineStockMovement::TYPE_ADJUSTMENT,
null,
$note,
['old' => $oldStock, 'new' => $newStock, 'old_product_id' => $oldProductId, 'new_product_id' => $actualProductId]
['slot_no' => $existingSlot->slot_no, 'old' => $oldStock, 'new' => $newStock, 'old_product_id' => $oldProductId, 'new_product_id' => $actualProductId]
);
}
} else {
@ -260,7 +260,7 @@ class MachineService
MachineStockMovement::TYPE_ADJUSTMENT,
null,
"movement.note.initial_sync_report",
['old' => 0, 'new' => $newStock]
['slot_no' => $slotNo, 'old' => 0, 'new' => $newStock]
);
}
}
@ -283,19 +283,21 @@ class MachineService
foreach ($orphanedSlots as $orphan) {
$oldStock = (int) $orphan->stock;
// 先記流水帳(保留歷史可追溯性)
if ($oldStock > 0) {
// 先將 stock 設為 0 以便 recordStockMovement 正確計算 before/after
$orphan->stock = 0;
$this->recordStockMovement(
$orphan,
-$oldStock,
MachineStockMovement::TYPE_DECOMMISSION,
MachineStockMovement::TYPE_ADJUSTMENT, // 使用 adjustment 以確保相容舊版 Enum
null,
"movement.note.slot_decommissioned_by_b009",
['old' => $oldStock, 'new' => 0, 'slot_no' => $orphan->slot_no]
);
}
// 硬刪除貨道B009 全量同步,機台沒有就不該存在)
// 更新貨道狀態為非使用中或直接刪除 (依據需求決定,目前採刪除以維持 B009 全量同步語意)
$orphan->delete();
}
});
@ -356,7 +358,7 @@ class MachineService
MachineStockMovement::TYPE_ADJUSTMENT,
null,
"movement.note.manual_adjustment",
['old' => $oldData['stock'], 'new' => $stock]
['slot_no' => $slot->slot_no, 'old' => $oldData['stock'], 'new' => $stock]
);
}
@ -443,7 +445,8 @@ class MachineService
-1,
MachineStockMovement::TYPE_REMOTE_DISPENSE,
$command,
"遠端出貨指令 (B055),指令 ID: {$command->id}"
"movement.note.remote_dispense_queued",
['slot_no' => $slotNo, 'id' => $command->id]
);
// 4. 推播 MQTT

View File

@ -1704,6 +1704,7 @@
"movement.note.product_changed_and_adjusted": "B009 report: product changed and stock adjusted (:old → :new)",
"movement.note.replenishment_correction": "B009 inventory report correction (old: :old → new: :new)",
"movement.note.slot_decommissioned_by_b009": "B009 full sync: slot :slot_no not in report, stock :old cleared and slot removed",
"movement.note.remote_dispense_queued": "Remote dispense command (B055), Command ID: :id",
"of": "of",
"of items": "of items",
"pending": "pending",

View File

@ -1843,6 +1843,7 @@
"movement.note.product_changed_and_adjusted": "B009 廢道商品變更並調整庫存(庫存 :old → :new",
"movement.note.replenishment_correction": "B009 盤點回報修正(舊: :old → 新: :new",
"movement.note.slot_decommissioned_by_b009": "B009 全量同步:貨道 :slot_no 不在回報清單中,庫存 :old 歸零並移除",
"movement.note.remote_dispense_queued": "遠端出貨指令 (B055),指令 ID: :id",
"movement.type.adjustment": "盤點調整",
"movement.type.decommission": "B009 全量同步移除",
"movement.type.pickup": "取貨碼消耗",

View File

@ -770,7 +770,7 @@
placeholder="{{ __('Enter machine location') }}">
</div>
<div class="relative z-30">
<div class="relative z-40">
<label
class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">
{{ __('Model') }} <span class="text-rose-500">*</span>
@ -782,7 +782,7 @@
</x-searchable-select>
</div>
<div class="relative z-20">
<div class="relative z-50">
<label
class="block text-[11px] font-black text-slate-400 uppercase tracking-[0.2em] mb-2">
{{ __('Owner') }}

View File

@ -644,7 +644,7 @@
<template x-if="movement.note">
<p class="text-[11px] text-slate-400 flex items-center gap-1 font-medium italic">
<svg class="w-3 h-3 text-slate-300" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span x-text="movement.note"></span>
<span x-text="movement.translated_note || movement.note"></span>
</p>
</template>
</div>