건축물 등록 페이지 개발중

This commit is contained in:
leedj312
2025-03-28 18:00:56 +09:00
parent a4350c9788
commit ca30fc9a33
5 changed files with 225 additions and 27 deletions
@@ -2,12 +2,32 @@ import { useWrStore } from "@/app/store";
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { FormField, FormUi, SelectBox } from "@common/business_components";
import { Button, Input } from "@common/components";
import { useFieldArray } from "react-hook-form";
export default function BdstReg(form: any) {
const { code } = useWrStore((state) => {
return state;
});
const { fields, append, remove } = useFieldArray({
control: form.control,
name: "history"
});
const plusHist = () => {
append({
bdstNm: '',
daddr: '',
bdstUsgCd: ''
});
};
const removeLastItem = () => {
if (fields.length > 0) {
remove(fields.length - 1);
}
};
return (
<>
@@ -165,10 +185,68 @@ export default function BdstReg(form: any) {
<h1 className="bg-gray-400 text-xl text-center border-2 p-2 mt-4">
중축, 개축, 증축
</h1>
<div className="flex justify-end">
<Button className="mr-4 rounded-lg ">이력추가</Button>
<div className="flex justify-end gap-2">
<Button className="rounded-lg" onClick={plusHist}>이력추가</Button>
<Button className="rounded-lg bg-red-500 text-white" onClick={removeLastItem}>삭제</Button>
</div>
<div className="border-b border-gray-300 my-4"> </div>
{fields.map((field, index) => (
<div key={field.id} className="grid grid-cols-6 gap-2 mt-4">
<div className="col-span-2">
<FormField
control={form.control}
name={`history.${index}.bdstNm`}
render={({ field }) => (
<FormUi label="구분">
<SelectBox
className={""}
selectClass={selectClass}
label={""}
selectArray={code.cityCd}
onSelectValue={(val) => {
field.onChange(val);
}}
value={field.value}
/>
</FormUi>
)}
/>
</div>
<div className="col-span-2">
<FormField
control={form.control}
name={`history.${index}.daddr`}
render={({ field }) => (
<FormUi label="허가일">
<Input
className=""
placeholder="1,000,000"
type="search"
{...field}
/>
</FormUi>
)}
/>
</div>
<div className="col-span-2">
<FormField
control={form.control}
name={`history.${index}.bdstUsgCd`}
render={({ field }) => (
<FormUi label="면적">
<Input
className=""
placeholder="1,000,000"
type="text"
{...field}
/>
</FormUi>
)}
/>
</div>
</div>
))}
<div className="border-b border-gray-300 my-4"> </div>
</>
);
}
@@ -27,7 +27,6 @@ export function RainRegForm({
data: rainRuseBd[];
isModal: boolean;
}) {
console.log(isModal);
const formSchema = isModal
? z.object({ ...rainZod, ...bdstZod })
: z.object(rainZod);
@@ -35,6 +34,7 @@ export function RainRegForm({
const { rain, code } = useWrStore((state) => state);
const { rainFcltCd } = code;
useEffect(() => {
// console.log( " data ", data)
if (data && data.length > 0) {
console.log(data);
const selectedOption = rainFcltCd.find(