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

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

View File

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