재이용시설현황 페이지 조회항목설정 변경, 헤드리스트 번호 제거
This commit is contained in:
@@ -173,7 +173,7 @@ export default function PbnstSttn() {
|
||||
<div className="col-span-6">
|
||||
<ListDiv>
|
||||
<UiTable
|
||||
headName={[]}
|
||||
headName={undefined}
|
||||
tableData={bdstTable || []}
|
||||
children={
|
||||
<HeadMakeColSpan upHeadList={pbnstSttn.pbnstSttNodeList} />
|
||||
|
||||
@@ -136,7 +136,7 @@ export const rainSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
export const rainSttNodeListExport: CommonTableProps[] = [
|
||||
{
|
||||
id: "bdnstInfo",
|
||||
title: "1.건축물정보",
|
||||
title: "건축물정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
@@ -144,7 +144,7 @@ export const rainSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "rainFcltInfo",
|
||||
title: "2.빗물이용시설정보",
|
||||
title: "빗물이용시설정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
@@ -152,7 +152,7 @@ export const rainSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "insenInfo",
|
||||
title: "3.인센티브 정보",
|
||||
title: "인센티브 정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
|
||||
@@ -130,7 +130,7 @@ export const rswtSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
export const rswtSttNodeListExport: CommonTableProps[] = [
|
||||
{
|
||||
id: "bdnstInfo",
|
||||
title: "1.건축물정보",
|
||||
title: "건축물정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
@@ -138,7 +138,7 @@ export const rswtSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "rswtFcltInfo",
|
||||
title: "2.중수도시설정보",
|
||||
title: "중수도시설정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
@@ -146,7 +146,7 @@ export const rswtSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "insenInfo",
|
||||
title: "3.인센티브 정보",
|
||||
title: "인센티브 정보",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { sttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList";
|
||||
import { sttnHeadListType } from "@/app/store/ruseFcltMng/fcltSttn/rainSttn/headList";
|
||||
import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage } from "@common/business_components/ui";
|
||||
import { Button, Checkbox } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -7,33 +7,54 @@ import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
|
||||
export default function HeadChModal({headList, type }:{headList : z.infer<typeof sttnHeadListType> ,type:string }) {
|
||||
const { rainChSttnHead , rswtChSttnHead, htdflChSttnHead, pbnstChSttnHead} = useWrStore((state) => state);
|
||||
|
||||
|
||||
let items = headList.map(item => ({id:item.id, title:item.title, val:item.visible }));
|
||||
|
||||
|
||||
const form = useForm<z.infer<typeof sttnHeadListType>>({
|
||||
resolver: zodResolver(sttnHeadListType),
|
||||
defaultValues: [],
|
||||
})
|
||||
export default function HeadChModal({ headList, type }: { headList: z.infer<typeof sttnHeadListType>, type: string }) {
|
||||
const { rainChSttnHead, rswtChSttnHead, htdflChSttnHead, pbnstChSttnHead } = useWrStore((state) => state);
|
||||
|
||||
|
||||
useEffect(() =>{
|
||||
form.reset(headList)
|
||||
let items = headList.map(item => ({ id: item.id, title: item.title, val: item.visible }));
|
||||
|
||||
|
||||
},[headList])
|
||||
/*const form = useForm<z.infer<typeof sttnHeadListType>>({
|
||||
resolver: zodResolver(sttnHeadListType),
|
||||
defaultValues: [],
|
||||
})
|
||||
|
||||
const onSubmit = (valueList : z.infer<typeof sttnHeadListType> ) =>{
|
||||
if(type==='RNB'){
|
||||
|
||||
useEffect(() =>{
|
||||
form.reset(headList)
|
||||
|
||||
|
||||
},[headList])*/
|
||||
|
||||
const form = useForm<z.infer<typeof sttnHeadListType>>({
|
||||
resolver: zodResolver(sttnHeadListType),
|
||||
defaultValues: headList,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
form.reset(headList);
|
||||
}, [headList, form]);
|
||||
|
||||
const rawValues = form.watch();
|
||||
const values: Array<{ visible: boolean }> = Array.isArray(rawValues)
|
||||
? rawValues
|
||||
: Object.values(rawValues);
|
||||
|
||||
const allChecked = values.every((v) => v.visible);
|
||||
|
||||
const toggleAll = (checked: boolean) => {
|
||||
const newValues = values.map((v) => ({ ...v, visible: checked }));
|
||||
form.reset(newValues);
|
||||
};
|
||||
|
||||
const onSubmit = (valueList: z.infer<typeof sttnHeadListType>) => {
|
||||
if (type === 'RNB') {
|
||||
rainChSttnHead(valueList)
|
||||
}else if(type=== 'RST'){
|
||||
} else if (type === 'RST') {
|
||||
rswtChSttnHead(valueList)
|
||||
}else if(type === 'HTB'){
|
||||
} else if (type === 'HTB') {
|
||||
htdflChSttnHead(valueList)
|
||||
}else if(type === 'PBN'){
|
||||
} else if (type === 'PBN') {
|
||||
pbnstChSttnHead(valueList)
|
||||
}
|
||||
}
|
||||
@@ -42,42 +63,50 @@ export default function HeadChModal({headList, type }:{headList : z.infer<typeo
|
||||
<>
|
||||
<div>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
|
||||
|
||||
<div className="mb-4">
|
||||
<h3>조회항목 설정</h3>
|
||||
</div>
|
||||
{items.map((item,index) => (
|
||||
<FormField
|
||||
key={`${index}.id`}
|
||||
control={form.control}
|
||||
name={`${index}.visible`}
|
||||
render={({ field }) =>
|
||||
{
|
||||
return (
|
||||
<FormItem
|
||||
key={`${index}.id`+'item'}
|
||||
className="flex flex-row items-start space-x-3 space-y-0"
|
||||
>
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={(checked) =>
|
||||
{
|
||||
field.onChange(checked);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormLabel className="text-xl">
|
||||
{item.title}
|
||||
</FormLabel>
|
||||
</FormItem>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
|
||||
|
||||
<div className="mb-4">
|
||||
<h3>조회항목 설정</h3>
|
||||
</div>
|
||||
{/* 전체 선택/해제 체크박스 */}
|
||||
<FormItem className="flex flex-row items-start space-x-3">
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={allChecked}
|
||||
onCheckedChange={(checked) => toggleAll(checked as boolean)}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormLabel className="text-xl font-bold">전체</FormLabel>
|
||||
</FormItem>
|
||||
{items.map((item, index) => (
|
||||
<FormField
|
||||
key={`${index}.id`}
|
||||
control={form.control}
|
||||
name={`${index}.visible`}
|
||||
render={({ field }) => {
|
||||
return (
|
||||
<FormItem
|
||||
key={`${index}.id` + 'item'}
|
||||
className="flex flex-row items-start space-x-3 space-y-0"
|
||||
>
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormLabel className="text-xl">
|
||||
{item.title}
|
||||
</FormLabel>
|
||||
</FormItem>
|
||||
);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
<Button type="submit">항목 표출 변경</Button>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
Reference in New Issue
Block a user