Merge branch 'dev' of https://git.hanasys.jp/qcast3/qcast-front into feature/skeleton-dev

This commit is contained in:
ysCha 2025-12-24 09:14:19 +09:00
commit f9359c6445
2 changed files with 66 additions and 15 deletions

View File

@ -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 && (

View File

@ -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({}) {
</td>
<td>
<div className="input-wrap" style={{ width: '100%' }}>
<input
type="text"
className="input-light al-r"
{/*<input*/}
{/* type="text"*/}
{/* 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(',', ''))}
disabled={item.itemId === '' || !!item?.paDispOrder}
onChange={(e) => {
onChangeAmount(e.target.value, item.dispOrder, index)
onChange={(value) =>{
onChangeAmount(value, item.dispOrder, index)
}}
maxLength={6}
/>
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div>
</td>
<td>{item.unit}</td>
<td>
<div className="form-flex-wrap">
<div className="input-wrap mr5">
<input
type="text"
className="input-light al-r"
{/*<input*/}
{/* type="text"*/}
{/* 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={
item.openFlg === '1'
? 'OPEN'
@ -2140,13 +2176,15 @@ export default function Estimate({}) {
: item.itemId === '' || !!item?.paDispOrder
? true
: item.openFlg === '1'
? true
: false
}
onChange={(e) => {
onChangeSalePrice(e.target.value, item.dispOrder, index)
onChange={(value) =>{
onChangeSalePrice(value, item.dispOrder, index)
}}
maxLength={12}
options={{
allowNegative: false,
allowDecimal: false
}}
/>
</div>
{item.openFlg === '1' && (