@@ -169,12 +169,13 @@ export const getdmdMatFlag = (flag: string | undefined | null) => {
|
||||
const cleanFlag = (flag ?? "").trim();
|
||||
|
||||
|
||||
console.log('cleanFlag ', cleanFlag)
|
||||
switch (cleanFlag) {
|
||||
case "Sub":
|
||||
return "검토";
|
||||
case "matched":
|
||||
case "Matched":
|
||||
return "매칭완료";
|
||||
case "Checked":
|
||||
return '검토완료';
|
||||
default:
|
||||
return "신청";
|
||||
}
|
||||
|
||||
@@ -22,8 +22,7 @@ import {
|
||||
UiTable,
|
||||
} from "@common/business_components/ui";
|
||||
import PopoverUi from "@common/business_components/ui/popover_ui";
|
||||
import { Button, Input, Label } from "@common/components/ui";
|
||||
import type { read } from "fs";
|
||||
import { Button, Checkbox, Input, Label } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { type UseFormReturn } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
@@ -48,6 +47,8 @@ export default function ConCostForm({
|
||||
|
||||
const ref = useRef<boolean>(false);
|
||||
|
||||
const [checkFinish, setCheckFinish] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
@@ -57,6 +58,13 @@ export default function ConCostForm({
|
||||
}
|
||||
}, [ref, getConstCostFee, getRateFee]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
// 다른 행을 선택하면(selectionVersion 변경) 체크박스 상태를 초기화합니다.
|
||||
setCheckFinish(false);
|
||||
}, [selectionVersion]);
|
||||
|
||||
|
||||
const zipDowonLoad = () => {
|
||||
fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => {
|
||||
const blobRet = await response.blob();
|
||||
@@ -74,36 +82,38 @@ export default function ConCostForm({
|
||||
const cstrnCst = form.watch("demandCst.cstrnCst");
|
||||
const useUsgCdWatch = form.watch("useUsgCd");
|
||||
|
||||
|
||||
|
||||
const calculateConstCost = useCallback(() => {
|
||||
const usgPrcsProcs = usgPrcsProcsWatch;
|
||||
if(!dmndQtyWatch){
|
||||
toast.error('요구수량(M3/d)을 확인해주세요 계산할수 없습니다. ')
|
||||
return
|
||||
if (!dmndQtyWatch) {
|
||||
toast.error("요구수량(M3/d)을 확인해주세요 계산할수 없습니다. ");
|
||||
return;
|
||||
}
|
||||
if (usgPrcsProcs === null || usgPrcsProcs === undefined) {
|
||||
toast.error(
|
||||
"용도에 따른 처리공정을 확인할수 없습니다. 용도를 확인해주세요. "
|
||||
);
|
||||
return;
|
||||
}
|
||||
if(usgPrcsProcs === null || usgPrcsProcs === undefined){
|
||||
toast.error('용도에 따른 처리공정을 확인할수 없습니다. 용도를 확인해주세요. ')
|
||||
return
|
||||
}
|
||||
|
||||
const dmndQtyYear = dmndQtyWatch * 365;
|
||||
if (usgPrcsProcs && usgPrcsProcs?.length > 0) {
|
||||
const firstProc = getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || "";
|
||||
const secondProc = getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || "";
|
||||
const firstProc =
|
||||
getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || "";
|
||||
const secondProc =
|
||||
getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || "";
|
||||
|
||||
const { lower: firstLower, upper: firstUpper } = findBounds(
|
||||
constCostRes,
|
||||
firstProc || "",
|
||||
'fctCd',
|
||||
'fctCpc',
|
||||
"fctCd",
|
||||
"fctCpc",
|
||||
Number(dmndQtyYear)
|
||||
);
|
||||
const { lower: secondLower, upper: secondUpper } = findBounds(
|
||||
constCostRes,
|
||||
secondProc || "",
|
||||
'fctCd',
|
||||
'fctCpc',
|
||||
"fctCd",
|
||||
"fctCpc",
|
||||
Number(dmndQtyYear)
|
||||
);
|
||||
|
||||
@@ -122,52 +132,56 @@ export default function ConCostForm({
|
||||
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);
|
||||
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 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));
|
||||
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(value.demandCst&& !value.demandCst.prcsFcltCpctCstrnCst ){
|
||||
toast.error('공사비 계산 진행 후 저장을 눌러주새요')
|
||||
return
|
||||
if (value.demandCst && !value.demandCst.prcsFcltCpctCstrnCst) {
|
||||
toast.error("공사비 계산 진행 후 저장을 눌러주새요");
|
||||
return;
|
||||
}
|
||||
if (type === "mat") {
|
||||
|
||||
if(value.demandCst ){
|
||||
if (value.demandCst) {
|
||||
const data: DedMatUpdateType = {
|
||||
dmdInfoSn: value.dmdInfoSn,
|
||||
usgPrcsProcs: value.demandCst.usgPrcsProcs|| "",
|
||||
cstrnCst: value.demandCst.cstrnCst ||0,
|
||||
fcltSbsdCstrnCst: value.demandCst.fcltSbsdCstrnCst ||0,
|
||||
prcsFcltCpctCstrnCst: value.demandCst.prcsFcltCpctCstrnCst ||0,
|
||||
usgPrcsProcs: value.demandCst.usgPrcsProcs || "",
|
||||
cstrnCst: value.demandCst.cstrnCst || 0,
|
||||
fcltSbsdCstrnCst: value.demandCst.fcltSbsdCstrnCst || 0,
|
||||
prcsFcltCpctCstrnCst: value.demandCst.prcsFcltCpctCstrnCst || 0,
|
||||
flg: checkFinish?'Checked':'Sub',
|
||||
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
|
||||
|
||||
delete value.totalConstCost;
|
||||
delete value.ruseUtztnFcltNm;
|
||||
|
||||
ruseRvwCalUpdate(value);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" form ", form.formState.errors);
|
||||
console.log(" form ", form.formState.errors);
|
||||
}, [form.formState]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
form.register("dmdInfoSn");
|
||||
form.register("dmdInfoFk");
|
||||
@@ -187,18 +201,30 @@ export default function ConCostForm({
|
||||
<Button className="mx-3" size={"sm"} onClick={calculateConstCost}>
|
||||
계산
|
||||
</Button>
|
||||
<Button className="mr-3" 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>
|
||||
<Label>검토완료</Label>
|
||||
<Checkbox
|
||||
className="ml-3 mr-6"
|
||||
checked={checkFinish}
|
||||
onCheckedChange={(checked) =>
|
||||
// 'indeterminate' 상태를 무시하고 순수 boolean 값으로만 상태를 업데이트합니다.
|
||||
setCheckFinish(checked === true)}
|
||||
></Checkbox>
|
||||
<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>
|
||||
@@ -310,14 +336,14 @@ export default function ConCostForm({
|
||||
<h1 className={formH1Class}>공사비 입력사항</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="col-span-2 mt-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<PopoverUi
|
||||
childrenTriger={
|
||||
<>
|
||||
<Label className="underline">
|
||||
처리시설용량에 따른 공사비(백만원) <i className="diveicon di-search" />
|
||||
처리시설용량에 따른 공사비(백만원){" "}
|
||||
<i className="diveicon di-search" />
|
||||
</Label>
|
||||
</>
|
||||
}
|
||||
@@ -394,7 +420,8 @@ export default function ConCostForm({
|
||||
childrenTriger={
|
||||
<>
|
||||
<Label className="underline">
|
||||
처리시설 총사업비(백만원) <i className="diveicon di-search" />
|
||||
처리시설 총사업비(백만원){" "}
|
||||
<i className="diveicon di-search" />
|
||||
</Label>
|
||||
</>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user