견적서 pkgAsp

This commit is contained in:
basssy 2024-12-07 07:01:24 +09:00
parent b2293962c5
commit 655b8f29cd

View File

@ -493,19 +493,37 @@ export default function Estimate({ params }) {
setSelection(newSelection) setSelection(newSelection)
} }
function formatNumberWithComma(number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
//PKG input //PKG input
const onChangePkgAsp = (value) => { const onChangePkgAsp = (value) => {
if (estimateContextState.estimateType === 'YJSS') { if (estimateContextState.estimateType === 'YJSS') {
let pkgAsp = Number(value.replace(/[^-\.0-9]/g, '').replaceAll(',', '')) let newValue = value.replace(/[^0-9.]/g, '')
if (isNaN(pkgAsp)) { if (newValue.length > 1) {
pkgAsp = 0 newValue = newValue.replace(/(^0+)/, '')
} else { if (newValue.length === 0) {
pkgAsp = pkgAsp.toLocaleString() newValue = '0'
}
} }
// PKG
const parts = newValue.split('.')
if (parts.length > 2) {
newValue = parts[0] + '.' + parts.slice(1).join('')
}
if (parts[1] && parts[1].length > 2) {
newValue = parts[0] + '.' + parts[1].substring(0, 2)
}
let pkgAsp = newValue || '0'
// PKG
let totVolKw = estimateContextState.totVolKw * 1000 let totVolKw = estimateContextState.totVolKw * 1000
let pkgTotPrice = pkgAsp?.replaceAll(',', '') * totVolKw * 1000 let pkgTotPrice = parseFloat(pkgAsp?.replaceAll(',', '')) * totVolKw * 1000
// pkgAsp = formatNumberWithComma(parseFloat(pkgAsp).toFixed(2))
setEstimateContextState({ setEstimateContextState({
pkgAsp: pkgAsp, pkgAsp: pkgAsp,