fo: 수질현황 팝업 exceldown 수정
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
"use client"
|
||||
import { useFoStore } from "@/app/store";
|
||||
import {
|
||||
ContentsDiv, downloadExcel, downloadMultipleExcel, filePickedBlobArray, MainDiv
|
||||
ContentsDiv, downloadExcelFormat, downloadMultipleExcel, filePickedBlobArrayFormat, MainDiv
|
||||
, SelectBox, UITab, type SelectDataType
|
||||
} from "@common/business_components";
|
||||
import { Button, TabsContent } from "@common/components/ui";
|
||||
@@ -197,7 +197,8 @@ export default function DashBoard() {
|
||||
headerRange: 'A1:G2',
|
||||
sheetName: '운영실태',
|
||||
startCol: 'A',
|
||||
decimalRange0: 'B9:B11',
|
||||
decimalRange0: 'B3:G2,B9:B11',
|
||||
decimalRange1: 'B5:G5',
|
||||
},
|
||||
{
|
||||
data: excelData2,
|
||||
@@ -211,7 +212,7 @@ export default function DashBoard() {
|
||||
}
|
||||
];
|
||||
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
|
||||
await filePickedBlobArray(blobRet, '시설정보및운영현황', sheetParameter);
|
||||
await filePickedBlobArrayFormat(blobRet, '시설정보및운영현황', sheetParameter);
|
||||
});
|
||||
};
|
||||
await searchOperationStatus(false, searchYear, fcltyList.bscFctCd);
|
||||
@@ -266,11 +267,15 @@ export default function DashBoard() {
|
||||
case 'rainManage': // 강우일 운영현황
|
||||
searchRainManage(searchYear, fcltyList.bscFctCd, true);
|
||||
if (excelList && excelList.length > 0) {
|
||||
downloadExcel({
|
||||
downloadExcelFormat({
|
||||
data: excelList as unknown as JSON[],
|
||||
fileName: '강우일 운영현황',
|
||||
sheetNameArray: ['강우일 운영현황'],
|
||||
headerRange: 'A1:T1' });
|
||||
headerRange: 'A1:T1',
|
||||
decimalArray0: [2,3],
|
||||
decimalArray1: [1,4,5,6,7,10,11,12,15,16,17],
|
||||
decimalArray3: [8,9,13,14,18,19],
|
||||
});
|
||||
}
|
||||
break;
|
||||
// Add other cases for different tabs as needed
|
||||
|
||||
@@ -394,7 +394,7 @@ export default function WaterQualityModal({ fcltyName = '', facilityCd = '', sea
|
||||
"유입BOD(mg/L)": CommaToNumber(item.tpInflWqltBod),
|
||||
"유입TP(mg/L)": CommaToNumber(item.tpInflWqltTp),
|
||||
"유출BOD(mg/L)": CommaToNumber(item.efflWqltBod),
|
||||
"유출TP(mg/L)": CommaToNumber(item.efflWqltTn),
|
||||
"유출TP(mg/L)": CommaToNumber(item.efflWqltTp),
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import FacilityTermModalHeader from "@/app/components/common/FacilityTermModalHe
|
||||
import { useFoStore } from "@/app/store";
|
||||
import type { FlowRateModalInterface, modalExcelType } from "@/app/store/flowRate";
|
||||
import { dataFormSetting } from "@/app/store/flowRate";
|
||||
import { downloadExcel, UITab, UiTable } from "@common/business_components/ui";
|
||||
import { downloadExcelFormat, UITab, UiTable } from "@common/business_components/ui";
|
||||
import { Button, TabsContent } from "@common/components/ui";
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import type { ReturnType } from "../../../../components/common/FacilityTermModalHeader";
|
||||
@@ -201,7 +201,14 @@ export default function FlowRateModal(props: { fcltyName: string; facilityCd: st
|
||||
});
|
||||
}
|
||||
if (excelDownList && excelDownList.length > 0) {
|
||||
downloadExcel({ data: JSON.parse(JSON.stringify(excelDownList)), fileName: props.searchYear + '년 ' + props.fcltyName + ' 유량현황', sheetNameArray: [props.fcltyName + ' 유량현황'], headerRange: 'A1:H1' });
|
||||
downloadExcelFormat({
|
||||
data: JSON.parse(JSON.stringify(excelDownList)),
|
||||
fileName: props.searchYear + '년 ' + props.fcltyName + ' 유량현황',
|
||||
sheetNameArray: [props.fcltyName + ' 유량현황'],
|
||||
headerRange: 'A1:H1',
|
||||
decimalArray0: [1, 2, 3, 4, 5, 6],
|
||||
decimalArray1: [0],
|
||||
});
|
||||
} else if (prevExcelListRef.current && prevExcelListRef.current.length > 0) {
|
||||
alert('조회된 결과가 없습니다.');
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ export default function ProcessFacilityInfoModal(props: ModalType) {
|
||||
const sheetParameter = [
|
||||
{
|
||||
data: excelData,
|
||||
headerNum: 2,
|
||||
headerNum: 3,
|
||||
headerRange: 'A1:S2',
|
||||
sheetName: '시설 수질정보',
|
||||
startCol: 'A'
|
||||
|
||||
@@ -268,6 +268,27 @@ export const filePickedBlobArray = async (
|
||||
oFile: ArrayBuffer,
|
||||
fileNm: string,
|
||||
sheetArray: SheetParameter[]
|
||||
): Promise<JSON | undefined> => {
|
||||
const wb = XLSX.read(oFile, { type: 'binary' });
|
||||
wb.SheetNames.forEach(function (sheetName, index) {
|
||||
if (sheetArray[index]) {
|
||||
const sheet = wb.Sheets[sheetName];
|
||||
if (sheet) {
|
||||
const startCol = sheetArray[index].startCol ? sheetArray[index].startCol : 'A';
|
||||
XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol + sheetArray[index].headerNum });
|
||||
} else {
|
||||
console.error(`Sheet "${sheetName}" is undefined.`);
|
||||
}
|
||||
}
|
||||
});
|
||||
await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm);
|
||||
return undefined;
|
||||
};
|
||||
|
||||
export const filePickedBlobArrayFormat = async (
|
||||
oFile: ArrayBuffer,
|
||||
fileNm: string,
|
||||
sheetArray: SheetParameter[]
|
||||
): Promise<JSON | undefined> => {
|
||||
const wb = XLSX.read(oFile, { type: "binary" });
|
||||
|
||||
@@ -276,6 +297,7 @@ export const filePickedBlobArray = async (
|
||||
const sheet = wb.Sheets[sheetName];
|
||||
if (sheet) {
|
||||
const startCol = sheetArray[index].startCol ?? "A";
|
||||
|
||||
XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, {
|
||||
origin: startCol + sheetArray[index].headerNum,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user