건축물 등록 페이지 개발중
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useWrStore } from "@/app/store";
|
||||
import {
|
||||
selectClass,
|
||||
type bdstType,
|
||||
type selectArray,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { ScrollArea, SearchInput, SelectBox, UiTable } from "@common/business_components";
|
||||
import { Button, Input } from "@common/components";
|
||||
@@ -11,41 +12,69 @@ import { useEffect, useState } from "react";
|
||||
import { RainRegForm } from "../../form/fcltReg/rainReg/component";
|
||||
|
||||
export function BdstReg() {
|
||||
const { rain, code, init } = useWrStore((state) => {
|
||||
const { rain, code, bdst, findBdst } = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
|
||||
const [bdstTable, setbdstTable] = useState<bdstType[]>();
|
||||
const [rainBdstForm, setRainBdstForm] = useState<[]>();
|
||||
const [rainBdstForm, setRainBdstForm] = useState<bdstType[] | undefined>();
|
||||
const { bdstObj, rainRuseObj } = rain;
|
||||
const getCity = (val: string | number) => {
|
||||
console.log(val);
|
||||
const [selectSgg, setSelectSgg] = useState<selectArray[] | undefined>()
|
||||
const [searchTxt, setSearchTxt] = useState<string>()
|
||||
|
||||
const getCity = (val: string ) => {
|
||||
|
||||
|
||||
const data = code.sggCd
|
||||
.filter((item) => String(item.val).substring(0, 2) === val)
|
||||
.map((item) => ({ ...item, val: String(item.val) })); // Ensure 'val' is a string
|
||||
setSelectSgg(data);
|
||||
};
|
||||
|
||||
const getSgg = (val: string | number) => {
|
||||
console.log(val);
|
||||
};
|
||||
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
|
||||
// console.log("searchTxt ", searchTxt)
|
||||
findBdst(searchTxt)
|
||||
},[searchTxt])
|
||||
|
||||
useEffect(() => {
|
||||
if (code.sggCd.length > 0) {
|
||||
const table = bdstObj.map((item) => {
|
||||
const table = bdst?.bdstBase?.map((item) => {
|
||||
const sggText = code.sggCd.find(
|
||||
(cd) => cd.val.toString() === item.sggCd
|
||||
(cd) => cd.val === Number(item.sggCd)
|
||||
)?.text;
|
||||
const cityText = code.cityCd.find(
|
||||
(cd) => cd.val.toString() === item.ctpvCd
|
||||
(cd) => cd.val === Number(item.ctpvCd)
|
||||
)?.text;
|
||||
return { ...item, sggText: sggText, cityText: cityText };
|
||||
});
|
||||
|
||||
|
||||
setbdstTable(table);
|
||||
}
|
||||
}, [code, bdstObj]);
|
||||
}, [code, bdst]);
|
||||
|
||||
const cellClick = () => {};
|
||||
const nodeList = headMakeColSpan(rain.upHeadList);
|
||||
const tableClick: (val: number | undefined) => void = (val) => {
|
||||
|
||||
console.log("val , " ,val)
|
||||
console.log("bdst , " ,bdst?.bdstBase[val])
|
||||
if(val!==undefined && bdst?.bdstBase.length>0){
|
||||
const data =bdst?.bdstBase[val]
|
||||
console.log("data ", [data])
|
||||
setRainBdstForm([data]);
|
||||
}
|
||||
}
|
||||
|
||||
const nodeList = headMakeColSpan(bdst.moUpHeadList);
|
||||
return (
|
||||
<>
|
||||
<div className="grid grid-cols-12 gap-4 pb-4">
|
||||
<div className="grid grid-cols-12 gap-4">
|
||||
<SelectBox
|
||||
className="col-span-3 col-start-4"
|
||||
label={"시도"}
|
||||
@@ -59,7 +88,7 @@ export function BdstReg() {
|
||||
className="col-span-3"
|
||||
label={"시군구"}
|
||||
selectClass={selectClass}
|
||||
selectArray={code.sggCd}
|
||||
selectArray={selectSgg || []}
|
||||
onSelectValue={getSgg}
|
||||
>
|
||||
{" "}
|
||||
@@ -67,33 +96,31 @@ export function BdstReg() {
|
||||
<SearchInput
|
||||
className="col-span-3 col-start-10"
|
||||
label="건물명"
|
||||
textValue={""}
|
||||
setText={function (val: string): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}}
|
||||
textValue={searchTxt}
|
||||
setText={ setSearchTxt}
|
||||
|
||||
/>
|
||||
</div>
|
||||
<div className="border-t border-gray-300 my-4"></div>
|
||||
<div className="h-auto">
|
||||
<div>
|
||||
<UiTable
|
||||
tableData={bdstTable || []}
|
||||
headlist={rain.upHeadList}
|
||||
headlist={bdst.moUpHeadList}
|
||||
pageSize={-10}
|
||||
total={-1}
|
||||
headName={undefined}
|
||||
cellClick={cellClick}
|
||||
cellClick={tableClick}
|
||||
>
|
||||
{nodeList}
|
||||
</UiTable>
|
||||
</div>
|
||||
<div >
|
||||
|
||||
<div className="border-t border-gray-300 my-4"></div>
|
||||
<ScrollArea className="h-[60vh]">
|
||||
<div>
|
||||
<RainRegForm data={rainBdstForm || []} isModal={true}></RainRegForm>
|
||||
</div>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user