st: refactor:

- Real Grid 컴포넌트 @rsone/components 로 모듈화
- 컴포넌트 동적 import 경로 수정(engName -> urlPath)
This commit is contained in:
2026-01-09 10:21:00 +09:00
parent a4147a4c67
commit d9d5b49057
37 changed files with 1898 additions and 345 deletions
+6 -4
View File
@@ -312,10 +312,12 @@ const DataGrid = ({ columnInfo, rowStartNum, isExcelImport = true, isExcelExport
<span>가져오기</span>
</Button>
}
{isExcelExport && <Button className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]" type="button" onClick={exportExcel}>
<i className="diveicon di-file-excel" />
<span>내보내기</span>
</Button>}
{isExcelExport &&
<Button className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]" type="button" onClick={exportExcel}>
<i className="diveicon di-file-excel" />
<span>내보내기</span>
</Button>
}
</div>
<div className="h-[65vh]">
<RealGridReact
+30 -28
View File
@@ -15,7 +15,7 @@ import { Button } from "@common/components";
// RealGrid 타입 확장
declare module "realgrid" {
interface GridView {
setOptions(options: {
setOptions(options: {
footer?: { visible?: boolean };
summaryMode?: 'aggregate' | 'statistical' | 'none';
checkBar?: { visible?: boolean };
@@ -161,7 +161,7 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
const col = range.s.c + colIndex;
const cell = worksheet[XLSX.utils.encode_cell({ r: row, c: col })];
const headerName = headers[colIndex] || `Column${colIndex + 1}`;
let cellValue: string | number = '';
if (cell && cell.v !== undefined && cell.v !== null) {
// 엑셀 셀 타입이 숫자이거나 값이 숫자인 경우 숫자로 변환
@@ -301,24 +301,26 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
onChange={(e) => handleFileChange(e, tabKey)}
/>
<div className="flex justify-end items-center gap-[0.6rem]">
{isExcelImport && (
<Button
className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]"
type="button"
{isExcelImport &&
<Button
className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]"
type="button"
onClick={() => importExcel(tabKey)}
>
<i className="diveicon di-file-excel" />
<span>가져오기</span>
</Button>
)}
<Button
className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]"
type="button"
onClick={() => exportExcel(tabKey)}
>
<i className="diveicon di-file-excel" />
<span>내보내기</span>
</Button>
}
{isExcelExport &&
<Button
className="h-[3.2rem] px-6 bg-gradient-green hover:bg-gradient-green-hover w-[96px]"
type="button"
onClick={() => exportExcel(tabKey)}
>
<i className="diveicon di-file-excel" />
<span>내보내기</span>
</Button>
}
</div>
<div className="h-[60vh]">
<RealGridReact
@@ -330,31 +332,31 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
setTimeout(() => {
const gridView = el.gridView;
if (!gridView) return;
const currentInfo = columnInfo.find(info => info.tabKey === tabKey);
if (!currentInfo) return;
gridView.setDisplayOptions({
fitStyle: GridFitStyle.EVEN
});
gridView.header.height = 60;
// 헤더 체크박스 표시 여부 설정
gridView.setOptions({
checkBar: { visible: showHeaderCheckbox },
rowIndicator: { visible: false },
});
// footer가 있는 컬럼이 있으면 footer 높이 설정
const hasFooter = currentInfo.columns.some(col => col.footer);
if (hasFooter) {
gridView.footer.height = 40;
}
gridView.setOptions({
summaryMode: "aggregate"
});
// footer의 valueCallback 설정
currentInfo.columns.forEach(col => {
if (col.footer && col.footer.valueCallback) {
@@ -364,21 +366,21 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
}
}
});
// 고정 컬럼 설정
if (currentInfo.fixedColumns !== undefined && currentInfo.fixedColumns > 0) {
gridView.setFixedOptions({
colCount: currentInfo.fixedColumns,
});
}
// valueType이 설정된 컬럼에 대해 필드의 dataType을 명시적으로 설정
// autoGenerateField={true}일 때 valueType prop만으로는 필드의 dataType이 설정되지 않을 수 있음
if (el.dataProvider) {
const dataProvider = el.dataProvider;
const fieldsToSet: Array<{ fieldName: string; dataType: string }> = [];
const fieldMap = new Map<string, string>();
currentInfo.columns.forEach(col => {
if (col.valueType && col.fieldName && !fieldMap.has(col.fieldName)) {
fieldMap.set(col.fieldName, col.valueType);
@@ -395,13 +397,13 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
// 기존 필드 정보 가져오기
const existingFields = (dataProvider as { getFields?: () => Array<{ fieldName: string; dataType?: string }> }).getFields?.() || [];
const existingFieldMap = new Map(existingFields.map(f => [f.fieldName, f.dataType || 'text']));
// valueType이 설정된 필드 중 dataType이 다른 필드만 업데이트
const fieldsToUpdate = fieldsToSet.filter(field => {
const existingDataType = existingFieldMap.get(field.fieldName);
return existingDataType !== field.dataType;
});
if (fieldsToUpdate.length > 0) {
// 기존 필드 정보를 유지하면서 dataType만 업데이트
// 컬럼 정의에 valueType이 있으면 그것을 우선 사용, 없으면 기존 필드의 dataType 사용
@@ -409,14 +411,14 @@ const TabDataGrid = ({ columnInfo, isExcelImport = true, isExcelExport = true, r
fieldName: f.fieldName,
dataType: fieldMap.get(f.fieldName) || f.dataType || 'text'
}));
// 새로 추가할 필드가 있으면 추가
fieldsToSet.forEach(field => {
if (!existingFieldMap.has(field.fieldName)) {
allFields.push({ fieldName: field.fieldName, dataType: field.dataType });
}
});
// setFields를 호출하여 필드의 dataType 업데이트
(dataProvider as { setFields: (fields: Array<{ fieldName: string; dataType: string }>) => void })
.setFields(allFields);