@@ -56,14 +56,14 @@ export function PbnstBuseForm({
|
||||
pbnst,
|
||||
demandCompList,
|
||||
getDemandCompList,
|
||||
getFcOrgwts,
|
||||
regDemandCompany,
|
||||
} = useWrStore((state) => state);
|
||||
const { pbnstBizCycle, pbnstRes } = pbnst;
|
||||
const { fcOrgwtsNmList } = pbnst;
|
||||
const { fields: fcBizs, append: appendBiz } = useFieldArray({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs`,
|
||||
});
|
||||
const [bizCycle, setBizCycle] = useState("1");
|
||||
const [ppiSelectList, setPpiSelectList] =
|
||||
useState<[{ name: string; val: SelectDataType[] }]>();
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
@@ -76,25 +76,72 @@ export function PbnstBuseForm({
|
||||
>([{ text: "없음", val: 0 }]);
|
||||
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;
|
||||
}>({ isMoal: false, data: {} as DemandCompType });
|
||||
|
||||
useEffect(() => {
|
||||
const total =
|
||||
const etc= isNaN(Number(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`)))
|
||||
let total =
|
||||
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`) ?? 0) +
|
||||
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.lcep`) ?? 0) +
|
||||
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`) ?? 0);
|
||||
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`) ?? 0)
|
||||
|
||||
if( !etc ) {
|
||||
total+=Number(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`))
|
||||
}
|
||||
|
||||
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.totalMoney`, total);
|
||||
}, [
|
||||
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`),
|
||||
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.lcep`),
|
||||
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`),
|
||||
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`)
|
||||
]);
|
||||
|
||||
|
||||
const fcOrgwts = form.watch( `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`)
|
||||
|
||||
useEffect(() =>{
|
||||
|
||||
console.log('fcOrgwts ', fcOrgwts)
|
||||
if(fcOrgwts&&fcOrgwts?.length>0){
|
||||
const swtrmtFcltFkList = fcOrgwts.map((item) => item.swtrmtFcltFk);
|
||||
|
||||
console.log('swtrmtFcltFkList ', swtrmtFcltFkList)
|
||||
|
||||
if(swtrmtFcltFkList.length > 0){
|
||||
getFcOrgwts(swtrmtFcltFkList.filter((item): item is string => item != null), fcOrgwts?.length)
|
||||
}
|
||||
}
|
||||
},[fcOrgwts])
|
||||
|
||||
useEffect(() =>{
|
||||
|
||||
if (fcOrgwtsNmList && fcOrgwtsNmList.length > 0) {
|
||||
|
||||
console.log('fcOrgwtsNmList ', fcOrgwtsNmList)
|
||||
console.log('fcOrgwts ', fcOrgwts)
|
||||
|
||||
fcOrgwts?.forEach((item, index) => {
|
||||
const orgwtNm = fcOrgwtsNmList.find(
|
||||
(orgwt) => orgwt.bscFctCd === item.swtrmtFcltFk
|
||||
)?.bscFctNm;
|
||||
|
||||
console.log('orgwtNm ', orgwtNm)
|
||||
if (orgwtNm) {
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts.${index}.ruseUtztnFcltNm`,
|
||||
orgwtNm
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
},[fcOrgwtsNmList,fcOrgwts])
|
||||
|
||||
|
||||
// fcBizs 데이터가 변경될 때마다 차수 선택 목록을 업데이트합니다.
|
||||
useEffect(() => {
|
||||
const cycleLength = fcBizs.length;
|
||||
|
||||
@@ -29,6 +29,10 @@ import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { Label } from "@common/business_components/ui/form/lib/label";
|
||||
import React from "react";
|
||||
import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm";
|
||||
import {
|
||||
handleCommaNumberChange,
|
||||
formatCommaNumber,
|
||||
} from "@/components/lib/func/commom";
|
||||
export type FilesType = {
|
||||
atflCd: string;
|
||||
file: File;
|
||||
@@ -46,13 +50,9 @@ export function PbnstMngForm({
|
||||
indexMng: number;
|
||||
setIndexMng: (index: number) => void;
|
||||
}) {
|
||||
const {
|
||||
code,
|
||||
pbnst,
|
||||
pbnstInsert,
|
||||
fileDelete,
|
||||
fileDownLoad,
|
||||
} = useWrStore((state) => state);
|
||||
const { code, pbnst, pbnstInsert, fileDelete, fileDownLoad } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
|
||||
const { pbnstRes } = pbnst;
|
||||
const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null);
|
||||
@@ -215,16 +215,14 @@ export function PbnstMngForm({
|
||||
|
||||
useEffect(() => {
|
||||
if (pbnst.pbnstRes && pbnst.pbnstRes?.length >= 0) {
|
||||
|
||||
const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({
|
||||
text: item.ruseUtztnFcltNm,
|
||||
val: String(index),
|
||||
}));
|
||||
|
||||
|
||||
console.log(' fcltNmList ', fcltNmList)
|
||||
console.log(" fcltNmList ", fcltNmList);
|
||||
if (fcltNmList) setFcltNm(fcltNmList);
|
||||
}else{
|
||||
} else {
|
||||
setFcltNm(null);
|
||||
}
|
||||
}, [pbnst.pbnstRes]);
|
||||
@@ -253,16 +251,14 @@ export function PbnstMngForm({
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
|
||||
useEffect(() =>{
|
||||
// console.log(' fcltNm ', watchedItem?.ruseUtztnFcltNm)
|
||||
},[watchedItem])
|
||||
|
||||
useEffect(() => {
|
||||
// console.log(' fcltNm ', watchedItem?.ruseUtztnFcltNm)
|
||||
}, [watchedItem]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log(" form indexMng ", indexMng);
|
||||
}, [indexMng]);
|
||||
|
||||
}, [indexMng]);
|
||||
|
||||
return (
|
||||
<div className=" !mx-[1.6rem] !p-0r">
|
||||
<div>
|
||||
@@ -297,8 +293,6 @@ export function PbnstMngForm({
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<Input
|
||||
|
||||
|
||||
className="!text-2xl"
|
||||
placeholder=""
|
||||
type="text"
|
||||
@@ -379,11 +373,12 @@ export function PbnstMngForm({
|
||||
<Input
|
||||
key={`items.${indexMng}.fcltCpct`}
|
||||
placeholder=""
|
||||
type="number"
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
if (formType !== "sttn")
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -401,11 +396,12 @@ export function PbnstMngForm({
|
||||
<Input
|
||||
key={`items.${indexMng}.ruseCpct`}
|
||||
placeholder=""
|
||||
type="number"
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
if (formType !== "sttn")
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -422,11 +418,12 @@ export function PbnstMngForm({
|
||||
<Input
|
||||
key={`items.${indexMng}.splyExtraCpct`}
|
||||
placeholder=""
|
||||
type="number"
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
if (formType !== "sttn")
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={formType === "sttn" ? true : false}
|
||||
/>
|
||||
</FormUi>
|
||||
|
||||
+37
-23
@@ -2,17 +2,14 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { formDetailType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList";
|
||||
import { formH1Class } from "@/components/lib/class/comClass";
|
||||
import { safeDate } from "@/components/lib/func/commom";
|
||||
import { formatCommaNumber, handleCommaNumberChange, safeDate } from "@/components/lib/func/commom";
|
||||
import {
|
||||
DatePicker,
|
||||
FormField,
|
||||
FormUi,
|
||||
SearchInputSelect,
|
||||
SelectBox,
|
||||
type SelectDataType,
|
||||
} from "@common/business_components/ui";
|
||||
import { Input } from "@common/components/ui";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function MngRegFormDetail({
|
||||
formList,
|
||||
@@ -55,9 +52,7 @@ export default function MngRegFormDetail({
|
||||
name={fieldId}
|
||||
render={({ field }) => (
|
||||
<FormUi label={formHead.lable}>
|
||||
{formHead.type === "select" ? (
|
||||
<Input placeholder="" type="text" {...field} />
|
||||
) : formHead.type === "date" ? (
|
||||
{formHead.type === "date" ? (
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
className={"rounded-lg !w-full"}
|
||||
@@ -67,35 +62,54 @@ export default function MngRegFormDetail({
|
||||
field.onChange(date),
|
||||
}}
|
||||
selectClass={"w-full"}
|
||||
disabled={formHead.option === "disabled" ? true : false}
|
||||
|
||||
/>
|
||||
) : formHead.type === "number" ? (
|
||||
<Input
|
||||
placeholder=""
|
||||
type="number"
|
||||
value={field.value ?? 0}
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
field.onChange(Number(e.target.value));
|
||||
handleCommaNumberChange(
|
||||
e,
|
||||
field.onChange
|
||||
);
|
||||
}}
|
||||
readOnly={formHead.option === "readOnly"?true:false}
|
||||
/>
|
||||
) : formHead.type === "selectYn" ? (
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.yn}
|
||||
onSelectValue={(val: string | number) =>
|
||||
field.onChange(val)
|
||||
}
|
||||
value={field.value ?? "Y"}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={formHead.option === "readOnly" ? true : false}
|
||||
disabled={formHead.option === "disabled" ? true : false}
|
||||
|
||||
/>
|
||||
) : formHead.type === "select" ? (
|
||||
(() => {
|
||||
const potentialOptions = formHead.selectData
|
||||
? code[formHead.selectData as keyof typeof code]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={
|
||||
Array.isArray(potentialOptions)
|
||||
? potentialOptions
|
||||
: []
|
||||
}
|
||||
onSelectValue={field.onChange}
|
||||
value={field.value.trim()}
|
||||
readOnly={formHead.option === "readOnly"}
|
||||
/>
|
||||
);
|
||||
})()
|
||||
) : (
|
||||
<Input
|
||||
placeholder=""
|
||||
type="text"
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={formHead.option === "readOnly"?true:false}
|
||||
readOnly={formHead.option === "readOnly" ? true : false}
|
||||
disabled={formHead.option === "disabled" ? true : false}
|
||||
/>
|
||||
)}
|
||||
</FormUi>
|
||||
|
||||
Reference in New Issue
Block a user