하수 재이용 등록 작업 완료

This commit is contained in:
leedj312
2025-06-02 16:23:08 +09:00
parent 67400409fc
commit 72585f9d91
8 changed files with 155 additions and 68 deletions
+1 -5
View File
@@ -35,11 +35,7 @@ export const getFetch = async (type: string, url: string) => {
const blob = await response.blob();
const blobUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
// 파일명 추출 (서버에서 header에 Content-Disposition을 보낼 경우 활용)
const disposition = response.headers.get("Content-Disposition");
const match = disposition?.match(/filename="?(.+)"?/);
const filename = match?.[1] || "downloaded_file";
const filename = "downloaded_file.PDF";
a.href = blobUrl;
a.download = filename;
@@ -12,6 +12,7 @@ import {
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList";
import {
fcBizSchema,
type customPbnst,
type fcBizType,
type ppInstlType,
} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
@@ -40,9 +41,16 @@ export function PbnstBuseForm({
firstBizData?: fcBizType[];
}) {
const ref = useRef<ppInstlType[] | null>(null);
const { code, pbnst, pbnstBizData ,getPbnstUpdateIndex} = useWrStore((state) => state);
const {
code,
pbnst,
pbnstBizData,
getpbnstInsertIndex,
appendRuseFclt,
getBizCycle,
} = useWrStore((state) => state);
const { pbnstBizCycle, pbnstRes } = pbnst;
const [getBizCycle, setBizCycle] = useState("1");
const [bizCycle, setBizCycle] = useState("1");
const [ppiSelectList, setPpiSelectList] =
useState<[{ name: string; val: SelectDataType[] }]>();
const [ppiYn, setPpiYn] = useState("Y");
@@ -57,11 +65,13 @@ export function PbnstBuseForm({
pbnst.pbnstMngRegData[0]?.fcBizs
? (pbnst.pbnstMngRegData[0].fcBizs[0] ?? {})
: formType === "update" &&
typeof pbnst.pbnsUpdateIndex.biz === "number" &&
pbnst.pbnsUpdateIndex.biz >= 0 &&
pbnst.pbnstRes
? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[pbnst.pbnsUpdateIndex.biz]
: fcBizSchema.parse({}),
typeof pbnst.pbnsUpdateIndex.biz === "number" &&
pbnst.pbnsUpdateIndex.biz >= 0 &&
pbnst.pbnstRes
? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[
pbnst.pbnsUpdateIndex.biz
]
: fcBizSchema.parse({}),
});
// 2. Define a submit handler.
@@ -69,6 +79,33 @@ export function PbnstBuseForm({
// console.log(values);
}
// 2. Define a submit handler.
function addRuseFcltObj() {
const newItem = fcBizSchema.parse({});
const index = pbnst.pbnsUpdateIndex.mng;
let regData: fcBizType = {} as fcBizType;
if (
pbnst.pbnstRes &&
pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] &&
pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs
) {
regData = {
pbnstRuseFcltFk:
String(pbnst.pbnstRes[0]?.swtrmtFcltFk) +
String(pbnst.pbnstRes.length + 1),
cycl: Number(
(pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs?.length || 0) + 1
),
} as fcBizType;
const newPbnstRes = [...(pbnst.pbnstRes as customPbnst[])];
newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData);
getBizCycle(newPbnstRes[index] as customPbnst);
appendRuseFclt(newPbnstRes);
}
}
const { fields: fcOrgwtFiled } = useFieldArray({
control: form.control,
name: "fcOrgwts",
@@ -143,12 +180,12 @@ export function PbnstBuseForm({
};
useEffect(() => {
if (getBizCycle&&formType !== "reg") {
const index = Number(getBizCycle) - 1;
if (bizCycle && formType !== "reg") {
const index = Number(bizCycle) - 1;
form.reset(pbnst.pbnstResObj?.fcBizs[index]);
ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? [];
}
}, [getBizCycle, pbnst.pbnstResObj , formType]);
}, [bizCycle, pbnst.pbnstResObj, formType]);
useEffect(() => {
const ppl = [] as { name: string; val: SelectDataType[] }[];
@@ -186,16 +223,23 @@ export function PbnstBuseForm({
<SelectBox
label=""
selectArray={pbnstBizCycle}
value={getBizCycle ?? pbnstBizCycle[0]?.val}
value={bizCycle ?? pbnstBizCycle[0]?.val}
className={""}
selectClass={selectClass}
onSelectValue={(val) => {
setBizCycle(String(val));
getPbnstUpdateIndex({...pbnst.pbnsUpdateIndex, biz: Number(val)})
getpbnstInsertIndex({
...pbnst.pbnsUpdateIndex,
biz: Number(val),
});
}}
></SelectBox>
<Button type="submit" size={commonButonSize}>
<Button
onClick={addRuseFcltObj}
type="button"
size={commonButonSize}
>
저장
</Button>
</div>
@@ -18,6 +18,7 @@ import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTab
import {
pbnstRegZod,
type customPbnst,
type fcBizType,
type fcFileType,
type operType,
type selectLabel,
@@ -39,12 +40,13 @@ export function PbnstMngForm({
}) {
const {
pbnst,
pbnstUpdate,
pbnstInsert,
pbnstMngData,
fileDelete,
fileDownLoad,
getBizCycle,
getPbnstUpdateIndex,
getpbnstInsertIndex,
appendRuseFclt
} = useWrStore((state) => state);
const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null);
@@ -86,10 +88,9 @@ export function PbnstMngForm({
if (pbnst.pbnstRes && pbnst.pbnstRes[val]) {
getBizCycle(pbnst.pbnstRes[val]);
form.reset(pbnst.pbnstRes[val]);
getPbnstUpdateIndex({ ...pbnst.pbnsUpdateIndex, mng: val });
getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val });
}
};
const fileDownload = (index: number) => {};
const plusHist = () => {
const regData = {
choose: false,
@@ -205,7 +206,6 @@ export function PbnstMngForm({
useEffect(() => {
const defaultFiles = form.getValues("fcFiles");
console.log("defaultFiles : ", defaultFiles);
if (defaultFiles && defaultFiles.length > 0) {
const relationFileList = defaultFiles.filter(
(item) => item.fileKnd === "계통도"
@@ -241,7 +241,6 @@ export function PbnstMngForm({
) {
const bizData = pbnst.pbnstRes[pbnst.pbnsUpdateIndex.biz];
console.log(" bizData : ", bizData);
if (bizData) {
getBizCycle(bizData);
}
@@ -268,15 +267,19 @@ export function PbnstMngForm({
}));
setFcltNm(fcltNmList);
}, [pbnst.pbnstRes]);
// 2. Define a submit handler.
function onSubmit(values: z.infer<typeof pbnstRegZod>) {
values.fcOpers = fcOpresData || [];
values.fcFiles = regFileList || [];
pbnstUpdate(values);
pbnstInsert(values);
}
useEffect(() => {
if (relationfiles) {
setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || []));
@@ -335,9 +338,9 @@ export function PbnstMngForm({
)}
</div>
<Button type="submit" size={commonButonSize}>
저장
</Button>
{/* <Button onClick={addRuseFcltObj} type="button" size={commonButonSize}>
추가
</Button> */}
</div>
<div>
@@ -18,7 +18,7 @@ import { useEffect, useState } from "react";
import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm";
export function PbnstRegModal({ data }: { data: pubHasuType }) {
const { pbnst, pbnstUpdate } = useWrStore((state) => {
const { pbnst, pbnstInsert } = useWrStore((state) => {
return state;
});
const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>(
@@ -27,7 +27,7 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) {
const [currentTab, setCurrentTab] = useState<string>("mng");
const pbnstRegTotal = () => {
if (pbnst.pbnstMngRegData[0]) pbnstUpdate(pbnst.pbnstMngRegData[0]);
if (pbnst.pbnstMngRegData[0]) pbnstInsert(pbnst.pbnstMngRegData[0]);
};
const handleTabChange = (value: string) => {