This commit is contained in:
hyojun.choi 2025-12-24 09:40:46 +09:00
commit cc5734db16
10 changed files with 1622 additions and 1822 deletions

View File

@ -3,7 +3,7 @@ import { createCalculator } from '@/util/calc-utils'
import '@/styles/calc.scss' import '@/styles/calc.scss'
export const CalculatorInput = forwardRef( 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 [showKeypad, setShowKeypad] = useState(false)
const [displayValue, setDisplayValue] = useState(value || '0') const [displayValue, setDisplayValue] = useState(value || '0')
const [hasOperation, setHasOperation] = useState(false) const [hasOperation, setHasOperation] = useState(false)
@ -48,28 +48,56 @@ export const CalculatorInput = forwardRef(
const calculator = calculatorRef.current const calculator = calculatorRef.current
let newDisplayValue = '' let newDisplayValue = ''
// maxLength
if (maxLength > 0) {
const currentLength = (calculator.currentOperand || '').length + (calculator.previousOperand || '').length + (calculator.operation || '').length
if (currentLength >= maxLength) {
return
}
}
// 2 // 2
const shouldPreventInput = (value) => { const shouldPreventInput = (value) => {
const decimalParts = (value || '').split('.') if (!value) return false
const decimalParts = value.toString().split('.')
return decimalParts.length > 1 && decimalParts[1].length >= 2 return decimalParts.length > 1 && decimalParts[1].length >= 2
} }
//
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()
}
// 0. 0
if (current === '0' && num === '0') {
return '0.'
}
return current + num
}
if (hasOperation) { if (hasOperation) {
// //
if (calculator.currentOperand === '0' || calculator.shouldResetDisplay) { if (calculator.shouldResetDisplay) {
calculator.currentOperand = num.toString() calculator.currentOperand = num.toString()
calculator.shouldResetDisplay = false calculator.shouldResetDisplay = false
}else if (!shouldPreventInput(calculator.currentOperand)) { // 2 } else if (num === '.') {
calculator.currentOperand = (calculator.currentOperand || '') + num if (!calculator.currentOperand.includes('.')) {
calculator.currentOperand = calculator.currentOperand || '0' + '.'
} }
// else { } else if (!shouldPreventInput(calculator.currentOperand)) {
// calculator.currentOperand = (calculator.currentOperand || '') + num calculator.currentOperand = appendNumber(calculator.currentOperand || '0', num)
// } }
newDisplayValue = calculator.previousOperand + calculator.operation + calculator.currentOperand newDisplayValue = calculator.previousOperand + calculator.operation + calculator.currentOperand
setDisplayValue(newDisplayValue) setDisplayValue(newDisplayValue)
} else { } else {
// //
if (displayValue === '0' || calculator.shouldResetDisplay) { if (calculator.shouldResetDisplay) {
calculator.currentOperand = num.toString() calculator.currentOperand = num.toString()
calculator.shouldResetDisplay = false calculator.shouldResetDisplay = false
newDisplayValue = calculator.currentOperand newDisplayValue = calculator.currentOperand
@ -77,8 +105,17 @@ export const CalculatorInput = forwardRef(
if (!hasOperation) { if (!hasOperation) {
onChange(calculator.currentOperand) onChange(calculator.currentOperand)
} }
} else if (!shouldPreventInput(calculator.currentOperand)) { // 2 } else if (num === '.') {
calculator.currentOperand = (calculator.currentOperand || '') + num if (!calculator.currentOperand.includes('.')) {
calculator.currentOperand = (calculator.currentOperand || '0') + '.'
newDisplayValue = calculator.currentOperand
setDisplayValue(newDisplayValue)
if (!hasOperation) {
onChange(newDisplayValue)
}
}
} else if (!shouldPreventInput(calculator.currentOperand)) {
calculator.currentOperand = appendNumber(calculator.currentOperand || '0', num)
newDisplayValue = calculator.currentOperand newDisplayValue = calculator.currentOperand
setDisplayValue(newDisplayValue) setDisplayValue(newDisplayValue)
if (!hasOperation) { if (!hasOperation) {
@ -382,6 +419,7 @@ export const CalculatorInput = forwardRef(
placeholder={placeholder} placeholder={placeholder}
autoComplete={'off'} autoComplete={'off'}
disabled={disabled} disabled={disabled}
maxLength={maxLength}
/> />
{showKeypad && !readOnly && ( {showKeypad && !readOnly && (

View File

@ -57,6 +57,7 @@ export default function Qna() {
endRow : endRow, endRow : endRow,
schMainYn : 'N', schMainYn : 'N',
siteTpCd : 'QC', siteTpCd : 'QC',
langCd : 'JA',
}) })
const apiUrl = `${url}?${params.toString()}` const apiUrl = `${url}?${params.toString()}`

View File

@ -24,6 +24,7 @@ import { useSwal } from '@/hooks/useSwal'
import { QcastContext } from '@/app/QcastProvider' import { QcastContext } from '@/app/QcastProvider'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import {normalizeDigits, normalizeDecimal} from '@/util/input-utils' import {normalizeDigits, normalizeDecimal} from '@/util/input-utils'
import { CalculatorInput } from '@/components/common/input/CalcInput'
export default function Estimate({}) { export default function Estimate({}) {
const [uniqueData, setUniqueData] = useState([]) const [uniqueData, setUniqueData] = useState([])
const [handlePricingFlag, setHandlePricingFlag] = useState(false) const [handlePricingFlag, setHandlePricingFlag] = useState(false)
@ -1693,13 +1694,13 @@ export default function Estimate({}) {
{/* 파일첨부 끝 */} {/* 파일첨부 끝 */}
{/* 견적특이사항 시작 */} {/* 견적특이사항 시작 */}
<div className="table-box-title-wrap"> <div className="table-box-title-wrap">
<div className="title-wrap"> {/*<div className="title-wrap">*/}
<h3 className="product">{getMessage('estimate.detail.header.specialEstimate')}</h3> {/* <h3 className="product">{getMessage('estimate.detail.header.specialEstimate')}</h3>*/}
<div className="estimate-check-btn"> {/* <div className="estimate-check-btn">*/}
<button className={`estimate-arr-btn down mr5 ${hidden ? '' : 'on'}`} onClick={() => setHidden(false)}></button> {/* <button className={`estimate-arr-btn down mr5 ${hidden ? '' : 'on'}`} onClick={() => setHidden(false)}></button>*/}
<button className={`estimate-arr-btn up ${hidden ? 'on' : ''}`} onClick={() => setHidden(true)}></button> {/* <button className={`estimate-arr-btn up ${hidden ? 'on' : ''}`} onClick={() => setHidden(true)}></button>*/}
</div> {/* </div>*/}
</div> {/*</div>*/}
</div> </div>
{/* 견적 특이사항 코드영역시작 */} {/* 견적 특이사항 코드영역시작 */}
<div className={`estimate-check-wrap ${hidden ? 'hide' : ''}`}> <div className={`estimate-check-wrap ${hidden ? 'hide' : ''}`}>
@ -2106,15 +2107,27 @@ export default function Estimate({}) {
</td> </td>
<td> <td>
<div className="input-wrap" style={{ width: '100%' }}> <div className="input-wrap" style={{ width: '100%' }}>
<input {/*<input*/}
type="text" {/* type="text"*/}
className="input-light al-r" {/* className="input-light al-r"*/}
{/* value={convertNumberToPriceDecimal(item?.amount?.replaceAll(',', ''))}*/}
{/* disabled={item.itemId === '' || !!item?.paDispOrder}*/}
{/* onChange={(e) => {*/}
{/* onChangeAmount(e.target.value, item.dispOrder, index)*/}
{/* }}*/}
{/* maxLength={6}*/}
{/*/>*/}
<CalculatorInput
className={"input-light al-r"}
value={convertNumberToPriceDecimal(item?.amount?.replaceAll(',', ''))} value={convertNumberToPriceDecimal(item?.amount?.replaceAll(',', ''))}
disabled={item.itemId === '' || !!item?.paDispOrder} disabled={item.itemId === '' || !!item?.paDispOrder}
onChange={(e) => { onChange={(value) =>{
onChangeAmount(e.target.value, item.dispOrder, index) onChangeAmount(value, item.dispOrder, index)
}}
options={{
allowNegative: false,
allowDecimal: false
}} }}
maxLength={6}
/> />
</div> </div>
</td> </td>
@ -2122,9 +2135,32 @@ export default function Estimate({}) {
<td> <td>
<div className="form-flex-wrap"> <div className="form-flex-wrap">
<div className="input-wrap mr5"> <div className="input-wrap mr5">
<input {/*<input*/}
type="text" {/* type="text"*/}
className="input-light al-r" {/* className="input-light al-r"*/}
{/* value={*/}
{/* item.openFlg === '1'*/}
{/* ? 'OPEN'*/}
{/* : convertNumberToPriceDecimal(item?.showSalePrice === '0' ? null : item?.salePrice?.replaceAll(',', ''))*/}
{/* }*/}
{/* disabled={*/}
{/* item.openFlg === '1'*/}
{/* ? true*/}
{/* : estimateContextState?.estimateType === 'YJSS'*/}
{/* ? item?.paDispOrder*/}
{/* ? true*/}
{/* : item.pkgMaterialFlg !== '1'*/}
{/* : item.itemId === '' || !!item?.paDispOrder*/}
{/* ? true*/}
{/* : item.openFlg === '1'*/}
{/* }*/}
{/* onChange={(e) => {*/}
{/* onChangeSalePrice(e.target.value, item.dispOrder, index)*/}
{/* }}*/}
{/* maxLength={12}*/}
{/*/>*/}
<CalculatorInput
className={"input-light al-r"}
value={ value={
item.openFlg === '1' item.openFlg === '1'
? 'OPEN' ? 'OPEN'
@ -2140,13 +2176,15 @@ export default function Estimate({}) {
: item.itemId === '' || !!item?.paDispOrder : item.itemId === '' || !!item?.paDispOrder
? true ? true
: item.openFlg === '1' : item.openFlg === '1'
? true
: false
} }
onChange={(e) => { onChange={(value) =>{
onChangeSalePrice(e.target.value, item.dispOrder, index) onChangeSalePrice(value, item.dispOrder, index)
}} }}
maxLength={12} maxLength={12}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
{item.openFlg === '1' && ( {item.openFlg === '1' && (

View File

@ -235,11 +235,23 @@ export default function Module({ setTabNum }) {
<div className="eaves-keraba-td"> <div className="eaves-keraba-td">
<div className="outline-form"> <div className="outline-form">
<div className="grid-select mr10"> <div className="grid-select mr10">
<input {/*<input*/}
type="text" {/* type="text"*/}
{/* className="input-origin block"*/}
{/* value={inputVerticalSnowCover}*/}
{/* onChange={(e) => setInputVerticalSnowCover(normalizeDecimal(e.target.value))}*/}
{/*/>*/}
<CalculatorInput
id=""
name=""
label=""
className="input-origin block" className="input-origin block"
value={inputVerticalSnowCover} value={inputVerticalSnowCover}
onChange={(e) => setInputVerticalSnowCover(normalizeDecimal(e.target.value))} onChange={(value) => setInputVerticalSnowCover(value)}
options={{
allowNegative: false,
allowDecimal: false
}}
/> />
</div> </div>
<span className="thin">cm</span> <span className="thin">cm</span>

View File

@ -638,7 +638,7 @@ export const Orientation = forwardRef((props, ref) => {
name="" name=""
label="" label=""
className="input-origin block" className="input-origin block"
value={inputInstallHeight} value={inputVerticalSnowCover}
onChange={(value) => handleChangeVerticalSnowCover(value)} onChange={(value) => handleChangeVerticalSnowCover(value)}
options={{ options={{
allowNegative: false, allowNegative: false,

View File

@ -2125,12 +2125,12 @@ export default function StuffDetail() {
{/* {...register('verticalSnowCover')}*/} {/* {...register('verticalSnowCover')}*/}
{/*/>*/} {/*/>*/}
<CalculatorInput <CalculatorInput
id="" id="verticalSnowCover"
name="" name="verticalSnowCover"
label="" label=""
className="input-light" className="input-light"
value={form.watch('verticalSnowCover') || ''} value={form.watch('verticalSnowCover') || ''}
onChange={()=>{}} onChange={(value) => form.setValue('verticalSnowCover', value)}
options={{ options={{
allowNegative: false, allowNegative: false,
allowDecimal: false allowDecimal: false
@ -2197,12 +2197,12 @@ export default function StuffDetail() {
{/* {...register('installHeight')}*/} {/* {...register('installHeight')}*/}
{/*/>*/} {/*/>*/}
<CalculatorInput <CalculatorInput
id="" id="installHeight"
name="" name="installHeight"
label="" label=""
className="input-light" className="input-light"
value={form.watch('installHeight') || ''} value={form.watch('installHeight') || ''}
onChange={()=>{}} onChange={(value) => form.setValue('installHeight', value)}
options={{ options={{
allowNegative: false, allowNegative: false,
allowDecimal: false allowDecimal: false
@ -2721,12 +2721,12 @@ export default function StuffDetail() {
{/* {...register('verticalSnowCover')}*/} {/* {...register('verticalSnowCover')}*/}
{/*/>*/} {/*/>*/}
<CalculatorInput <CalculatorInput
id="" id="verticalSnowCover"
name="" name="verticalSnowCover"
label="" label=""
className="input-light" className="input-light"
value={form.watch('verticalSnowCover') || ''} value={form.watch('verticalSnowCover') || ''}
onChange={()=>{}} onChange={(value) => form.setValue('verticalSnowCover', value)}
options={{ options={{
allowNegative: false, allowNegative: false,
allowDecimal: false allowDecimal: false
@ -2797,12 +2797,12 @@ export default function StuffDetail() {
{/*/>*/} {/*/>*/}
<CalculatorInput <CalculatorInput
id="" id="installHeight"
name="" name="installHeight"
label="" label=""
className="input-light" className="input-light"
value={form.watch('installHeight') || ''} value={form.watch('installHeight') || ''}
onChange={()=>{}} onChange={(value) => form.setValue('installHeight', value)}
options={{ options={{
allowNegative: false, allowNegative: false,
allowDecimal: false allowDecimal: false

View File

@ -631,7 +631,7 @@ export function useMovementSetting(id) {
} }
return Big(0); // 기본값으로 0 반환 또는 다른 적절한 기본값 return Big(0); // 기본값으로 0 반환 또는 다른 적절한 기본값
})(); })();
if (target.y1 === target.y2) { if (Math.abs(target.y1 - target.y2) < 0.5) {
value = value.neg() value = value.neg()
} }
} else { } else {

View File

@ -473,7 +473,20 @@ export function useRoofAllocationSetting(id) {
// Filter out any eaveHelpLines that are already in lines to avoid duplicates // Filter out any eaveHelpLines that are already in lines to avoid duplicates
const existingEaveLineIds = new Set(roofBase.lines.map((line) => line.id)) const existingEaveLineIds = new Set(roofBase.lines.map((line) => line.id))
const newEaveLines = roofEaveHelpLines.filter((line) => !existingEaveLineIds.has(line.id)) const newEaveLines = roofEaveHelpLines.filter((line) => !existingEaveLineIds.has(line.id))
roofBase.lines = [...newEaveLines] // Filter out lines from roofBase.lines that share any points with newEaveLines
const linesToKeep = roofBase.lines.filter(roofLine => {
return !newEaveLines.some(eaveLine => {
// Check if any endpoint of roofLine matches any endpoint of eaveLine
return (
// Check if any endpoint of roofLine matches any endpoint of eaveLine
(Math.abs(roofLine.x1 - eaveLine.x1) < 0.1 && Math.abs(roofLine.y1 - eaveLine.y1) < 0.1) || // p1 matches p1
(Math.abs(roofLine.x2 - eaveLine.x2) < 0.1 && Math.abs(roofLine.y2 - eaveLine.y2) < 0.1) // p2 matches p2
);
});
});
// Combine remaining lines with newEaveLines
roofBase.lines = [...linesToKeep, ...newEaveLines];
} else { } else {
roofBase.lines = [...roofEaveHelpLines] roofBase.lines = [...roofEaveHelpLines]
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff