feat(inventory): 販賣機視覺優化、修復匯入日期缺失與倉庫刪除權限錯誤

This commit is contained in:
2026-02-09 10:19:46 +08:00
parent f22df90e01
commit 5e542752ba
14 changed files with 255 additions and 71 deletions

View File

@@ -9,10 +9,11 @@ use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;
use Maatwebsite\Excel\Concerns\WithValidation;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
use Maatwebsite\Excel\Imports\HeadingRowFormatter;
use Illuminate\Support\Facades\DB;
class InventoryImport implements ToModel, WithHeadingRow, WithValidation, WithMapping
class InventoryImport implements ToModel, WithHeadingRow, WithValidation, WithMapping, SkipsEmptyRows
{
private $warehouse;
private $inboundDate;
@@ -35,6 +36,9 @@ class InventoryImport implements ToModel, WithHeadingRow, WithValidation, WithMa
if (isset($row['商品代號'])) {
$row['商品代號'] = (string) $row['商品代號'];
}
if (isset($row['儲位/貨道'])) {
$row['儲位/貨道'] = (string) $row['儲位/貨道'];
}
return $row;
}
@@ -100,8 +104,11 @@ class InventoryImport implements ToModel, WithHeadingRow, WithValidation, WithMa
'batch_number' => $inventory->batch_number,
'quantity' => $quantity,
'unit_cost' => $unitCost,
'transaction_type' => '手動入庫',
'type' => '手動入庫',
'reason' => 'Excel 匯入入庫',
'balance_before' => $oldQty,
'balance_after' => $inventory->quantity,
'actual_time' => $this->inboundDate,
'notes' => $this->notes,
'expiry_date' => $inventory->expiry_date,
]);
@@ -115,8 +122,11 @@ class InventoryImport implements ToModel, WithHeadingRow, WithValidation, WithMa
return [
'商品條碼' => ['nullable', 'string'],
'商品代號' => ['nullable', 'string'],
'數量' => ['required', 'numeric', 'min:0.01'],
'單位' => ['required', 'string'],
'數量' => [
'required_with:商品條碼,商品代號', // 只有在有商品資訊時,數量才是必填
'numeric',
'min:0' // 允許數量為 0
],
'入庫單價' => ['nullable', 'numeric', 'min:0'],
'儲位/貨道' => ['nullable', 'string', 'max:50'],
'批號' => ['nullable', 'string'],