견적서 저장
This commit is contained in:
parent
747a36b51b
commit
5e54269456
@ -20,6 +20,7 @@ import ProductFeaturesPop from './popup/ProductFeaturesPop'
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
export default function Estimate({ params }) {
|
export default function Estimate({ params }) {
|
||||||
|
const [uniqueData, setUniqueData] = useState([])
|
||||||
const [handlePricingFlag, setHandlePricingFlag] = useState(false)
|
const [handlePricingFlag, setHandlePricingFlag] = useState(false)
|
||||||
const [specialNoteFirstFlg, setSpecialNoteFirstFlg] = useState(false)
|
const [specialNoteFirstFlg, setSpecialNoteFirstFlg] = useState(false)
|
||||||
const fixedKey = 'itemKey'
|
const fixedKey = 'itemKey'
|
||||||
@ -123,7 +124,6 @@ export default function Estimate({ params }) {
|
|||||||
if (estimateContextState?.estimateOption) {
|
if (estimateContextState?.estimateOption) {
|
||||||
res.map((row) => {
|
res.map((row) => {
|
||||||
let estimateOption = estimateContextState?.estimateOption?.split('、')
|
let estimateOption = estimateContextState?.estimateOption?.split('、')
|
||||||
// console.log('최초:::', estimateOption)
|
|
||||||
row.check = false
|
row.check = false
|
||||||
estimateOption.map((row2) => {
|
estimateOption.map((row2) => {
|
||||||
if (row.pkgYn === '0') {
|
if (row.pkgYn === '0') {
|
||||||
@ -175,6 +175,8 @@ export default function Estimate({ params }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//선택된 견적특이사항 setEstimateContextState
|
//선택된 견적특이사항 setEstimateContextState
|
||||||
|
|
||||||
|
// console.log('specialNoteList::', specialNoteList)
|
||||||
if (isNotEmptyArray(specialNoteList)) {
|
if (isNotEmptyArray(specialNoteList)) {
|
||||||
const liveCheckedData = specialNoteList.filter((row) => row.check === true)
|
const liveCheckedData = specialNoteList.filter((row) => row.check === true)
|
||||||
|
|
||||||
@ -184,7 +186,9 @@ export default function Estimate({ params }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const newData = data.join('、')
|
const newData = data.join('、')
|
||||||
setEstimateContextState({ estimateOption: newData })
|
//저장용 보내기
|
||||||
|
// console.log('유니크??', uniqueData)
|
||||||
|
setEstimateContextState({ estimateOption: newData, specialNoteList: specialNoteList, uniqueData: uniqueData })
|
||||||
}
|
}
|
||||||
}, [specialNoteList])
|
}, [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 버튼
|
//Pricing 버튼
|
||||||
const handlePricing = async (showPriceCd) => {
|
const handlePricing = async (showPriceCd) => {
|
||||||
const param = {
|
const param = {
|
||||||
@ -656,26 +706,10 @@ export default function Estimate({ params }) {
|
|||||||
estimateContextState.itemList.sort((a, b) => {
|
estimateContextState.itemList.sort((a, b) => {
|
||||||
return a.dispOrder - b.dispOrder
|
return a.dispOrder - b.dispOrder
|
||||||
})
|
})
|
||||||
console.log('YJOD 토탈만들어주기::::::::::', estimateContextState.itemList)
|
// console.log('YJOD 토탈만들어주기::::::::::', estimateContextState.itemList)
|
||||||
|
|
||||||
let pushData = []
|
//아이템에서 제품관련 특이사항 중복제거해서 만드는 함수
|
||||||
let uniquSet = new Set()
|
makeUniqueSpecialNoteCd(estimateContextState.itemList)
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
estimateContextState.itemList.map((item) => {
|
estimateContextState.itemList.map((item) => {
|
||||||
delete item.showSalePrice
|
delete item.showSalePrice
|
||||||
@ -712,8 +746,10 @@ export default function Estimate({ params }) {
|
|||||||
totPrice: totPrice.toFixed(3),
|
totPrice: totPrice.toFixed(3),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
//아이템에서 제품관련 특이사항 중복제거해서 만드는 함수
|
||||||
|
makeUniqueSpecialNoteCd(estimateContextState.itemList)
|
||||||
//YJSS
|
//YJSS
|
||||||
console.log('YJSS 토탈만들어주기::::::::::', estimateContextState.itemList)
|
// console.log('YJSS 토탈만들어주기::::::::::', estimateContextState.itemList)
|
||||||
estimateContextState.itemList.sort((a, b) => {
|
estimateContextState.itemList.sort((a, b) => {
|
||||||
return a.dispOrder - b.dispOrder
|
return a.dispOrder - b.dispOrder
|
||||||
})
|
})
|
||||||
@ -1127,6 +1163,7 @@ export default function Estimate({ params }) {
|
|||||||
setSpecialNoteList((specialNote) =>
|
setSpecialNoteList((specialNote) =>
|
||||||
specialNote.map((temp) => (temp.code === row.code ? { ...temp, check: !temp.check } : temp)),
|
specialNote.map((temp) => (temp.code === row.code ? { ...temp, check: !temp.check } : temp)),
|
||||||
)
|
)
|
||||||
|
|
||||||
settingShowContent(row.code, event)
|
settingShowContent(row.code, event)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -242,8 +242,34 @@ export const useEstimateController = (planNo) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log('아이템리스트::', estimateData.itemList)
|
let estimateOptions = ''
|
||||||
console.log('최종 정보::;', estimateData)
|
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. 상세데이터 저장
|
//2. 상세데이터 저장
|
||||||
// return
|
// return
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user