From 0ee7f6c59048e9c96c54e8ed266e2da32f3daf9b Mon Sep 17 00:00:00 2001 From: ysCha Date: Tue, 23 Dec 2025 14:19:35 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=EA=B3=84=EC=82=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 66 ++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index 4cdffbed..a8f5f148 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -24,6 +24,7 @@ import { useSwal } from '@/hooks/useSwal' import { QcastContext } from '@/app/QcastProvider' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import {normalizeDigits, normalizeDecimal} from '@/util/input-utils' +import { CalculatorInput } from '@/components/common/input/CalcInput' export default function Estimate({}) { const [uniqueData, setUniqueData] = useState([]) const [handlePricingFlag, setHandlePricingFlag] = useState(false) @@ -2106,25 +2107,60 @@ export default function Estimate({}) {
- {*/} + {/* onChangeAmount(e.target.value, item.dispOrder, index)*/} + {/* }}*/} + {/* maxLength={6}*/} + {/*/>*/} + { - onChangeAmount(e.target.value, item.dispOrder, index) + onChange={(value) =>{ + onChangeAmount(value, item.dispOrder, index) }} - maxLength={6} - /> + options={{ + allowNegative: false, + allowDecimal: false + }} + />
{item.unit}
- {*/} + {/* onChangeSalePrice(e.target.value, item.dispOrder, index)*/} + {/* }}*/} + {/* maxLength={12}*/} + {/*/>*/} + { - onChangeSalePrice(e.target.value, item.dispOrder, index) + onChange={(value) =>{ + onChangeSalePrice(value, item.dispOrder, index) }} maxLength={12} + options={{ + allowNegative: false, + allowDecimal: false + }} />
{item.openFlg === '1' && ( -- 2.47.2 From 59b65df1d6b2156c8537a3ce11c2f1b5d4bfcd5e Mon Sep 17 00:00:00 2001 From: ysCha Date: Tue, 23 Dec 2025 15:21:29 +0900 Subject: [PATCH 2/3] =?UTF-8?q?abs()=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/util/skeleton-utils.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/util/skeleton-utils.js b/src/util/skeleton-utils.js index d1019c66..943f1f38 100644 --- a/src/util/skeleton-utils.js +++ b/src/util/skeleton-utils.js @@ -871,7 +871,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //newPStart.y = wallLine.y1; //외곽 라인 그리기 const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() - newPStart.y = Big(wallBaseLine.y1).minus(rLineM).abs().toNumber() + newPStart.y = Big(wallBaseLine.y1).minus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if (inLine) { if (inLine.x2 > inLine.x1) { @@ -927,7 +927,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //외곽 라인 그리기 const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() - newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).abs().toNumber() + newPEnd.y = Big(wallBaseLine.y2).plus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if (inLine) { if (inLine.x2 > inLine.x1) { @@ -1041,7 +1041,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //newPStart.y = wallLine.y1; //외곽 라인 그리기 const rLineM = Big(wallBaseLine.x1).minus(roofLine.x1).abs().toNumber() - newPStart.y = Big(wallBaseLine.y1).plus(rLineM).abs().toNumber() + newPStart.y = Big(wallBaseLine.y1).plus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if (inLine) { if (inLine.x2 > inLine.x1) { @@ -1096,7 +1096,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //외곽 라인 그리기 const rLineM = Big(wallBaseLine.x2).minus(roofLine.x2).abs().toNumber() - newPEnd.y = Big(wallBaseLine.y2).minus(rLineM).abs().toNumber() + newPEnd.y = Big(wallBaseLine.y2).minus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if (inLine) { if (inLine.x2 > inLine.x1) { @@ -1229,7 +1229,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { } else { //외곽 라인 그리기 const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber() - newPStart.x = Big(wallBaseLine.x1).plus(rLineM).abs().toNumber() + newPStart.x = Big(wallBaseLine.x1).plus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if (inLine) { if (inLine.y2 > inLine.y1) { @@ -1282,7 +1282,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //newPEnd.x = wallLine.x2; //외곽 라인 그리기 const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber() - newPEnd.x = Big(wallBaseLine.x2).minus(rLineM).abs().toNumber() + newPEnd.x = Big(wallBaseLine.x2).minus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if (inLine) { if (inLine.y1 > inLine.y2) { @@ -1392,7 +1392,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //newPStart.x = wallLine.x1; //외곽 라인 그리기 const rLineM = Big(wallBaseLine.y1).minus(roofLine.y1).abs().toNumber() - newPStart.x = Big(wallBaseLine.x1).minus(rLineM).abs().toNumber() + newPStart.x = Big(wallBaseLine.x1).minus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPStart.y, x: newPStart.x }) if (inLine) { if (inLine.y2 > inLine.y1) { @@ -1446,7 +1446,7 @@ const createInnerLinesFromSkeleton = (roofId, canvas, skeleton, textMode) => { //newPEnd.x = wallLine.x2; //외곽 라인 그리기 const rLineM = Big(wallBaseLine.y2).minus(roofLine.y2).abs().toNumber() - newPEnd.x = Big(wallBaseLine.x2).plus(rLineM).abs().toNumber() + newPEnd.x = Big(wallBaseLine.x2).plus(rLineM).toNumber() const inLine = findLineContainingPoint(innerLines, { y: newPEnd.y, x: newPEnd.x }) if (inLine) { if (inLine.y1 > inLine.y2) { -- 2.47.2 From dc080a873784491cd621f669d5abd56d37fcd1ad Mon Sep 17 00:00:00 2001 From: ysCha Date: Tue, 23 Dec 2025 15:30:27 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=EC=97=90=20?= =?UTF-8?q?=EA=B3=84=EC=82=B0=EA=B8=B0=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/common/input/CalcInput.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/common/input/CalcInput.jsx b/src/components/common/input/CalcInput.jsx index 14118b87..d386bd7d 100644 --- a/src/components/common/input/CalcInput.jsx +++ b/src/components/common/input/CalcInput.jsx @@ -3,7 +3,7 @@ import { createCalculator } from '@/util/calc-utils' import '@/styles/calc.scss' export const CalculatorInput = forwardRef( - ({ value, onChange, label, options = {}, id, className = 'calculator-input', readOnly = false, placeholder, name='', disabled = false }, ref) => { + ({ value, onChange, label, options = {}, id, className = 'calculator-input', readOnly = false, placeholder, name='', disabled = false, maxLength = 6 }, ref) => { const [showKeypad, setShowKeypad] = useState(false) const [displayValue, setDisplayValue] = useState(value || '0') const [hasOperation, setHasOperation] = useState(false) @@ -48,6 +48,14 @@ export const CalculatorInput = forwardRef( const calculator = calculatorRef.current let newDisplayValue = '' + // maxLength 체크 + if (maxLength > 0) { + const currentLength = (calculator.currentOperand || '').length + (calculator.previousOperand || '').length + (calculator.operation || '').length + if (currentLength >= maxLength) { + return + } + } + // 소수점 이하 2자리 제한 로직 추가 const shouldPreventInput = (value) => { if (!value) return false @@ -57,6 +65,10 @@ export const CalculatorInput = forwardRef( // 숫자 추가 함수 const appendNumber = (current, num) => { + // maxLength 체크 + if (maxLength > 0 && (current + num).length > maxLength) { + return current + } // 현재 값이 0이고 소수점이 없을 때 0이 아닌 숫자를 입력하면 대체 if (current === '0' && num !== '.' && !current.includes('.')) { return num.toString() @@ -407,6 +419,7 @@ export const CalculatorInput = forwardRef( placeholder={placeholder} autoComplete={'off'} disabled={disabled} + maxLength={maxLength} /> {showKeypad && !readOnly && ( -- 2.47.2