견적서 소스정리 & 첨부파일

This commit is contained in:
basssy 2024-12-02 14:20:10 +09:00
parent 11d4bb9167
commit 186c15bedf
2 changed files with 64 additions and 104 deletions

View File

@ -562,7 +562,7 @@ export default function Estimate({ params }) {
let updateList = []
let updates = {}
get({ url: apiUrl }).then((res) => {
console.log('아이템디테일::::::::', res)
// console.log('::::::::', res)
updates.objectNo = objectNo
updates.planNo = planNo
updates.itemId = res.itemId
@ -696,98 +696,61 @@ export default function Estimate({ params }) {
useEffect(() => {
if (itemChangeYn) {
let totAmount = 0
let totVolKw = 0
let supplyPrice = 0
let vatPrice = 0
let totPrice = 0
let addSupplyPrice = 0
let pkgTotPrice = 0
if (estimateContextState.estimateType === 'YJOD') {
estimateContextState.itemList.sort((a, b) => {
return a.dispOrder - b.dispOrder
})
// console.log('YJOD ::::::::::', estimateContextState.itemList)
let totals = {
totAmount: 0,
totVolKw: 0,
supplyPrice: 0,
vatPrice: 0,
totPrice: 0,
addSupplyPrice: 0,
pkgTotPrice: 0,
}
//
makeUniqueSpecialNoteCd(estimateContextState.itemList)
const calculateYJODTotals = (itemList) => {
itemList.sort((a, b) => a.dispOrder - b.dispOrder)
makeUniqueSpecialNoteCd(itemList)
estimateContextState.itemList.map((item) => {
itemList.forEach((item) => {
delete item.showSalePrice
delete item.showSaleTotPrice
if (item.delFlg === '0') {
let amount = Number(item?.amount?.replace(/[^0-9]/g, '').replaceAll(',', ''))
if (isNaN(amount)) {
amount = '0'
}
let price = Number(item?.saleTotPrice?.replaceAll(',', ''))
if (isNaN(price)) {
price = 0
}
let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) || 0
let price = Number(item.saleTotPrice?.replaceAll(',', '')) || 0
if (item.moduleFlg === '1') {
//(Kw) 1
const volKw = (item.pnowW * amount) / 1000
// const volKw = item.pnowW * amount
totVolKw += volKw
totals.totVolKw += volKw
}
// const price
totAmount += amount
supplyPrice += price
totals.totAmount += amount
totals.supplyPrice += price
}
})
vatPrice = supplyPrice * 0.1
totPrice = supplyPrice + vatPrice
totals.vatPrice = totals.supplyPrice * 0.1
totals.totPrice = totals.supplyPrice + totals.vatPrice
}
setEstimateContextState({
totAmount: totAmount,
totVolKw: totVolKw.toFixed(3),
supplyPrice: supplyPrice.toFixed(3),
vatPrice: vatPrice.toFixed(3),
totPrice: totPrice.toFixed(3),
})
} else {
//
makeUniqueSpecialNoteCd(estimateContextState.itemList)
//YJSS
// console.log('YJSS ::::::::::', estimateContextState.itemList)
estimateContextState.itemList.sort((a, b) => {
return a.dispOrder - b.dispOrder
})
estimateContextState.itemList.map((item) => {
const calculateYJSSTotals = (itemList) => {
itemList.sort((a, b) => a.dispOrder - b.dispOrder)
makeUniqueSpecialNoteCd(itemList)
itemList.forEach((item) => {
if (item.delFlg === '0') {
let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', ''))
let salePrice = Number(item.salePrice?.replaceAll(',', ''))
let saleTotPrice = Number(item.saleTotPrice?.replaceAll(',', ''))
let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) || 0
let salePrice = Number(item.salePrice?.replaceAll(',', '')) || 0
if (isNaN(amount)) {
amount = '0'
}
if (isNaN(saleTotPrice)) {
saleTotPrice = 0
}
if (isNaN(salePrice)) {
salePrice = 0
}
if (item.moduleFlg === '1') {
//(Kw) 1
const volKw = (item.pnowW * amount) / 1000
totVolKw += volKw
totals.totVolKw += volKw
}
// const saleTotPrice
totAmount += amount
totals.totAmount += amount
if (item.pkgMaterialFlg === '1') {
const saleTotPrice = amount * salePrice
//
//YJSS PKG(1) * (supplyPrice)
addSupplyPrice += saleTotPrice
totals.addSupplyPrice += saleTotPrice
}
if (!item.paDispOrder) {
//paDispOrder
if (item.pkgMaterialFlg === '0') {
item.showSalePrice = '0'
item.showSaleTotPrice = '0'
@ -795,34 +758,40 @@ export default function Estimate({ params }) {
}
}
})
pkgTotPrice = estimateContextState.pkgAsp.replaceAll(',', '') * totVolKw * 1000
setEstimateContextState({
pkgTotPrice: pkgTotPrice,
})
supplyPrice = addSupplyPrice + pkgTotPrice
vatPrice = supplyPrice * 0.1
totPrice = supplyPrice + vatPrice
totals.pkgTotPrice = Number(estimateContextState.pkgAsp.replaceAll(',', '')) * totals.totVolKw * 1000
totals.supplyPrice = totals.addSupplyPrice + totals.pkgTotPrice
totals.vatPrice = totals.supplyPrice * 0.1
totals.totPrice = totals.supplyPrice + totals.vatPrice
}
if (estimateContextState.estimateType === 'YJOD') {
calculateYJODTotals(estimateContextState.itemList)
setEstimateContextState({
totAmount: totAmount,
totVolKw: totVolKw.toFixed(3),
supplyPrice: supplyPrice.toFixed(3),
vatPrice: vatPrice.toFixed(3),
totPrice: totPrice.toFixed(3),
totAmount: totals.totAmount,
totVolKw: totals.totVolKw.toFixed(3),
supplyPrice: totals.supplyPrice.toFixed(3),
vatPrice: totals.vatPrice.toFixed(3),
totPrice: totals.totPrice.toFixed(3),
})
} else if (estimateContextState.estimateType === 'YJSS') {
calculateYJSSTotals(estimateContextState.itemList)
setEstimateContextState({
pkgTotPrice: totals.pkgTotPrice,
totAmount: totals.totAmount,
totVolKw: totals.totVolKw.toFixed(3),
supplyPrice: totals.supplyPrice.toFixed(3),
vatPrice: totals.vatPrice.toFixed(3),
totPrice: totals.totPrice.toFixed(3),
})
}
setItemChangeYn(false)
} else {
estimateContextState.itemList.map((item) => {
if (estimateContextState.estimateType === 'YJSS') {
if (!item.paDispOrder) {
//paDispOrder
if (item.pkgMaterialFlg === '0') {
item.showSalePrice = '0'
item.showSaleTotPrice = '0'
}
}
estimateContextState.itemList.forEach((item) => {
if (estimateContextState.estimateType === 'YJSS' && !item.paDispOrder && item.pkgMaterialFlg === '0') {
item.showSalePrice = '0'
item.showSaleTotPrice = '0'
}
})
}
@ -1160,13 +1129,7 @@ export default function Estimate({ params }) {
{specialNoteList.length > 0 &&
specialNoteList.map((row) => {
return (
<div
key={uuidv4()}
className="special-note-check-item"
onClick={(event) => {
// settingShowContent(row.code, event)
}}
>
<div key={uuidv4()} className="special-note-check-item">
<div className="d-check-box light">
<input
type="checkbox"
@ -1181,9 +1144,7 @@ export default function Estimate({ params }) {
settingShowContent(row.code, event)
}}
/>
<label htmlFor={row.code}>
{row.codeNm} / {row.code}
</label>
<label htmlFor={row.code}>{row.codeNm}</label>
</div>
</div>
)
@ -1386,7 +1347,6 @@ export default function Estimate({ params }) {
<thead>
<tr>
<th>
{/* <div className="d-check-box pop no-text" style={{ display: 'none' }}> */}
<div className="d-check-box pop no-text">
<input type="checkbox" id="ch97" checked={isSelectedAll()} onChange={onChangeSelectAll} />
<label htmlFor="ch97"></label>

View File

@ -3,7 +3,7 @@ import { useContext, useEffect, useReducer, useState } from 'react'
import { useRecoilState, useRecoilValue } from 'recoil'
import { globalLocaleStore } from '@/store/localeAtom'
import { estimateState, floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import { isObjectNotEmpty, isNotEmptyArray } from '@/util/common-utils'
import { isObjectNotEmpty } from '@/util/common-utils'
import { SessionContext } from '@/app/SessionProvider'
import { useMessage } from '@/hooks/useMessage'
import { useRouter } from 'next/navigation'
@ -206,7 +206,7 @@ export const useEstimateController = (planNo) => {
if (flag && fileFlg && itemFlg) {
//1. 첨부파일 저장시작
const formData = new FormData()
if (isNotEmptyArray(estimateData.tempFileList) > 1) {
if (estimateData?.tempFileList?.length > 0) {
estimateData.tempFileList.forEach((file) => {
formData.append('files', file)
})