feat(倉庫): 機台庫存匯出 Excel 加「商品ID」欄

機台庫存概覽批次匯出(多分頁)與單機台詳細匯出的欄位,於貨道號後、商品名稱前
新增「商品ID」欄;空貨道商品ID留空。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
twsystem1004 2026-07-14 05:16:29 +00:00
parent 34b0a7faf6
commit 168a990a7e

View File

@ -745,7 +745,7 @@ class WarehouseController extends Controller
->orderByRaw('CAST(slot_no AS UNSIGNED) ASC') ->orderByRaw('CAST(slot_no AS UNSIGNED) ASC')
->get(); ->get();
$headers = ['貨道號', '商品名稱', '商品條碼', '類型', '目前庫存', '滿庫容量', '庫存率(%)', '效期', '批號', '啟用', '鎖定']; $headers = ['貨道號', '商品ID', '商品名稱', '商品條碼', '類型', '目前庫存', '滿庫容量', '庫存率(%)', '效期', '批號', '啟用', '鎖定'];
$safeSerial = preg_replace('/[^A-Za-z0-9_-]/', '', (string) $machine->serial_no); $safeSerial = preg_replace('/[^A-Za-z0-9_-]/', '', (string) $machine->serial_no);
$filename = '貨道明細_' . ($safeSerial ?: $machine->id) . '_' . now()->format('YmdHis') . '.' . $ext; $filename = '貨道明細_' . ($safeSerial ?: $machine->id) . '_' . now()->format('YmdHis') . '.' . $ext;
@ -772,6 +772,7 @@ class WarehouseController extends Controller
$row = [ $row = [
$slot->slot_no, $slot->slot_no,
$slot->product_id ?? '',
$slot->product->name ?? '', $slot->product->name ?? '',
$slot->product->barcode ?? '', $slot->product->barcode ?? '',
$slot->type, $slot->type,
@ -829,7 +830,7 @@ class WarehouseController extends Controller
} }
$machines = $query->get(); $machines = $query->get();
$headers = ['貨道號', '商品名稱', '商品條碼', '類型', '目前庫存', '滿庫容量', '庫存率(%)', '效期', '批號', '啟用', '鎖定']; $headers = ['貨道號', '商品ID', '商品名稱', '商品條碼', '類型', '目前庫存', '滿庫容量', '庫存率(%)', '效期', '批號', '啟用', '鎖定'];
$ts = now()->format('YmdHis'); $ts = now()->format('YmdHis');
// 單台的資料列 // 單台的資料列
@ -841,6 +842,7 @@ class WarehouseController extends Controller
$rate = $capacity > 0 ? round($stock / $capacity * 100) : 0; $rate = $capacity > 0 ? round($stock / $capacity * 100) : 0;
$rows[] = [ $rows[] = [
(string) $slot->slot_no, (string) $slot->slot_no,
$slot->product_id ?? '',
$slot->product->name ?? '', $slot->product->name ?? '',
$slot->product->barcode ?? '', $slot->product->barcode ?? '',
(string) $slot->type, (string) $slot->type,