feat(Inventory): 實作批號溯源完整功能與 UI 呈現,包含文字敘述卡片與更完整的關聯屬性
This commit is contained in:
42
app/Modules/Inventory/Controllers/TraceabilityController.php
Normal file
42
app/Modules/Inventory/Controllers/TraceabilityController.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Inventory\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use App\Modules\Inventory\Services\TraceabilityService;
|
||||
|
||||
class TraceabilityController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
protected TraceabilityService $traceabilityService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 顯示批號溯源查詢的主頁面
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$batchNumber = $request->input('batch_number');
|
||||
$direction = $request->input('direction', 'backward'); // backward 或 forward
|
||||
|
||||
$result = null;
|
||||
|
||||
if ($batchNumber) {
|
||||
if ($direction === 'backward') {
|
||||
$result = $this->traceabilityService->traceBackward($batchNumber);
|
||||
} else {
|
||||
$result = $this->traceabilityService->traceForward($batchNumber);
|
||||
}
|
||||
}
|
||||
|
||||
return Inertia::render('Inventory/Traceability/Index', [
|
||||
'search' => [
|
||||
'batch_number' => $batchNumber,
|
||||
'direction' => $direction,
|
||||
],
|
||||
'result' => $result
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user