견적서 저장

This commit is contained in:
basssy 2024-11-30 22:19:30 +09:00
parent 747a36b51b
commit 5e54269456
2 changed files with 87 additions and 24 deletions

View File

@ -20,6 +20,7 @@ import ProductFeaturesPop from './popup/ProductFeaturesPop'
import { v4 as uuidv4 } from 'uuid'
export default function Estimate({ params }) {
const [uniqueData, setUniqueData] = useState([])
const [handlePricingFlag, setHandlePricingFlag] = useState(false)
const [specialNoteFirstFlg, setSpecialNoteFirstFlg] = useState(false)
const fixedKey = 'itemKey'
@ -123,7 +124,6 @@ export default function Estimate({ params }) {
if (estimateContextState?.estimateOption) {
res.map((row) => {
let estimateOption = estimateContextState?.estimateOption?.split('、')
// console.log(':::', estimateOption)
row.check = false
estimateOption.map((row2) => {
if (row.pkgYn === '0') {
@ -175,6 +175,8 @@ export default function Estimate({ params }) {
useEffect(() => {
// setEstimateContextState
// console.log('specialNoteList::', specialNoteList)
if (isNotEmptyArray(specialNoteList)) {
const liveCheckedData = specialNoteList.filter((row) => row.check === true)
@ -184,7 +186,9 @@ export default function Estimate({ params }) {
}
const newData = data.join('、')
setEstimateContextState({ estimateOption: newData })
//
// console.log('??', uniqueData)
setEstimateContextState({ estimateOption: newData, specialNoteList: specialNoteList, uniqueData: uniqueData })
}
}, [specialNoteList])
@ -309,6 +313,52 @@ export default function Estimate({ params }) {
})
}
const makeUniqueSpecialNoteCd = (itemList) => {
let pushData = []
let uniquSet = new Set()
itemList.forEach((item) => {
if (item.delFlg === '0') {
if (item.specialNoteCd) {
let splitData = item.specialNoteCd.split('、')
splitData.forEach((note) => {
if (!uniquSet.has(note)) {
uniquSet.add(note)
pushData.push(note)
}
})
setSpecialNoteFirstFlg(false)
}
}
})
// console.log(' :::', pushData)
setUniqueData(pushData)
specialNoteList.map((item) => {
if (item.pkgYn === '1') {
let flg = '0'
let codes = item.code
for (let i = 0; i < pushData.length; i++) {
if (codes.indexOf(pushData[i]) > -1) {
flg = '1'
}
}
if (flg === '1') {
item.check = true
} else {
item.check = false
}
}
})
setEstimateContextState({
specialNoteList: specialNoteList,
uniqueData: uniqueData,
})
}
//Pricing
const handlePricing = async (showPriceCd) => {
const param = {
@ -656,26 +706,10 @@ export default function Estimate({ params }) {
estimateContextState.itemList.sort((a, b) => {
return a.dispOrder - b.dispOrder
})
console.log('YJOD 토탈만들어주기::::::::::', estimateContextState.itemList)
// console.log('YJOD ::::::::::', estimateContextState.itemList)
let pushData = []
let uniquSet = new Set()
estimateContextState.itemList.forEach((item) => {
if (item.delFlg === '1') {
if (item.specialNoteCd) {
let splitData = item.specialNoteCd.split('、')
splitData.forEach((note) => {
if (!uniquSet.has(note)) {
uniquSet.add(note)
pushData.push(note)
}
})
setSpecialNoteFirstFlg(false)
}
}
})
//
makeUniqueSpecialNoteCd(estimateContextState.itemList)
estimateContextState.itemList.map((item) => {
delete item.showSalePrice
@ -712,8 +746,10 @@ export default function Estimate({ params }) {
totPrice: totPrice.toFixed(3),
})
} else {
//
makeUniqueSpecialNoteCd(estimateContextState.itemList)
//YJSS
console.log('YJSS 토탈만들어주기::::::::::', estimateContextState.itemList)
// console.log('YJSS ::::::::::', estimateContextState.itemList)
estimateContextState.itemList.sort((a, b) => {
return a.dispOrder - b.dispOrder
})
@ -1127,6 +1163,7 @@ export default function Estimate({ params }) {
setSpecialNoteList((specialNote) =>
specialNote.map((temp) => (temp.code === row.code ? { ...temp, check: !temp.check } : temp)),
)
settingShowContent(row.code, event)
}}
/>

View File

@ -242,8 +242,34 @@ export const useEstimateController = (planNo) => {
}
})
console.log('아이템리스트::', estimateData.itemList)
console.log('최종 정보::;', estimateData)
let estimateOptions = ''
estimateData.specialNoteList.map((item) => {
if (item.pkgYn === '0') {
if (item.check) {
if (estimateOptions === '') {
estimateOptions = item.code
} else {
estimateOptions += '、' + item.code
}
}
} else {
if (item.check) {
let flg = '0'
for (let i = 0; i < estimateData.uniqueData.length; i++) {
if (item.code.indexOf(estimateData.uniqueData[i]) > -1) {
flg = '1'
}
if (flg === '1') {
estimateOptions += '、' + estimateData.uniqueData[i]
}
}
}
}
})
estimateData.estimateOption = estimateOptions
// console.log('최종첨부파일:::', estimateData.fileList)
// console.log('최종아이템:::', estimateData.itemList)
// console.log('최종저장::', estimateData)
//2. 상세데이터 저장
// return
try {