중수도 시설 현황 작업중

This commit is contained in:
leedj312
2025-05-07 18:21:27 +09:00
parent 2e1fa426a8
commit eb2fca7621
8 changed files with 684 additions and 65 deletions
+73 -52
View File
@@ -1,70 +1,80 @@
import type { comCodeState, } from "@/app/store/common/code";
import { filePickedBlob, type SelectDataType } from "@common/business_components/ui";
import type { comCodeState } from "@/app/store/common/code";
import {
filePickedBlob,
type SelectDataType,
type ReturnType,
} from "@common/business_components/ui";
import type { RefObject } from "react";
export const getCity = (val: string, sggCd: SelectDataType[]) => {
const data = sggCd
.filter((item) => String(item.val).substring(0, 2) === val)
.map((item) => ({
val: item.val,
text: item.text // 한국어 텍스트
}));
return data
};
const data = sggCd
.filter((item) => String(item.val).substring(0, 2) === val)
.map((item) => ({
val: item.val,
text: item.text, // 한국어 텍스트
}));
return data;
};
// cd text 넣기
export const tableData = ( data: any,code:comCodeState)=>{
const chCode = code.code;
return data?.map((item: { sggCd: string; ctpvCd: string; reuseBuilding: { lawTrgtYn: any , bdstUsgCd:any}[]; }) => {
export const tableData = (data: any, code: comCodeState) => {
const chCode = code.code;
return data?.map(
(item: {
sggCd: string;
ctpvCd: string;
reuseBuilding: { lawTrgtYn: any; bdstUsgCd: any }[];
}) => {
let returnData = {};
const sggText = chCode.sggCd.find(
(cd) => cd.val === String(item.sggCd)
(cd) => cd.val === String(item.sggCd)
)?.text;
const cityText = chCode.cityCd.find(
(cd) => cd.val === String(item.ctpvCd)
)?.text;
console
.log(item?.reuseBuilding)
if (item?.reuseBuilding?.length >0) {
if (item?.reuseBuilding?.length > 0) {
const bdsgUsgText = chCode.bdstUsgCd.find(
(cd) =>Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd
)?.text
const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn
console
.log(bdsgUsgText)
(cd) => Number(cd.val) === item?.reuseBuilding[0]?.bdstUsgCd
)?.text;
const lawTrgtYn = item?.reuseBuilding[0]?.lawTrgtYn;
returnData= { ...item, sggText: sggText??'없음', cityText: cityText??'없음' ,bdsgUsgText:bdsgUsgText ,lawTrgtYn:lawTrgtYn};
}else{
returnData= { ...item, sggText: sggText??'없음', cityText: cityText??'없음'};
returnData = {
...item,
sggText: sggText ?? "없음",
cityText: cityText ?? "없음",
bdsgUsgText: bdsgUsgText,
lawTrgtYn: lawTrgtYn,
};
} else {
returnData = {
...item,
sggText: sggText ?? "없음",
cityText: cityText ?? "없음",
};
}
return returnData;
});
}
export const excelDownload =(excelList: [][], fileNm:string ,sampleFile:string, headerRange='A1:V3') =>{
if (excelList.length === 0) return;
fetch(`/${sampleFile}`, {})
.then(async (response) => {
if (!response.ok) {
throw Error(response.statusText)
}
// 받은 파일 바인너리 처리
const blobRet = await response.arrayBuffer()
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
await filePickedBlob(blobRet, excelList,fileNm, 4,headerRange)
})
}
}
);
};
export const excelDownload = (
excelList: [][],
fileNm: string,
sampleFile: string,
headerRange = "A1:V3"
) => {
if (excelList.length === 0) return;
fetch(`/${sampleFile}`, {}).then(async (response) => {
if (!response.ok) {
throw Error(response.statusText);
}
// 받은 파일 바인너리 처리
const blobRet = await response.arrayBuffer();
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
await filePickedBlob(blobRet, excelList, fileNm, 4, headerRange);
});
};
// onchange 텍스트를 숫자로 and ,제거
export const handleCommaNumberChange = (
@@ -82,4 +92,15 @@ export const formatCommaNumber = (
): string => {
if (value === undefined || value === null || value === "") return "";
return Number(value).toLocaleString();
};
};
export const getCityOrSgg = (ref: RefObject<ReturnType>) => {
let con;
if (ref.current != null)
if (ref.current.sigunValue != "0") {
con = ref.current.sigunValue;
} else {
con = ref.current.sidoValue;
}
return con;
};