잠재수요처 등록, 상세정보 수정
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import { type customLdrmntBdst } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { type customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { ldrmntNodeListExport } from "@/app/store/matDmd/ldrmntCoSttn/headList";
|
||||
import {
|
||||
excelDownload,
|
||||
@@ -34,23 +34,18 @@ export default function LdrmntCoSttn() {
|
||||
(state) => state
|
||||
);
|
||||
const { ldrmntRes } = ldrmnt;
|
||||
const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customLdrmntBdst | undefined }>({ data: undefined, isOpen: false })
|
||||
const [detailModal, setDetailModal] = useState<{ isOpen: boolean, data: customLdrmnt | undefined }>({ data: undefined, isOpen: false })
|
||||
const [pageNation, setPageNation] = useState(1);
|
||||
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>()
|
||||
const [objSearch, setObjSearch] = useState<objSearchType>({ sgg: "", city: "" });
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const [bdstTable, setBdstTable] = useState<customLdrmntBdst[]>();
|
||||
const [codeData, setCodeData] = useState<string>();
|
||||
const [bdstTable, setBdstTable] = useState<customLdrmnt[]>();
|
||||
const [searchTxt, setSearchTxt] = useState<string>();
|
||||
const [bdstChgProps, setBdstChgProps] = useState<{
|
||||
isOpen: boolean;
|
||||
data: customLdrmntBdst[];
|
||||
}>({ isOpen: false, data: [] });
|
||||
|
||||
const excelClick = useCallback(() => {
|
||||
excelDownload(
|
||||
[[]],
|
||||
"잠재수요처 관리",
|
||||
"sample_ldrmnt.xlsx",
|
||||
"sample_ldrmntCoSttn.xlsx",
|
||||
"A1:AL1",
|
||||
2
|
||||
);
|
||||
@@ -86,8 +81,9 @@ export default function LdrmntCoSttn() {
|
||||
|
||||
useEffect(() => {
|
||||
const data = tableData(ldrmntRes, { code });
|
||||
console.log("data", data)
|
||||
const tbData = Array.isArray(data)
|
||||
? data.map((item: customLdrmntBdst) => ({
|
||||
? data.map((item: customLdrmnt) => ({
|
||||
...item,
|
||||
ctpvCd: item.fctryAddr.split(" ")[0] || "",
|
||||
sggCd: item.fctryAddr.split(" ")[1] || ""
|
||||
|
||||
@@ -46,16 +46,30 @@ export const names: nameMap = {
|
||||
}
|
||||
|
||||
|
||||
export const excelToLdrmntData = (excelData: File[],) => {
|
||||
export const excelPbnstSttnParsing = (data: any[]): string[][] => {
|
||||
|
||||
const ldrmntData = Object.values(excelData);
|
||||
const data = ldrmntData.map((item) => {
|
||||
const excelExportData: string[][] = [];
|
||||
|
||||
return ({
|
||||
...(item as object),
|
||||
rgtr: TEST_UUID,
|
||||
mdfr: TEST_UUID,
|
||||
})
|
||||
data.forEach((item) => {
|
||||
excelExportData.push([
|
||||
item.rvbsn,
|
||||
String(item.lgbsn),
|
||||
item.mdmbsn ?? "",
|
||||
item.rgnNm ?? "",
|
||||
String(item.sido ?? ""),
|
||||
String(item.gugun ?? ""),
|
||||
String(item.bscFctNm ?? ""),
|
||||
String(item.efflWqltStndrdNm ?? ""),
|
||||
String(item.fctCpc ?? ""),
|
||||
String(item.tel ?? ""),
|
||||
String(item.ruseUtztnFcltNm ?? ""),
|
||||
String(item.fcltCpct ?? ""),
|
||||
String(item.splyExtraCpct ?? ""),
|
||||
String(item.ruseCpct ?? ""),
|
||||
String(item.usageTotal ?? ""),
|
||||
String(item.inUsage ?? ""),
|
||||
String(item.outUsage ?? ""),
|
||||
])
|
||||
})
|
||||
return data;
|
||||
return excelExportData;
|
||||
};
|
||||
@@ -1,10 +1,12 @@
|
||||
import { z } from "zod";
|
||||
import type { CommonTableProps } from "../../common/type/header";
|
||||
import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
|
||||
|
||||
export const ldrmntZod = z.object({
|
||||
fctryMngSn: z.string().default(''),
|
||||
ctpvCd: z.string().default(''),
|
||||
sggCd: z.string().default(''),
|
||||
mngInst: z.string().default('').nullish(),
|
||||
mngInstNm: z.string().default('').nullish(),
|
||||
dmdCoNm: z.string().default(''),
|
||||
fctrySe: z.string().default(''),
|
||||
cmpxNm: z.string().default(''),
|
||||
@@ -40,6 +42,7 @@ export const ldrmntZod = z.object({
|
||||
fctryAddr: z.string().default(''),
|
||||
fctryLotnoAddr: z.string().default(''),
|
||||
fctryMngNo: z.string().default(''),
|
||||
rgtr:z.string().default(TEST_UUID).nullish()
|
||||
})
|
||||
|
||||
export const ldrmntHeadListExport: CommonTableProps[] = [
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { CommonTableProps } from "@/app/store/common/type/header";
|
||||
import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { deleteFectch, fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import { z } from "zod";
|
||||
import { ldrmntHeadListExport, ldrmntNodeListExport, ldrmntZod } from "./headList";
|
||||
import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +30,7 @@ type ldrmntActions = {
|
||||
ldrmntInit: () => void;
|
||||
ldrmntSearch: (sggCd: string, coNm: string) => void;
|
||||
ldrmntUpdate: (ldrmntRes: customLdrmnt) => void;
|
||||
ldrmntDelete: () => void;
|
||||
};
|
||||
|
||||
export type ldrmntType = ldrmntState & ldrmntActions;
|
||||
@@ -127,6 +129,7 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
},
|
||||
ldrmntUpdate: async (ldrmntRes: customLdrmnt) => {
|
||||
try {
|
||||
ldrmntRes.rgtr = TEST_UUID;
|
||||
console.log("ldrmntRes", ldrmntRes)
|
||||
const response = await putFectch(
|
||||
`/reuseFc/request/temp`,
|
||||
@@ -146,5 +149,15 @@ export const ldrmntActionsExport: (set: any) => ldrmntActions = (
|
||||
console.error("Error ldrmntUpdate:", error);
|
||||
}
|
||||
},
|
||||
ldrmntDelete: async () => {
|
||||
try {
|
||||
const response = await deleteFectch(
|
||||
`/reuseFc/request/temp`,
|
||||
);
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error ldrmntDelete:", error);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { coRegExcel } from "@/app/store/matDmd/coSttn/headList";
|
||||
import type { customLdrmntBdst } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import type { customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
|
||||
import { excelToLdrmntData, 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";
|
||||
@@ -16,13 +16,14 @@ export default function CoRegExcel() {
|
||||
const form = useForm<z.infer<typeof coRegExcel>>({
|
||||
resolver: zodResolver(coRegExcel),
|
||||
});
|
||||
const { ldrmntRegData } = useWrStore((state) => state);
|
||||
const [excelData, setExcelData] = useState<customLdrmntBdst[]>();
|
||||
const { ldrmntRegData, ldrmntDelete } = useWrStore((state) => state);
|
||||
const [excelData, setExcelData] = useState<customLdrmnt[]>();
|
||||
|
||||
|
||||
const [file, setFiles] = useState<File | undefined>();
|
||||
|
||||
const onSubmit = (values: z.infer<typeof coRegExcel>) => {
|
||||
ldrmntDelete();
|
||||
if (file) {
|
||||
filePicked(file, 0).then((res) => {
|
||||
try {
|
||||
@@ -50,7 +51,7 @@ export default function CoRegExcel() {
|
||||
}
|
||||
})
|
||||
ldrmntRegData(array);
|
||||
console.log("array22", array)
|
||||
console.log("array끝", array)
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ export default function SttnDetailModal({
|
||||
formObj: any;
|
||||
}) {
|
||||
const { ldrmntUpdate } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
(state) => state
|
||||
);
|
||||
const defaultValues: z.infer<typeof ldrmntZod> = ldrmntZod.parse({});
|
||||
const form = useForm<z.infer<typeof ldrmntZod>>({
|
||||
resolver: zodResolver(ldrmntZod),
|
||||
@@ -35,7 +35,6 @@ export default function SttnDetailModal({
|
||||
if (ldrmntZod) form.reset(formObj);
|
||||
|
||||
}, [formObj]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ScrollArea className="h-[85vh]">
|
||||
@@ -50,6 +49,23 @@ export default function SttnDetailModal({
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="fctryMngSn"
|
||||
render={({ field }) => (
|
||||
<FormUi label="">
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder=""
|
||||
type="hidden"
|
||||
onChange={(e) => {
|
||||
}}
|
||||
value={field.value ?? ""}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-4 gap-2 mt-4">
|
||||
<div className="col-span-2">
|
||||
<FormField
|
||||
@@ -73,7 +89,7 @@ export default function SttnDetailModal({
|
||||
<div className="col-span-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="mngInst"
|
||||
name="mngInstNm"
|
||||
render={({ field }) => (
|
||||
<FormUi label="관리기관">
|
||||
<Input
|
||||
@@ -90,7 +106,7 @@ export default function SttnDetailModal({
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="grid grid-cols-4 gap-2 mt-4">
|
||||
<div className="col-span-2">
|
||||
<FormField
|
||||
@@ -716,7 +732,7 @@ export default function SttnDetailModal({
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="fctryMngNo"
|
||||
render={({ field }) => (
|
||||
render={({ field, fieldState }) => (
|
||||
<FormUi label="공장관리번호">
|
||||
<Input
|
||||
className={selectClass}
|
||||
|
||||
Reference in New Issue
Block a user