From 7848976a06fde4ec5c9103d6276fb72351e55695 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Thu, 8 Jan 2026 12:00:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=96=AE=E4=BD=8D=E9=A1=AF=E7=A4=BA=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/ProductController.php | 3 +-- resources/js/Components/Product/ProductTable.tsx | 12 ++++++++---- resources/js/Pages/Product/Index.tsx | 6 +++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/ProductController.php b/app/Http/Controllers/ProductController.php index 418b0b1..9e3e527 100644 --- a/app/Http/Controllers/ProductController.php +++ b/app/Http/Controllers/ProductController.php @@ -39,7 +39,7 @@ class ProductController extends Controller $sortDirection = $request->input('sort_direction', 'desc'); // Define allowed sort fields to prevent SQL injection - $allowedSorts = ['id', 'code', 'name', 'category_id', 'base_unit', 'conversion_rate']; + $allowedSorts = ['id', 'code', 'name', 'category_id', 'base_unit_id', 'conversion_rate']; if (!in_array($sortField, $allowedSorts)) { $sortField = 'id'; } @@ -62,7 +62,6 @@ class ProductController extends Controller $categories = \App\Models\Category::where('is_active', true)->get(); return Inertia::render('Product/Index', [ - 'products' => $products, 'products' => $products, 'categories' => $categories, 'units' => Unit::all(), diff --git a/resources/js/Components/Product/ProductTable.tsx b/resources/js/Components/Product/ProductTable.tsx index e4a3da7..cac8e54 100644 --- a/resources/js/Components/Product/ProductTable.tsx +++ b/resources/js/Components/Product/ProductTable.tsx @@ -89,7 +89,11 @@ export default function ProductTable({ 分類 - 基本單位 + + + 換算率 操作 @@ -121,11 +125,11 @@ export default function ProductTable({ {product.category?.name || '-'} - {product.baseUnit?.name || '-'} + {product.base_unit?.name || '-'} - {product.largeUnit ? ( + {product.large_unit ? ( - 1 {product.largeUnit?.name} = {Number(product.conversion_rate)} {product.baseUnit?.name} + 1 {product.large_unit?.name} = {Number(product.conversion_rate)} {product.base_unit?.name} ) : ( '-' diff --git a/resources/js/Pages/Product/Index.tsx b/resources/js/Pages/Product/Index.tsx index b7e73f6..55b89a0 100644 --- a/resources/js/Pages/Product/Index.tsx +++ b/resources/js/Pages/Product/Index.tsx @@ -33,12 +33,12 @@ export interface Product { brand?: string; specification?: string; base_unit_id: number; - baseUnit?: Unit; + base_unit?: Unit; large_unit_id?: number; - largeUnit?: Unit; + large_unit?: Unit; conversion_rate?: number; purchase_unit_id?: number; - purchaseUnit?: Unit; + purchase_unit?: Unit; created_at: string; updated_at: string; }