feat: 新增採購單發票欄位、更新 SearchableSelect 樣式與搜尋門檻至 10 個項目
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Successful in 1m17s
Koori-ERP-Deploy-System / deploy-production (push) Has been skipped

This commit is contained in:
2026-01-09 10:18:52 +08:00
parent d60367ac57
commit 24ae6f3eee
13 changed files with 451 additions and 268 deletions

View File

@@ -11,13 +11,7 @@ import { Button } from "@/Components/ui/button";
import { Input } from "@/Components/ui/input";
import { Label } from "@/Components/ui/label";
import { Textarea } from "@/Components/ui/textarea";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/Components/ui/select";
import { SearchableSelect } from "@/Components/ui/searchable-select";
import { useForm } from "@inertiajs/react";
import { toast } from "sonner";
import type { Product, Category } from "@/Pages/Product/Index";
@@ -123,21 +117,14 @@ export default function ProductDialog({
<Label htmlFor="category_id">
<span className="text-red-500">*</span>
</Label>
<Select
<SearchableSelect
value={data.category_id}
onValueChange={(value) => setData("category_id", value)}
>
<SelectTrigger id="category_id" className={errors.category_id ? "border-red-500" : ""}>
<SelectValue placeholder="選擇分類" />
</SelectTrigger>
<SelectContent>
{categories.map((category) => (
<SelectItem key={category.id} value={category.id.toString()}>
{category.name}
</SelectItem>
))}
</SelectContent>
</Select>
options={categories.map((c) => ({ label: c.name, value: c.id.toString() }))}
placeholder="選擇分類"
searchPlaceholder="搜尋分類..."
className={errors.category_id ? "border-red-500" : ""}
/>
{errors.category_id && <p className="text-sm text-red-500">{errors.category_id}</p>}
</div>
@@ -188,42 +175,30 @@ export default function ProductDialog({
<Label htmlFor="base_unit_id">
<span className="text-red-500">*</span>
</Label>
<Select
<SearchableSelect
value={data.base_unit_id}
onValueChange={(value) => setData("base_unit_id", value)}
>
<SelectTrigger id="base_unit_id" className={errors.base_unit_id ? "border-red-500" : ""}>
<SelectValue placeholder="選擇單位" />
</SelectTrigger>
<SelectContent>
{units.map((unit) => (
<SelectItem key={unit.id} value={unit.id.toString()}>
{unit.name}
</SelectItem>
))}
</SelectContent>
</Select>
options={units.map((u) => ({ label: u.name, value: u.id.toString() }))}
placeholder="選擇單位"
searchPlaceholder="搜尋單位..."
className={errors.base_unit_id ? "border-red-500" : ""}
/>
{errors.base_unit_id && <p className="text-sm text-red-500">{errors.base_unit_id}</p>}
</div>
<div className="space-y-2">
<Label htmlFor="large_unit_id"></Label>
<Select
<SearchableSelect
value={data.large_unit_id}
onValueChange={(value) => setData("large_unit_id", value)}
>
<SelectTrigger id="large_unit_id" className={errors.large_unit_id ? "border-red-500" : ""}>
<SelectValue placeholder="無" />
</SelectTrigger>
<SelectContent>
<SelectItem value="none"></SelectItem>
{units.map((unit) => (
<SelectItem key={unit.id} value={unit.id.toString()}>
{unit.name}
</SelectItem>
))}
</SelectContent>
</Select>
options={[
{ label: "無", value: "none" },
...units.map((u) => ({ label: u.name, value: u.id.toString() }))
]}
placeholder="無"
searchPlaceholder="搜尋單位..."
className={errors.large_unit_id ? "border-red-500" : ""}
/>
{errors.large_unit_id && <p className="text-sm text-red-500">{errors.large_unit_id}</p>}
</div>