물재이용 수요처관리 작업중
This commit is contained in:
@@ -1,84 +0,0 @@
|
||||
"use client";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import {
|
||||
Form,
|
||||
FormField,
|
||||
FormUi,
|
||||
ScrollArea,
|
||||
SelectBox,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { CoRegForm } from "@/components/ui/form/matDmd/coRegForm/component";
|
||||
import toast, { Toaster } from "react-hot-toast";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
|
||||
const formSchema = z.object({
|
||||
ctpv: z.string(),
|
||||
sgg: z.string(),
|
||||
coNm: z.string().min(1).max(20),
|
||||
bznmNo: z.string().min(1).min(9).max(12),
|
||||
addr: z.string().min(1).min(6).max(20),
|
||||
telNo: z.string().min(8).max(12),
|
||||
|
||||
});
|
||||
|
||||
export default function MyForm() {
|
||||
|
||||
|
||||
|
||||
const form = useForm<z.infer<typeof formSchema>>({
|
||||
resolver: zodResolver(formSchema),
|
||||
defaultValues: {
|
||||
coNm:'',
|
||||
bznmNo:'',
|
||||
addr:'',
|
||||
telNo:'',
|
||||
},
|
||||
});
|
||||
|
||||
function onSubmit(values: z.infer<typeof formSchema>) {
|
||||
try {
|
||||
toast.dismiss();
|
||||
//ToastFormUi("수요신청 화면으로 이동하시겠습니까?", "수요처 등록 완료", "./dmdReg", "이동")
|
||||
|
||||
} catch (error) {
|
||||
console.error("Form submission error", error);
|
||||
toast.error("수요처 등록이 실패하였습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid h-40 grid-cols-3 place-content-center">
|
||||
<h1 className=" col-start-2 col-span-1 text-4xl underline">
|
||||
수요처 정보입력
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-5 gap-4 overflow-hidden">
|
||||
<div className="col-span-1 "/>
|
||||
<div className="col-span-3 ">
|
||||
<div>
|
||||
<Form {...form}>
|
||||
<form
|
||||
onSubmit={form.handleSubmit(onSubmit)}
|
||||
className="space-y-8 max-w-3xl mx-auto"
|
||||
>
|
||||
<CoRegForm>{form}</CoRegForm>
|
||||
|
||||
|
||||
<Button type="submit">수요처등록</Button>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-span-1 " >
|
||||
<Toaster position="top-center" />
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import type { customCoSttnBdst } from "@/app/store/matDmd/coSttn";
|
||||
import { excelDownload, getCity, getCityOrSgg, tableData } from "@/components/lib/func/commom";
|
||||
import {
|
||||
excelDownload,
|
||||
getCity,
|
||||
getCityOrSgg,
|
||||
tableData,
|
||||
} from "@/components/lib/func/commom";
|
||||
import {
|
||||
ContentsDiv,
|
||||
SearchBaseForm,
|
||||
SearchDiv,
|
||||
SearchFormLeft,
|
||||
SearchFormRight,
|
||||
@@ -15,58 +18,74 @@ import {
|
||||
Title,
|
||||
UiModal,
|
||||
UiTable,
|
||||
type ReturnType,
|
||||
type SelectDataType
|
||||
type SelectDataType,
|
||||
} from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button, DatePicker, Label } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import SdmInsertForm, { type DemandCompType } from "@common/business_components/ui/sdmInsertForm";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import SdmInsertForm, {
|
||||
type DemandCompType,
|
||||
} from "@common/business_components/ui/sdmInsertForm";
|
||||
import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
|
||||
import { Toaster } from "react-hot-toast";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
|
||||
export default function CoSttn() {
|
||||
const [bdstTable, setBdstTable] = useState<customCoSttnBdst[]>();
|
||||
|
||||
const {
|
||||
code,
|
||||
coSttn,
|
||||
coSttnInit,
|
||||
coSttnSearch,
|
||||
getDemandCompList,
|
||||
regDemandCompany,
|
||||
coSttnTxtSearch,
|
||||
demandCompList,
|
||||
} = useWrStore((state) => state);
|
||||
|
||||
const [bdstTable, setBdstTable] = useState<DemandCompType[]>();
|
||||
const [pageNation, setPageNation] = useState(1);
|
||||
const { code, coSttn, coSttnInit, coSttnSearch, getDemandCompList, regDemandCompany, demandCompList } = useWrStore((state) => state);
|
||||
const { coSttnRes } = coSttn;
|
||||
const [isDmdModal, setIsDmdModal] = useState<{ isMoal: boolean, data: DemandCompType }>({ isMoal: false, data: {} as DemandCompType })
|
||||
const [fromDate, setFromDate] = useState<Date>(new Date());
|
||||
const [toDate, setToDate] = useState<Date>(new Date());
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>()
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({ sgg: "", city: "" });
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const codeData = getCityOrSgg(ref);
|
||||
const [isDmdModal, setIsDmdModal] = useState<{
|
||||
isMoal: boolean;
|
||||
data: DemandCompType;
|
||||
}>({ isMoal: false, data: {} as DemandCompType });
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>();
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({
|
||||
sgg: "",
|
||||
city: "",
|
||||
});
|
||||
|
||||
const [seartchTxt, setSearchTxt] = useState<string>();
|
||||
const [upadateData, setUpdateData] = useState<DemandCompType>();
|
||||
|
||||
const getSelCity = (val: string | number) => {
|
||||
const cityValue = String(val); // Ensure val is treated as a string
|
||||
const data = getCity(cityValue, code.sggCd);
|
||||
setSelectSgg(data);
|
||||
setObjSearch({ city: cityValue, sgg: '' });
|
||||
setObjSearch({ city: cityValue, sgg: "" });
|
||||
};
|
||||
|
||||
const getSgg = (val: string | number) => {
|
||||
console.log(val);
|
||||
setObjSearch({ ...objSearch, sgg: String(val) })
|
||||
setObjSearch({ ...objSearch, sgg: String(val) });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!coSttn.isInit) {
|
||||
coSttnInit(codeData ?? "0");
|
||||
const con = objSearch.sgg ? objSearch.sgg : objSearch.city;
|
||||
coSttnInit("1", "13", "45");
|
||||
}
|
||||
}, [coSttn.isInit, coSttnInit]);
|
||||
}, [coSttn.isInit, coSttnInit, objSearch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (coSttnRes.length > 0 && code.cityCd.length > 0) {
|
||||
if (coSttnRes?.length > 0 && code.cityCd.length > 0) {
|
||||
const data = tableData(coSttnRes, { code });
|
||||
const chData = data
|
||||
.map((item: any) => ({
|
||||
...item
|
||||
}))
|
||||
const chData = data.map((item: any) => ({
|
||||
...item,
|
||||
}));
|
||||
// .filter((item: any) => item !== undefined);
|
||||
setBdstTable(chData);
|
||||
} else if (coSttnRes.length == 0) {
|
||||
setBdstTable([]);
|
||||
}
|
||||
}, [coSttnRes]);
|
||||
|
||||
@@ -84,10 +103,20 @@ export default function CoSttn() {
|
||||
}, [coSttn.excelList]);
|
||||
|
||||
const excelClick = useCallback(() => {
|
||||
console.log("??")
|
||||
coSttnSearch("마인드원", 1);
|
||||
}, [coSttnSearch]);
|
||||
const con = objSearch.sgg ? objSearch.sgg : objSearch.city;
|
||||
if (con) coSttnSearch("1", "10000", String(con));
|
||||
}, [coSttnSearch, objSearch.city, objSearch.sgg]);
|
||||
|
||||
const searchClick = () => {
|
||||
const con = objSearch.sgg ? objSearch.sgg : objSearch.city;
|
||||
if (con) {
|
||||
if (seartchTxt && seartchTxt?.length > 0) {
|
||||
coSttnTxtSearch("1", "13", String(con), seartchTxt ?? "");
|
||||
} else {
|
||||
coSttnSearch("1", "13", String(con));
|
||||
}
|
||||
}
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<ContentsDiv>
|
||||
@@ -111,42 +140,27 @@ export default function CoSttn() {
|
||||
selectArray={selectSgg || []}
|
||||
onSelectValue={getSgg}
|
||||
/>
|
||||
<div className="col-span-5 w-auto">
|
||||
<div className="flex flex-row items-center">
|
||||
<Label className="text-xl text-gray-600">수요신청년도</Label>
|
||||
<div className="flex flex-row w-1/4">
|
||||
<DatePicker mode={'single'}
|
||||
selected={fromDate}
|
||||
onSelect={(date: Date | undefined) => { if (date) setFromDate(date) }} />
|
||||
<span>~</span>
|
||||
<DatePicker mode={'single'}
|
||||
selected={toDate}
|
||||
onSelect={(date: Date | undefined) => { if (date) setToDate(date) }} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<SearchInput
|
||||
className={"text-2xl"}
|
||||
className={"!text-3xl"}
|
||||
label="회사명"
|
||||
textValue={""}
|
||||
textValue={seartchTxt ?? ""}
|
||||
setText={(e) => {
|
||||
setSearchTxt(e);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</SearchFormLeft>
|
||||
<SearchFormRight
|
||||
className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 ">
|
||||
<SearchFormRight className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 ">
|
||||
<div className="flex flex-row space-x-2">
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={(e) => { }}
|
||||
>
|
||||
<Button size={"sm"} onClick={searchClick}>
|
||||
조회
|
||||
</Button>
|
||||
<Button
|
||||
size={"sm"}
|
||||
className={btnClass}
|
||||
onClick={() => {
|
||||
|
||||
setUpdateData(undefined);
|
||||
setIsDmdModal({ ...isDmdModal, isMoal: true });
|
||||
}}
|
||||
>
|
||||
@@ -157,6 +171,13 @@ export default function CoSttn() {
|
||||
className={btnClass}
|
||||
onClick={() => {
|
||||
/* 저장 로직 */
|
||||
if (!upadateData) {
|
||||
<ToastFormUi body={"수요처 변경을 원하는 행을 선택해주세요"} title={"수요처관리"}></ToastFormUi>;
|
||||
}else{
|
||||
setIsDmdModal({
|
||||
...isDmdModal,
|
||||
isMoal: true})
|
||||
}
|
||||
}}
|
||||
>
|
||||
저장
|
||||
@@ -182,7 +203,9 @@ export default function CoSttn() {
|
||||
headlist={coSttn.coSttHeadList}
|
||||
pageSize={20}
|
||||
total={10000}
|
||||
cellClick={(index: number | undefined, headId: string) => { }}
|
||||
cellClick={(index: number | undefined, headId: string) => {
|
||||
setUpdateData(coSttnRes[index as number]);
|
||||
}}
|
||||
onPageChange={setPageNation}
|
||||
></UiTable>
|
||||
</ListDiv>
|
||||
@@ -203,17 +226,16 @@ export default function CoSttn() {
|
||||
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"}
|
||||
updateList={upadateData}
|
||||
></SdmInsertForm>
|
||||
}
|
||||
></UiModal>
|
||||
</ContentsDiv>
|
||||
<Toaster position="top-center" />
|
||||
</>
|
||||
|
||||
)
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ export default function PublicReuseFaciltyInsert() {
|
||||
pbnstMngData,
|
||||
pbnstRuseFcltUpdate,
|
||||
pbnstRuseBizUpdate,
|
||||
getHasuFlow
|
||||
} = useWrStore((state) => state);
|
||||
const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst;
|
||||
const [currentTab, setCurrentTab] = useState<string>("mng");
|
||||
@@ -95,7 +94,6 @@ export default function PublicReuseFaciltyInsert() {
|
||||
setIsRuseReg({ ...isRuseReg, data: selectRow });
|
||||
pbnstRegClick(selectRow);
|
||||
|
||||
getHasuFlow(selectRow.gugun, selectRow.bscFctNm)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -102,6 +102,12 @@ const dmdUszCd = [
|
||||
|
||||
]
|
||||
|
||||
const ruseMngMtd = [
|
||||
{ val: "자체운영", text: "자체운영" },
|
||||
{ val: "공기업", text: "공기업" },
|
||||
{ val: "민간(대행)", text: "민간(대행)" },
|
||||
]
|
||||
|
||||
|
||||
const pplQulity = [
|
||||
{ val: "도복장강관", text: "도복장강관" },
|
||||
@@ -154,6 +160,7 @@ export type comCodeState = {
|
||||
RNB:string,
|
||||
HTB:string
|
||||
}
|
||||
ruseMngMtd:SelectDataType[]
|
||||
};
|
||||
};
|
||||
|
||||
@@ -292,6 +299,7 @@ export const comCodeStateExport: comCodeState = {
|
||||
yn: yn,
|
||||
dmdUszCd:dmdUszCd,
|
||||
buildingType:buildingType,
|
||||
ruseMngMtd:ruseMngMtd,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const coZod = z.object({
|
||||
ctpv: z.string(),
|
||||
sgg: z.string(),
|
||||
coNm: z.string().min(1).max(20),
|
||||
bznmNo: z.string().min(1).min(9).max(12),
|
||||
addr: z.string().min(1).min(6).max(20),
|
||||
telNo: z.string().min(8).max(12)
|
||||
|
||||
});
|
||||
|
||||
export type customCoBdst = z.infer<typeof coZod>;
|
||||
@@ -15,12 +15,12 @@ export const coRegExcel = z.object({
|
||||
|
||||
export const coSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
{
|
||||
id: "ctpvCd",
|
||||
id: "cityText",
|
||||
title: "시도",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "sggCd",
|
||||
id: "sggText",
|
||||
title: "시군구",
|
||||
visible: true,
|
||||
},
|
||||
@@ -31,12 +31,12 @@ export const coSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
},
|
||||
{
|
||||
id: "daddr",
|
||||
title: "공장주소",
|
||||
title: "주소",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "dmdInfoPk",
|
||||
title: "공장관리번호",
|
||||
title: "사업자번호",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
@@ -48,7 +48,7 @@ export const coSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
|
||||
export const coSttNodeListExport: CommonTableProps[] = [
|
||||
{
|
||||
id: "ctpvCd",
|
||||
id: "cityText",
|
||||
title: "시도",
|
||||
visible: true,
|
||||
row: 1,
|
||||
@@ -56,7 +56,7 @@ export const coSttNodeListExport: CommonTableProps[] = [
|
||||
colSpan: 1,
|
||||
},
|
||||
{
|
||||
id: "sggCd",
|
||||
id: "sggText",
|
||||
title: "시군구",
|
||||
visible: true,
|
||||
row: 1,
|
||||
@@ -73,7 +73,7 @@ export const coSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "daddr",
|
||||
title: "공장주소",
|
||||
title: "주소",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
@@ -81,7 +81,7 @@ export const coSttNodeListExport: CommonTableProps[] = [
|
||||
},
|
||||
{
|
||||
id: "dmdInfoPk",
|
||||
title: "공장관리번호",
|
||||
title: "사업자번호",
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
|
||||
@@ -3,27 +3,17 @@ import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { z } from "zod";
|
||||
import { coSttHeadListExport, coSttNodeListExport } from "./headList";
|
||||
import { excelCoSttnParsing } from "./excel";
|
||||
import type { DemandCompType } from "@common/business_components/ui";
|
||||
|
||||
// 테이블 헤드 리스트
|
||||
const coSttNodeList = coSttNodeListExport;
|
||||
const coSttHeadList = coSttHeadListExport;
|
||||
const coSttnRes: customCoSttnBdst[] = [];
|
||||
const coSttnRes: DemandCompType[] = [];
|
||||
|
||||
const coSttnZod = z.object({
|
||||
ctpvCd: z.string(),
|
||||
sggCd: z.string(),
|
||||
dmdCoNm: z.string().min(1).max(20),
|
||||
dmdInfoPk: z.string().min(1).min(10).max(14),
|
||||
daddr: z.string().min(1).min(6).max(20),
|
||||
telno: z.string().min(11).max(12)
|
||||
|
||||
});
|
||||
|
||||
export type customCoSttnBdst = z.infer<typeof coSttnZod>;
|
||||
|
||||
export type coSttnState = {
|
||||
coSttn: {
|
||||
coSttnRes: customCoSttnBdst[];
|
||||
coSttnRes: DemandCompType[];
|
||||
coSttHeadList: CommonTableProps[];
|
||||
coSttNodeList: CommonTableProps[];
|
||||
excelList: [];
|
||||
@@ -32,8 +22,9 @@ export type coSttnState = {
|
||||
};
|
||||
|
||||
type coSttnActions = {
|
||||
coSttnInit:(con:string) => void;
|
||||
coSttnSearch: (txt: string, cnt: number) => void;
|
||||
coSttnInit:(pageNo:string, pageCnt:string, con: string) => void;
|
||||
coSttnSearch: (pageNo:string, pageCnt:string, con: string) => void;
|
||||
coSttnTxtSearch:(pageNo:string, pageCnt:string, con: string,txt:string) => void;
|
||||
};
|
||||
|
||||
export type coSttnType = coSttnState & coSttnActions;
|
||||
@@ -48,17 +39,20 @@ export const coSttnStateExport: coSttnState = {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
export const coSttnActionsExport: (set: any) => coSttnActions = (
|
||||
set: any
|
||||
) => {
|
||||
return {
|
||||
coSttnInit: async (con: string) => {
|
||||
coSttnInit: async (pageNo:string, pageCnt:string, con: string) => {
|
||||
try {
|
||||
|
||||
const coSttnRes = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/마인드원/3`
|
||||
`/reuseFc/request/${pageNo}/${pageCnt}/${con}`
|
||||
);
|
||||
|
||||
|
||||
set((state: coSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
@@ -73,13 +67,13 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
coSttnSearch: async (txt: string, cnt: number) => {
|
||||
coSttnSearch: async (pageNo:string, pageCnt:string, con: string) => {
|
||||
try {
|
||||
const coSttnRes = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/${txt}/${cnt}`
|
||||
`/reuseFc/request/${pageNo}/${pageCnt}/${con}`
|
||||
);
|
||||
if (Number(cnt) > 0) {
|
||||
if (Number(pageCnt) >= 10000) {
|
||||
const coExcel = excelCoSttnParsing(coSttnRes);
|
||||
set((state: coSttnState) => {
|
||||
return {
|
||||
@@ -87,6 +81,7 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
|
||||
coSttn: {
|
||||
...state.coSttn,
|
||||
excelList: coExcel,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -105,5 +100,22 @@ export const coSttnActionsExport: (set: any) => coSttnActions = (
|
||||
console.log("error", erTxt);
|
||||
}
|
||||
},
|
||||
coSttnTxtSearch: async (pageNo:string, pageCnt:string, con: string, txt: string) => {
|
||||
try {
|
||||
const coSttnRes = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/${pageNo}/${pageCnt}/${con}/${txt}`)
|
||||
set((state: coSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
coSttn: {
|
||||
...state.coSttn,
|
||||
coSttnRes: coSttnRes,
|
||||
isInit: false,
|
||||
}}})
|
||||
} catch (erTxt) {
|
||||
console.log("error", erTxt);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,11 @@ export const pubFacHeadListExport: TableUpperProps[] = [
|
||||
|
||||
export const pbnstMngUpHeadListExport: TableUpperProps[] = [
|
||||
{ id: "choose", title: "선택", type: "checkbox" },
|
||||
{ id: "operMthd", title: "운영방식", edit: true },
|
||||
{ id: "operMthd", title: "운영방식",type: "select", selectData: "ruseMngMtd" },
|
||||
{ id: "rprtvBzenty", title: "대행업체", edit: true },
|
||||
{
|
||||
id: "bgngDt",
|
||||
title: "시작일",
|
||||
upName: "upChangeRe",
|
||||
upSequnce: 1,
|
||||
type: "date",
|
||||
},
|
||||
@@ -50,7 +49,7 @@ export const pbnstDemandHeadListExport: TableUpperProps[] = [
|
||||
];
|
||||
|
||||
export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [
|
||||
{ id: "ruseUtztnFcltNm", title: "운영방식" },
|
||||
{ id: "ruseUtztnFcltNm", title: "하수처리장명" },
|
||||
{ id: "orgwtWtritQnt", title: "원수취수량" },
|
||||
{ id: "tmsYn", title: "하수처리량TMS 전후" },
|
||||
{ id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후" },
|
||||
|
||||
@@ -51,7 +51,6 @@ export type pubFacState = {
|
||||
fcOrgwtsHeadList: TableUpperProps[];
|
||||
pbnstMngRegData: customPbnst[];
|
||||
pbnsUpdateIndex: pbnstInsertIndex;
|
||||
efflAmnt:string
|
||||
dmdComList: any[];
|
||||
};
|
||||
};
|
||||
@@ -69,7 +68,6 @@ type pubFacActions = {
|
||||
getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
|
||||
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
|
||||
pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
|
||||
getHasuFlow: (sggCd:string, swtrmtFcltNm:string) => void
|
||||
};
|
||||
export type pubFacType = pubFacState & pubFacActions;
|
||||
|
||||
@@ -81,7 +79,6 @@ export const pubFacStateExport: pubFacState = {
|
||||
pbnstMngNm: pbnstMngNm,
|
||||
pbnstOrgwtHeadList: pbnstOrgwtHeadList,
|
||||
pbnstHasuRes: [],
|
||||
efflAmnt:'',
|
||||
pbnstResObj: null, // 초기값을 null로 변경
|
||||
pbnstRes: [], // 초기값을 null로 변경
|
||||
pbnstBizCycle: [{ text: "없음", val: "1" }],
|
||||
@@ -216,6 +213,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
pbnstInsert: async (pbnstRes: customPbnst) => {
|
||||
try {
|
||||
|
||||
console.log( ' pbnstRes ' , pbnstRes)
|
||||
const response = await postFectch(
|
||||
`/reuseFc/pubFc`,
|
||||
JSON.stringify( writeRgtrAndMdfr([pbnstRes]))
|
||||
@@ -321,7 +319,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
pbnstMngData: (data: customPbnst[]) => {
|
||||
if (data.length > 0) {
|
||||
}
|
||||
console.log('data', data)
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnstMngRegData = data;
|
||||
state.pbnst.pbnstBizCycle =
|
||||
@@ -373,21 +370,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
},getHasuFlow: async(sggCd:string, swtrmtFcltNm:string) =>{
|
||||
try{
|
||||
const year = new Date().getFullYear()-1
|
||||
const flow = await getFetch( fetchType.COMMON, `/fclt/flow/1/1/${year}/A/${sggCd}/0/1/${swtrmtFcltNm}`)
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
efflAmnt: flow[0].efflAmnt,
|
||||
},
|
||||
}));
|
||||
}catch(e){
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -165,8 +165,8 @@ export const fcBizSchema = z.object({
|
||||
cycl: z.number().default(1),
|
||||
seCd: z.string().default(""),
|
||||
bizMthdCd: z.string().default(""),
|
||||
instlAprvSncnDt: z.date().nullish(),
|
||||
bizCmcnDay: z.date().nullish(),
|
||||
instlAprvSncnDt: z.date().default(new Date()),
|
||||
bizCmcnDay: z.date().default(new Date()),
|
||||
gvsbs: z.number().default(0),
|
||||
lcep: z.number().default(0),
|
||||
cusrAlotm: z.number().default(0),
|
||||
@@ -244,5 +244,4 @@ export const pbnstRegZod = z.object({
|
||||
fcFiles: z.array(fcFileSchema).default([]),
|
||||
fcBizs: z.array(fcBizSchema).default([]),
|
||||
fcOpers: z.array(fcOperSchema).default([]),
|
||||
hasuhasu: z.number().default(0),
|
||||
});
|
||||
|
||||
@@ -21,6 +21,7 @@ export const getCity = (val: string, sggCd: SelectDataType[]) => {
|
||||
// cd text 넣기
|
||||
export const tableData = (data: any, code: comCodeState) => {
|
||||
const chCode = code.code;
|
||||
|
||||
return data?.map(
|
||||
(item: {
|
||||
sggCd: string;
|
||||
@@ -29,17 +30,16 @@ export const tableData = (data: any, code: comCodeState) => {
|
||||
}) => {
|
||||
let returnData = {};
|
||||
const sggText = chCode.sggCd.find(
|
||||
(cd) => cd.val === String(item.sggCd)
|
||||
(cd) => cd.val === String(item.sggCd).trim()
|
||||
)?.text;
|
||||
const cityText = chCode.cityCd.find(
|
||||
(cd) => cd.val === String(item.ctpvCd)
|
||||
(cd) => cd.val === String(item.ctpvCd).trim()
|
||||
)?.text;
|
||||
if (item?.reuseBuilding?.length > 0) {
|
||||
const bdsgUsgText = chCode.bdstUsgCd.find(
|
||||
(cd) => Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd
|
||||
)?.text;
|
||||
const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn;
|
||||
|
||||
returnData = {
|
||||
...item,
|
||||
sggText: sggText ?? "없음",
|
||||
@@ -54,7 +54,6 @@ export const tableData = (data: any, code: comCodeState) => {
|
||||
cityText: cityText ?? "없음",
|
||||
};
|
||||
}
|
||||
|
||||
return returnData;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -75,6 +75,7 @@ export function PbnstBuseForm({
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
|
||||
const [sumCpct, setSumCpct] = useState<number>(0);
|
||||
const [getDmdList, setGetFmdList] = useState<number>(0);
|
||||
const [isDmdModal, setIsDmdModal] = useState<{
|
||||
isMoal: boolean;
|
||||
data: DemandCompType;
|
||||
@@ -95,6 +96,7 @@ export function PbnstBuseForm({
|
||||
pbnst.pbnsUpdateIndex.biz
|
||||
]
|
||||
: fcBizSchema.parse({}),
|
||||
mode: "onChange",
|
||||
});
|
||||
|
||||
// 2. Define a submit handler.
|
||||
@@ -157,9 +159,11 @@ export function PbnstBuseForm({
|
||||
useEffect(() => {
|
||||
const formData = form.watch();
|
||||
|
||||
//console.log(" formData.fcDemands. ", formData.fcDemands);
|
||||
formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사
|
||||
formData.fcDemands = fcDemands;
|
||||
formData.fcOrgwts = fcOrgwtFiled;
|
||||
//formData.fcDemands = fcDemands;
|
||||
//formData.fcOrgwts = fcOrgwtFiled;
|
||||
console.log(" formData. ", formData);
|
||||
if (formType === "reg") {
|
||||
if (
|
||||
firstBizData &&
|
||||
@@ -174,15 +178,11 @@ export function PbnstBuseForm({
|
||||
form.setValue("cycl", firstBizData[0].cycl);
|
||||
}
|
||||
pbnstBizData(formData as fcBizType);
|
||||
}else if(formType === "update"){
|
||||
|
||||
} else if (formType === "update") {
|
||||
pbnstBizData(formData as fcBizType);
|
||||
|
||||
|
||||
}
|
||||
}, [firstBizData, form.formState, formType, pbnst.pbnstRes]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (ppiYn === "N") {
|
||||
form.setValue("pplInstls", []);
|
||||
@@ -195,7 +195,8 @@ export function PbnstBuseForm({
|
||||
|
||||
const plusHist = () => {
|
||||
const regData = {
|
||||
ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? form.getValues('pbnstRuseFcltBizPk'),
|
||||
ruseFcltBizFk:
|
||||
ref.current?.[0]?.ruseFcltBizFk ?? form.getValues("pbnstRuseFcltBizPk"),
|
||||
choose: false,
|
||||
ppMqlt: "",
|
||||
pdmt: "",
|
||||
@@ -220,9 +221,9 @@ export function PbnstBuseForm({
|
||||
splyEndDay: new Date(),
|
||||
splyCpct: 0,
|
||||
splyFmYn: "Y",
|
||||
pbnstRuseFcltBizPk: form.getValues('pbnstRuseFcltBizPk'),
|
||||
pbnstRuseFcltFk: form.getValues('pbnstRuseFcltFk')??'',
|
||||
dmdInfoFk: '',
|
||||
pbnstRuseFcltBizPk: form.getValues("pbnstRuseFcltBizPk"),
|
||||
pbnstRuseFcltFk: form.getValues("pbnstRuseFcltFk") ?? "",
|
||||
dmdInfoFk: "",
|
||||
//telno: "",
|
||||
});
|
||||
};
|
||||
@@ -258,6 +259,13 @@ export function PbnstBuseForm({
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" fcDemands ", fcDemands);
|
||||
}, [fcDemands]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" demandCompList ", demandCompList);
|
||||
}, [demandCompList]);
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
@@ -459,62 +467,74 @@ export function PbnstBuseForm({
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="수요처명">
|
||||
<SearchInputText
|
||||
label={'수요처'}
|
||||
label={"수요처"}
|
||||
initValue={f.value}
|
||||
setValue={(val) => {
|
||||
f.onChange(val);
|
||||
if (val) getDemandCompList(val, 3);
|
||||
console.log("val ", val);
|
||||
if (val && val.length > 2) {
|
||||
getDemandCompList(val, 3);
|
||||
}
|
||||
}}
|
||||
setRtnData={(valList: any[]) => {
|
||||
if (
|
||||
valList.length > 0 &&
|
||||
valList['0']
|
||||
) {
|
||||
form.setValue(
|
||||
`fcDemands.${index}.pbnstRuseFcltBizPk`,
|
||||
form.getValues('pbnstRuseFcltBizPk')
|
||||
setRtnData={(valList: any) => {
|
||||
if (valList) {
|
||||
console.log(
|
||||
" form.getValues ",
|
||||
form.getValues("pbnstRuseFcltBizPk")
|
||||
);
|
||||
const bizPk =
|
||||
form.getValues("pbnstRuseFcltBizPk");
|
||||
|
||||
if (form.getValues("pbnstRuseFcltBizPk")) {
|
||||
form.setValue(
|
||||
`fcDemands.${index}.pbnstRuseFcltBizPk`,
|
||||
bizPk
|
||||
);
|
||||
}
|
||||
form.setValue(
|
||||
`fcDemands.${index}.pbnstRuseFcltFk`,
|
||||
form.getValues('pbnstRuseFcltFk')??''
|
||||
|
||||
form.getValues("pbnstRuseFcltFk") ?? ""
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.dmdCoNm`,
|
||||
valList['0'].dmdCoNm
|
||||
valList.dmdCoNm
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.daddr`,
|
||||
valList['0'].daddr
|
||||
valList.daddr
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.useUsgCd`,
|
||||
valList['0'].useUsgCd
|
||||
valList.useUsgCd
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.splyCpct`,
|
||||
valList['0'].splyCpct
|
||||
valList.splyCpct
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.splyFmYn`,
|
||||
valList['0'].splyFmYn ?? "Y"
|
||||
valList.splyFmYn ?? "Y"
|
||||
);
|
||||
form.setValue(
|
||||
`fcDemands.${index}.dmdInfoFk`,
|
||||
valList['0'].dmdInfoPk?.toString() ?? ""
|
||||
valList.dmdInfoPk?.toString() ?? ""
|
||||
);
|
||||
}
|
||||
|
||||
// field.daddr=valList.daddr;
|
||||
// field.useUsgCd=valList.useUsgCd;
|
||||
// field.splyCpct=valList.splyCpct;
|
||||
// field.splyFmYn=valList.splyFmYn;
|
||||
// field.dmdInfoFk=valList.dmdInfoPk?.toString();
|
||||
// field.dmdCoNm=valList.dmdCoNm;
|
||||
}
|
||||
}}
|
||||
searchList={demandCompList?.map((item=>{
|
||||
return({
|
||||
searchList={demandCompList?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
searchNm:item.dmdCoNm,
|
||||
searchPk:item.dmdInfoPk
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
searchNm: item.dmdCoNm,
|
||||
searchPk: item.dmdInfoPk,
|
||||
};
|
||||
})}
|
||||
></SearchInputText>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -544,13 +564,13 @@ export function PbnstBuseForm({
|
||||
name={`fcDemands.${index}.useUsgCd`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="사용용도">
|
||||
<SelectBox
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.dmdUszCd}
|
||||
onSelectValue={f.onChange}
|
||||
value={f.value?? code.dmdUszCd[0]?.val}
|
||||
value={f.value ?? code.dmdUszCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -668,7 +688,6 @@ export function PbnstBuseForm({
|
||||
getDemandCompList(searchText, pageCnt);
|
||||
}}
|
||||
rtnInputData={(data) => {
|
||||
console.log(" rtn data ", data);
|
||||
regDemandCompany(data as DemandCompType);
|
||||
setIsDmdModal({ isMoal: false, data: data as DemandCompType });
|
||||
}}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { FileUpload, FormUi, SelectBox } from "@common/business_components/ui";
|
||||
import { FileUpload, FormUi, SelectBox, type SelectDataType } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input } from "@common/components";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -18,7 +18,6 @@ import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTab
|
||||
import {
|
||||
pbnstRegZod,
|
||||
type customPbnst,
|
||||
type fcBizType,
|
||||
type fcFileType,
|
||||
type operType,
|
||||
type selectLabel,
|
||||
@@ -39,6 +38,7 @@ export function PbnstMngForm({
|
||||
firstFcltData?: customPbnst;
|
||||
}) {
|
||||
const {
|
||||
code,
|
||||
pbnst,
|
||||
pbnstInsert,
|
||||
pbnstMngData,
|
||||
@@ -54,6 +54,7 @@ export function PbnstMngForm({
|
||||
const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null);
|
||||
const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null);
|
||||
const [fcOpresData, setFcOpresData] = useState<operType[] | null>(null);
|
||||
const [mngMtdCode, setMngMtdCode] = useState<{ name: string, val: SelectDataType[] }[]>();
|
||||
|
||||
const [progress, setProgress] = useState(0);
|
||||
//const new File([] as BlobPart[], "") 파일 다운로드 활용
|
||||
@@ -73,13 +74,13 @@ export function PbnstMngForm({
|
||||
? {
|
||||
ruseUtztnFcltNm: firstFcltData?.ruseUtztnFcltNm,
|
||||
fcltCpct: firstFcltData?.fcltCpct,
|
||||
hasuhasu: firstFcltData?.hasuhasu,
|
||||
ruseCpct: firstFcltData?.ruseCpct,
|
||||
splyExtraCpct: firstFcltData?.splyExtraCpct,
|
||||
fcOpers: firstFcltData?.fcOpers,
|
||||
fcFiles: firstFcltData?.fcFiles,
|
||||
}
|
||||
: pbnstRegZod.parse({}),
|
||||
mode: "onChange",
|
||||
});
|
||||
const {
|
||||
fields: fcOpersField,
|
||||
@@ -99,7 +100,6 @@ export function PbnstMngForm({
|
||||
getBizCycle(pbnst.pbnstRes[val]);
|
||||
form.reset(pbnst.pbnstRes[val]);
|
||||
|
||||
form.setValue("hasuhasu", Number(pbnst.efflAmnt) ?? 0);
|
||||
getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val });
|
||||
}
|
||||
};
|
||||
@@ -314,6 +314,12 @@ export function PbnstMngForm({
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
|
||||
useEffect(() => {
|
||||
if(code.ruseMngMtd){
|
||||
setMngMtdCode( [{name:"ruseMngMtd",val:code.ruseMngMtd}])
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
return (
|
||||
<div className=" !mx-[1.6rem] !p-0r">
|
||||
<div>
|
||||
@@ -356,10 +362,6 @@ export function PbnstMngForm({
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* <Button onClick={addRuseFcltObj} type="button" size={commonButonSize}>
|
||||
추가
|
||||
</Button> */}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -389,6 +391,7 @@ export function PbnstMngForm({
|
||||
tableData={fcOpersField}
|
||||
headList={pbnst.pbnstMngUpHeadList}
|
||||
upHeadList={pbnst.pbnstMngNm}
|
||||
code={mngMtdCode || []}
|
||||
onTableSet={(val) => {
|
||||
setFcOpresData(val);
|
||||
}}
|
||||
@@ -404,7 +407,7 @@ export function PbnstMngForm({
|
||||
control={form.control}
|
||||
name="fcltCpct"
|
||||
render={({ field }) => (
|
||||
<FormUi label="시설용량(m³/일)">
|
||||
<FormUi label="재이용 시설용량(m³/일)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
@@ -417,31 +420,13 @@ export function PbnstMngForm({
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3 mt-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="hasuhasu"
|
||||
render={({ field }) => (
|
||||
<FormUi label="하수처리량(m³/일)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="col-span-3 mt-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="ruseCpct"
|
||||
render={({ field }) => (
|
||||
<FormUi label="재이용량(m³/일)">
|
||||
<FormUi label="재이용수공급량(m³/일)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
|
||||
@@ -8,7 +8,7 @@ type thisProps = {
|
||||
label: string | undefined;
|
||||
initValue: string | undefined;
|
||||
setValue: (searchNm?: string) => void;
|
||||
setRtnData: (rtnData: any[]) => void;
|
||||
setRtnData: (rtnData: any) => void;
|
||||
searchList?: any[];
|
||||
};
|
||||
export default function SearchInputText({
|
||||
@@ -42,7 +42,7 @@ export default function SearchInputText({
|
||||
setTextValue(dmdCoNm);
|
||||
setValue(dmdCoNm);
|
||||
setIsOpen(false);
|
||||
setRtnData(searchList || []);
|
||||
setRtnData(searchList?.find((item) => item.dmdCoNm === dmdCoNm) || {});
|
||||
},
|
||||
[searchList, setRtnData, setValue]
|
||||
);
|
||||
|
||||
@@ -42,8 +42,7 @@ const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
|
||||
}, [tableState,onTableSet]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(tableData)
|
||||
setTableState(tableData);
|
||||
@@ -92,7 +91,7 @@ const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
|
||||
) : head.type === "select" ? (
|
||||
<SelectBox
|
||||
label=""
|
||||
selectArray={code.find(item => item.name === head.selectData)?.val ?? []}
|
||||
selectArray={code?.find(item => item.name === head.selectData)?.val ?? []}
|
||||
value={
|
||||
tableState[i][head.id] || ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user