UI優化: 全系統狀態標籤 (StatusBadge) 統一化重構完成 (Phase 3 & 4)
This commit is contained in:
@@ -32,12 +32,20 @@ import { validateWarehouse } from "@/utils/validation";
|
||||
import { toast } from "sonner";
|
||||
import { SearchableSelect } from "@/Components/ui/searchable-select";
|
||||
|
||||
interface TransitWarehouseOption {
|
||||
id: string;
|
||||
name: string;
|
||||
license_plate?: string;
|
||||
driver_name?: string;
|
||||
}
|
||||
|
||||
interface WarehouseDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
warehouse: Warehouse | null;
|
||||
onSave: (warehouse: Omit<Warehouse, "id" | "createdAt" | "updatedAt">) => void;
|
||||
onDelete?: (warehouseId: string) => void;
|
||||
transitWarehouses?: TransitWarehouseOption[];
|
||||
}
|
||||
|
||||
const WAREHOUSE_TYPE_OPTIONS: { label: string; value: WarehouseType }[] = [
|
||||
@@ -55,6 +63,7 @@ export default function WarehouseDialog({
|
||||
warehouse,
|
||||
onSave,
|
||||
onDelete,
|
||||
transitWarehouses = [],
|
||||
}: WarehouseDialogProps) {
|
||||
const [formData, setFormData] = useState<{
|
||||
code: string;
|
||||
@@ -64,6 +73,7 @@ export default function WarehouseDialog({
|
||||
type: WarehouseType;
|
||||
license_plate: string;
|
||||
driver_name: string;
|
||||
default_transit_warehouse_id: string | null;
|
||||
}>({
|
||||
code: "",
|
||||
name: "",
|
||||
@@ -72,6 +82,7 @@ export default function WarehouseDialog({
|
||||
type: "standard",
|
||||
license_plate: "",
|
||||
driver_name: "",
|
||||
default_transit_warehouse_id: null,
|
||||
});
|
||||
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
@@ -86,6 +97,7 @@ export default function WarehouseDialog({
|
||||
type: warehouse.type || "standard",
|
||||
license_plate: warehouse.license_plate || "",
|
||||
driver_name: warehouse.driver_name || "",
|
||||
default_transit_warehouse_id: warehouse.default_transit_warehouse_id ? String(warehouse.default_transit_warehouse_id) : null,
|
||||
});
|
||||
} else {
|
||||
setFormData({
|
||||
@@ -96,6 +108,7 @@ export default function WarehouseDialog({
|
||||
type: "standard",
|
||||
license_plate: "",
|
||||
driver_name: "",
|
||||
default_transit_warehouse_id: null,
|
||||
});
|
||||
}
|
||||
}, [warehouse, open]);
|
||||
@@ -216,6 +229,32 @@ export default function WarehouseDialog({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 預設在途倉設定(僅非 transit 類型顯示) */}
|
||||
{formData.type !== 'transit' && transitWarehouses.length > 0 && (
|
||||
<div className="space-y-4 bg-blue-50 p-4 rounded-lg border border-blue-100">
|
||||
<div className="border-b border-blue-200 pb-2">
|
||||
<h4 className="text-sm text-blue-800 font-medium">調撥配送設定</h4>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label>預設在途倉</Label>
|
||||
<p className="text-xs text-gray-500">從此倉庫建立調撥單時,系統將自動帶入此在途倉作為配送中繼倉</p>
|
||||
<SearchableSelect
|
||||
value={formData.default_transit_warehouse_id || ""}
|
||||
onValueChange={(val) => setFormData({ ...formData, default_transit_warehouse_id: val || null })}
|
||||
options={[
|
||||
{ label: "不指定", value: "" },
|
||||
...transitWarehouses.map((tw) => ({
|
||||
label: `${tw.name}${tw.license_plate ? ` (${tw.license_plate})` : ''}`,
|
||||
value: tw.id,
|
||||
})),
|
||||
]}
|
||||
placeholder="選擇預設在途倉"
|
||||
className="h-9 bg-white"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
|
||||
{/* 區塊 B:位置 */}
|
||||
|
||||
Reference in New Issue
Block a user