feat(view): 도면 불러오기 — read the bearing drawing values from an xlsx or csv sheet on ②
The sheet needs the header names No, EL.X, h1 and h2 (case, spaces, dots and units in parentheses are ignored). Rows are checked: No must be a unique positive integer, EL.X must be in metres (30–100), h1 and h2 must be positive mm up to 1000. Any error stops the import with the first messages; a valid sheet fills this pier's drawing values and regenerates the pier. The parser is pure and tested. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4e141c801
commit
6f32bd96c4
3 files changed
+124
No files matched your search
+31
@@ -15,6 +15,7 @@ import { shearSegments } from './core/rebar/coping';
|
||||
import { buildRebar3D, type RebarColorMode, type RebarScene } from './view/rebar3d';
|
||||
import { DEFAULT_MATERIAL, FCK_MEMBERS, fyOf, GRADE_CHOICES, isAssumedMaterial, materialFrom, type BendFactors, type FckByMember, type FckMember, type GradeKey, type Material } from './core/rebar/common';
|
||||
import { buildQuantity, quantityRows, type Quantity, type QuantityLine } from './core/rebar/quantity';
|
||||
import { parseDrawingRows } from './core/drawing-import';
|
||||
import { P1_COPING_GEOM } from './core/coping-geom';
|
||||
import { applyBearingRules, BEARING_ELEVATION_REF, BEARING_RULES_DEFAULT, type BearingBasis, type BearingRules, type DrawingBearing, DRAWING_TOL_MM, drawingCopingCheck, SOLPLATE_REF, SOLPLATE_T_RULE, solplateTs, withDrawingBasis } from './core/bearing-ref';
|
||||
|
||||
@@ -1337,6 +1338,36 @@ function renderBearingBasis(wrap: HTMLDivElement, pier: Pier): void {
|
||||
table.appendChild(body);
|
||||
wrap.appendChild(el('div', undefined, 'table-scroll')).appendChild(table);
|
||||
|
||||
// 도면 불러오기 (승인 2026-10-23): a sheet with No, EL.X, h1, h2 (xlsx or csv) fills this pier's drawing values.
|
||||
const importInput = el('input');
|
||||
importInput.type = 'file';
|
||||
importInput.accept = '.xlsx,.xls,.csv';
|
||||
importInput.id = 'drawing-import';
|
||||
importInput.addEventListener('change', async () => {
|
||||
const file = importInput.files?.[0];
|
||||
if (!file) return;
|
||||
try {
|
||||
const wb = XLSX.read(await file.arrayBuffer(), { type: 'array' });
|
||||
const sheet = wb.Sheets[wb.SheetNames[0]];
|
||||
const rows = XLSX.utils.sheet_to_json<unknown[]>(sheet, { header: 1, blankrows: false, defval: '' });
|
||||
const result = parseDrawingRows(rows);
|
||||
if (result.errors.length) {
|
||||
setError(`도면 불러오기 실패: ${result.errors.slice(0, 3).join(' ')}`);
|
||||
return;
|
||||
}
|
||||
bearingDrawing = { ...bearingDrawing, [name]: result.rows };
|
||||
regenerateAllPiers();
|
||||
renderAll();
|
||||
setStatus(`${file.name}에서 받침 ${result.rows.length}개의 도면 값을 불러왔습니다.`);
|
||||
} catch (err) {
|
||||
setError(`도면 파일을 읽지 못했습니다: ${(err as Error).message}`);
|
||||
} finally {
|
||||
importInput.value = '';
|
||||
}
|
||||
});
|
||||
const importLabel = el('label', '도면 파일 불러오기 (xlsx·csv)');
|
||||
importLabel.appendChild(importInput);
|
||||
wrap.appendChild(importLabel);
|
||||
const fill = el('button', '도면값 채우기 (참조 값)', 'btn small');
|
||||
fill.type = 'button';
|
||||
fill.addEventListener('click', () => {
|
||||
|
||||
Reference in new issue
Block a user