Merge commit '5b48dcaeaadaaecb540c839b7155311214172956' into iipbs/wr/form_fuction
This commit is contained in:
@@ -14,9 +14,6 @@ import {
|
||||
tableData,
|
||||
yearOptions,
|
||||
} from "@/components/lib/func/commom";
|
||||
import { CmpttnModal } from "@/components/ui/modal/coMat/constCostFeeTable";
|
||||
import { CoMatModal } from "@/components/ui/modal/coMat/rateFeeModal";
|
||||
import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
import {
|
||||
ContentsDiv,
|
||||
Form,
|
||||
@@ -43,6 +40,7 @@ import moment from "moment";
|
||||
import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import ConCostForm from "@/components/ui/form/coMat/conCostForm/conCostForm";
|
||||
import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
|
||||
export default function CoMatRvw() {
|
||||
const { code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } =
|
||||
@@ -114,7 +112,7 @@ export default function CoMatRvw() {
|
||||
}, [form.watch("useUsgCd")]);
|
||||
|
||||
useEffect(() => {
|
||||
if (coMatRvwRes) {
|
||||
if (coMatRvwRes.length > 0) {
|
||||
const data = coMatRvwRes?.map((item, index) => {
|
||||
let flag = "";
|
||||
flag = getdmdMatFlag(item?.demandMatching?.splyFcltFlg ??"");
|
||||
|
||||
@@ -94,7 +94,6 @@ export default function RuseRvwHstry() {
|
||||
} else {
|
||||
|
||||
|
||||
console.log("시도코드", sggCd);
|
||||
ruseRvwInqua(pageNation, 13, String(startYear), String(endYear), sggCd);
|
||||
}
|
||||
};
|
||||
@@ -122,7 +121,7 @@ export default function RuseRvwHstry() {
|
||||
?.map((item) => {
|
||||
form.clearErrors;
|
||||
if (item?.completeYn) {
|
||||
return item.dmdInfoSn;
|
||||
return Number(item.dmdInfoSn);
|
||||
}
|
||||
})
|
||||
.filter((item) => item !== undefined);
|
||||
@@ -136,7 +135,7 @@ export default function RuseRvwHstry() {
|
||||
<button
|
||||
onClick={() => {
|
||||
toast.dismiss(t.id);
|
||||
ruseRvwComplete(completeData as string[]);
|
||||
ruseRvwComplete(completeData as Number[]);
|
||||
}}
|
||||
>
|
||||
확인
|
||||
@@ -145,7 +144,7 @@ export default function RuseRvwHstry() {
|
||||
</span>
|
||||
));
|
||||
} else {
|
||||
ruseRvwComplete(completeData as string[]);
|
||||
ruseRvwComplete(completeData as Number[]);
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
@@ -165,7 +164,6 @@ export default function RuseRvwHstry() {
|
||||
let flag = "";
|
||||
flag = getdmdMatFlag(item.demandMatching?.splyFcltFlg ?? "");
|
||||
|
||||
console.log("flag", flag);
|
||||
return {
|
||||
...item,
|
||||
ctpvCd: item.demandCo?.ctpvCd,
|
||||
@@ -193,7 +191,6 @@ export default function RuseRvwHstry() {
|
||||
}
|
||||
}, [rvwHistRes]);
|
||||
|
||||
useEffect(() => {}, [form.formState]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("변경여부 ", form.formState.isDirty);
|
||||
|
||||
@@ -87,6 +87,7 @@ export default function PbnstSttn() {
|
||||
}
|
||||
}, [pbnstSttn.isInit, pbnSttnInit, ref.current]);
|
||||
useEffect(() => {
|
||||
|
||||
setBdstTable(pbnstSttn.pbnstSttnRes);
|
||||
}, [pbnstSttn.pbnstSttnRes]);
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ export default function Page() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!rainChkgdn.isInit) {
|
||||
rainChkInit("2024", "0");
|
||||
rainChkInit(new Date().getFullYear().toString(), "0");
|
||||
isRainSttn(false)
|
||||
|
||||
setIsModal({ data: {}, open: false });
|
||||
@@ -78,7 +78,7 @@ export default function Page() {
|
||||
}
|
||||
|
||||
if (!rswtChkgdn.isInit) {
|
||||
rswtChkgdnInit("2024", "0");
|
||||
rswtChkgdnInit(new Date().getFullYear().toString(), "0");
|
||||
setIsModal({ data: {}, open: false });
|
||||
setIsRegExcel(false);
|
||||
}
|
||||
|
||||
@@ -84,10 +84,10 @@ export default function prfmncPrfmncReg() {
|
||||
isModal: false,
|
||||
data: prfmncRes[index] || ({} as FcPrfType),
|
||||
});
|
||||
const inUsageData = [...initValInUsage];
|
||||
const outUsageData = [...initValOutUsage];
|
||||
const inSubtotal = subTotalObj;
|
||||
const outSubtotal = subTotalObj;
|
||||
const inUsageData = structuredClone(initValInUsage);
|
||||
const outUsageData = structuredClone(initValOutUsage);
|
||||
const inSubtotal = structuredClone(subTotalObj);
|
||||
const outSubtotal = structuredClone(subTotalObj);
|
||||
if (prfmncRes[index]?.prfList) {
|
||||
prfmncRes[index].prfList?.forEach((prfItem) => {
|
||||
const month = Number(prfItem?.ym?.slice(4)); // "MM"
|
||||
@@ -123,7 +123,7 @@ export default function prfmncPrfmncReg() {
|
||||
});
|
||||
inUsageData.push(inSubtotal);
|
||||
outUsageData.push(outSubtotal);
|
||||
const usageTotalObj: { [key: string]: any } = totalObj;
|
||||
const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
|
||||
for (const key in usageTotalObj) {
|
||||
if (["usage", "gubun", "edit"].includes(key)) continue;
|
||||
const val =
|
||||
@@ -135,7 +135,6 @@ export default function prfmncPrfmncReg() {
|
||||
const tableData = [...inUsageData, ...outUsageData, usageTotalObj];
|
||||
setPbnstRuseFcltPk(prfmncRes[index].pbnstRuseFcltPk);
|
||||
|
||||
console.log(' tableData ' ,tableData)
|
||||
setInputData(tableData);
|
||||
} else {
|
||||
setInputData([]);
|
||||
|
||||
@@ -78,12 +78,12 @@ export default function PbnstPrfmncSttn() {
|
||||
type barChartForm = { label: string, "장내용수": number, "장외용수": number };
|
||||
type lineChartDataProps = { label: string, val: number, color: string };
|
||||
|
||||
const prfTableData = (prfList: PrfType[], year: string) => {
|
||||
const inUsageData = initValInUsage;
|
||||
const outUsageData = initValOutUsage;
|
||||
const prfTableData = (prfList: PrfType[], year:string) => {
|
||||
const inUsageData = structuredClone(initValInUsage);
|
||||
const outUsageData = structuredClone(initValOutUsage);
|
||||
|
||||
const inSubtotal = subTotalObj;
|
||||
const outSubtotal = subTotalObj;
|
||||
const inSubtotal = structuredClone(subTotalObj);
|
||||
const outSubtotal = structuredClone(subTotalObj);
|
||||
|
||||
const prfFilter = prfList?.filter((e) => e.ym.slice(0, 4) === year)
|
||||
if (prfList && prfFilter.length > 0) {
|
||||
@@ -121,7 +121,7 @@ export default function PbnstPrfmncSttn() {
|
||||
});
|
||||
inUsageData.push(inSubtotal);
|
||||
outUsageData.push(outSubtotal);
|
||||
const usageTotalObj: { [key: string]: any } = totalObj;
|
||||
const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
|
||||
for (const key in usageTotalObj) {
|
||||
if (["usage", "gubun", "edit"].includes(key)) continue;
|
||||
const val =
|
||||
|
||||
@@ -22,5 +22,6 @@ export type TableUpperProps = {
|
||||
selectData ?:string; // type 이 seelct 일경우 selectarray 정하기 위해
|
||||
row?:number;
|
||||
mergeCell?:boolean // 셀을 합칠경우
|
||||
readonly?:boolean
|
||||
};
|
||||
|
||||
|
||||
@@ -187,13 +187,13 @@ export const rateFeeHeadListExport: CommonTableProps[] = [
|
||||
];
|
||||
|
||||
export const usageProcData = [
|
||||
{ usage: "청소", process: "총인처리시설 + 염소소독" },
|
||||
{ usage: "화장실용수", process: "총인처리시설 + 염소소독" },
|
||||
{ usage: "세척", process: "총인처리시설 + UV소독" },
|
||||
{ usage: "살수", process: "총인처리시설 + UV소독" },
|
||||
{ usage: "조경", process: "총인처리시설 + UV소독" },
|
||||
{ usage: "농업", process: "총인처리시설 + UV소독" },
|
||||
{ usage: "하천", process: "총인처리시설 + UV소독" },
|
||||
{ usage: "지하수", process: "전처리시설 + RO" },
|
||||
{ usage: "공업", process: "전처리시설 + RO" },
|
||||
{ usage: "청소", process: "총인처리시설+염소소독" },
|
||||
{ usage: "화장실용수", process: "총인처리시설+염소소독" },
|
||||
{ usage: "세척", process: "총인처리시설+UV소독" },
|
||||
{ usage: "살수", process: "총인처리시설+UV소독" },
|
||||
{ usage: "조경", process: "총인처리시설+UV소독" },
|
||||
{ usage: "농업", process: "총인처리시설+UV소독" },
|
||||
{ usage: "하천", process: "총인처리시설+UV소독" },
|
||||
{ usage: "지하수", process: "전처리시설+RO" },
|
||||
{ usage: "공업", process: "전처리시설+RO" },
|
||||
];
|
||||
|
||||
@@ -62,7 +62,7 @@ import { z } from "zod";
|
||||
dmdInfoSn: z.number(),
|
||||
usgPrcsProcs: z.string().nullish(),
|
||||
cstrnCst: z.number(),
|
||||
fcltSbsdEpsTrf: z.number(),
|
||||
fcltSbsdCstrnCst: z.number(),
|
||||
prcsFcltCpctCstrnCst: z.number()
|
||||
});
|
||||
|
||||
@@ -73,19 +73,19 @@ import { z } from "zod";
|
||||
dmdInfoFk: z.string(),
|
||||
dmndTmng: z.coerce.date(),
|
||||
dmndQty: z.number(),
|
||||
wntUntprc: z.number(),
|
||||
grssClfg: z.number(),
|
||||
combResdch: z.number(),
|
||||
trbt: z.number(),
|
||||
wntUntprc: z.number().nullish(),
|
||||
grssClfg: z.number().nullish(),
|
||||
combResdch: z.number().nullish(),
|
||||
trbt: z.number().nullish(),
|
||||
blgcOxygDmndQnt: z.number(),
|
||||
smll: z.number(),
|
||||
crmty: z.number(),
|
||||
tn: z.number(),
|
||||
tph: z.number(),
|
||||
ph: z.number(),
|
||||
clIonQnt: z.number(),
|
||||
smll: z.number().nullish(),
|
||||
crmty: z.number().nullish(),
|
||||
tn: z.number().nullish(),
|
||||
tph: z.number().nullish(),
|
||||
ph: z.number().nullish(),
|
||||
clIonQnt: z.number().nullish(),
|
||||
cdtnv: z.number(),
|
||||
rmrk: z.string(),
|
||||
rmrk: z.string().nullish(),
|
||||
useUsgCd: z.string().nullish(),
|
||||
mtchnCmptnYmd: z.string().nullish(),
|
||||
rvwCmptnYmd: z.string().nullish(),
|
||||
@@ -93,6 +93,8 @@ import { z } from "zod";
|
||||
demandMatching: DemandMatchingSchema.nullish(),
|
||||
demandCst: DemandCstSchema,
|
||||
ruseUtztnFcltNm:z.string().nullish(),
|
||||
totalConstCost:z.number().nullish(),
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -113,7 +115,7 @@ export type DedMatUpdateType =
|
||||
dmdInfoSn: number;
|
||||
usgPrcsProcs: string;
|
||||
cstrnCst: number;
|
||||
fcltSbsdEpsTrf: number;
|
||||
fcltSbsdCstrnCst: number;
|
||||
prcsFcltCpctCstrnCst: number;
|
||||
rgtr: string;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ruseHstryHeadListExport } from "./headList";
|
||||
import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
|
||||
import type { DmdCoReqType } from "../coMatRvw/type";
|
||||
import toast from "react-hot-toast";
|
||||
import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
|
||||
|
||||
const ruseHistHeadList = ruseHstryHeadListExport;
|
||||
|
||||
@@ -29,6 +30,21 @@ export const ruseHstryStateExport: ruseHstryState = {
|
||||
|
||||
export type ruseHstryType = ruseHstryState & ruseHstryActions;
|
||||
|
||||
//
|
||||
export const addRgtrAndMdfrToDemandObj = (data: DmdCoReqType) => {
|
||||
// 최상위 demand 객체
|
||||
// demandCo가 있을 경우
|
||||
if (data.demandCo) {
|
||||
data.demandCo.rgtr = TEST_UUID;
|
||||
data.demandCo.mdfr = TEST_UUID;
|
||||
}
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
|
||||
|
||||
type ruseHstryActions = {
|
||||
ruseRvwHistInit: (
|
||||
pageNo: number,
|
||||
@@ -54,7 +70,7 @@ type ruseHstryActions = {
|
||||
endYear: string,
|
||||
sggCd: string
|
||||
) => void;
|
||||
ruseRvwComplete:( data: string[]) => void;
|
||||
ruseRvwComplete:( data: Number[]) => void;
|
||||
};
|
||||
|
||||
const irvwHistInit = async (
|
||||
@@ -106,9 +122,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
},
|
||||
ruseRvwCalUpdate: async (data: DmdCoReqType) => {
|
||||
try {
|
||||
|
||||
const updatedData = addRgtrAndMdfrToDemandObj(data);
|
||||
const update = await putFectch(
|
||||
`/reuseFc/request/cst`,
|
||||
JSON.stringify(data)
|
||||
updatedData
|
||||
);
|
||||
if (update.status === 200) {
|
||||
toast.success("매칭 계산 저장이 완료입니다.");
|
||||
@@ -193,11 +211,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
console.log(" error ", e);
|
||||
}
|
||||
},
|
||||
ruseRvwComplete: async (data: string[]) => {
|
||||
ruseRvwComplete: async (data: Number[]) => {
|
||||
try {
|
||||
const complet = await postFectch(
|
||||
`/reuseFc/request/completeCheck`,
|
||||
JSON.stringify(data),
|
||||
data,
|
||||
fetchType.WR
|
||||
);
|
||||
if (complet.status === 200) {
|
||||
@@ -207,7 +225,8 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
|
||||
10,
|
||||
new Date().getFullYear().toString(),
|
||||
new Date().getFullYear().toString(),
|
||||
"0"
|
||||
"0",
|
||||
'0'
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -164,6 +164,9 @@ export const initValInUsage = [
|
||||
"11월": 0,
|
||||
"12월": 0,
|
||||
},
|
||||
];
|
||||
|
||||
export const initValOutUsage = [
|
||||
{
|
||||
usage: "resn",
|
||||
용수명: "세척살수용수",
|
||||
@@ -198,9 +201,6 @@ export const initValInUsage = [
|
||||
"11월": 0,
|
||||
"12월": 0,
|
||||
},
|
||||
];
|
||||
|
||||
export const initValOutUsage = [
|
||||
{
|
||||
usage: "lndwtr",
|
||||
용수명: "조경용수",
|
||||
|
||||
@@ -132,11 +132,11 @@ const dmdColist = z.object({
|
||||
dmdInfoFk: z.string().default(''),
|
||||
dmdCoNm: z.string().default(''),
|
||||
daddr: z.string(),
|
||||
useUsgCd: z.string().default(""),
|
||||
useUsgCd: z.string().nullish(),
|
||||
splyBgngDay: zDateDefaultNow,
|
||||
splyEndDay: zDateDefaultNow,
|
||||
splyCpct: zNumDefaultZero,
|
||||
splyFmYn: z.string().default('Y'),
|
||||
splyFmYn: z.string().nullish(),
|
||||
rgtr: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
pbnstRuseFcltBizPk: zNumDefaultZero,
|
||||
@@ -208,7 +208,7 @@ export const fcBizSchema = z.object({
|
||||
ruseFcltCstClcln: zNumNullish,
|
||||
fcOrgwts: z.array(fcOrgwtSchema).nullish(),
|
||||
pplInstls: z.array(pplInstlSchema).nullish(),
|
||||
fcDemands: z.array(dmdColist).default([]).nullish(),
|
||||
fcDemands: z.array(dmdColist).nullish(),
|
||||
flg: z.string().nullish(),
|
||||
regDt: z.string().nullish(),
|
||||
rgtr: z.string().nullish(),
|
||||
|
||||
@@ -31,8 +31,8 @@ export const pbnSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
{ id: "bscFctNm", title: "시설명", visible: true },
|
||||
{ id: "efflWqltStndrdNm", title: "지역구분", visible: true },
|
||||
|
||||
{ id: "fctCpc", title: "시설용량(톤/일)", visible: true },
|
||||
{ id: "tel", title: "전화번호", visible: true },
|
||||
{ id: "fctCpc", title: "시설용량(톤/일)", visible: true },
|
||||
{ id: "ruseUtztnFcltNm", title: "재이용시설명", visible: true },
|
||||
|
||||
{
|
||||
@@ -132,7 +132,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [
|
||||
colSpan: 1,
|
||||
},
|
||||
{
|
||||
id: "phone",
|
||||
id: "tel",
|
||||
title: "전화번호",
|
||||
visible: true,
|
||||
row: 1,
|
||||
@@ -140,7 +140,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [
|
||||
colSpan: 1,
|
||||
},
|
||||
{
|
||||
id: "fcltQuantity",
|
||||
id: "fctCpc",
|
||||
title: "시설용량(톤/일)",
|
||||
visible: true,
|
||||
row: 1,
|
||||
@@ -325,7 +325,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
colSpan: 10,
|
||||
colSpan: 9,
|
||||
},
|
||||
{
|
||||
id: "ruseFclt",
|
||||
@@ -333,10 +333,10 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
|
||||
visible: true,
|
||||
row: 1,
|
||||
rowSpan: 1,
|
||||
colSpan: 5,
|
||||
colSpan: 3,
|
||||
},
|
||||
{
|
||||
id: "mainSply",
|
||||
id: "mainSplyPumpCpct",
|
||||
title: "메인공급펌프용량",
|
||||
visible: true,
|
||||
row: 1,
|
||||
@@ -349,7 +349,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
|
||||
visible: true,
|
||||
row: 2,
|
||||
rowSpan: 1,
|
||||
colSpan: 6,
|
||||
colSpan: 5,
|
||||
},
|
||||
{
|
||||
id: "instlAprvSncnDt",
|
||||
@@ -424,14 +424,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
|
||||
rowSpan: 1,
|
||||
colSpan: 1,
|
||||
},
|
||||
{
|
||||
id: "cusrAlotm2",
|
||||
title: "원인자부담금",
|
||||
visible: true,
|
||||
row: 3,
|
||||
rowSpan: 1,
|
||||
colSpan: 1,
|
||||
},
|
||||
|
||||
{ id: "etc", title: "기타", visible: true, row: 3, rowSpan: 1, colSpan: 1 },
|
||||
{
|
||||
id: "totalMoney",
|
||||
@@ -498,11 +491,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [
|
||||
title: "민간투자비",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "cusrAlotm2",
|
||||
title: "원인자부담금",
|
||||
visible: true,
|
||||
},
|
||||
|
||||
{ id: "etc", title: "기타", visible: true },
|
||||
{
|
||||
id: "totalMoney",
|
||||
@@ -545,7 +534,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "mainSply",
|
||||
id: "mainSplyPumpCpct",
|
||||
title: "메인공급펌프용량",
|
||||
visible: true,
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`;
|
||||
export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`;
|
||||
// export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`;
|
||||
|
||||
// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
|
||||
/// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
|
||||
export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
export const findBounds = (
|
||||
data: any[],
|
||||
fctCd: string,
|
||||
dataCode: string,
|
||||
qtyCode:string,
|
||||
qty: number
|
||||
): { lower: any; upper: any } => {
|
||||
|
||||
|
||||
const filtered = data.filter((item) => item[dataCode] === fctCd);
|
||||
|
||||
const lowers = filtered.filter((item) => Number(item[qtyCode]) <= qty);
|
||||
const uppers = filtered.filter((item) => Number(item[qtyCode]) > qty);
|
||||
|
||||
const lower =
|
||||
lowers.length > 0
|
||||
? lowers.reduce((acc, curr) =>
|
||||
Number(curr[qtyCode]) > Number(acc[qtyCode]) ? curr : acc
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const upper =
|
||||
uppers.length > 0
|
||||
? uppers.reduce((acc, curr) =>
|
||||
Number(curr[qtyCode]) < Number(acc[qtyCode]) ? curr : acc
|
||||
)
|
||||
: undefined;
|
||||
|
||||
// ✅ 바운더리 하나만 있을 경우 대체 처리
|
||||
if (!lower && upper) return { lower: upper, upper };
|
||||
if (!upper && lower) return { lower, upper: lower };
|
||||
|
||||
// ✅ 정상 보간 구간
|
||||
if (lower && upper) return { lower, upper };
|
||||
|
||||
// ❌ 둘 다 없을 경우 (fctCd 필터 결과가 없음)
|
||||
throw new Error(`No matching bounds found for fctCd: ${fctCd}, qty: ${qty}`);
|
||||
};
|
||||
|
||||
|
||||
// (기울기) a = (y2 - y1) / (x2 - x1)
|
||||
// (절편) b = y1 - a * x1
|
||||
// ↓
|
||||
// 결과값 y = a * x + b
|
||||
|
||||
|
||||
export const getInterpolation = (
|
||||
Upper: { stdCost: number; fctCpc: number },
|
||||
Lower: { stdCost: number; fctCpc: number },
|
||||
qtyYear: number
|
||||
): number => {
|
||||
const x1 = Number(Lower.fctCpc); // 최소 처리 용량
|
||||
const y1 = Number(Lower.stdCost); // 최소 공사비/요율
|
||||
const x2 = Number(Upper.fctCpc); // 최대 처리 용량
|
||||
const y2 = Number(Upper.stdCost); // 최대 공사비/요율
|
||||
|
||||
if (qtyYear <= x1) return y1; // 최소 이하면 y1 반환
|
||||
if (qtyYear >= x2) return y2; // 최대 이상이면 y2 반환
|
||||
|
||||
const slope = (y2 - y1) / (x2 - x1); // 기울기 a
|
||||
const intercept = y1 - slope * x1; // 절편 b
|
||||
|
||||
return slope * qtyYear + intercept; // 보간 계산
|
||||
};
|
||||
|
||||
export const transformAndInterpolate = (
|
||||
rawData: any,
|
||||
dmndQtyYear: number
|
||||
): any => {
|
||||
const result: any = {};
|
||||
|
||||
for (const key in rawData) {
|
||||
const item = rawData[key];
|
||||
|
||||
const range = {
|
||||
Lower: {
|
||||
fctCpc: item.lower?.stdCost,
|
||||
stdCost: item.lower?.rt,
|
||||
},
|
||||
Upper: {
|
||||
fctCpc: item.upper?.stdCost,
|
||||
stdCost: item.upper?.rt,
|
||||
},
|
||||
};
|
||||
result[key] = getInterpolation(range.Upper, range.Lower, dmndQtyYear);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
export const getConstFctCode = (fctCd: string) => {
|
||||
const fctMap: { [key: string]: string } = {
|
||||
총인처리시설: "001",
|
||||
염소소독: "002",
|
||||
UV소독: "003",
|
||||
전처리시설: "004",
|
||||
RO: "005",
|
||||
};
|
||||
|
||||
return fctMap[fctCd];
|
||||
};
|
||||
@@ -153,3 +153,6 @@ export const getdmdMatFlag = (flag: string|undefined) => {
|
||||
}
|
||||
return flagMat;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ import type {
|
||||
} from "@/app/store/matDmd/coMatRvw/type";
|
||||
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { formH1Class } from "@/components/lib/class/comClass";
|
||||
import {
|
||||
findBounds,
|
||||
getConstFctCode,
|
||||
getInterpolation,
|
||||
transformAndInterpolate,
|
||||
} from "@/components/lib/func/calculateConstCost ";
|
||||
import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable";
|
||||
import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal";
|
||||
import {
|
||||
@@ -17,8 +23,10 @@ import {
|
||||
} from "@common/business_components/ui";
|
||||
import PopoverUi from "@common/business_components/ui/popover_ui";
|
||||
import { Button, Input, Label } from "@common/components/ui";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import type { read } from "fs";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { type UseFormReturn } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
export default function ConCostForm({
|
||||
form,
|
||||
@@ -27,7 +35,14 @@ export default function ConCostForm({
|
||||
form: UseFormReturn<DmdCoReqType>;
|
||||
type: string;
|
||||
}) {
|
||||
const { coMatRvwUpdate, ruseRvwCalUpdate,getRateFee ,getConstCostFee} = useWrStore((state) => state);
|
||||
const {
|
||||
constCostRes,
|
||||
rateFeeRes,
|
||||
coMatRvwUpdate,
|
||||
ruseRvwCalUpdate,
|
||||
getRateFee,
|
||||
getConstCostFee,
|
||||
} = useWrStore((state) => state);
|
||||
|
||||
const ref = useRef<boolean>(false);
|
||||
|
||||
@@ -38,15 +53,7 @@ export default function ConCostForm({
|
||||
getRateFee(String(currentYear));
|
||||
ref.current = true;
|
||||
}
|
||||
}, [ref, getConstCostFee ,getRateFee ]);
|
||||
|
||||
|
||||
const [isTrfMo, setIsTrfMo] = useState<{
|
||||
isModal: boolean;
|
||||
}>({ isModal: false });
|
||||
const [isCmpttnMo, setIsCmpttnMo] = useState<{
|
||||
isModal: boolean;
|
||||
}>({ isModal: false });
|
||||
}, [ref, getConstCostFee, getRateFee]);
|
||||
|
||||
const zipDowonLoad = () => {
|
||||
fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => {
|
||||
@@ -59,25 +66,88 @@ export default function ConCostForm({
|
||||
link.click();
|
||||
});
|
||||
};
|
||||
const usgPrcsProcsWatch = form.watch("demandCst.usgPrcsProcs");
|
||||
const dmndQtyWatch = form.watch("dmndQty");
|
||||
const totalConstCost = form.watch("totalConstCost");
|
||||
const cstrnCst = form.watch("demandCst.cstrnCst");
|
||||
|
||||
const calculateConstCost = useCallback(() => {
|
||||
const usgPrcsProcs = usgPrcsProcsWatch;
|
||||
const dmndQtyYear = dmndQtyWatch * 365;
|
||||
if (usgPrcsProcs && usgPrcsProcs?.length > 0) {
|
||||
const firstProc = getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || "";
|
||||
const secondProc = getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || "";
|
||||
|
||||
const { lower: firstLower, upper: firstUpper } = findBounds(
|
||||
constCostRes,
|
||||
firstProc || "",
|
||||
'fctCd',
|
||||
'fctCpc',
|
||||
Number(dmndQtyYear)
|
||||
);
|
||||
const { lower: secondLower, upper: secondUpper } = findBounds(
|
||||
constCostRes,
|
||||
secondProc || "",
|
||||
'fctCd',
|
||||
'fctCpc',
|
||||
Number(dmndQtyYear)
|
||||
);
|
||||
|
||||
const firstConstFee = getInterpolation(
|
||||
firstUpper,
|
||||
firstLower,
|
||||
dmndQtyYear
|
||||
);
|
||||
const secondConstFee = getInterpolation(
|
||||
secondUpper,
|
||||
secondLower,
|
||||
dmndQtyYear
|
||||
);
|
||||
const result = Math.round(firstConstFee + secondConstFee) / 100;
|
||||
|
||||
const groupCodes = ["BD", "CE", "SE", "WD"];
|
||||
const groupedBounds: { [key: string]: { lower?: any; upper?: any } } = {};
|
||||
for (const code of groupCodes) {
|
||||
|
||||
groupedBounds[code] = findBounds(rateFeeRes, code, 'incExpCd', 'stdCost',result);
|
||||
}
|
||||
const resultRate = transformAndInterpolate(groupedBounds, result);
|
||||
const fcltSbsdCstrnCst = (result* (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD) / 100);
|
||||
const realResult = result + fcltSbsdCstrnCst;
|
||||
|
||||
form.setValue("demandCst.prcsFcltCpctCstrnCst", Math.round(result) );
|
||||
form.setValue("demandCst.fcltSbsdCstrnCst", Math.round(fcltSbsdCstrnCst)) ;
|
||||
form.setValue("totalConstCost", Math.round(realResult));
|
||||
}
|
||||
}, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]);
|
||||
const onSubmit = (value: DmdCoReqType) => {
|
||||
|
||||
if( !form.getValues('demandCst.prcsFcltCpctCstrnCst') ){
|
||||
toast.error('공사비 계산 진행 후 저장을 눌러주새요')
|
||||
return
|
||||
}
|
||||
if (type === "mat") {
|
||||
const data: DedMatUpdateType = {
|
||||
dmdInfoSn: form.getValues("dmdInfoSn"),
|
||||
usgPrcsProcs: form.getValues("demandCst.usgPrcsProcs"),
|
||||
cstrnCst: form.getValues("demandCst.cstrnCst"),
|
||||
fcltSbsdEpsTrf: form.getValues("demandCst.fcltSbsdEpsTrf"),
|
||||
fcltSbsdCstrnCst: form.getValues("demandCst.fcltSbsdCstrnCst"),
|
||||
prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"),
|
||||
rgtr: TEST_UUID,
|
||||
};
|
||||
coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data);
|
||||
coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data);
|
||||
} else if (type === "hist") {
|
||||
|
||||
delete value.totalConstCost
|
||||
delete value.ruseUtztnFcltNm
|
||||
|
||||
|
||||
ruseRvwCalUpdate(value);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" form ", form.formState.errors);
|
||||
console.log(" form ", form.formState.errors);
|
||||
}, [form.formState]);
|
||||
|
||||
return (
|
||||
@@ -90,12 +160,21 @@ export default function ConCostForm({
|
||||
<div className="flex items-center mx-3 mb-3">
|
||||
<h1 className="">처리시설 표준공사비 산정</h1>
|
||||
|
||||
<Button size={"sm"} onClick={(e) => {}}>
|
||||
<Button className="mx-3" size={"sm"} onClick={calculateConstCost}>
|
||||
계산
|
||||
</Button>
|
||||
<Button size={"sm"} onClick={form.handleSubmit(onSubmit)}>
|
||||
<Button className="mr-3" size={"sm"} onClick={form.handleSubmit(onSubmit)}>
|
||||
저장
|
||||
</Button>
|
||||
<Label>관로 표준공사비 산정 프로그램</Label>
|
||||
<Button
|
||||
color="green"
|
||||
size={"sm"}
|
||||
onClick={zipDowonLoad}
|
||||
className="bg-none ml-6"
|
||||
>
|
||||
다운로드
|
||||
</Button>
|
||||
</div>
|
||||
<div className="col-span-12 w-full">
|
||||
<h1 className={formH1Class}>기본사항</h1>
|
||||
@@ -111,7 +190,7 @@ export default function ConCostForm({
|
||||
placeholder=""
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
field.onChange((e.target.value));
|
||||
field.onChange(e.target.value);
|
||||
}}
|
||||
value={field.value ?? ""}
|
||||
/>
|
||||
@@ -194,9 +273,10 @@ export default function ConCostForm({
|
||||
type="number"
|
||||
step="0.001"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
//field.onChange(Number(e.target.value) * 365 );
|
||||
}}
|
||||
value={Number(field.value) * 365 || 0}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -207,14 +287,23 @@ export default function ConCostForm({
|
||||
</div>
|
||||
<div className="col-span-3 mt-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label>처리시설용량에 따른 공사비(백만원)</Label>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={(e) => setIsCmpttnMo({ isModal: true })}
|
||||
className="bg-none"
|
||||
>
|
||||
공사비 산정표 보기
|
||||
</Button>
|
||||
<PopoverUi
|
||||
childrenTriger={
|
||||
<>
|
||||
<Label className="underline">
|
||||
처리시설용량에 따른 공사비(백만원) <i className="diveicon di-search" />
|
||||
</Label>
|
||||
</>
|
||||
}
|
||||
childrenBody={
|
||||
<>
|
||||
<ConstCostFeeTable
|
||||
setReturnData={(e) => {}}
|
||||
></ConstCostFeeTable>
|
||||
</>
|
||||
}
|
||||
bodyClassName={"w-[40vw] h-full"}
|
||||
></PopoverUi>
|
||||
</div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
@@ -229,6 +318,7 @@ export default function ConCostForm({
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -236,17 +326,27 @@ export default function ConCostForm({
|
||||
</div>
|
||||
<div className="col-span-3 mt-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Label>시설부대경비 요율(%)</Label>
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={(e) => setIsTrfMo({ isModal: true })}
|
||||
>
|
||||
요율표 보기
|
||||
</Button>
|
||||
<PopoverUi
|
||||
childrenTriger={
|
||||
<>
|
||||
<Label className="underline">
|
||||
시설부대경비 <i className="diveicon di-search" />
|
||||
</Label>
|
||||
</>
|
||||
}
|
||||
childrenBody={
|
||||
<>
|
||||
<RateFeeTableModal
|
||||
setReturnData={(e) => {}}
|
||||
></RateFeeTableModal>
|
||||
</>
|
||||
}
|
||||
bodyClassName={"w-[22vw]"}
|
||||
></PopoverUi>
|
||||
</div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="demandCst.fcltSbsdEpsTrf"
|
||||
name="demandCst.fcltSbsdCstrnCst"
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<Input
|
||||
@@ -257,6 +357,7 @@ export default function ConCostForm({
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -286,16 +387,22 @@ export default function ConCostForm({
|
||||
}
|
||||
bodyClassName={"w-[22vw]"}
|
||||
></PopoverUi>
|
||||
<Input
|
||||
placeholder=""
|
||||
className="mt-2"
|
||||
type="number"
|
||||
step="0.01"
|
||||
onChange={(e) => {}}
|
||||
value={
|
||||
form.getValues("demandCst.prcsFcltCpctCstrnCst") +
|
||||
form.getValues("demandCst.fcltSbsdEpsTrf") || 0
|
||||
}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="totalConstCost"
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<Input
|
||||
placeholder=""
|
||||
className="mt-2"
|
||||
type="number"
|
||||
step="0.01"
|
||||
onChange={(e) => {}}
|
||||
value={field.value ?? 0}
|
||||
readOnly
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-3 mt-4">
|
||||
@@ -323,75 +430,37 @@ export default function ConCostForm({
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-4 mt-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="demandCst.cstrnCst"
|
||||
render={({ field }) => (
|
||||
<FormUi label="공급관로 표준공사비(백만원)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="text"
|
||||
step="0.001"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-4 mt-4 mb-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name=""
|
||||
render={({ field }) => (
|
||||
<Label className="text-xl">
|
||||
처리시설 + 공급관로 총사업비(백만원)
|
||||
<FormUi label="">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
step="0.001"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
readOnly={true}
|
||||
value={field.value ?? 0}
|
||||
/>
|
||||
</FormUi>
|
||||
</Label>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className=" col-span-4 mt-4 ">
|
||||
<Label>관로 표준공사비 산정 프로그램</Label>
|
||||
<Button
|
||||
color="green"
|
||||
size={"sm"}
|
||||
onClick={zipDowonLoad}
|
||||
className="bg-none ml-6"
|
||||
>
|
||||
다운로드
|
||||
</Button>
|
||||
</div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="demandCst.cstrnCst"
|
||||
render={({ field }) => (
|
||||
<FormUi label="공급관로 표준공사비(백만원)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
step="0.01"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-4 mt-4 mb-3">
|
||||
<Label className="text-xl">
|
||||
처리시설 + 공급관로 총사업비(백만원)
|
||||
</Label>
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
step="0.001"
|
||||
readOnly={true}
|
||||
value={(totalConstCost ?? 0) + (cstrnCst ?? 0)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<UiModal
|
||||
body={<RateFeeTableModal setReturnData={(e) =>{}}></RateFeeTableModal>}
|
||||
bodyClass="w-[40vw] h-[40vh] "
|
||||
open={isTrfMo.isModal}
|
||||
onOpenChange={(open) => {
|
||||
setIsTrfMo({ isModal: open });
|
||||
}}
|
||||
/>
|
||||
<UiModal
|
||||
body={<ConstCostFeeTable setReturnData={(e) =>{}}></ConstCostFeeTable>}
|
||||
bodyClass="w-[40vw] max-w-none h-[40vh]"
|
||||
open={isCmpttnMo.isModal}
|
||||
onOpenChange={(open) => {
|
||||
setIsCmpttnMo({ isModal: open });
|
||||
}}
|
||||
/>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -9,8 +9,8 @@ import {
|
||||
} from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, Input } from "@common/components";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useFieldArray, useForm, type UseFormReturn } from "react-hook-form";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useFieldArray, useWatch, type UseFormReturn } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import {
|
||||
commonButonSize,
|
||||
@@ -38,10 +38,10 @@ export function PbnstMngForm({
|
||||
form,
|
||||
formType,
|
||||
firstFcltData,
|
||||
indexMng ,
|
||||
indexMng,
|
||||
setIndexMng,
|
||||
}: {
|
||||
form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
form: UseFormReturn<{ items: PbnstRegArrrayType }>;
|
||||
formType: string;
|
||||
firstFcltData?: customPbnst;
|
||||
indexMng: number;
|
||||
@@ -64,37 +64,11 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null);
|
||||
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[], "") 파일 다운로드 활용
|
||||
//const ref = useRef<operType[] | null>(null);
|
||||
|
||||
|
||||
// const form = useForm<z.infer<typeof pbnstRegZod>>({
|
||||
// resolver: zodResolver(pbnstRegZod),
|
||||
// defaultValues:
|
||||
// formType === "reg" && pbnst.pbnstMngRegData
|
||||
// ? pbnst.pbnstMngRegData[0]
|
||||
// : formType === "update" &&
|
||||
// typeof pbnst.pbnsUpdateIndex.mng === "number" &&
|
||||
// pbnst.pbnsUpdateIndex.mng >= 0 &&
|
||||
// pbnst.pbnstRes
|
||||
// ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]
|
||||
// : formType === "sttn" && firstFcltData
|
||||
// ? {
|
||||
// ruseUtztnFcltNm: firstFcltData?.ruseUtztnFcltNm,
|
||||
// fcltCpct: firstFcltData?.fcltCpct,
|
||||
// ruseCpct: firstFcltData?.ruseCpct,
|
||||
// splyExtraCpct: firstFcltData?.splyExtraCpct,
|
||||
// fcOpers: firstFcltData?.fcOpers,
|
||||
// fcFiles: firstFcltData?.fcFiles,
|
||||
// }
|
||||
// : pbnstRegZod.parse({}),
|
||||
// mode: "onChange",
|
||||
// });
|
||||
const {
|
||||
fields: fcOpersField,
|
||||
append,
|
||||
@@ -104,39 +78,33 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
name: `items.${indexMng}.fcOpers`,
|
||||
});
|
||||
|
||||
|
||||
|
||||
const selectFclt = (val: number) => {
|
||||
// if (pbnst.pbnstRes && pbnst.pbnstRes[val]) {
|
||||
// getBizCycle(pbnst.pbnstRes[val]);
|
||||
// // form.reset(pbnst.pbnstRes[val]);
|
||||
|
||||
// getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val });
|
||||
// }
|
||||
};
|
||||
const watchedItem = useWatch({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}`,
|
||||
});
|
||||
|
||||
const plusHist = () => {
|
||||
append( {
|
||||
append({
|
||||
choose: false,
|
||||
pbnstRuseFcltFk: form.getValues(`items.${indexMng}.pbnstRuseFcltPk`) ?? "",
|
||||
pbnstRuseFcltFk:
|
||||
form.getValues(`items.${indexMng}.pbnstRuseFcltPk`) ?? "",
|
||||
rgtr: "",
|
||||
mdfr: "",
|
||||
operMthd: "",
|
||||
rprtvBzenty: "",
|
||||
bgngDt: new Date(),
|
||||
endDt: new Date(),
|
||||
})
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
const removeSelected = () => {
|
||||
const nowOpers = form.getValues(`items.${indexMng}.fcOpers`);
|
||||
if (!nowOpers) return;
|
||||
|
||||
const nowOpers = form.getValues(`items.${indexMng}.fcOpers`);
|
||||
if(!nowOpers) return;
|
||||
|
||||
const selectedIdxs = nowOpers.map((item, idx) => (item.choose ? idx : -1))
|
||||
.filter((idx) => idx !== -1);
|
||||
selectedIdxs.reverse().forEach((idx) => remove(idx));
|
||||
const selectedIdxs = nowOpers
|
||||
.map((item, idx) => (item.choose ? idx : -1))
|
||||
.filter((idx) => idx !== -1);
|
||||
selectedIdxs.reverse().forEach((idx) => remove(idx));
|
||||
};
|
||||
|
||||
const fileHandler = (files: File[], type: string) => {
|
||||
@@ -209,32 +177,14 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
return [...exFileDatas, ...currentdata];
|
||||
};
|
||||
|
||||
// 등록할때 신규 값을 계속 가지고 있으려고
|
||||
useEffect(() => {
|
||||
// if (
|
||||
// formType === "reg" &&
|
||||
// firstFcltData &&
|
||||
// (form.getValues(`items.${indexMng}.swtrmtFcltFk`) === "" ||
|
||||
// form.getValues(`items.${indexMng}.swtrmtFcltFk`) === undefined)
|
||||
// ) {
|
||||
// form.setValue(`items.${indexMng}.swtrmtFcltFk`, firstFcltData.swtrmtFcltFk);
|
||||
// form.setValue(
|
||||
// `items.${indexMng}.pbnstRuseFcltPk`,
|
||||
// String(firstFcltData.pbnstRuseFcltPk)
|
||||
// );
|
||||
// form.setValue(`items.${indexMng}.fcBizs`, firstFcltData.fcBizs);
|
||||
// }
|
||||
console.log('indexMng ', indexMng)
|
||||
}, [indexMng]);
|
||||
|
||||
useEffect(() => {
|
||||
if(indexMng>=0){
|
||||
const defaultFiles = form.getValues(`items.${indexMng}.fcFiles`);
|
||||
if (indexMng >= 0) {
|
||||
const defaultFiles = watchedItem?.fcFiles;
|
||||
if (defaultFiles && defaultFiles.length > 0) {
|
||||
const relationFileList = defaultFiles.filter(
|
||||
(item) => item.fileKnd === "계통도"
|
||||
);
|
||||
|
||||
|
||||
const planFileList = defaultFiles.filter(
|
||||
(item) => item.fileKnd === "평면도"
|
||||
);
|
||||
@@ -244,8 +194,11 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
atflCd: item.fileTkn,
|
||||
file: new File([] as BlobPart[], item.filePath),
|
||||
}))
|
||||
); // 또는 파일 형식 변환 로직이 있다면 여기에 추가
|
||||
|
||||
);
|
||||
else {
|
||||
setRelationFiles(null);
|
||||
}
|
||||
|
||||
if (planFileList.length > 0)
|
||||
setPlanFiles(
|
||||
planFileList.map((item) => ({
|
||||
@@ -253,46 +206,15 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
file: new File([] as BlobPart[], item.filePath),
|
||||
}))
|
||||
);
|
||||
}else{
|
||||
else {
|
||||
setPlanFiles(null);
|
||||
}
|
||||
} else {
|
||||
setRelationFiles(null);
|
||||
setPlanFiles(null);
|
||||
}
|
||||
}
|
||||
}, [form.watch(`items.${indexMng}`),indexMng]); // 초기화 이후 1회 실행
|
||||
|
||||
// 등록할때 신규 값을 계속 가지고 있으려고
|
||||
useEffect(() => {
|
||||
// if (
|
||||
// formType === "update" &&
|
||||
// pbnst.pbnsUpdateIndex.biz >= 0 &&
|
||||
// pbnst.pbnstRes
|
||||
// ) {
|
||||
// const bizData = pbnst.pbnstRes[pbnst.pbnsUpdateIndex.biz];
|
||||
|
||||
// if (bizData) {
|
||||
// getBizCycle(bizData);
|
||||
// }
|
||||
// }
|
||||
}, [pbnst.pbnsUpdateIndex, pbnst.pbnstRes, formType, getBizCycle]);
|
||||
|
||||
//신규 등록시 입력할때 데이터 넣기
|
||||
useEffect(() => {
|
||||
// const formData = form.watch();
|
||||
// formData.fcOpers = ref.current ? [...ref.current] : [];
|
||||
// formData.fcFiles = regFileList ? [...regFileList] : [];
|
||||
// if (formType === "reg") {
|
||||
// console.log("formData ", formData);
|
||||
// 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, pbnst.pbnstRes]);
|
||||
}, [watchedItem, indexMng]);
|
||||
|
||||
useEffect(() => {
|
||||
// pbnstMngData(pbnst.pbnstMngRegData);
|
||||
@@ -309,7 +231,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: z.infer<typeof pbnstRegZod>) {
|
||||
values.fcOpers = [];
|
||||
values.fcOpers = [];
|
||||
values.fcFiles = regFileList || [];
|
||||
pbnstInsert(values);
|
||||
}
|
||||
@@ -325,15 +247,12 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
}
|
||||
}, [planFiles]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (code.ruseMngMtd) {
|
||||
setMngMtdCode([{ name: "ruseMngMtd", val: code.ruseMngMtd }]);
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className=" !mx-[1.6rem] !p-0r">
|
||||
<div>
|
||||
@@ -348,7 +267,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
|
||||
{formType === "update" ? (
|
||||
<FormField
|
||||
key={`items.${indexMng}.ruseUtztnFcltNm-key`}
|
||||
key={`items.${indexMng}.ruseUtztnFcltNm-key`}
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.ruseUtztnFcltNm`}
|
||||
render={({ field }) => (
|
||||
@@ -381,6 +300,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
field.onChange(String(e.target.value));
|
||||
}}
|
||||
value={field.value ?? ""}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -393,28 +313,41 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
<div className="h-[200px] overflow-y-auto">
|
||||
<div className="flex justify-between items-center mx-3 mb-3">
|
||||
<span className={formTableName}>재이용시설 운영정보</span>
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl"
|
||||
onClick={plusHist}
|
||||
>
|
||||
추가등록
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl !bg-red-500 !text-white ml-1"
|
||||
onClick={removeSelected}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
{formType === "sttn" ? (
|
||||
<></>
|
||||
) : (
|
||||
<div>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl"
|
||||
onClick={plusHist}
|
||||
>
|
||||
추가등록
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size={commonButonSize}
|
||||
className="!text-xl !bg-red-500 !text-white ml-1"
|
||||
onClick={removeSelected}
|
||||
>
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<RuseMngTableForm
|
||||
tableData={form.getValues(`items.${indexMng}.fcOpers`)||[]}
|
||||
headList={pbnst.pbnstMngUpHeadList}
|
||||
tableData={form.getValues(`items.${indexMng}.fcOpers`) || []}
|
||||
headList={
|
||||
formType === "sttn"
|
||||
? pbnst.pbnstMngUpHeadList.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
readonly: true,
|
||||
};
|
||||
})
|
||||
: pbnst.pbnstMngUpHeadList
|
||||
}
|
||||
upHeadList={pbnst.pbnstMngNm}
|
||||
code={mngMtdCode || []}
|
||||
onTableSet={(val) => {
|
||||
@@ -423,7 +356,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
indexMng={indexMng}
|
||||
form={form}
|
||||
formNm={"fcOpers"}
|
||||
// ref={ref}
|
||||
// ref={ref}
|
||||
></RuseMngTableForm>
|
||||
</div>
|
||||
</div>
|
||||
@@ -445,6 +378,7 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -453,19 +387,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
|
||||
<div className="col-span-4 mt-4">
|
||||
<FormField
|
||||
key={`FormField-items.${indexMng}.ruseCpct`}
|
||||
key={`FormField-items.${indexMng}.ruseCpct`}
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.ruseCpct`}
|
||||
render={({ field }) => (
|
||||
<FormUi label="재이용수공급량(m³/일)">
|
||||
<Input
|
||||
key={`items.${indexMng}.ruseCpct`}
|
||||
key={`items.${indexMng}.ruseCpct`}
|
||||
placeholder=""
|
||||
type="number"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -473,19 +408,20 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
</div>
|
||||
<div className="col-span-4 mt-4">
|
||||
<FormField
|
||||
key={`FormField-items.${indexMng}.splyExtraCpct`}
|
||||
key={`FormField-items.${indexMng}.splyExtraCpct`}
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.splyExtraCpct`}
|
||||
render={({ field }) => (
|
||||
<FormUi label="공급여유량(m³/일)">
|
||||
<Input
|
||||
key={`items.${indexMng}.splyExtraCpct`}
|
||||
key={`items.${indexMng}.splyExtraCpct`}
|
||||
placeholder=""
|
||||
type="number"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -497,40 +433,78 @@ form: UseFormReturn<{items:PbnstRegArrrayType}>;
|
||||
</div>
|
||||
<div className="grid grid-cols-12 gap-4 my-4">
|
||||
<div className="col-span-6">
|
||||
<FormUi label="계통도">
|
||||
<FileUpload
|
||||
files={relationfiles?.map((item) => item.file) || []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files) fileHandler(files, "relation");
|
||||
}}
|
||||
fileTypes="PDF"
|
||||
onFileClick={(index) => {
|
||||
fileDownLoad(
|
||||
relationfiles?.find(
|
||||
(item, fileIndex) => fileIndex === index
|
||||
)?.atflCd as string
|
||||
);
|
||||
}}
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
{formType === "sttn" ? (
|
||||
relationfiles && relationfiles?.length > 0 ? (
|
||||
<>
|
||||
<Label className="text-3xl">계통도</Label>
|
||||
{relationfiles?.map((item, index) => (
|
||||
<span
|
||||
key={index + "plan"}
|
||||
className="text-2xl block cursor-pointer text-blue-600 hover:underline"
|
||||
onClick={() => fileDownLoad(item.atflCd)}
|
||||
>
|
||||
{item.file.name}
|
||||
</span>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
) : (
|
||||
<FormUi label="계통도">
|
||||
<FileUpload
|
||||
files={relationfiles?.map((item) => item.file) || []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files) fileHandler(files, "relation");
|
||||
}}
|
||||
fileTypes="PDF"
|
||||
onFileClick={(index) => {
|
||||
fileDownLoad(
|
||||
relationfiles?.find(
|
||||
(item, fileIndex) => fileIndex === index
|
||||
)?.atflCd as string
|
||||
);
|
||||
}}
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
)}
|
||||
</div>
|
||||
<div className="col-span-6">
|
||||
<FormUi label="평면도">
|
||||
<FileUpload
|
||||
files={planFiles?.map((item) => item.file) || []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files) fileHandler(files, "plan");
|
||||
}}
|
||||
fileTypes="PDF"
|
||||
onFileClick={(index) => {
|
||||
fileDownLoad(
|
||||
planFiles?.find(
|
||||
(item, fileIndex) => fileIndex === index
|
||||
)?.atflCd as string
|
||||
);
|
||||
}}
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
{formType === "sttn" ? (
|
||||
planFiles && planFiles?.length > 0 ? (
|
||||
<>
|
||||
<Label className="text-3xl">평면도</Label>
|
||||
{planFiles?.map((item, index) => (
|
||||
<span
|
||||
key={index + "plan"}
|
||||
className="text-2xl block cursor-pointer text-blue-600 hover:underline"
|
||||
onClick={() => fileDownLoad(item.atflCd)}
|
||||
>
|
||||
{item.file.name}
|
||||
</span>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<></>
|
||||
)
|
||||
) : (
|
||||
<FormUi label="평면도">
|
||||
<FileUpload
|
||||
files={planFiles?.map((item) => item.file) || []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files) fileHandler(files, "plan");
|
||||
}}
|
||||
fileTypes="PDF"
|
||||
onFileClick={(index) => {
|
||||
fileDownLoad(
|
||||
planFiles?.find(
|
||||
(item, fileIndex) => fileIndex === index
|
||||
)?.atflCd as string
|
||||
);
|
||||
}}
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -99,7 +99,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
|
||||
selectClass={""}
|
||||
label=""
|
||||
selectArray={yearOptions}
|
||||
value={field.value}
|
||||
value={field.value||new Date().getFullYear()}
|
||||
onSelectValue={(val) => field.onChange(val)}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -113,7 +113,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
|
||||
<FormUi label="시설명">
|
||||
<Input
|
||||
className="w-1/4 text-3xl"
|
||||
value={field.value}
|
||||
value={field.value||''}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
@@ -127,7 +127,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
|
||||
<FormUi label="재이용시설명">
|
||||
<Input
|
||||
className="w-1/4 text-3xl"
|
||||
value={field.value}
|
||||
value={field.value||''}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
@@ -146,6 +146,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
|
||||
if (files) setFiles(files);
|
||||
}}
|
||||
fileTypes="xlsx"
|
||||
maxFiles={1}
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
)}
|
||||
|
||||
@@ -23,12 +23,12 @@ export function ConstCostFeeTable({
|
||||
const [constCostData, setConstCostData] = useState<ContCostMap[]>([]);
|
||||
|
||||
|
||||
function getFctDescription(fctCd: string) {
|
||||
const getFctDescription = (fctCd: string) => {
|
||||
const fctMap: { [key: string]: string } = {
|
||||
"001": "총인",
|
||||
"002": "염소.소독",
|
||||
"003": "uv소독",
|
||||
"004": "생물학적탈질",
|
||||
"001": "총인처리시설",
|
||||
"002": "염소소독",
|
||||
"003": "UV소독",
|
||||
"004": "전처리시설",
|
||||
"005": "RO",
|
||||
};
|
||||
|
||||
@@ -61,7 +61,6 @@ export function ConstCostFeeTable({
|
||||
},
|
||||
[]
|
||||
);
|
||||
console.log("tableData", tableData);
|
||||
const formattedTableData = tableData?.map((item: ContCostMap) => {
|
||||
return {
|
||||
...item,
|
||||
@@ -73,7 +72,7 @@ export function ConstCostFeeTable({
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListDiv className="!w-full ">
|
||||
<ListDiv className="h-[calc(100vh-60vh)] overflow-auto">
|
||||
<h3 className="mt-4 ml-2 text-2xl font-medium text-label">
|
||||
공사비 산정표 보기
|
||||
</h3>
|
||||
@@ -89,7 +88,6 @@ export function ConstCostFeeTable({
|
||||
onSelectValue={(val: string | number) => setYear(String(val))}
|
||||
/>
|
||||
</div>
|
||||
<ScrollArea className="h-[calc(100vh-300px)] w-full">
|
||||
<UiTable
|
||||
headName={""}
|
||||
tableData={constCostData || []}
|
||||
@@ -99,7 +97,6 @@ export function ConstCostFeeTable({
|
||||
cellClick={() => {}}
|
||||
onPageChange={() => {}}
|
||||
/>
|
||||
</ScrollArea>
|
||||
</ListDiv>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { rateFeeType } from "@/app/store/common/searchCode/type";
|
||||
import { yearOptions } from "@/components/lib/func/commom";
|
||||
import { SelectBox, UiTable } from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Label, ScrollArea } from "@common/components/ui";
|
||||
import { Input, Label, ScrollArea } from "@common/components/ui";
|
||||
import { Scroll } from "lucide-react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
@@ -14,7 +14,7 @@ export function RateFeeTableModal({
|
||||
}: {
|
||||
setReturnData: (data: any) => void;
|
||||
}) {
|
||||
const { code, coRvw,rateFeeRes } = useWrStore((state) => state);
|
||||
const { code, coRvw, rateFeeRes } = useWrStore((state) => state);
|
||||
const [year, setYear] = useState<string>(String(new Date().getFullYear()));
|
||||
const [reateFeeTable, setRateFeeTable] = useState<rateFeeType[]>([]);
|
||||
|
||||
@@ -31,26 +31,24 @@ export function RateFeeTableModal({
|
||||
10000: "100억원까지",
|
||||
20000: "200억원까지",
|
||||
30000: "300억원까지",
|
||||
40000: "400억원까지",
|
||||
50000: "500억원까지",
|
||||
70000: "700억원까지",
|
||||
100000: "1000억원까지",
|
||||
150000: "1500억원까지",
|
||||
200000: "2000억원까지",
|
||||
300000: "3000억원까지",
|
||||
500000: "5000억원까지",
|
||||
};
|
||||
|
||||
|
||||
const fetchData = async (rateFeeRes: rateFeeType[]) => {
|
||||
const data = await rateFeeRes?.reduce((acc: any, cur: rateFeeType) => {
|
||||
const data = await rateFeeRes?.filter((item: rateFeeType) => {
|
||||
return item.incExpCd !== "SS";
|
||||
})
|
||||
.reduce((acc: any, cur: rateFeeType) => {
|
||||
const key = cur.stdCost;
|
||||
let target = acc.find((item: any) => item.stdCost === key);
|
||||
if (!target) {
|
||||
target = {
|
||||
stdCost: cur.stdCost,
|
||||
BD: 0,
|
||||
WD: 0,
|
||||
SE: 0,
|
||||
CE: 0,
|
||||
};
|
||||
@@ -60,18 +58,18 @@ export function RateFeeTableModal({
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
|
||||
const dataGubun = data?.map((item: any) => {
|
||||
return {
|
||||
...item,
|
||||
gubun: gubunLabelMap[item.stdCost] || item.stdCost,
|
||||
};
|
||||
});
|
||||
})
|
||||
|
||||
return dataGubun?.sort((a: any, b: any) => a.stdCost - b.stdCost);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log("rateFeeRes ", rateFeeRes);
|
||||
if (rateFeeRes?.length >= 0) {
|
||||
fetchData(rateFeeRes).then((data) => {
|
||||
setRateFeeTable(data);
|
||||
@@ -81,28 +79,26 @@ export function RateFeeTableModal({
|
||||
|
||||
return (
|
||||
<>
|
||||
<ListDiv className="!h-[calc(100vh-100px)] w-[90vw] max-w-[1200px] min-w-[600px] overflow-hidden">
|
||||
<ListDiv className="min-w-[600px] h-[calc(100vh-60vh)] overflow-auto">
|
||||
<div className="sticky top-0 z-10 grid grid-cols-6 gap-4 p-4 bg-white">
|
||||
<h3 className="col-span-6 text-2xl font-medium text-label">
|
||||
요율표 보기
|
||||
</h3>
|
||||
<hr className="col-span-6 border-gray-300" />
|
||||
|
||||
<div className="col-span-2 flex items-center">
|
||||
<Label className="text-xl text-gray-600">기준년도</Label>
|
||||
<SelectBox
|
||||
className="h-full text-2xl"
|
||||
label=""
|
||||
selectClass={"ml-4"}
|
||||
selectArray={yearOptions}
|
||||
value={year}
|
||||
onSelectValue={(val: string | number) => setYear(String(val))}
|
||||
<div className="col-span-5 flex items-center">
|
||||
<Label className=" text-xl text-gray-600">기준년도</Label>
|
||||
<Input
|
||||
className="col-span-1 text-2xl text-right ml-2 w-32"
|
||||
placeholder=""
|
||||
type="text"
|
||||
onChange={(e) => {}}
|
||||
value={new Date().getFullYear() || ""}
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-6">
|
||||
<ScrollArea className="h-[60vh] overflow-auto">
|
||||
<div className="col-span-6 pr-6">
|
||||
<UiTable
|
||||
className="min-w-full"
|
||||
className="min-w-full pr-12"
|
||||
key={"rateTable" + reateFeeTable?.length}
|
||||
headName={""}
|
||||
tableData={reateFeeTable || []}
|
||||
@@ -112,7 +108,6 @@ export function RateFeeTableModal({
|
||||
total={0}
|
||||
cellClick={undefined}
|
||||
/>
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</div>
|
||||
</ListDiv>
|
||||
|
||||
@@ -53,6 +53,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
mode: "onChange",
|
||||
});
|
||||
|
||||
|
||||
const { monthHeadList } = prfmnc;
|
||||
useEffect(() => {
|
||||
let tableData;
|
||||
@@ -77,6 +78,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
majorPrcsMsrcCd: item.majorPrcsMsrcCd ?? "-",
|
||||
inoutYn: item.inoutYn ?? "-",
|
||||
addr: item.addr ?? "-",
|
||||
mainSplyPumpCpct: item.mainSplyPumpCpct ?? "-",
|
||||
};
|
||||
});
|
||||
} else if (fcltTab === "sply") {
|
||||
@@ -113,6 +115,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
smll: item.smll,
|
||||
crmty: item.crmty,
|
||||
tph: item.tph,
|
||||
|
||||
tn: item.tn,
|
||||
ph: item.ph,
|
||||
cdtnv: item.cdtnv,
|
||||
@@ -121,7 +124,6 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
} else if (fcltTab === "dmdCo") {
|
||||
tableData = data.fcBizs?.flatMap((item: fcBizType) => {
|
||||
|
||||
console.log("item.fcDemands", item.fcDemands);
|
||||
return item?.fcDemands?.map((dmd) => {
|
||||
return {
|
||||
cycl: item.cycl + "차",
|
||||
@@ -163,10 +165,10 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
]);
|
||||
|
||||
const getTablePrfData = (prfList: PrfType[]) => {
|
||||
const inUsageData = [...initValInUsage];
|
||||
const outUsageData = [...initValOutUsage];
|
||||
const inSubtotal = subTotalObj;
|
||||
const outSubtotal = subTotalObj;
|
||||
const inUsageData = structuredClone(initValInUsage);
|
||||
const outUsageData = structuredClone(initValOutUsage);
|
||||
const inSubtotal = structuredClone(subTotalObj);
|
||||
const outSubtotal = structuredClone(subTotalObj);
|
||||
|
||||
if (prfList) {
|
||||
prfList?.forEach((prfItem) => {
|
||||
@@ -203,7 +205,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
});
|
||||
inUsageData.push(inSubtotal);
|
||||
outUsageData.push(outSubtotal);
|
||||
const usageTotalObj: { [key: string]: any } = totalObj;
|
||||
const usageTotalObj: { [key: string]: any } = structuredClone(totalObj);
|
||||
for (const key in usageTotalObj) {
|
||||
if (["usage", "gubun", "edit"].includes(key)) continue;
|
||||
const val =
|
||||
@@ -227,14 +229,13 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
(item) => item.pbnstRuseFcltPk === data.pbnstRuseFcltPk
|
||||
)?.prfList;
|
||||
|
||||
if (prfList) {
|
||||
if (prfList) {console.log("prfList", prfList);
|
||||
|
||||
getTablePrfData(prfList);
|
||||
}
|
||||
}
|
||||
}, [pbnstSttn.pbnstSttnRes, data]);
|
||||
|
||||
useEffect(() => {}, [ruseBizData?.head]);
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
|
||||
@@ -243,6 +244,11 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
}
|
||||
|
||||
},[data, form])
|
||||
|
||||
|
||||
useEffect(()=>{
|
||||
console.log("prfData", prfData);
|
||||
},[prfData])
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
@@ -254,7 +260,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
indexMng={indexMng}
|
||||
setIndexMng={setIndexMng}
|
||||
/>
|
||||
<Tabs defaultValue="mng" onValueChange={setFcltTab}>
|
||||
<Tabs defaultValue="fclt" onValueChange={setFcltTab}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="fclt">
|
||||
하수처리수 재이용시설 현황
|
||||
@@ -292,7 +298,7 @@ export function PbnstSttnModal({ data }: { data: customPbnst }) {
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
<Tabs defaultValue="mng" onValueChange={setRuseTab}>
|
||||
<Tabs onValueChange={setRuseTab}>
|
||||
<TabsList className="">
|
||||
<TabsTrigger className="!text-xl" value="totalPrf">
|
||||
장내외합계
|
||||
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@common/components/ui";
|
||||
import { read } from "fs";
|
||||
import React, { useEffect, useState } from "react";
|
||||
|
||||
type RuseMngTableProps = {
|
||||
@@ -37,22 +38,9 @@ type RuseMngTableProps = {
|
||||
|
||||
const RuseMngTableForm = React.forwardRef<any, RuseMngTableProps>(
|
||||
({ tableData, headList, upHeadList, code, onTableSet, indexMng, form,formNm,indexBiz }, ref) => {
|
||||
// const [tableState, setTableState] = useState([...tableData]);
|
||||
|
||||
// // useEffect(() => {
|
||||
|
||||
// // if (ref && typeof ref === "object" && "current" in ref) {
|
||||
// // ref.current = tableState;
|
||||
// // }
|
||||
// // if (onTableSet) onTableSet(tableState);
|
||||
// // }, [tableState, onTableSet]);
|
||||
|
||||
// useEffect(() => {
|
||||
|
||||
// if (tableData)
|
||||
// setTableState(tableData);
|
||||
// }, [tableData]);
|
||||
|
||||
console.log('tableData ', tableData)
|
||||
return (
|
||||
<>
|
||||
<Table key={`table-${indexMng}-${indexBiz}`} variant="secondary">
|
||||
@@ -107,6 +95,7 @@ const RuseMngTableForm = React.forwardRef<any, RuseMngTableProps>(
|
||||
? (Number(field.value) ?? 0)
|
||||
: field.value || ""
|
||||
}
|
||||
readOnly ={head.readonly ? true : false}
|
||||
/>
|
||||
) : head.type === "select" ? (
|
||||
<SelectBox
|
||||
@@ -122,16 +111,26 @@ const RuseMngTableForm = React.forwardRef<any, RuseMngTableProps>(
|
||||
className={""}
|
||||
selectClass={selectClass}
|
||||
onSelectValue={(val) => {
|
||||
field.onChange(val);
|
||||
|
||||
if(head.readonly === true){
|
||||
return
|
||||
}else{
|
||||
|
||||
field.onChange(val);
|
||||
}
|
||||
}}
|
||||
// Disabled prop removed as SelectBox does not support it
|
||||
></SelectBox>
|
||||
) : head.type === "date" ? (
|
||||
<DatePicker
|
||||
mode="single"
|
||||
field={{
|
||||
value: field.value || new Date(),
|
||||
onChange: (date: Date | undefined) =>
|
||||
field.onChange(date),
|
||||
value:typeof field.value === "string" ? new Date(field.value) : field.value,
|
||||
onChange: (date: Date | undefined) => {
|
||||
|
||||
console.log("date", date);
|
||||
field.onChange(date); // readonly 상태가 아닐 때만 값 변경
|
||||
},
|
||||
}}
|
||||
selectClass={"w-full"}
|
||||
/>
|
||||
@@ -141,7 +140,6 @@ const RuseMngTableForm = React.forwardRef<any, RuseMngTableProps>(
|
||||
checked={ field.value || false}
|
||||
onCheckedChange={(checked) => {
|
||||
field.onChange(checked);
|
||||
|
||||
}}
|
||||
></Checkbox>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user