單位顯示修正
This commit is contained in:
@@ -39,7 +39,7 @@ class ProductController extends Controller
|
|||||||
$sortDirection = $request->input('sort_direction', 'desc');
|
$sortDirection = $request->input('sort_direction', 'desc');
|
||||||
|
|
||||||
// Define allowed sort fields to prevent SQL injection
|
// 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)) {
|
if (!in_array($sortField, $allowedSorts)) {
|
||||||
$sortField = 'id';
|
$sortField = 'id';
|
||||||
}
|
}
|
||||||
@@ -62,7 +62,6 @@ class ProductController extends Controller
|
|||||||
$categories = \App\Models\Category::where('is_active', true)->get();
|
$categories = \App\Models\Category::where('is_active', true)->get();
|
||||||
|
|
||||||
return Inertia::render('Product/Index', [
|
return Inertia::render('Product/Index', [
|
||||||
'products' => $products,
|
|
||||||
'products' => $products,
|
'products' => $products,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'units' => Unit::all(),
|
'units' => Unit::all(),
|
||||||
|
|||||||
@@ -89,7 +89,11 @@ export default function ProductTable({
|
|||||||
分類 <SortIcon field="category_id" />
|
分類 <SortIcon field="category_id" />
|
||||||
</button>
|
</button>
|
||||||
</TableHead>
|
</TableHead>
|
||||||
<TableHead>基本單位</TableHead>
|
<TableHead>
|
||||||
|
<button onClick={() => onSort("base_unit_id")} className="flex items-center hover:text-gray-900 font-semibold">
|
||||||
|
基本單位 <SortIcon field="base_unit_id" />
|
||||||
|
</button>
|
||||||
|
</TableHead>
|
||||||
<TableHead>換算率</TableHead>
|
<TableHead>換算率</TableHead>
|
||||||
<TableHead className="text-center">操作</TableHead>
|
<TableHead className="text-center">操作</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
@@ -121,11 +125,11 @@ export default function ProductTable({
|
|||||||
{product.category?.name || '-'}
|
{product.category?.name || '-'}
|
||||||
</Badge>
|
</Badge>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>{product.baseUnit?.name || '-'}</TableCell>
|
<TableCell>{product.base_unit?.name || '-'}</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
{product.largeUnit ? (
|
{product.large_unit ? (
|
||||||
<span className="text-sm text-gray-500">
|
<span className="text-sm text-gray-500">
|
||||||
1 {product.largeUnit?.name} = {Number(product.conversion_rate)} {product.baseUnit?.name}
|
1 {product.large_unit?.name} = {Number(product.conversion_rate)} {product.base_unit?.name}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
'-'
|
'-'
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ export interface Product {
|
|||||||
brand?: string;
|
brand?: string;
|
||||||
specification?: string;
|
specification?: string;
|
||||||
base_unit_id: number;
|
base_unit_id: number;
|
||||||
baseUnit?: Unit;
|
base_unit?: Unit;
|
||||||
large_unit_id?: number;
|
large_unit_id?: number;
|
||||||
largeUnit?: Unit;
|
large_unit?: Unit;
|
||||||
conversion_rate?: number;
|
conversion_rate?: number;
|
||||||
purchase_unit_id?: number;
|
purchase_unit_id?: number;
|
||||||
purchaseUnit?: Unit;
|
purchase_unit?: Unit;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user