하수재이용 등록 업데이트 완료
This commit is contained in:
@@ -28,6 +28,7 @@ import { z } from "zod";
|
||||
import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg";
|
||||
|
||||
export default function PublicReuseFaciltyInsert() {
|
||||
const {
|
||||
@@ -38,6 +39,8 @@ export default function PublicReuseFaciltyInsert() {
|
||||
pbnstRegClick,
|
||||
getSwtrmtFcltNm,
|
||||
pbnstMngData,
|
||||
pbnstRuseFcltUpdate,
|
||||
pbnstRuseBizUpdate,
|
||||
} = useWrStore((state) => state);
|
||||
const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst;
|
||||
const [currentTab, setCurrentTab] = useState<string>("mng");
|
||||
@@ -51,12 +54,35 @@ export default function PublicReuseFaciltyInsert() {
|
||||
const [bdstTable, setbdstTable] = useState<pubHasuType[]>();
|
||||
const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!pbnst.isInit) {
|
||||
pubHasuInit("1", "11");
|
||||
}
|
||||
}, [pbnst.isInit, pubHasuInit]);
|
||||
|
||||
|
||||
|
||||
const saveRuseData = async ()=>{
|
||||
const data = writeRgtrAndMdfr(pbnst.pbnstMngRegData)
|
||||
let bizs =[] as fcBizType[]
|
||||
data.forEach((fclt) =>{
|
||||
bizs = [
|
||||
...bizs,
|
||||
...fclt.fcBizs
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
await pbnstRuseFcltUpdate(data)
|
||||
console.log('bizs ', bizs)
|
||||
|
||||
await pbnstRuseBizUpdate(bizs)
|
||||
|
||||
console.log(' data ', data)
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(code.sggCd.length){
|
||||
if(searchFclts){
|
||||
@@ -156,7 +182,7 @@ export default function PublicReuseFaciltyInsert() {
|
||||
<TabsTrigger className="!text-xl" value="buse">
|
||||
차수별정보
|
||||
</TabsTrigger>
|
||||
<Button size={"sm"} className="!justify-end">
|
||||
<Button size={"sm"} onClick={ saveRuseData}className="!justify-end">
|
||||
저장
|
||||
</Button>
|
||||
</TabsList>
|
||||
|
||||
@@ -91,6 +91,18 @@ const chBuCd = [
|
||||
]
|
||||
|
||||
|
||||
|
||||
const dmdUszCd = [
|
||||
{ val: "조경용수", text: "조경용수" },
|
||||
{ val: "청소화장실용수", text: "청소화장실용수" },
|
||||
{ val: "농업용수", text: "농업용수" },
|
||||
{ val: "공업용수", text: "공업용수" },
|
||||
{ val: "친수용수", text: "친수용수" },
|
||||
{ val: "기타", text: "기타" },
|
||||
|
||||
]
|
||||
|
||||
|
||||
const pplQulity = [
|
||||
{ val: "도복장강관", text: "도복장강관" },
|
||||
{ val: "PE관", text: "PE관" },
|
||||
@@ -136,6 +148,7 @@ export type comCodeState = {
|
||||
yn: SelectDataType[];
|
||||
pplQulity: SelectDataType[];
|
||||
pplLenght: SelectDataType[];
|
||||
dmdUszCd:SelectDataType[]
|
||||
buildingType: {
|
||||
RST:string,
|
||||
RNB:string,
|
||||
@@ -277,6 +290,7 @@ export const comCodeStateExport: comCodeState = {
|
||||
pplQulity:pplQulity,
|
||||
pplLenght:pplLenght,
|
||||
yn: yn,
|
||||
dmdUszCd:dmdUszCd,
|
||||
buildingType:buildingType,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
|
||||
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type { DemandCompType } from "./type";
|
||||
import type { DemandCompType } from "@common/business_components/ui";
|
||||
export type comFcltState = {
|
||||
searchFclts: pubHasuType;
|
||||
demandCompList: DemandCompType[];
|
||||
};
|
||||
export type comFcltActions = {
|
||||
getSwtrmtFcltNm: (searchNm: string) => void;
|
||||
getDemandCompList :(searchNm: string) => void
|
||||
getDemandCompList :(searchNm: string,cnt:number) => void
|
||||
regDemandCompany:(data:DemandCompType ) => void
|
||||
};
|
||||
|
||||
export const searchActions: (set: any) => comFcltActions = (set: any) => {
|
||||
@@ -30,15 +31,22 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => {
|
||||
searchFclts: fcltNmCd,
|
||||
}));
|
||||
},
|
||||
getDemandCompList: async (searchNm: string) => {
|
||||
getDemandCompList: async (searchNm: string ,cnt:number) => {
|
||||
const coList = await getFetch(
|
||||
fetchType.WR,
|
||||
`reuseFc/request/${searchNm}/{3}`
|
||||
`/reuseFc/request/${searchNm}/${cnt}`
|
||||
);
|
||||
return set((state: comFcltState) => ({
|
||||
...state,
|
||||
demandCompList: coList,
|
||||
}));
|
||||
},
|
||||
},regDemandCompany: async (data:DemandCompType)=>{
|
||||
|
||||
try{
|
||||
const response = await postFectch('/reuseFc/request',data,fetchType.WR )
|
||||
}catch(err){
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
export type DemandCompType = {
|
||||
dmdInfoPk : string | '';
|
||||
bzmnNo : string | '';
|
||||
dmdCoNm : string | '';
|
||||
daddr : string | '';
|
||||
telno : string | '';
|
||||
rgtr : string | '';
|
||||
useUsgCd : string | '';
|
||||
ctpvCd : string | '';
|
||||
sggCd : string | '';
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
fetchType,
|
||||
getFetch,
|
||||
postFectch,
|
||||
putFectch,
|
||||
} from "@/components/lib/api";
|
||||
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import {
|
||||
@@ -66,9 +67,9 @@ type pubFacActions = {
|
||||
pbnstMngData: (data: customPbnst[]) => void;
|
||||
pbnstBizData(data: fcBizType): void;
|
||||
getBizCycle: (pbnstObj: customPbnst) => void;
|
||||
getDmdCompany: (txt: string) => void;
|
||||
getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
|
||||
searchDmdColist:(txt:string) =>void
|
||||
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
|
||||
pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
|
||||
};
|
||||
|
||||
export type pubFacType = pubFacState & pubFacActions;
|
||||
@@ -123,30 +124,40 @@ const initFetch = async (ruseFcltPk: string | undefined) => {
|
||||
return pbnstRes;
|
||||
};
|
||||
|
||||
const writeRgtrAndMdfr = (data: customPbnst) => {
|
||||
data.rgtr = TEST_UUID;
|
||||
data.mdfr = TEST_UUID;
|
||||
data.fcBizs = data.fcBizs.map((item) => {
|
||||
export const writeRgtrAndMdfr = (data: customPbnst[]) => {
|
||||
|
||||
data.forEach((pbnst) => {
|
||||
pbnst.rgtr = TEST_UUID;
|
||||
pbnst.mdfr = TEST_UUID;
|
||||
|
||||
pbnst.fcBizs = pbnst.fcBizs?.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
item.fcOrgwts = item.fcOrgwts?.map((item) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
item.rgtr = TEST_UUID;
|
||||
return item;
|
||||
item.fcOrgwts = item.fcOrgwts?.map((orgwt) => {
|
||||
orgwt.mdfr = TEST_UUID;
|
||||
orgwt.rgtr = TEST_UUID;
|
||||
return orgwt;
|
||||
});
|
||||
|
||||
item.fcDemands = item.fcDemands?.map((dmd) => {
|
||||
dmd.mdfr = TEST_UUID;
|
||||
dmd.rgtr = TEST_UUID;
|
||||
return dmd;
|
||||
});
|
||||
|
||||
return item;
|
||||
});
|
||||
data.fcOpers = data.fcOpers.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
return item;
|
||||
pbnst.fcOpers = pbnst.fcOpers.map((oper) => {
|
||||
oper.rgtr = TEST_UUID;
|
||||
oper.mdfr = TEST_UUID;
|
||||
return oper;
|
||||
});
|
||||
data.fcFiles = data.fcFiles.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
return item;
|
||||
pbnst.fcFiles = pbnst.fcFiles.map((file) => {
|
||||
file.rgtr = TEST_UUID;
|
||||
file.mdfr = TEST_UUID;
|
||||
return file;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
return data;
|
||||
@@ -207,7 +218,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
|
||||
const response = await postFectch(
|
||||
`/reuseFc/pubFc`,
|
||||
JSON.stringify( writeRgtrAndMdfr(pbnstRes))
|
||||
JSON.stringify( writeRgtrAndMdfr([pbnstRes]))
|
||||
);
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
@@ -221,7 +232,39 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
} catch (error) {
|
||||
console.error("Error updating pbnst:", error);
|
||||
}
|
||||
},
|
||||
},pbnstRuseFcltUpdate : async(ruseRes:customPbnst[])=>{
|
||||
try {
|
||||
|
||||
const response = await putFectch(
|
||||
`/reuseFc/pubFc`,
|
||||
ruseRes
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error pbnstRuseFcltUpdate:", error);
|
||||
}
|
||||
} ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{
|
||||
try {
|
||||
|
||||
console.log('ruseRes ', ruseRes)
|
||||
const response = await putFectch(
|
||||
`/reuseFc/pubFcBiz`,
|
||||
ruseRes
|
||||
);
|
||||
const pbnstRes = await hasuListFetch("11", "11");
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
pbnstRes: pbnstRes,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error("Error pbnstRuseFcltUpdate:", error);
|
||||
}
|
||||
} ,
|
||||
getBizCycle: async (pbnstObj: customPbnst) => {
|
||||
const pbnstBizCycle = pbnstObj.fcBizs.map((item) => {
|
||||
return {
|
||||
@@ -303,23 +346,15 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
|
||||
if (bizIdx >= 0) {
|
||||
regData.fcBizs[bizIdx] = data;
|
||||
const pbnstData = state.pbnst.pbnstMngRegData
|
||||
state.pbnst.pbnstMngRegData= [...pbnstData]
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return state;
|
||||
});
|
||||
},
|
||||
getDmdCompany: async (txt: string) => {
|
||||
const company = await getFetch(fetchType.WR, `/reuseFc/request/${txt}/3`);
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
},
|
||||
getpbnstInsertIndex: async (data: pbnstInsertIndex) => {
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnsUpdateIndex = data;
|
||||
@@ -339,24 +374,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},searchDmdColist:async (txt:string)=>{
|
||||
|
||||
try{
|
||||
console.log(' txt ', txt)
|
||||
const coList = await getFetch(fetchType.WR, `reuseFc/request/${txt}/{3}`);
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
dmdCoList: coList,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -44,6 +44,25 @@ export type ruseFcltType = {
|
||||
splyExtraCpct: number;
|
||||
};
|
||||
|
||||
export type PbnstDemandComType = {
|
||||
dmdInfoPk : string | '';
|
||||
bzmnNo : string | '';
|
||||
dmdCoNm : string | '';
|
||||
daddr : string | '';
|
||||
telno : string | '';
|
||||
rgtr : string | '';
|
||||
useUsgCd : string | '';
|
||||
ctpvCd : string | '';
|
||||
sggCd : string | '';
|
||||
dmdAplyPswd: string | '';
|
||||
splyCpct: number | 0;
|
||||
splyFmYn:string|'Y'
|
||||
dmdInfoFk:string|''
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export type fcBizType = z.infer<typeof fcBizSchema>;
|
||||
export type fcOrgwtType = z.infer<typeof fcOrgwtSchema>;
|
||||
export type ppInstlType = z.infer<typeof pplInstlSchema>;
|
||||
@@ -53,7 +72,7 @@ export type fcFileType = z.infer<typeof fcFileSchema>;
|
||||
|
||||
|
||||
const pplInstlSchema = z.object({
|
||||
ruseFcltBizFk: z.string(),
|
||||
ruseFcltBizFk: z.number(),
|
||||
choose:z.boolean().default(false),
|
||||
pdmt: z.string().default(''),
|
||||
ppMqlt: z.string().default(""),
|
||||
@@ -72,7 +91,7 @@ const fcFileSchema = z.object({
|
||||
|
||||
const fcOperSchema = z.object({
|
||||
pbnstRuseFcltOperInfoPk: z.number().nullish(),
|
||||
pbnstRuseFcltFk: z.number().nullish(),
|
||||
pbnstRuseFcltFk: z.string().nullish(),
|
||||
operMthd: z.string(),
|
||||
rprtvBzenty: z.string(),
|
||||
bgngDt: z.date().default(new Date()),
|
||||
@@ -121,13 +140,18 @@ export type pubHasuType = z.infer<typeof pubHasuZod>;
|
||||
|
||||
|
||||
const dmdColist = z.object({
|
||||
dmdInfoFk:z.string().default(''),
|
||||
dmdCoNm: z.string().default(''),
|
||||
daddr: z.string(),
|
||||
useUsgCd: z.string().default(""),
|
||||
splyBgngDay: z.date().default(new Date()),
|
||||
splyEndDay: z.date().default(new Date()),
|
||||
splyCpct: z.string().default(""),
|
||||
splyFmYn: z.number().default(0),
|
||||
splyCpct: z.number().default(0),
|
||||
splyFmYn: z.string().default('Y'),
|
||||
rgtr: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
pbnstRuseFcltBizPk: z.number(),
|
||||
pbnstRuseFcltFk: z.string(),
|
||||
//telno:z.string().default('')
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ export const getFetch = async (type: string, url: string) => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`오류 발생: ${response.status}`);
|
||||
console.log(`오류 발생: ${response.status}`);
|
||||
}
|
||||
const contentType = response.headers.get("content-type") ?? "";
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
fcBizSchema,
|
||||
type customPbnst,
|
||||
type fcBizType,
|
||||
type PbnstDemandComType,
|
||||
type ppInstlType,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
@@ -31,16 +32,22 @@ import {
|
||||
type SelectDataType,
|
||||
} from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, DatePicker, Input, Label } from "@common/components";
|
||||
import {
|
||||
Button,
|
||||
DataTable,
|
||||
DatePicker,
|
||||
Input,
|
||||
Label,
|
||||
} from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useFieldArray, useForm } from "react-hook-form";
|
||||
import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail";
|
||||
import {
|
||||
safeDate,
|
||||
} from "@/components/lib/func/commom";
|
||||
import { safeDate } from "@/components/lib/func/commom";
|
||||
import SearchInputText from "@/components/ui/searchInput/searchInput";
|
||||
import type { DemandCompType } from "@/app/store/common/searchCode/type";
|
||||
import SdmInsertForm, {
|
||||
type DemandCompType,
|
||||
} from "@common/business_components/ui/sdmInsertForm";
|
||||
|
||||
export function PbnstBuseForm({
|
||||
formType,
|
||||
@@ -53,11 +60,13 @@ export function PbnstBuseForm({
|
||||
const {
|
||||
code,
|
||||
pbnst,
|
||||
demandCompList,
|
||||
pbnstBizData,
|
||||
getpbnstInsertIndex,
|
||||
appendRuseFclt,
|
||||
getBizCycle,
|
||||
searchDmdColist,
|
||||
getDemandCompList,
|
||||
regDemandCompany,
|
||||
} = useWrStore((state) => state);
|
||||
const { pbnstBizCycle, pbnstRes } = pbnst;
|
||||
const [bizCycle, setBizCycle] = useState("1");
|
||||
@@ -66,7 +75,10 @@ export function PbnstBuseForm({
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
|
||||
const [sumCpct, setSumCpct] = useState<number>(0);
|
||||
const [searchDmdCo, setSeachDmdCo] = useState<DemandCompType[]>();
|
||||
const [isDmdModal, setIsDmdModal] = useState<{
|
||||
isMoal: boolean;
|
||||
data: DemandCompType;
|
||||
}>({ isMoal: false, data: {} as DemandCompType });
|
||||
|
||||
const form = useForm<fcBizType>({
|
||||
resolver: zodResolver(fcBizSchema),
|
||||
@@ -143,6 +155,9 @@ export function PbnstBuseForm({
|
||||
|
||||
// 등록할때 신규 값을 계속 가지고 있으려고
|
||||
useEffect(() => {
|
||||
const formData = form.watch();
|
||||
|
||||
formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사
|
||||
if (formType === "reg") {
|
||||
if (
|
||||
firstBizData &&
|
||||
@@ -156,15 +171,16 @@ export function PbnstBuseForm({
|
||||
);
|
||||
form.setValue("cycl", firstBizData[0].cycl);
|
||||
}
|
||||
const formData = form.watch();
|
||||
formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사
|
||||
pbnstBizData(formData as fcBizType);
|
||||
}
|
||||
}, [firstBizData, form.formState, formType]);
|
||||
}else if(formType === "update"){
|
||||
|
||||
console.log('formdata ', formData)
|
||||
pbnstBizData(formData as fcBizType);
|
||||
|
||||
|
||||
}
|
||||
}, [firstBizData, form.formState, formType, pbnst.pbnstRes]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("searchDmdCo ", searchDmdCo);
|
||||
}, [searchDmdCo]);
|
||||
|
||||
useEffect(() => {
|
||||
if (ppiYn === "N") {
|
||||
@@ -178,7 +194,7 @@ export function PbnstBuseForm({
|
||||
|
||||
const plusHist = () => {
|
||||
const regData = {
|
||||
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? "",
|
||||
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? form.getValues('pbnstRuseFcltBizPk'),
|
||||
choose: false,
|
||||
ppMqlt: "",
|
||||
pdmt: "",
|
||||
@@ -195,15 +211,16 @@ export function PbnstBuseForm({
|
||||
};
|
||||
|
||||
const plusArray = () => {
|
||||
console.log("qweqwe ");
|
||||
appendDemand({
|
||||
dmdCoNm: "",
|
||||
daddr: "",
|
||||
useUsgCd: "",
|
||||
splyBgngDay: new Date(),
|
||||
splyEndDay: new Date(),
|
||||
splyCpct: "",
|
||||
splyFmYn: 0,
|
||||
splyCpct: 0,
|
||||
splyFmYn: "Y",
|
||||
pbnstRuseFcltBizPk: form.getValues('pbnstRuseFcltBizPk'),
|
||||
pbnstRuseFcltFk: form.getValues('pbnstRuseFcltFk')??'',
|
||||
//telno: "",
|
||||
});
|
||||
};
|
||||
@@ -401,12 +418,27 @@ export function PbnstBuseForm({
|
||||
moClass="grid grid-cols-12 gap-4"
|
||||
sonClass="col-span-4"
|
||||
/>
|
||||
<div>
|
||||
<div key={"hasu"}>
|
||||
<h1 className={formH1Class}>{"하수처리수 재이용수 수요처"}</h1>
|
||||
<div className="text-right mb-3">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={plusArray}
|
||||
onClick={() => {
|
||||
plusArray();
|
||||
}}
|
||||
size={commonButonSize}
|
||||
className="mt-6 mr-3"
|
||||
>
|
||||
수요항목 추가
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
setIsDmdModal({
|
||||
isMoal: true,
|
||||
data: {} as DemandCompType,
|
||||
});
|
||||
}}
|
||||
size={commonButonSize}
|
||||
className="mt-6"
|
||||
>
|
||||
@@ -414,8 +446,11 @@ export function PbnstBuseForm({
|
||||
</Button>
|
||||
</div>
|
||||
{fcDemands.map((field, index) => (
|
||||
<div className="grid grid-cols-12 gap-4 mt-3">
|
||||
<div className="col-span-4">
|
||||
<div
|
||||
key={index + "loot"}
|
||||
className="grid grid-cols-12 gap-4 mt-3"
|
||||
>
|
||||
<div key={index + "keySon1"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.dmdCoNm`}
|
||||
@@ -424,16 +459,60 @@ export function PbnstBuseForm({
|
||||
<SearchInputText
|
||||
label={undefined}
|
||||
initValue={f.value}
|
||||
setValue={f.onChange}
|
||||
setRtnData={(valList : DemandCompType[]) =>{
|
||||
setSeachDmdCo(valList)
|
||||
setValue={(val) => {
|
||||
f.onChange(val);
|
||||
|
||||
if (val) getDemandCompList(val, 3);
|
||||
}}
|
||||
setRtnData={(valList: PbnstDemandComType[]) => {
|
||||
console.log('valList[0] ', index)
|
||||
if (
|
||||
valList.length > 0 &&
|
||||
valList['0']
|
||||
) {
|
||||
form.setValue(
|
||||
`fcDemands.${index}.pbnstRuseFcltBizPk`,
|
||||
form.getValues('pbnstRuseFcltBizPk')
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.pbnstRuseFcltFk`,
|
||||
form.getValues('pbnstRuseFcltFk')??''
|
||||
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.dmdCoNm`,
|
||||
valList['0'].dmdCoNm
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.daddr`,
|
||||
valList['0'].daddr
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.useUsgCd`,
|
||||
valList['0'].useUsgCd
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.splyCpct`,
|
||||
valList['0'].splyCpct
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.splyFmYn`,
|
||||
valList['0'].splyFmYn ?? "Y"
|
||||
);
|
||||
|
||||
form.setValue(
|
||||
`fcDemands.${index}.dmdInfoPk`,
|
||||
valList['0'].dmdInfoPk ?? "Y"
|
||||
);
|
||||
}
|
||||
|
||||
}}
|
||||
></SearchInputText>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-4">
|
||||
<div key={index + "keySon2"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.daddr`}
|
||||
@@ -442,6 +521,7 @@ export function PbnstBuseForm({
|
||||
<Input
|
||||
placeholder="-"
|
||||
type="text"
|
||||
readOnly
|
||||
onChange={(e) => f.onChange(e.target.value)}
|
||||
value={f.value}
|
||||
className={selectClass}
|
||||
@@ -450,24 +530,27 @@ export function PbnstBuseForm({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-4">
|
||||
<div key={index + "keySon3"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.useUsgCd`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="사용용도">
|
||||
<Input
|
||||
placeholder="-"
|
||||
type="text"
|
||||
onChange={(e) => f.onChange(e.target.value)}
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.dmdUszCd}
|
||||
onSelectValue={(val: string | number) =>
|
||||
f.onChange(val)
|
||||
}
|
||||
value={f.value}
|
||||
className={selectClass}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3">
|
||||
<div key={index + "keySon4"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.splyBgngDay`}
|
||||
@@ -485,7 +568,7 @@ export function PbnstBuseForm({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3">
|
||||
<div key={index + "keySon5"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.splyEndDay`}
|
||||
@@ -503,7 +586,7 @@ export function PbnstBuseForm({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3">
|
||||
<div key={index + "keySon6"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.splyCpct`}
|
||||
@@ -521,7 +604,7 @@ export function PbnstBuseForm({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3">
|
||||
<div key={index + "keySon7"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`fcDemands.${index}.splyFmYn`}
|
||||
@@ -563,6 +646,30 @@ export function PbnstBuseForm({
|
||||
></FcOrgwtsRegModal>
|
||||
}
|
||||
></UiModal>
|
||||
|
||||
<UiModal
|
||||
bodyClass={"w-[40vw] max-w-none h-[90vh]"}
|
||||
open={isDmdModal.isMoal}
|
||||
onOpenChange={() => {
|
||||
setIsDmdModal({ isMoal: false, data: {} as DemandCompType });
|
||||
}}
|
||||
body={
|
||||
<SdmInsertForm
|
||||
selectSidoData={code.cityCd}
|
||||
selectSigunData={code.sggCd}
|
||||
dataList={demandCompList}
|
||||
rtnValue={(searchText: string, pageCnt: number) => {
|
||||
getDemandCompList(searchText, pageCnt);
|
||||
}}
|
||||
rtnInputData={(data) => {
|
||||
console.log(" rtn data ", data);
|
||||
regDemandCompany(data as DemandCompType);
|
||||
setIsDmdModal({ isMoal: false, data: data as DemandCompType });
|
||||
}}
|
||||
bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"}
|
||||
></SdmInsertForm>
|
||||
}
|
||||
></UiModal>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -94,8 +94,10 @@ export function PbnstMngForm({
|
||||
|
||||
|
||||
const plusHist = () => {
|
||||
const currentTableDataFromRef = ref.current ? [...ref.current] : [];
|
||||
const regData = {
|
||||
choose: false,
|
||||
pbnstRuseFcltFk:form.getValues('pbnstRuseFcltPk')??"",
|
||||
rgtr: "",
|
||||
mdfr: "",
|
||||
operMthd: "",
|
||||
@@ -103,7 +105,6 @@ export function PbnstMngForm({
|
||||
bgngDt: new Date(),
|
||||
endDt: new Date(),
|
||||
};
|
||||
const currentTableDataFromRef = ref.current ? [...ref.current] : [];
|
||||
const newDataForRHF = [...currentTableDataFromRef, regData];
|
||||
form.setValue("fcOpers", newDataForRHF, {
|
||||
shouldValidate: true, // 필요하다면 유효성 검사 실행
|
||||
@@ -251,13 +252,21 @@ export function PbnstMngForm({
|
||||
|
||||
//신규 등록시 입력할때 데이터 넣기
|
||||
useEffect(() => {
|
||||
const formData = form.watch();
|
||||
formData.fcOpers = ref.current ? [...ref.current] : [];
|
||||
formData.fcFiles = regFileList ? [...regFileList] : [];
|
||||
if (formType === "reg") {
|
||||
const formData = form.watch();
|
||||
formData.fcOpers = ref.current ? [...ref.current] : [];
|
||||
formData.fcFiles = regFileList ? [...regFileList] : [];
|
||||
pbnstMngData([formData] as customPbnst[]);
|
||||
} else if (formType === "update"){
|
||||
const updateRes = pbnst.pbnstRes?.map((item)=>{
|
||||
if(item.pbnstRuseFcltPk === item.pbnstRuseFcltPk){
|
||||
item=formData as customPbnst
|
||||
}
|
||||
return item
|
||||
})
|
||||
pbnstMngData(updateRes as customPbnst[]);
|
||||
}
|
||||
}, [form.formState, regFileList, formType]);
|
||||
}, [form.formState, regFileList, formType, pbnst.pbnstRes]);
|
||||
|
||||
useEffect(() => {
|
||||
pbnstMngData(pbnst.pbnstMngRegData);
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
|
||||
import { useWrStore } from '@/app/store';
|
||||
import type { DemandCompType } from '@/app/store/common/searchCode/type';
|
||||
import type { PbnstDemandComType } from '@/app/store/ruseFcltMng/fcltReg/pbnstReg/type';
|
||||
import type { DemandCompType } from '@common/business_components/ui';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
type thisProps = {
|
||||
label: string | undefined;
|
||||
initValue: string | undefined;
|
||||
setValue : (dmdCoNm?: string) => void;
|
||||
setRtnData : (rtnData: DemandCompType[]) => void;
|
||||
setRtnData : (rtnData: PbnstDemandComType[]) => void;
|
||||
}
|
||||
|
||||
|
||||
export default function SearchInputText({label=undefined, initValue=undefined, setValue=()=>{}, setRtnData=()=>{}} :thisProps) {
|
||||
|
||||
const { getDemandCompList, demandCompList } = useWrStore((state) => state);
|
||||
const { demandCompList } = useWrStore((state) => state);
|
||||
|
||||
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
@@ -25,11 +26,10 @@ export default function SearchInputText({label=undefined, initValue=undefined, s
|
||||
setValue(value);
|
||||
if (value) {
|
||||
setIsOpen(true);
|
||||
getDemandCompList(value);
|
||||
} else {
|
||||
setIsOpen(false);
|
||||
}
|
||||
}, [getDemandCompList, setValue]);
|
||||
}, [ setValue]);
|
||||
|
||||
const handleSuggestionClick = useCallback((dmdCoNm: string) => {
|
||||
setTextValue(dmdCoNm);
|
||||
|
||||
Reference in New Issue
Block a user