Files
vexplor/frontend/app/test-autocomplete-mapping/page.tsx
SeongHyun Kim 68f79db6ed feat(autocomplete-search-input): 필드 자동 매핑 및 저장 위치 선택 기능 추가
- 필드 자동 매핑 기능 구현
  * FieldMapping 타입 추가 (sourceField → targetField)
  * applyFieldMappings() 함수로 선택 시 자동 입력
  * 여러 필드를 한 번에 자동으로 채움 (거래처 선택 → 주소/전화 자동 입력)

- 값 필드 저장 위치 선택 기능 추가
  * ValueFieldStorage 타입 추가 (targetTable, targetColumn)
  * 기본값(화면 연결 테이블) 또는 명시적 테이블/컬럼 지정 가능
  * 중간 테이블, 이력 테이블 등 다중 테이블 저장 지원

- UI/UX 개선
  * 모든 선택 필드를 Combobox 스타일로 통일
  * 각 필드 아래 간략한 사용 설명 추가
  * 저장 위치 동작 미리보기 박스 추가

- 문서 작성
  * 사용_가이드.md 신규 작성 (실전 예제 3개 포함)
  * 빠른 시작 가이드, FAQ, 체크리스트 제공
2025-11-20 13:47:21 +09:00

142 lines
5.0 KiB
TypeScript

"use client";
import React, { useState } from "react";
import { AutocompleteSearchInputComponent } from "@/lib/registry/components/autocomplete-search-input/AutocompleteSearchInputComponent";
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
export default function TestAutocompleteMapping() {
const [selectedValue, setSelectedValue] = useState("");
const [customerName, setCustomerName] = useState("");
const [address, setAddress] = useState("");
const [phone, setPhone] = useState("");
return (
<div className="container mx-auto py-8 space-y-6">
<Card>
<CardHeader>
<CardTitle>AutocompleteSearchInput </CardTitle>
<CardDescription>
</CardDescription>
</CardHeader>
<CardContent className="space-y-6">
{/* 검색 컴포넌트 */}
<div className="space-y-2">
<Label> </Label>
<AutocompleteSearchInputComponent
config={{
tableName: "customer_mng",
displayField: "customer_name",
valueField: "customer_code",
searchFields: ["customer_name", "customer_code"],
placeholder: "거래처명 또는 코드로 검색",
enableFieldMapping: true,
fieldMappings: [
{
sourceField: "customer_name",
targetField: "customer_name_input",
label: "거래처명",
},
{
sourceField: "address",
targetField: "address_input",
label: "주소",
},
{
sourceField: "phone",
targetField: "phone_input",
label: "전화번호",
},
],
}}
value={selectedValue}
onChange={(value, fullData) => {
setSelectedValue(value);
console.log("선택된 항목:", fullData);
}}
/>
</div>
{/* 구분선 */}
<div className="border-t pt-6">
<h3 className="text-sm font-semibold mb-4">
</h3>
<div className="space-y-4">
{/* 거래처명 */}
<div className="space-y-2">
<Label htmlFor="customer_name_input"></Label>
<Input
id="customer_name_input"
value={customerName}
onChange={(e) => setCustomerName(e.target.value)}
placeholder="자동으로 채워집니다"
/>
</div>
{/* 주소 */}
<div className="space-y-2">
<Label htmlFor="address_input"></Label>
<Input
id="address_input"
value={address}
onChange={(e) => setAddress(e.target.value)}
placeholder="자동으로 채워집니다"
/>
</div>
{/* 전화번호 */}
<div className="space-y-2">
<Label htmlFor="phone_input"></Label>
<Input
id="phone_input"
value={phone}
onChange={(e) => setPhone(e.target.value)}
placeholder="자동으로 채워집니다"
/>
</div>
</div>
</div>
{/* 상태 표시 */}
<div className="border-t pt-6">
<h3 className="text-sm font-semibold mb-2"> </h3>
<div className="p-4 bg-muted rounded-lg">
<pre className="text-xs">
{JSON.stringify(
{
selectedValue,
customerName,
address,
phone,
},
null,
2
)}
</pre>
</div>
</div>
</CardContent>
</Card>
{/* 사용 안내 */}
<Card>
<CardHeader>
<CardTitle className="text-base"> </CardTitle>
</CardHeader>
<CardContent className="space-y-2 text-sm">
<ol className="list-decimal list-inside space-y-2">
<li> </li>
<li> </li>
<li> </li>
<li> </li>
</ol>
</CardContent>
</Card>
</div>
);
}