Merge commit 'af92a70f136b5f250f5c83155dd379672f7c341f' into iipbs/wr/dev
iipbs_wr / build (push) Waiting to run
iipbs_wr / build (push) Waiting to run
This commit is contained in:
@@ -18,7 +18,6 @@ import {
|
||||
Form,
|
||||
FormField,
|
||||
FormUi,
|
||||
UiModal,
|
||||
UiTable,
|
||||
} from "@common/business_components/ui";
|
||||
import PopoverUi from "@common/business_components/ui/popover_ui";
|
||||
@@ -65,30 +64,6 @@ export default function ConCostForm({
|
||||
}, [selectionVersion]);
|
||||
|
||||
|
||||
const confrirmToast = () => {
|
||||
|
||||
if (checkFinish) {
|
||||
toast((t) => (
|
||||
<span className="flex flex-col items-center">
|
||||
검토완료 변경시 공사비는 변경할수 없습니다.
|
||||
<br />
|
||||
진행하시겠습니까?
|
||||
<Button
|
||||
onClick={() => {
|
||||
toast.dismiss(t.id);
|
||||
|
||||
|
||||
}}
|
||||
>
|
||||
확인
|
||||
</Button>
|
||||
<Button onClick={() => toast.dismiss(t.id)}>취소</Button>
|
||||
</span>
|
||||
));
|
||||
} else {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const zipDowonLoad = () => {
|
||||
fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => {
|
||||
@@ -105,7 +80,6 @@ export default function ConCostForm({
|
||||
const dmndQtyWatch = form.watch("dmndQty");
|
||||
const totalConstCost = form.watch("totalConstCost");
|
||||
const cstrnCst = form.watch("demandCst.cstrnCst");
|
||||
const useUsgCdWatch = form.watch("useUsgCd");
|
||||
|
||||
const calculateConstCost = useCallback(() => {
|
||||
const usgPrcsProcs = usgPrcsProcsWatch;
|
||||
@@ -372,6 +346,7 @@ export default function ConCostForm({
|
||||
type="number"
|
||||
step="0.001"
|
||||
onChange={(e) => {
|
||||
console.log('dmndQty ', e)
|
||||
//field.onChange(Number(e.target.value) * 365 );
|
||||
}}
|
||||
value={Number(field.value) * 365 || 0}
|
||||
@@ -398,9 +373,7 @@ export default function ConCostForm({
|
||||
}
|
||||
childrenBody={
|
||||
<>
|
||||
<ConstCostFeeTable
|
||||
setReturnData={(e) => {}}
|
||||
></ConstCostFeeTable>
|
||||
<ConstCostFeeTable/>
|
||||
</>
|
||||
}
|
||||
bodyClassName={"w-[40vw] h-full"}
|
||||
@@ -437,9 +410,8 @@ export default function ConCostForm({
|
||||
}
|
||||
childrenBody={
|
||||
<>
|
||||
<RateFeeTableModal
|
||||
setReturnData={(e) => {}}
|
||||
></RateFeeTableModal>
|
||||
<RateFeeTableModal/>
|
||||
|
||||
</>
|
||||
}
|
||||
bodyClassName={"w-[22vw]"}
|
||||
@@ -499,7 +471,10 @@ export default function ConCostForm({
|
||||
className="mt-2"
|
||||
type="number"
|
||||
step="0.01"
|
||||
onChange={(e) => {}}
|
||||
onChange={(e) => {
|
||||
console.log('totalConstCost ', e)
|
||||
|
||||
}}
|
||||
value={field.value ?? 0}
|
||||
readOnly
|
||||
/>
|
||||
|
||||
@@ -6,7 +6,7 @@ import { formH1Class } from "@/components/lib/class/comClass";
|
||||
import { safeDate } from "@/components/lib/func/commom";
|
||||
import { DatePicker, FormField, FormUi, SelectBox } from "@common/business_components";
|
||||
import { Button, Checkbox, Input } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useFieldArray } from "react-hook-form";
|
||||
|
||||
export default function BdstAdd({ form, readonly }: { form: any; readonly?: boolean; }) {
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { formH1Class } from "@/components/lib/class/comClass";
|
||||
import {
|
||||
formatCommaNumber,
|
||||
getCity,
|
||||
handleCommaNumberChange,
|
||||
safeDate,
|
||||
} from "@/components/lib/func/commom";
|
||||
import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
import {
|
||||
FormField,
|
||||
FormUi,
|
||||
@@ -15,9 +8,8 @@ import {
|
||||
SelectBox,
|
||||
type SelectDataType,
|
||||
} from "@common/business_components";
|
||||
import { Button, Checkbox, Input } from "@common/components";
|
||||
import { Input } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useFieldArray } from "react-hook-form";
|
||||
|
||||
export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
const { code } = useWrStore((state) => {
|
||||
@@ -28,11 +20,11 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
const [useCityCd, setUserCityCd] = useState<SelectDataType[]>([])
|
||||
const [useSggCd, setUserSggCd] = useState<SelectDataType[]>([])
|
||||
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | undefined>();
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({
|
||||
sgg: "",
|
||||
city: "",
|
||||
});
|
||||
// const [selectSgg, setSelectSgg] = useState<SelectDataType[] | undefined>();
|
||||
// const [objSearch, setObjSearch] = useState<objSearchType>({
|
||||
// sgg: "",
|
||||
// city: "",
|
||||
// });
|
||||
|
||||
useEffect(() =>{
|
||||
if(userSiSggCd.length===2 && code.cityCd.length>0){
|
||||
@@ -58,24 +50,13 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
}
|
||||
},[form, userSiSggCd, code.cityCd, code.sggCd])
|
||||
|
||||
const getSelCity = (val: string) => {
|
||||
const data = getCity(val, code.sggCd);
|
||||
setSelectSgg(data);
|
||||
const sgg = form.getValues("sggCd");
|
||||
|
||||
setObjSearch({ city: val, sgg: "" });
|
||||
};
|
||||
|
||||
const getSgg = (val: string | number) => {
|
||||
const sgg = form.getValues("sggCd");
|
||||
setObjSearch({ ...objSearch, sgg: val != "" ? String(val) : sgg });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const city = form.getValues("ctpvCd");
|
||||
const sgg = form.getValues("sggCd");
|
||||
setObjSearch({ city: city, sgg: sgg });
|
||||
}, [selectSgg]);
|
||||
// useEffect(() => {
|
||||
// const city = form.getValues("ctpvCd");
|
||||
// const sgg = form.getValues("sggCd");
|
||||
// setObjSearch({ city: city, sgg: sgg });
|
||||
// }, [selectSgg]);
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = form.form?.watch((value: any) => {
|
||||
|
||||
@@ -199,7 +199,7 @@ export default function HtdflRegForm({
|
||||
selectArray={code.htdPowerMthdCd}
|
||||
onSelectValue={readonly ? () => { } : field.onChange}
|
||||
// value={field.value ?? ""}
|
||||
value={field.value || code.htdPowerMthdCd[0].val}
|
||||
value={field.value || (code?.htdPowerMthdCd[0] &&code?.htdPowerMthdCd[0].val)}
|
||||
readOnly={readonly || !isPowerPlant}
|
||||
/>
|
||||
</FormUi>
|
||||
|
||||
@@ -22,13 +22,12 @@ import {
|
||||
formTableName,
|
||||
} from "@/components/lib/class/comClass";
|
||||
import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal";
|
||||
import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable";
|
||||
import { SelectBox } from "@common/business_components";
|
||||
import { DatePicker, FormUi, UiModal } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { Button, DataTable, Input, Label } from "@common/components";
|
||||
import { Button, Input, Label } from "@common/components";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useFieldArray, useForm, type UseFormReturn } from "react-hook-form";
|
||||
import { useFieldArray, type UseFormReturn } from "react-hook-form";
|
||||
import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail";
|
||||
import {
|
||||
formatCommaNumber,
|
||||
@@ -54,7 +53,6 @@ export function PbnstBuseForm({
|
||||
indexBiz: number;
|
||||
setIndexBiz: (index: number) => void;
|
||||
}) {
|
||||
const ref = useRef<ppInstlType[] | null>(null);
|
||||
const {
|
||||
code,
|
||||
pbnst,
|
||||
@@ -68,10 +66,10 @@ export function PbnstBuseForm({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs`,
|
||||
});
|
||||
const [ppiSelectList, setPpiSelectList] =
|
||||
useState<[{ name: string; val: SelectDataType[] }]>();
|
||||
const [ppiSelectList, setPpiSelectList] = useState<
|
||||
{ name: string; val: SelectDataType[] }[] | undefined
|
||||
>();
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
|
||||
const [selectBizCycle, setSelectBizCycle] = useState<
|
||||
{
|
||||
text: string;
|
||||
@@ -125,7 +123,6 @@ export function PbnstBuseForm({
|
||||
|
||||
useEffect(() => {
|
||||
if (fcOrgwtsNmList && fcOrgwtsNmList.length > 0) {
|
||||
|
||||
fcOrgwts?.forEach((item, index) => {
|
||||
const orgwtNm = fcOrgwtsNmList.find(
|
||||
(orgwt) => orgwt.bscFctCd === item.swtrmtFcltFk
|
||||
@@ -175,11 +172,7 @@ export function PbnstBuseForm({
|
||||
appendBiz(newItem);
|
||||
setIndexBiz(pbnstBizCycle); // 새로 추가된 차수로 포커스 이동
|
||||
}
|
||||
const {
|
||||
fields: fcDemands,
|
||||
append: appendDemand,
|
||||
remove: removeDemand,
|
||||
} = useFieldArray({
|
||||
const { fields: fcDemands, append: appendDemand } = useFieldArray({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs.${indexBiz}.fcDemands`,
|
||||
});
|
||||
@@ -201,16 +194,7 @@ export function PbnstBuseForm({
|
||||
prevDemandsLengthRef.current = fcDemands.length;
|
||||
}, [fcDemands.length]);
|
||||
|
||||
|
||||
const { fields: fcOrgwtFiled } = useFieldArray({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`,
|
||||
});
|
||||
const {
|
||||
fields: pplInstls,
|
||||
append: appendPpl,
|
||||
remove: removePpl,
|
||||
} = useFieldArray({
|
||||
const { append: appendPpl, remove: removePpl } = useFieldArray({
|
||||
control: form.control,
|
||||
name: `items.${indexMng}.fcBizs.${indexBiz}.pplInstls`,
|
||||
});
|
||||
@@ -286,7 +270,7 @@ export function PbnstBuseForm({
|
||||
if (code.pplLenght) {
|
||||
ppl.push({ name: "pplQulity", val: code.pplQulity });
|
||||
}
|
||||
if (ppl.length > 0) {
|
||||
if (ppl && ppl.length > 0) {
|
||||
setPpiSelectList(ppl);
|
||||
} else {
|
||||
setPpiSelectList(undefined);
|
||||
@@ -297,7 +281,7 @@ export function PbnstBuseForm({
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
|
||||
useEffect(() => {
|
||||
useEffect(() => {
|
||||
const pplSum = form.watch(`items.${indexMng}.fcBizs.${indexBiz}.pplInstls`);
|
||||
if (!pplSum) return;
|
||||
let sum = 0;
|
||||
@@ -307,10 +291,9 @@ export function PbnstBuseForm({
|
||||
setSumCpct(sum);
|
||||
}, [form.formState, indexMng, indexBiz]);
|
||||
|
||||
useEffect(() =>{
|
||||
|
||||
console.log('form.formState ', form.formState)
|
||||
}, [form.formState]);
|
||||
useEffect(() => {
|
||||
console.log("form.formState ", form.formState);
|
||||
}, [form.formState]);
|
||||
|
||||
const pbnstBiz = form.watch(`items.${indexMng}.fcBizs`);
|
||||
|
||||
@@ -418,10 +401,11 @@ useEffect(() =>{
|
||||
</div>
|
||||
<RuseMngTableForm
|
||||
key={`fcOrgwts-${indexMng}-${indexBiz}`} // 이게 핵심!
|
||||
|
||||
tableData={
|
||||
form.getValues( `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`)||[]
|
||||
// fcOrgwtWatch||[]
|
||||
form.getValues(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`
|
||||
) || []
|
||||
// fcOrgwtWatch||[]
|
||||
}
|
||||
form={form}
|
||||
headList={pbnst.pbnstOrgwtHeadList}
|
||||
@@ -445,7 +429,7 @@ useEffect(() =>{
|
||||
<Label className="text-right">합계</Label>
|
||||
<Input
|
||||
type="text"
|
||||
value={ formatCommaNumber(sumCpct)}
|
||||
value={formatCommaNumber(sumCpct)}
|
||||
readOnly={true}
|
||||
className="w-32 border-gray-300 rounded pr-8 "
|
||||
/>
|
||||
@@ -479,7 +463,7 @@ useEffect(() =>{
|
||||
form.getValues(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.pplInstls`
|
||||
) ?? []
|
||||
// pplInstlsWatch||[]
|
||||
// pplInstlsWatch||[]
|
||||
}
|
||||
headList={pbnst.pplInstlsHeadLisat}
|
||||
code={ppiSelectList ?? []}
|
||||
@@ -532,173 +516,173 @@ useEffect(() =>{
|
||||
</div>
|
||||
<div ref={demandsContainerRef}>
|
||||
{fcDemands.map((field, index) => (
|
||||
<div
|
||||
<div
|
||||
key={field.id} // useFieldArray의 고유 id를 key로 사용
|
||||
className="grid grid-cols-12 gap-4 mt-3 border-b border-gray-400 pb-3"
|
||||
>
|
||||
<div key={index + "keySon1"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdCoNm`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="수요처명">
|
||||
<SearchInputText
|
||||
label={"수요처"}
|
||||
initValue={f.value}
|
||||
setValue={(val) => {
|
||||
f.onChange(val);
|
||||
if (val && val.length > 2) {
|
||||
getDemandCompList(val, 3);
|
||||
>
|
||||
<div key={index + "keySon1"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdCoNm`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="수요처명">
|
||||
<SearchInputText
|
||||
label={"수요처"}
|
||||
initValue={f.value}
|
||||
setValue={(val) => {
|
||||
f.onChange(val);
|
||||
if (val && val.length > 2) {
|
||||
getDemandCompList(val, 3);
|
||||
}
|
||||
}}
|
||||
setRtnData={(valList: any) => {
|
||||
if (valList) {
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`,
|
||||
valList.daddr
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`,
|
||||
valList.useUsgCd
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`,
|
||||
valList.splyCpct
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdInfoPk`,
|
||||
valList.dmdInfoPk?.toString()
|
||||
);
|
||||
}
|
||||
}}
|
||||
searchList={demandCompList?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
searchNm: item.dmdCoNm,
|
||||
searchPk: item.dmdInfoPk,
|
||||
};
|
||||
})}
|
||||
></SearchInputText>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon2"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="위치(주소)">
|
||||
<Input
|
||||
placeholder="-"
|
||||
type="text"
|
||||
readOnly
|
||||
onChange={(e) => f.onChange(e.target.value)}
|
||||
value={f.value}
|
||||
className={selectClass}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon3"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="사용용도">
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.dmdUszCd}
|
||||
onSelectValue={f.onChange}
|
||||
value={f.value ?? code.dmdUszCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon4"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyBgngDay`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급시작일">
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
field={{
|
||||
value: safeDate(f.value) || new Date(),
|
||||
onChange: (date: Date | undefined) =>
|
||||
f.onChange(date),
|
||||
}}
|
||||
selectClass={"rounded-lg !w-full"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon5"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyEndDay`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급종료일">
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
onSelect={(date: Date | undefined) =>
|
||||
f.onChange(date)
|
||||
}
|
||||
}}
|
||||
setRtnData={(valList: any) => {
|
||||
if (valList) {
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`,
|
||||
valList.daddr
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`,
|
||||
valList.useUsgCd
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`,
|
||||
valList.splyCpct
|
||||
);
|
||||
form.setValue(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.dmdInfoPk`,
|
||||
valList.dmdInfoPk?.toString()
|
||||
);
|
||||
field={{
|
||||
value: safeDate(f.value) || new Date(),
|
||||
onChange: (date: Date | undefined) =>
|
||||
f.onChange(date),
|
||||
}}
|
||||
selectClass={"rounded-lg !w-full"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon6"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="(계약)공급량(m³/일)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, f.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(f.value)}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon7"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyFmYn`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급 유량계 유무">
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.yn}
|
||||
onSelectValue={(val: string | number) =>
|
||||
f.onChange(val)
|
||||
}
|
||||
}}
|
||||
searchList={demandCompList?.map((item) => {
|
||||
return {
|
||||
...item,
|
||||
searchNm: item.dmdCoNm,
|
||||
searchPk: item.dmdInfoPk,
|
||||
};
|
||||
})}
|
||||
></SearchInputText>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
value={f.value ?? code.yn[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div key={index + "keySon2"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.daddr`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="위치(주소)">
|
||||
<Input
|
||||
placeholder="-"
|
||||
type="text"
|
||||
readOnly
|
||||
onChange={(e) => f.onChange(e.target.value)}
|
||||
value={f.value}
|
||||
className={selectClass}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon3"} className="col-span-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.useUsgCd`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="사용용도">
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.dmdUszCd}
|
||||
onSelectValue={f.onChange}
|
||||
value={f.value ?? code.dmdUszCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon4"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyBgngDay`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급시작일">
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
field={{
|
||||
value: safeDate(f.value) || new Date(),
|
||||
onChange: (date: Date | undefined) =>
|
||||
f.onChange(date),
|
||||
}}
|
||||
selectClass={"rounded-lg !w-full"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon5"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyEndDay`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급종료일">
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
onSelect={(date: Date | undefined) =>
|
||||
f.onChange(date)
|
||||
}
|
||||
field={{
|
||||
value: safeDate(f.value) || new Date(),
|
||||
onChange: (date: Date | undefined) =>
|
||||
f.onChange(date),
|
||||
}}
|
||||
selectClass={"rounded-lg !w-full"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon6"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyCpct`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="(계약)공급량(m³/일)">
|
||||
<Input
|
||||
placeholder=""
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, f.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(f.value)}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
<div key={index + "keySon7"} className="col-span-3">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name={`items.${indexMng}.fcBizs.${indexBiz}.fcDemands.${index}.splyFmYn`}
|
||||
render={({ field: f }) => (
|
||||
<FormUi label="공급 유량계 유무">
|
||||
<SelectBox
|
||||
label={""}
|
||||
selectClass={""}
|
||||
className="w-full"
|
||||
selectArray={code.yn}
|
||||
onSelectValue={(val: string | number) =>
|
||||
f.onChange(val)
|
||||
}
|
||||
value={f.value ?? code.yn[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -712,9 +696,11 @@ useEffect(() =>{
|
||||
bodyClass={"w-[70vw] max-w-none max-h-[90vh] overflow-y-auto"}
|
||||
body={
|
||||
<FcOrgwtsRegModal
|
||||
initTableData={form.getValues(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`
|
||||
) ?? []}
|
||||
initTableData={
|
||||
form.getValues(
|
||||
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`
|
||||
) ?? []
|
||||
}
|
||||
closeModal={() => {
|
||||
setIsFcOrgwts(false);
|
||||
}}
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
} from "@/components/lib/class/comClass";
|
||||
import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr";
|
||||
import {
|
||||
type customPbnst,
|
||||
type fcFileType,
|
||||
type PbnstRegArrrayType,
|
||||
type selectLabel,
|
||||
@@ -44,23 +43,17 @@ export function PbnstMngForm({
|
||||
}: {
|
||||
form: UseFormReturn<{ items: PbnstRegArrrayType }>;
|
||||
formType: string;
|
||||
firstFcltData?: customPbnst;
|
||||
indexMng: number;
|
||||
setIndexMng: (index: number) => void;
|
||||
}) {
|
||||
const { code, pbnst, fileDelete, fileDownLoad } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { pbnstRes } = pbnst;
|
||||
const fileInitRef = useRef<{ index: number; key: string } | null>(null);
|
||||
const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null);
|
||||
const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null);
|
||||
const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null);
|
||||
const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null);
|
||||
const [opersKey, setOpersKey] = useState(0);
|
||||
useEffect(() => {
|
||||
setOpersKey((prev) => prev + 1);
|
||||
}, [indexMng]);
|
||||
const [mngMtdCode, setMngMtdCode] =
|
||||
useState<{ name: string; val: SelectDataType[] }[]>();
|
||||
|
||||
@@ -125,6 +118,7 @@ export function PbnstMngForm({
|
||||
atflCd: tusFile.atflCd.toString(),
|
||||
file: item,
|
||||
});
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
type === "relation"
|
||||
? setRelationFiles(setReFiles)
|
||||
: setPlanFiles(setReFiles);
|
||||
@@ -151,6 +145,7 @@ export function PbnstMngForm({
|
||||
}
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
type === "relation"
|
||||
? setRelationFiles(setReFiles)
|
||||
: setPlanFiles(setReFiles);
|
||||
@@ -517,7 +512,3 @@ export function PbnstMngForm({
|
||||
</div>
|
||||
);
|
||||
}
|
||||
function trigger(arg0: string) {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
} from "@/components/lib/func/commom";
|
||||
import { DatePicker, FormUi } from "@common/business_components";
|
||||
import { Form, FormField, SelectBox } from "@common/business_components/ui";
|
||||
import { Button, Checkbox, Input, Label, ScrollArea } from "@common/components/ui";
|
||||
import { Button, Input, ScrollArea } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
@@ -35,16 +35,14 @@ export default function RainRegForm({
|
||||
setIsModal?: (modal: boolean) => void;
|
||||
readonly?: boolean;
|
||||
}) {
|
||||
const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore(
|
||||
const { code, rainBdstReg, rainBdstUpdate } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { rainFcltCd } = code;
|
||||
const defaultValues: z.infer<typeof rainZod> = rainZod.parse({});
|
||||
const form = useForm<z.infer<typeof rainZod>>({
|
||||
resolver: zodResolver(rainZod),
|
||||
// defaultValues: defaultValues,
|
||||
});
|
||||
const instlCst = form.watch(`reuseBuilding.0.instlCst`);
|
||||
const { t } = useTranslation('base');
|
||||
|
||||
const [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctYn] = form.watch([
|
||||
@@ -123,11 +121,6 @@ export default function RainRegForm({
|
||||
|
||||
const [regCtpvCd, regSggcd] = form.watch(["ctpvCd", "sggCd"]);
|
||||
|
||||
// form 값이 변경될 때마다 로그 출력
|
||||
useEffect(() => {
|
||||
const subscription = form.watch((value) => { });
|
||||
return () => subscription.unsubscribe();
|
||||
}, [form]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
@@ -411,8 +404,8 @@ export default function RainRegForm({
|
||||
control={form.control}
|
||||
name="reuseBuilding.0.rainyObj.filtrTrtmfctPrs"
|
||||
render={({ field }) => {
|
||||
const value = field.value;
|
||||
const isUnknown = value === null || value === "-"; // 또는 Number(value) === -1
|
||||
// const value = field.value;
|
||||
// const isUnknown = value === null || value === "-"; // 또는 Number(value) === -1
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function RswtrRegForm({
|
||||
setIsModal?: (isModal: boolean) => void;
|
||||
readonly?: boolean;
|
||||
}) {
|
||||
const { rswt, code, rswtBdstUpdate, rswtBdstReg } = useWrStore(
|
||||
const { code, rswtBdstUpdate, rswtBdstReg } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const [divStyle, setDivStyle] = useState("h-[53vh]");
|
||||
|
||||
@@ -24,7 +24,7 @@ import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type: string, setIsRegExcel:(open:boolean) =>void ,setYearChange:(year:string)=> void }) {
|
||||
const { rswtChkgdn, rainChkExcelDataUPload, rswtChkExceDataUpload } =
|
||||
const { rainChkExcelDataUPload, rswtChkExceDataUpload } =
|
||||
useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
@@ -143,18 +143,18 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
|
||||
}
|
||||
}, [file]);
|
||||
|
||||
function findMatchingItems<T>(
|
||||
arrayA: T[],
|
||||
arrayB: T[],
|
||||
keySelector: (item: T) => string,
|
||||
condition?: (item: T) => boolean
|
||||
): T[] {
|
||||
const bKeySet = new Set(arrayB.map(keySelector));
|
||||
return arrayA.filter(
|
||||
(item) =>
|
||||
(!condition || condition(item)) && bKeySet.has(keySelector(item))
|
||||
);
|
||||
}
|
||||
// function findMatchingItems<T>(
|
||||
// arrayA: T[],
|
||||
// arrayB: T[],
|
||||
// keySelector: (item: T) => string,
|
||||
// condition?: (item: T) => boolean
|
||||
// ): T[] {
|
||||
// const bKeySet = new Set(arrayB.map(keySelector));
|
||||
// return arrayA.filter(
|
||||
// (item) =>
|
||||
// (!condition || condition(item)) && bKeySet.has(keySelector(item))
|
||||
// );
|
||||
// }
|
||||
|
||||
const onSubmit = (values: z.infer<typeof chkgdRegExcel>) => {
|
||||
if (values.chckYr === "") {
|
||||
@@ -227,7 +227,6 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="file"
|
||||
@@ -236,7 +235,11 @@ export default function ChkgdExcel({ type,setIsRegExcel ,setYearChange }: { type
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={handleFileChange}
|
||||
onChange={(file) =>{
|
||||
handleFileChange( file)
|
||||
////TODO : 폼 을 써야하는 지 확인 필요
|
||||
console.log(field.value)
|
||||
} }
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
|
||||
import { pbnPrfRegExcelZod } from "@/app/store/prfmncReg/pbnstPrfmncReg/headList";
|
||||
import type { FcPrfType, PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
import type {
|
||||
FcPrfType,
|
||||
PrfType,
|
||||
} from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
import { yearOptions } from "@/components/lib/func/commom";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import {
|
||||
FileUpload,
|
||||
FormField,
|
||||
FormUi,
|
||||
SelectBox,
|
||||
Form,
|
||||
Title,
|
||||
type SelectDataType,
|
||||
filePicked,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
@@ -21,9 +20,15 @@ import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelData}: { data: FcPrfType ,setIsExcelOPen:(open:boolean )=>void,setModalExcelData:(excelData :PrfType)=>void }) {
|
||||
const { prfmnRegData } = useWrStore((state) => state);
|
||||
|
||||
export default function PbnPrfExcelModal({
|
||||
data,
|
||||
setIsExcelOPen,
|
||||
setModalExcelData,
|
||||
}: {
|
||||
data: FcPrfType;
|
||||
setIsExcelOPen: (open: boolean) => void;
|
||||
setModalExcelData: (excelData: PrfType) => void;
|
||||
}) {
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
const [excelData, setExcelData] = useState<PrfType[]>();
|
||||
const form = useForm<z.infer<typeof pbnPrfRegExcelZod>>({
|
||||
@@ -40,15 +45,14 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
}
|
||||
};
|
||||
const onSubmit = (values: z.infer<typeof pbnPrfRegExcelZod>) => {
|
||||
|
||||
if (excelData) {
|
||||
// prfmnRegData(1,'41', excelData as unknown as PrfType);
|
||||
////TODO: 궅이 서브밋을 써야하는 이유가 있는지 ?
|
||||
console.log("values ", values);
|
||||
// prfmnRegData(1,'41', excelData as unknown as PrfType); 활성화시 스토어 활성화 칠요
|
||||
|
||||
setModalExcelData(excelData as unknown as PrfType)
|
||||
setIsExcelOPen(false)
|
||||
setModalExcelData(excelData as unknown as PrfType);
|
||||
setIsExcelOPen(false);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
useEffect(() => {
|
||||
if (data && data.bscFctNm)
|
||||
@@ -57,12 +61,11 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
form.setValue("pbnstRuseFcltNm", data.ruseUtztnFcltNm);
|
||||
}, [data]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (file) {
|
||||
const isFile = file
|
||||
const isFile = file;
|
||||
if (form.getValues("ym").length < 1) {
|
||||
toast.error("파일업로드 이전에 등록년도를 작성해주세요 " );
|
||||
toast.error("파일업로드 이전에 등록년도를 작성해주세요 ");
|
||||
setFile(null);
|
||||
return;
|
||||
}
|
||||
@@ -70,7 +73,13 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
if (isFile) {
|
||||
filePicked(isFile, 0).then((res) => {
|
||||
if (res !== undefined)
|
||||
setExcelData(excelToPbnPrfData(res as unknown as JSON[], form.getValues("ym"), form.getValues('pbnstRuseFcltFk')) as PrfType[])
|
||||
setExcelData(
|
||||
excelToPbnPrfData(
|
||||
res as unknown as JSON[],
|
||||
form.getValues("ym"),
|
||||
form.getValues("pbnstRuseFcltFk")
|
||||
) as PrfType[]
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -117,7 +126,7 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
<FormUi label="시설명">
|
||||
<Input
|
||||
className="text-3xl"
|
||||
value={field.value || ''}
|
||||
value={field.value || ""}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
@@ -133,7 +142,7 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
<FormUi label="재이용시설명">
|
||||
<Input
|
||||
className="flex-1 text-3xl"
|
||||
value={field.value || ''}
|
||||
value={field.value || ""}
|
||||
onChange={field.onChange}
|
||||
readOnly
|
||||
/>
|
||||
@@ -160,13 +169,16 @@ export default function PbnPrfExcelModal({ data ,setIsExcelOPen ,setModalExcelDa
|
||||
|
||||
></FileUpload> */}
|
||||
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={handleFileChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={(file) => {
|
||||
console.log(" field. valus", field.value);
|
||||
if (file) handleFileChange(file);
|
||||
}}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -9,15 +9,11 @@ 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 { useEffect, useRef, useState } from "react";
|
||||
import { Label, } from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function ConstCostFeeTable({
|
||||
setReturnData,
|
||||
}: {
|
||||
setReturnData: (data: any) => void;
|
||||
}) {
|
||||
const { coRvw, constCostRes, getConstCostFee } = useWrStore((state) => state);
|
||||
export function ConstCostFeeTable() {
|
||||
const { coRvw, constCostRes } = useWrStore((state) => state);
|
||||
const [year, setYear] = useState<string>(String(new Date().getFullYear()));
|
||||
|
||||
const [constCostData, setConstCostData] = useState<ContCostMap[]>([]);
|
||||
|
||||
@@ -11,9 +11,11 @@ import { useEffect, useState } from "react"
|
||||
export default function DrgtDetailModal({
|
||||
data,
|
||||
}: {
|
||||
data: customDrgt;
|
||||
data: customDrgt[];
|
||||
}) {
|
||||
const [excelData, setExcelData] = useState<any[]>();
|
||||
|
||||
// const [isSggNm, setIsSggNm] = useState('')
|
||||
const [excelData, setExcelData] = useState<any[]>();
|
||||
const excelClick = () => {
|
||||
downloadExcel({
|
||||
data: excelData ?? [],
|
||||
@@ -30,10 +32,14 @@ export default function DrgtDetailModal({
|
||||
return {
|
||||
"년": item.year,
|
||||
"월": item.month,
|
||||
"가뭄상태": item.drgtState,
|
||||
"가뭄상태": item.drgtState, // Access drgtState directly from the item
|
||||
}
|
||||
}) : [];
|
||||
setExcelData(exData)
|
||||
// if(data&&data[0].sggNm){
|
||||
////TODO: data.sggNm [0[인지 data.sggNm 인지 사용하는지 확인필요
|
||||
// setIsSggNm(data[0].sggNm)
|
||||
// }
|
||||
}, [data])
|
||||
|
||||
return (
|
||||
@@ -41,7 +47,7 @@ export default function DrgtDetailModal({
|
||||
<div className="grid grid-cols-4 gap-4 h-full">
|
||||
<div className="col-span-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<Title title={`우리동네가뭄 상세내용 - ${data[0].sggNm}`} />
|
||||
<Title title={`우리동네가뭄 상세내용 - ${data[0]&&data[0].sggNm ?data[0].sggNm:'' }`} />
|
||||
<div className="flex flex-row space-x-2">
|
||||
<Button
|
||||
size={"sm"}
|
||||
@@ -59,11 +65,15 @@ export default function DrgtDetailModal({
|
||||
<ScrollArea className="h-[63vh]">
|
||||
<UiTable
|
||||
headName={undefined}
|
||||
tableData={data}
|
||||
tableData={data }
|
||||
headlist={drgtDetailHeadListExport}
|
||||
pageSize={10}
|
||||
total={10000}
|
||||
cellClick={(index: number | undefined, headId: string) => { }}
|
||||
cellClick={(index: number | undefined, headId: string) => {
|
||||
console.log(' indx ' , index)
|
||||
console.log(' headId ' , headId)
|
||||
|
||||
}}
|
||||
onPageChange={() => { }}
|
||||
></UiTable>
|
||||
</ScrollArea>
|
||||
|
||||
@@ -2,20 +2,13 @@
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
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 { UiTable } from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Input, Label, ScrollArea } from "@common/components/ui";
|
||||
import { Scroll } from "lucide-react";
|
||||
import { Input, Label } from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function RateFeeTableModal({
|
||||
setReturnData,
|
||||
}: {
|
||||
setReturnData: (data: any) => void;
|
||||
}) {
|
||||
const { code, coRvw, rateFeeRes } = useWrStore((state) => state);
|
||||
const [year, setYear] = useState<string>(String(new Date().getFullYear()));
|
||||
export function RateFeeTableModal() {
|
||||
const { coRvw, rateFeeRes } = useWrStore((state) => state);
|
||||
const [reateFeeTable, setRateFeeTable] = useState<rateFeeType[]>([]);
|
||||
|
||||
const gubunLabelMap: Record<number, string> = {
|
||||
|
||||
@@ -1,76 +1,80 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { coRegExcel } from "@/app/store/matDmd/coSttn/headList";
|
||||
import type { customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { names } from "@/app/store/matDmd/ldrmntCoSttn/excel";
|
||||
import { filePicked, FileUpload, FormUi, Title } from "@common/business_components/ui";
|
||||
import { Form, FormField } from "@common/business_components/ui/form";
|
||||
import { filePicked, Title } from "@common/business_components/ui";
|
||||
import { Form } from "@common/business_components/ui/form";
|
||||
import LoadingOverlay from "@common/business_components/ui/loadingBar";
|
||||
import { Button, Input, Progress } from "@common/components/ui";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => void }) {
|
||||
export default function CoRegExcel({
|
||||
isModal,
|
||||
}: {
|
||||
isModal: (open: boolean) => void;
|
||||
}) {
|
||||
const { ldrmnt, loadingOpen } = useWrStore((state) => state);
|
||||
const { isLoading } = ldrmnt;
|
||||
const form = useForm<z.infer<typeof coRegExcel>>({
|
||||
resolver: zodResolver(coRegExcel),
|
||||
});
|
||||
const { ldrmntRegData, ldrmntDelete } = useWrStore((state) => state);
|
||||
const [excelData, setExcelData] = useState<customLdrmnt[]>();
|
||||
const { ldrmntRegData } = useWrStore((state) => state);
|
||||
|
||||
const [file, setFiles] = useState<File | undefined>();
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const selectedFile = e.target.files?.[0];
|
||||
if (selectedFile) {
|
||||
setFiles(selectedFile);
|
||||
}
|
||||
};
|
||||
// const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
// const selectedFile = e.target.files?.[0];
|
||||
// if (selectedFile) {
|
||||
// setFiles(selectedFile);
|
||||
// }
|
||||
// };
|
||||
|
||||
const onSubmit = (values: z.infer<typeof coRegExcel>) => {
|
||||
//TODO:Onsubmit을 써야하는지
|
||||
const onSubmit = () => {
|
||||
loadingOpen(true);
|
||||
if (file) {
|
||||
filePicked(file, 0).then(async (res) => {
|
||||
filePicked(file, 0)
|
||||
.then(async (res) => {
|
||||
try {
|
||||
const array: { [key: string]: string | number }[] = [];
|
||||
if (Array.isArray(res)) {
|
||||
res.some((item) => {
|
||||
const object: { [key: string]: string | number } = {};
|
||||
Object.keys(names).some((key) => {
|
||||
if (item && names[key] !== undefined) {
|
||||
// if (key === "공장관리번호") {
|
||||
// item[key] = String(item[key])
|
||||
// } else {
|
||||
object[names[key] as string] = item[key];
|
||||
// }
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
array.push(object);
|
||||
|
||||
try {
|
||||
let array: { [key: string]: string | number }[] = []
|
||||
if (Array.isArray(res)) {
|
||||
res.some((item, index) => {
|
||||
let object: { [key: string]: string | number } = {}
|
||||
Object.keys(names).some((key) => {
|
||||
if (item && names[key] !== undefined) {
|
||||
// if (key === "공장관리번호") {
|
||||
// item[key] = String(item[key])
|
||||
// } else {
|
||||
object[names[key] as string] = item[key];
|
||||
// }
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
array.push(object)
|
||||
|
||||
return false;
|
||||
})
|
||||
});
|
||||
}
|
||||
await ldrmntRegData(array);
|
||||
isModal(false);
|
||||
loadingOpen(false);
|
||||
toast.success(`잠재수요처 등록이 완료되었습니다.`);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
loadingOpen(false);
|
||||
alert(e);
|
||||
return true;
|
||||
}
|
||||
await ldrmntRegData(array);
|
||||
isModal(false);
|
||||
loadingOpen(false);
|
||||
toast.success(`잠재수요처 등록이 완료되었습니다.`);
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
loadingOpen(false);
|
||||
alert(e)
|
||||
return true;
|
||||
}
|
||||
}).catch((e) => {
|
||||
console.log("file", e);
|
||||
});
|
||||
};
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("file", e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -85,28 +89,22 @@ export default function CoRegExcel({ isModal }: { isModal: (open: boolean) => vo
|
||||
<h3 className="text-2xl font-bold text-gray-900 mt-1 ml-7">
|
||||
{"잠재수요처 파일"}
|
||||
</h3>
|
||||
|
||||
<Button className="" type="submit" size={"sm"}>
|
||||
<Button className="" type="submit" size={"sm"} onClick={onSubmit}>
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="file"
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={handleFileChange}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
/>
|
||||
</div>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
<div className="space-y-4 p-4">
|
||||
<Input
|
||||
type="file"
|
||||
onChange={(e) => {
|
||||
const selectedFile = e.target.files?.[0];
|
||||
if (selectedFile) setFiles(selectedFile);
|
||||
}}
|
||||
accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { UiTable } from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { useEffect } from "react";
|
||||
|
||||
|
||||
|
||||
import type {
|
||||
@@ -10,7 +8,7 @@ import type {
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
export default function BdstChgModal({ chgBuilding }: { chgBuilding:chgBuilding[] }) {
|
||||
|
||||
const {bdst,rain} = useWrStore((state) => {
|
||||
const {bdst} = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const { bdstChgHeadList } = bdst;
|
||||
@@ -26,7 +24,6 @@ const { bdstChgHeadList } = bdst;
|
||||
onPageChange={() => {}}
|
||||
headName={"○건축물 변경 이력"}
|
||||
tableData={chgBuilding}
|
||||
children={undefined}
|
||||
cellClick={undefined}
|
||||
/>
|
||||
</ListDiv>
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "@common/business_components";
|
||||
import { Button, Input, Label } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getCity, tableData } from "@/components/lib/func/commom";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
|
||||
import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
|
||||
import RainRegForm from "@/components/ui/form/fcltReg/rainReg/rainRegForm";
|
||||
@@ -35,17 +35,15 @@ type BdstTypeMap = {
|
||||
interface BdstRegProps<T extends MoType> {
|
||||
moType: T;
|
||||
isModal: boolean;
|
||||
siSggCode?: string;
|
||||
setIsModal?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export function BdstReg<T extends MoType>({
|
||||
moType,
|
||||
setIsModal,
|
||||
siSggCode,
|
||||
isModal,
|
||||
}: BdstRegProps<T>) {
|
||||
const { rain, code, bdst, findBdst } = useWrStore((state) => {
|
||||
const { code, bdst, findBdst } = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
|
||||
@@ -56,14 +54,12 @@ export function BdstReg<T extends MoType>({
|
||||
{} as BdstTypeMap[T]
|
||||
);
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>();
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({
|
||||
sgg: "",
|
||||
city: "",
|
||||
});
|
||||
const [useCityCd, setUserCityCd] = useState<SelectDataType[]>([]);
|
||||
const [useSggCd, setUserSggCd] = useState<SelectDataType[]>([]);
|
||||
const [dataCode, setDataCode] = useState<string>();
|
||||
|
||||
const searchBdst = (searchTxt: string | undefined) => {
|
||||
let data = objSearch.city;
|
||||
@@ -78,7 +74,7 @@ export function BdstReg<T extends MoType>({
|
||||
useEffect(() => {
|
||||
if (code.sggCd.length > 0) {
|
||||
const bdstData = bdst.bdstBase.map((bdst) => {
|
||||
let archArea =
|
||||
const archArea =
|
||||
bdst?.archArea.split(".")[0] !== "-1"
|
||||
? bdst?.archArea.split(".")[0]
|
||||
: "확인불가";
|
||||
@@ -117,8 +113,7 @@ export function BdstReg<T extends MoType>({
|
||||
}, [userSiSggCd, code.cityCd, code.sggCd]);
|
||||
|
||||
const tableClick: (val: number | undefined, headId: string) => void = (
|
||||
val,
|
||||
headId
|
||||
val
|
||||
) => {
|
||||
if (val !== undefined && bdst?.bdstBase.length > 0) {
|
||||
const data: BdstTypeMap[T] = bdst?.bdstBase[val];
|
||||
@@ -195,6 +190,7 @@ export function BdstReg<T extends MoType>({
|
||||
cellClick={(idx, headId) => tableClick(idx, headId || "")}
|
||||
onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
console.log("page ", page);
|
||||
}}
|
||||
></UiTable>
|
||||
</div>
|
||||
@@ -212,16 +208,20 @@ export function BdstReg<T extends MoType>({
|
||||
<RswtrRegForm
|
||||
rswtForm={rainBdstForm as customRswtBdst}
|
||||
isModal={isModal}
|
||||
setIsModal={(open) => {
|
||||
setIsModal && setIsModal(open);
|
||||
setIsModal={(open?: boolean) => {
|
||||
if (setIsModal && open) {
|
||||
setIsModal(open);
|
||||
}
|
||||
}}
|
||||
></RswtrRegForm>
|
||||
) : (
|
||||
<HtdflRegForm
|
||||
htdflForm={rainBdstForm as unknown as customHtdflBdst}
|
||||
isModal={true}
|
||||
setIsModal={(open) => {
|
||||
setIsModal && setIsModal(open);
|
||||
setIsModal={(open?: boolean) => {
|
||||
if (setIsModal && open) {
|
||||
setIsModal(open);
|
||||
}
|
||||
}}
|
||||
></HtdflRegForm>
|
||||
)}
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type {
|
||||
pubHasuType,
|
||||
fcBizType,
|
||||
fcOrgwtType,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable";
|
||||
import { Title, UiTable } from "@common/business_components/ui";
|
||||
import { Title } from "@common/business_components/ui";
|
||||
import { Label } from "@common/business_components/ui/form/lib/label";
|
||||
import { Button } from "@common/business_components/ui/table/lib/button";
|
||||
import { Input } from "@common/components/ui";
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
"use client";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import {
|
||||
pbnstRegZod,
|
||||
type customPbnst,
|
||||
type PbnstRegArrrayType,
|
||||
type pubHasuType,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm";
|
||||
import { ScrollArea } from "@common/business_components";
|
||||
@@ -18,12 +16,10 @@ import {
|
||||
import { useEffect, useState } from "react";
|
||||
import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm";
|
||||
import {
|
||||
useFieldArray,
|
||||
type FieldErrors,
|
||||
type UseFormReturn,
|
||||
} from "react-hook-form";
|
||||
import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg";
|
||||
import toast from "react-hot-toast";
|
||||
import type { z } from "zod";
|
||||
|
||||
export function PbnstRegModal({
|
||||
@@ -36,10 +32,13 @@ export function PbnstRegModal({
|
||||
onInvalid:(errors: FieldErrors<{ items: z.infer<typeof pbnstRegZod>[] }>) => void
|
||||
}) {
|
||||
|
||||
const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>(
|
||||
{} as customPbnst
|
||||
);
|
||||
const [currentTab, setCurrentTab] = useState<string>("mng");
|
||||
// const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>(
|
||||
// {} as customPbnst
|
||||
// );
|
||||
|
||||
//TODO: 유즈 스테이트에 set만해도 되나?
|
||||
const [, setCurrentTab] = useState<string>("mng");
|
||||
//const setCurrentTab = "mng"
|
||||
const [indexMng, setIndexMng] = useState<number>(0);
|
||||
const [indexBiz, setIndexBiz] = useState<number>(0);
|
||||
|
||||
@@ -51,70 +50,7 @@ export function PbnstRegModal({
|
||||
setPbnstInsert(data[0]);
|
||||
}
|
||||
};
|
||||
// const onInvalid = (
|
||||
// errors: FieldErrors<{ items: z.infer<typeof pbnstRegZod>[] }>
|
||||
// ) => {
|
||||
// // 재귀 함수를 사용해 중첩된 에러 객체에서 모든 에러 메시지와 경로를 찾습니다.
|
||||
|
||||
|
||||
// const findAllErrors = (
|
||||
// errorObject: any,
|
||||
// path: (string | number)[] = []
|
||||
// ): { message: string; path: (string | number)[] }[] => {
|
||||
// if (!errorObject) return [];
|
||||
|
||||
// return Object.keys(errorObject).flatMap((key) => {
|
||||
// const value = errorObject[key];
|
||||
// const currentKey = !isNaN(parseInt(key)) ? parseInt(key) : key;
|
||||
// const newPath = [...path, currentKey];
|
||||
// if (value && typeof value === "object") {
|
||||
// if (typeof value.message === "string") {
|
||||
// return [{ message: value.message, path: newPath }]; // 에러 메시지와 경로 반환
|
||||
// }
|
||||
// return findAllErrors(value, newPath);
|
||||
// }
|
||||
// return [];
|
||||
// });
|
||||
// };
|
||||
|
||||
|
||||
// const errorList = findAllErrors(errors);
|
||||
|
||||
|
||||
// if (errorList.length > 0) {
|
||||
// errorList.forEach((errorInfo) => {
|
||||
// const { message, path } = errorInfo;
|
||||
// let prefix = "";
|
||||
// const itemsIndex = path.indexOf("items");
|
||||
|
||||
|
||||
// if (itemsIndex > -1 && path.length > itemsIndex + 1) {
|
||||
// const itemIdx = path[itemsIndex + 1] as number;
|
||||
// const facilityName = form.getValues(
|
||||
// `items.${itemIdx}.ruseUtztnFcltNm`
|
||||
// );
|
||||
// if (facilityName) {
|
||||
// prefix += `[${facilityName}] `;
|
||||
// }
|
||||
|
||||
// const fcBizsIndex = path.indexOf("fcBizs");
|
||||
// if (fcBizsIndex > -1 && path.length > fcBizsIndex + 1) {
|
||||
// const bizIdx = path[fcBizsIndex + 1] as number;
|
||||
// const cycle = form.getValues(
|
||||
// `items.${itemIdx}.fcBizs.${bizIdx}.cycl`
|
||||
// );
|
||||
// if (cycle) {
|
||||
// prefix += `[${cycle}차수] `;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// toast.error(`${prefix}${message}`);
|
||||
// });
|
||||
// }
|
||||
// };
|
||||
|
||||
|
||||
const handleTabChange = (value: string) => {
|
||||
setCurrentTab(value);
|
||||
};
|
||||
@@ -158,7 +94,7 @@ export function PbnstRegModal({
|
||||
<PbnstMngForm
|
||||
form={form}
|
||||
formType={"reg"}
|
||||
firstFcltData={pbnstBdstForm}
|
||||
// firstFcltData={pbnstBdstForm}
|
||||
indexMng={indexMng}
|
||||
setIndexMng={setIndexMng}
|
||||
/>
|
||||
@@ -170,7 +106,7 @@ export function PbnstRegModal({
|
||||
indexBiz={indexBiz}
|
||||
setIndexBiz={setIndexBiz}
|
||||
formType={"reg"}
|
||||
firstBizData={pbnstBdstForm.fcBizs}
|
||||
// firstBizData={pbnstBdstForm.fcBizs}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
|
||||
Reference in New Issue
Block a user