하수 재이용 등록 작업 완료
This commit is contained in:
@@ -103,7 +103,7 @@ export const ruseFcltinfo: formDetailType[] = [
|
||||
{ id: "majorPrcsMsrcCd", lable: "주처리공법" },
|
||||
{ id: "addr", lable: "위치(주소)" },
|
||||
{ id: "rprcsMthdCd", lable: "재처리방식" },
|
||||
{ id: "inoutYn", lable: "위치(처리장 내외)" }, // 머가 내? 외?,
|
||||
{ id: "inoutYn", lable: "위치(처리장 내외)" ,type: "selectYn" }, // 머가 내? 외?,
|
||||
{ id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" },
|
||||
];
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { z } from "zod";
|
||||
import type { TableUpperProps } from "../rainReg";
|
||||
import { TEST_UUID, type TableUpperProps } from "../rainReg";
|
||||
import {
|
||||
deleteFectch,
|
||||
fetchType,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
fcBizSchema,
|
||||
type customPbnst,
|
||||
type fcBizType,
|
||||
type PbnstUpdateIndex,
|
||||
type pbnstInsertIndex,
|
||||
type pubHasuType,
|
||||
} from "./type";
|
||||
import type { SelectDataType } from "@common/business_components/ui";
|
||||
@@ -51,22 +51,23 @@ export type pubFacState = {
|
||||
pbnstDemandHeadList: TableUpperProps[];
|
||||
fcOrgwtsHeadList: TableUpperProps[];
|
||||
pbnstMngRegData: customPbnst[];
|
||||
pbnsUpdateIndex: PbnstUpdateIndex;
|
||||
dmdComList:any[]
|
||||
pbnsUpdateIndex: pbnstInsertIndex;
|
||||
dmdComList: any[];
|
||||
};
|
||||
};
|
||||
type pubFacActions = {
|
||||
pubHasuInit: (page: string, sggOrCity: string) => void;
|
||||
pbnstRegInit: (pubHasuRes: pubHasuType) => void;
|
||||
pbnstReg: (txt: string | undefined) => void;
|
||||
pbnstUpdate(pbnstRes: customPbnst): Promise<void>;
|
||||
pbnstInsert(pbnstRes: customPbnst): Promise<void>;
|
||||
appendRuseFclt(array: customPbnst[]): void;
|
||||
fileDelete: (atflCd: string) => void;
|
||||
fileDownLoad: (atflCd: string) => void;
|
||||
pbnstMngData: (data: customPbnst[]) => void;
|
||||
pbnstBizData(data: fcBizType): void;
|
||||
getBizCycle: (pbnstObj: customPbnst) => void;
|
||||
getDmdCompany:(txt :string)=>void;
|
||||
getPbnstUpdateIndex: (data: PbnstUpdateIndex) => void;
|
||||
getBizCycle: (pbnstObj: customPbnst) => void;
|
||||
getDmdCompany: (txt: string) => void;
|
||||
getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
|
||||
};
|
||||
|
||||
export type pubFacType = pubFacState & pubFacActions;
|
||||
@@ -87,8 +88,8 @@ export const pubFacStateExport: pubFacState = {
|
||||
pbnstDemandHeadList: pbnstDemandHeadList,
|
||||
fcOrgwtsHeadList: fcOrgwtsHeadList,
|
||||
pbnstMngRegData: [],
|
||||
pbnsUpdateIndex : {} as PbnstUpdateIndex,
|
||||
dmdComList:[]
|
||||
pbnsUpdateIndex: {} as pbnstInsertIndex,
|
||||
dmdComList: [],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -121,6 +122,34 @@ const initFetch = async (code: string | undefined) => {
|
||||
return pbnstRes;
|
||||
};
|
||||
|
||||
const writeRgtrAndMdfr = (data: customPbnst) => {
|
||||
data.rgtr = TEST_UUID;
|
||||
data.mdfr = TEST_UUID;
|
||||
data.fcBizs = data.fcBizs.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
item.fcOrgwts = item.fcOrgwts?.map((item) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
item.rgtr = TEST_UUID;
|
||||
return item;
|
||||
});
|
||||
|
||||
return item;
|
||||
});
|
||||
data.fcOpers = data.fcOpers.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
return item;
|
||||
});
|
||||
data.fcFiles = data.fcFiles.map((item) => {
|
||||
item.rgtr = TEST_UUID;
|
||||
item.mdfr = TEST_UUID;
|
||||
return item;
|
||||
});
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
return {
|
||||
pubHasuInit: async (page: string, sggOrCity: string) => {
|
||||
@@ -140,7 +169,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
}
|
||||
},
|
||||
|
||||
pbnstRegInit: async (pubHasuRes: pubHasuType ) => {
|
||||
pbnstRegInit: async (pubHasuRes: pubHasuType) => {
|
||||
try {
|
||||
//const pbnstRes = await initFetch(txt);
|
||||
const pbnstRes = exampleData;
|
||||
@@ -160,7 +189,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
|
||||
pbnstReg: async (txt: string | undefined) => {
|
||||
try {
|
||||
const pbnstRes = await hasuListFetch('11' , '11');
|
||||
const pbnstRes = await hasuListFetch("11", "11");
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
@@ -173,11 +202,13 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
console.log(errorHasu);
|
||||
}
|
||||
},
|
||||
pbnstUpdate: async (pbnstRes: customPbnst) => {
|
||||
pbnstInsert: async (pbnstRes: customPbnst) => {
|
||||
try {
|
||||
|
||||
console.log('writeRgtrAndMdfr(pbnstRes) ', writeRgtrAndMdfr(pbnstRes))
|
||||
const response = await postFectch(
|
||||
`/reuseFc/pubFc`,
|
||||
JSON.stringify(pbnstRes)
|
||||
JSON.stringify( writeRgtrAndMdfr(pbnstRes))
|
||||
);
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
@@ -199,6 +230,8 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
val: item.cycl,
|
||||
};
|
||||
});
|
||||
|
||||
console.log(" pbnstBizCycle ", pbnstBizCycle);
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
@@ -243,24 +276,23 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
console.error("Error downloading file:", error);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
pbnstMngData: (data: customPbnst[]) => {
|
||||
if(data.length > 0){
|
||||
|
||||
|
||||
if (data.length > 0) {
|
||||
}
|
||||
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnstMngRegData = data;
|
||||
state.pbnst.pbnstBizCycle=data.length <=0 ? [{ text: "없음", val: "1" }] : state.pbnst.pbnstBizCycle
|
||||
state.pbnst.pbnstBizCycle =
|
||||
data.length <= 0
|
||||
? [{ text: "없음", val: "1" }]
|
||||
: state.pbnst.pbnstBizCycle;
|
||||
return state;
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
pbnstBizData: (data: fcBizType) => {
|
||||
return set((state: pubFacState) => {
|
||||
|
||||
|
||||
if (state.pbnst.pbnstMngRegData) {
|
||||
const regData = state.pbnst.pbnstMngRegData.find(
|
||||
(item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk
|
||||
@@ -277,25 +309,37 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
|
||||
}
|
||||
return state;
|
||||
});
|
||||
},getDmdCompany: async (txt:string)=>{
|
||||
|
||||
const company = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/${txt}/3`)
|
||||
},
|
||||
getDmdCompany: async (txt: string) => {
|
||||
const company = await getFetch(fetchType.WR, `/reuseFc/request/${txt}/3`);
|
||||
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
},
|
||||
getpbnstInsertIndex: async (data: pbnstInsertIndex) => {
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnsUpdateIndex = data;
|
||||
return state;
|
||||
});
|
||||
},
|
||||
appendRuseFclt: async (array: customPbnst[]) => {
|
||||
try {
|
||||
return set((state: pubFacState) => ({
|
||||
...state,
|
||||
pbnst: {
|
||||
...state.pbnst,
|
||||
pbnstRes: array,
|
||||
isInit: false,
|
||||
},
|
||||
|
||||
}))
|
||||
},getPbnstUpdateIndex:async(data : PbnstUpdateIndex)=>{
|
||||
return set((state: pubFacState) => {
|
||||
state.pbnst.pbnsUpdateIndex = data
|
||||
return state;
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
)}
|
||||
};
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ export type selectLabel = {
|
||||
val: string;
|
||||
};
|
||||
|
||||
export type PbnstUpdateIndex ={
|
||||
export type pbnstInsertIndex ={
|
||||
mng:number,
|
||||
biz:number
|
||||
}
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -22,7 +22,7 @@ export function middleware(req: NextRequest) {
|
||||
if (pathname.startsWith("/attach-service")) {
|
||||
const requestHeaders = new Headers(req.headers);
|
||||
const token =
|
||||
"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4NzkzNzAwfQ.BK1F_t9ou3R26aLc02lsyOsr2tMvqQjOdKrLz5rViUEFq_AURtvnbAxfhVCdJVgFXgUyesPln1Ydl6to-KMKbw";
|
||||
"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4ODQ4NDkxfQ.ZiYpKxAMyyoPuUquxsWxfQbMBzYN4tsa7itZ49_OEsdGvbUUmKzrIV6Or7VVbEjtAqhh7W97nqB5EP6GRzFC9Q";
|
||||
const userId = "a0ec7a07-752a-4f7f-89a6-854e63d2e3a0";
|
||||
//const token = req.cookies.get(CLAIM_NAME)?.value;
|
||||
//const userId = req.cookies.get(AUTH_USER_ID)?.value;
|
||||
|
||||
Reference in New Issue
Block a user