From 82dbd1fc1b20e3578344e821ecd4f05bb11ecda0 Mon Sep 17 00:00:00 2001 From: basssy Date: Tue, 26 Nov 2024 11:59:24 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=83=81?= =?UTF-8?q?=EC=84=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/estimate/Estimate.jsx | 95 +++++++++++++++++++++------- 1 file changed, 72 insertions(+), 23 deletions(-) diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx index d4c36a18..1846b2d5 100644 --- a/src/components/estimate/Estimate.jsx +++ b/src/components/estimate/Estimate.jsx @@ -20,6 +20,7 @@ import ProductFeaturesPop from './popup/ProductFeaturesPop' import { v4 as uuidv4 } from 'uuid' export default function Estimate({ params }) { + const [specialNoteFirstFlg, setSpecialNoteFirstFlg] = useState(false) const fixedKey = 'itemKey' const [itemChangeYn, setItemChangeYn] = useState(false) const { session } = useContext(SessionContext) @@ -102,33 +103,80 @@ export default function Estimate({ params }) { useEffect(() => { //견적특이사항 API호출 //여러개 선택하면 구분자로 (、) - let url = `/api/estimate/special-note-list` - get({ url: url }).then((res) => { - if (isNotEmptyArray(res)) { - if (estimateContextState?.estimateOption) { - res.map((row) => { - let estimateOption = estimateContextState?.estimateOption?.split('、') - row.check = false - estimateOption.map((row2) => { - if (row2 === row.code) { + if (!specialNoteFirstFlg) { + let url = `/api/estimate/special-note-list` + get({ url: url }).then((res) => { + if (isNotEmptyArray(res)) { + if (estimateContextState?.estimateOption) { + res.map((row) => { + let estimateOption = estimateContextState?.estimateOption?.split('、') + row.check = false + estimateOption.map((row2) => { + if (row2 === row.code) { + row.check = true + } + }) + //detail과 상관없이 디폴트 체크목록 + //ATTR003,ATTR007 + if (row.code === 'ATTR003') { + row.check = true + } + if (row.code === 'ATTR007') { row.check = true } }) - //detail과 상관없이 디폴트 체크목록 - //ATTR003,ATTR007 - if (row.code === 'ATTR003') { - row.check = true - } - if (row.code === 'ATTR007') { - row.check = true - } - }) - setSpecialNoteList(res) + + setSpecialNoteList(res) + + setSpecialNoteFirstFlg(true) + } } - } - }) + }) + } }, [estimateContextState?.estimateOption]) + //변경버전 + // useEffect(() => { + // //견적특이사항 API호출 + // //여러개 선택하면 구분자로 (、) + // let url = `/api/estimate/special-note-title-list` + // // let url = `/api/estimate/special-note-list` + // get({ url: url }).then((res) => { + // if (isNotEmptyArray(res)) { + // if (estimateContextState?.estimateOption) { + // res.map((row) => { + // // console.log('API결과:::', row) + // //ATTR001、ATTR002、ATTR009、ATTR010 + // let estimateOption = estimateContextState?.estimateOption?.split('、') + // row.check = false + // estimateOption.map((row2) => { + // if (row.pkgYn === '0') { + // if (row2 === row.code) { + // row.check = true + // } + // } else { + // if (row.code.includes(row2)) { + // row.check = true + // return + // } + // } + // }) + // //detail과 상관없이 디폴트 체크목록 + // //ATTR003,ATTR007 + // if (row.code === 'ATTR003') { + // row.check = true + // } + // if (row.code === 'ATTR007') { + // row.check = true + // } + // }) + + // setSpecialNoteList(res) + // } + // } + // }) + // }, [estimateContextState?.estimateOption]) + //API데이터로 견적일 셋팅 let begin = 1 useEffect(() => { @@ -141,7 +189,9 @@ export default function Estimate({ params }) { //견적일 set useEffect(() => { let estimateDate = dayjs(startDate).format('YYYY-MM-DD') - setEstimateContextState({ estimateDate: estimateDate }) + if (begin === 1) { + setEstimateContextState({ estimateDate: estimateDate }) + } }, [startDate]) useEffect(() => { @@ -335,7 +385,6 @@ export default function Estimate({ params }) { updateList.push({ ...item, salePrice: '0', saleTotPrice: '0' }) } }) - setEstimateContextState({ priceCd: showPriceCd, itemList: updateList,