견적서 수정
This commit is contained in:
parent
943c7fd4b2
commit
38f70437c6
@ -58,7 +58,7 @@ export default function Estimate({ params }) {
|
||||
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
||||
|
||||
//견적서 상세데이터
|
||||
const { state, setState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid)
|
||||
const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid)
|
||||
|
||||
//견적특이사항 List
|
||||
const [specialNoteList, setSpecialNoteList] = useState([])
|
||||
@ -105,9 +105,9 @@ export default function Estimate({ params }) {
|
||||
let url = `/api/estimate/special-note-list`
|
||||
get({ url: url }).then((res) => {
|
||||
if (isNotEmptyArray(res)) {
|
||||
if (state?.estimateOption) {
|
||||
if (estimateContextState?.estimateOption) {
|
||||
res.map((row) => {
|
||||
let estimateOption = state?.estimateOption?.split('、')
|
||||
let estimateOption = estimateContextState?.estimateOption?.split('、')
|
||||
row.text = false
|
||||
estimateOption.map((row2) => {
|
||||
if (row2 === row.code) {
|
||||
@ -119,16 +119,16 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
}
|
||||
})
|
||||
}, [state?.estimateOption])
|
||||
}, [estimateContextState?.estimateOption])
|
||||
|
||||
//견적일 set
|
||||
useEffect(() => {
|
||||
let estimateDate = dayjs(startDate).format('YYYY-MM-DD')
|
||||
setState({ estimateDate: estimateDate })
|
||||
setEstimateContextState({ estimateDate: estimateDate })
|
||||
}, [startDate])
|
||||
|
||||
useEffect(() => {
|
||||
//선택된 견적특이사항 setState
|
||||
//선택된 견적특이사항 setEstimateContextState
|
||||
if (isNotEmptyArray(specialNoteList)) {
|
||||
const liveCheckedData = specialNoteList.filter((row) => row.text === true)
|
||||
|
||||
@ -138,7 +138,7 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
|
||||
const newData = data.join('、')
|
||||
setState({ estimateOption: newData })
|
||||
setEstimateContextState({ estimateOption: newData })
|
||||
}
|
||||
}, [specialNoteList])
|
||||
|
||||
@ -148,23 +148,23 @@ export default function Estimate({ params }) {
|
||||
event.stopPropagation()
|
||||
}
|
||||
|
||||
// 추가한 첨부파일 state에 넣기
|
||||
// 추가한 첨부파일 estimateContextState에 넣기
|
||||
useEffect(() => {
|
||||
if (isNotEmptyArray(files)) {
|
||||
files.map((row) => {
|
||||
setState({ fileList: row.data })
|
||||
setEstimateContextState({ fileList: row.data })
|
||||
})
|
||||
} else {
|
||||
setState({ fileList: [] })
|
||||
setEstimateContextState({ fileList: [] })
|
||||
}
|
||||
}, [files])
|
||||
|
||||
//상세에서 내려온 첨부파일 set 만들기
|
||||
useEffect(() => {
|
||||
if (isNotEmptyArray(state.fileList)) {
|
||||
setOriginFiles(state.fileList)
|
||||
if (isNotEmptyArray(estimateContextState.fileList)) {
|
||||
setOriginFiles(estimateContextState.fileList)
|
||||
}
|
||||
}, [state?.fileList])
|
||||
}, [estimateContextState?.fileList])
|
||||
|
||||
// 기존첨부파일 삭제
|
||||
const deleteOriginFile = async (objectNo, no) => {
|
||||
@ -176,7 +176,7 @@ export default function Estimate({ params }) {
|
||||
await promisePost({ url: 'api/file/fileDelete', data: delParams }).then((res) => {
|
||||
if (res.status === 204) {
|
||||
setOriginFiles(originFiles.filter((file) => file.objectNo === objectNo && file.no !== no))
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
fileList: originFiles.filter((file) => file.objectNo === objectNo && file.no !== no),
|
||||
})
|
||||
}
|
||||
@ -185,11 +185,11 @@ export default function Estimate({ params }) {
|
||||
|
||||
//가격표시 option 목록 최초세팅 && 주문분류 변경시
|
||||
useEffect(() => {
|
||||
if (state.estimateType !== '') {
|
||||
if (estimateContextState.estimateType !== '') {
|
||||
const param = {
|
||||
saleStoreId: session.storeId,
|
||||
sapSalesStoreCd: session.custCd,
|
||||
docTpCd: state?.estimateType,
|
||||
docTpCd: estimateContextState?.estimateType,
|
||||
}
|
||||
|
||||
const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}`
|
||||
@ -201,13 +201,13 @@ export default function Estimate({ params }) {
|
||||
|
||||
setItemChangeYn(true)
|
||||
}
|
||||
}, [state?.estimateType])
|
||||
}, [estimateContextState?.estimateType])
|
||||
|
||||
useEffect(() => {
|
||||
if (state?.priceCd) {
|
||||
setShowPriceCd(state.priceCd)
|
||||
if (estimateContextState?.priceCd) {
|
||||
setShowPriceCd(estimateContextState.priceCd)
|
||||
}
|
||||
}, [state?.priceCd])
|
||||
}, [estimateContextState?.priceCd])
|
||||
|
||||
//가격 표시 option 변경 이벤트
|
||||
const onChangeStorePriceList = (priceCd) => {
|
||||
@ -217,7 +217,7 @@ export default function Estimate({ params }) {
|
||||
docTpCd: priceCd,
|
||||
}
|
||||
|
||||
//프라이싱 했을때 priceCd setState
|
||||
//프라이싱 했을때 priceCd setEstimateContextState
|
||||
//화면에 보여지는 값은 showPriceCd로 관리
|
||||
setShowPriceCd(priceCd)
|
||||
|
||||
@ -234,10 +234,10 @@ export default function Estimate({ params }) {
|
||||
const param = {
|
||||
saleStoreId: session.storeId,
|
||||
sapSalesStoreCd: session.custCd,
|
||||
docTpCd: state.estimateType,
|
||||
docTpCd: estimateContextState.estimateType,
|
||||
priceCd: showPriceCd,
|
||||
//itemIdList: state.itemList, //아이템 최초정보로 호출 delFlg 0인거만..
|
||||
itemIdList: state.itemList.filter((item) => item.delFlg === '0'),
|
||||
//itemIdList: estimateContextState.itemList, //아이템 최초정보로 호출 delFlg 0인거만..
|
||||
itemIdList: estimateContextState.itemList.filter((item) => item.delFlg === '0'),
|
||||
}
|
||||
|
||||
if (param.itemIdList.length > 0) {
|
||||
@ -264,7 +264,7 @@ export default function Estimate({ params }) {
|
||||
//itemId로 비교해서 단가정보만 업데이트
|
||||
if (data.result.code === 200) {
|
||||
if (isNotEmptyArray(data.data2)) {
|
||||
state.itemList.map((item) => {
|
||||
estimateContextState.itemList.map((item) => {
|
||||
let checkYn = false
|
||||
data.data2.map((item2) => {
|
||||
if (item2.itemId === item.itemId) {
|
||||
@ -278,7 +278,7 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
})
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
priceCd: showPriceCd,
|
||||
itemList: updateList,
|
||||
})
|
||||
@ -305,7 +305,7 @@ export default function Estimate({ params }) {
|
||||
|
||||
//주택PKG input 변경
|
||||
const onChangePkgAsp = (value) => {
|
||||
if (state.estimateType === 'YJSS') {
|
||||
if (estimateContextState.estimateType === 'YJSS') {
|
||||
let pkgAsp = Number(value.replace(/[^0-9]/g, '').replaceAll(',', ''))
|
||||
if (isNaN(pkgAsp)) {
|
||||
pkgAsp = 0
|
||||
@ -314,10 +314,10 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
//현재 PKG용량값 가져오기
|
||||
|
||||
let totVolKw = state.totVolKw * 1000
|
||||
let totVolKw = estimateContextState.totVolKw * 1000
|
||||
let pkgTotPrice = pkgAsp * totVolKw
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
pkgAsp: pkgAsp,
|
||||
pkgTotPrice: pkgTotPrice.toFixed(3),
|
||||
})
|
||||
@ -339,9 +339,9 @@ export default function Estimate({ params }) {
|
||||
updates.amount = amount
|
||||
updates.itemChangeFlg = '1'
|
||||
updates.partAdd = '0'
|
||||
updates.saleTotPrice = (Number(amount.replaceAll(',', '')) * state.itemList[index].salePrice.replaceAll(',', '')).toLocaleString()
|
||||
updates.saleTotPrice = (Number(amount.replaceAll(',', '')) * estimateContextState.itemList[index].salePrice.replaceAll(',', '')).toLocaleString()
|
||||
|
||||
updateList = state.itemList.map((item) => {
|
||||
updateList = estimateContextState.itemList.map((item) => {
|
||||
if (item.dispOrder === dispOrder) {
|
||||
return { ...item, ...updates }
|
||||
} else {
|
||||
@ -349,7 +349,7 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
})
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: updateList,
|
||||
})
|
||||
|
||||
@ -368,9 +368,9 @@ export default function Estimate({ params }) {
|
||||
let updateList = []
|
||||
let updates = {}
|
||||
updates.salePrice = salePrice
|
||||
updates.saleTotPrice = (Number(salePrice.replaceAll(',', '')) * state.itemList[index].amount.replaceAll(',', '')).toLocaleString()
|
||||
updates.saleTotPrice = (Number(salePrice.replaceAll(',', '')) * estimateContextState.itemList[index].amount.replaceAll(',', '')).toLocaleString()
|
||||
|
||||
updateList = state.itemList.map((item) => {
|
||||
updateList = estimateContextState.itemList.map((item) => {
|
||||
if (item.dispOrder === dispOrder) {
|
||||
return { ...item, ...updates }
|
||||
} else {
|
||||
@ -378,7 +378,7 @@ export default function Estimate({ params }) {
|
||||
}
|
||||
})
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: updateList,
|
||||
})
|
||||
|
||||
@ -414,12 +414,12 @@ export default function Estimate({ params }) {
|
||||
updates.specialNoteCd = res.spnAttrCds
|
||||
updates.itemGroup = res.itemGroup
|
||||
updates.delFlg = '0' // 삭제플래그 0
|
||||
// updates.saleTotPrice = res.salePrice * state.itemList[index].amount
|
||||
// updates.saleTotPrice = res.salePrice * estimateContextState.itemList[index].amount
|
||||
updates.saleTotPrice = '0' //추가때는 수량을 안받아서 합계를 무조건 0으로
|
||||
//104671
|
||||
let bomList = res.itemBomList
|
||||
|
||||
updateList = state.itemList.map((item) => {
|
||||
updateList = estimateContextState.itemList.map((item) => {
|
||||
if (item.dispOrder === dispOrder) {
|
||||
return { ...item, ...updates }
|
||||
} else if (item.paDispOrder === dispOrder) {
|
||||
@ -431,18 +431,18 @@ export default function Estimate({ params }) {
|
||||
//paDispOrder
|
||||
if (bomList) {
|
||||
bomList.map((bomItem, index) => {
|
||||
let newItemDispOrder = Math.max(...state.itemList.map((item) => item.dispOrder))
|
||||
let newItemDispOrder = Math.max(...estimateContextState.itemList.map((item) => item.dispOrder))
|
||||
bomItem.dispOrder = index + 1 + newItemDispOrder
|
||||
bomItem.delFlg = '0'
|
||||
bomItem.objectNo = objectNo
|
||||
bomItem.planNo = planNo
|
||||
})
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: [...updateList, ...bomList],
|
||||
})
|
||||
} else {
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: updateList,
|
||||
})
|
||||
}
|
||||
@ -455,7 +455,7 @@ export default function Estimate({ params }) {
|
||||
const removeItem = () => {
|
||||
const array = [...selection]
|
||||
let delList = []
|
||||
state.itemList.filter((row) => {
|
||||
estimateContextState.itemList.filter((row) => {
|
||||
array.map((row2) => {
|
||||
if (row2 === row.dispOrder) {
|
||||
delList.push({ ...row })
|
||||
@ -466,7 +466,7 @@ export default function Estimate({ params }) {
|
||||
})
|
||||
})
|
||||
|
||||
const updateList = state.itemList.map((item) => {
|
||||
const updateList = estimateContextState.itemList.map((item) => {
|
||||
const isDeleted = delList.some((row) => item.delFlg === '1' || item.dispOrder === row.dispOrder)
|
||||
return {
|
||||
...item,
|
||||
@ -485,7 +485,7 @@ export default function Estimate({ params }) {
|
||||
return alert(getMessage('estimate.detail.save.requiredItem'))
|
||||
}
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: updateList,
|
||||
})
|
||||
|
||||
@ -501,8 +501,8 @@ export default function Estimate({ params }) {
|
||||
let vatPrice = 0
|
||||
let totPrice = 0
|
||||
let addPkgPrice = 0
|
||||
if (state.estimateType === 'YJOD') {
|
||||
state.itemList.map((item) => {
|
||||
if (estimateContextState.estimateType === 'YJOD') {
|
||||
estimateContextState.itemList.map((item) => {
|
||||
if (item.delFlg === '0') {
|
||||
const amount = Number(item.amount.replace(/[^0-9]/g, '').replaceAll(',', ''))
|
||||
const price = Number(item.saleTotPrice.replaceAll(',', ''))
|
||||
@ -521,7 +521,7 @@ export default function Estimate({ params }) {
|
||||
vatPrice = supplyPrice * 0.1
|
||||
totPrice = supplyPrice + vatPrice
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
totAmount: totAmount,
|
||||
totVolKw: totVolKw.toFixed(3),
|
||||
supplyPrice: supplyPrice.toFixed(3),
|
||||
@ -530,7 +530,7 @@ export default function Estimate({ params }) {
|
||||
})
|
||||
} else {
|
||||
//YJSS
|
||||
state.itemList.map((item) => {
|
||||
estimateContextState.itemList.map((item) => {
|
||||
if (item.delFlg === '0') {
|
||||
const amount = Number(item.amount.replace(/[^0-9]/g, '').replaceAll(',', ''))
|
||||
const price = Number(item.saleTotPrice.replaceAll(',', ''))
|
||||
@ -556,7 +556,7 @@ export default function Estimate({ params }) {
|
||||
vatPrice = supplyPrice * 0.1
|
||||
totPrice = supplyPrice + vatPrice
|
||||
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
totAmount: totAmount,
|
||||
totVolKw: totVolKw.toFixed(3),
|
||||
supplyPrice: supplyPrice.toFixed(3),
|
||||
@ -567,21 +567,22 @@ export default function Estimate({ params }) {
|
||||
|
||||
setItemChangeYn(false)
|
||||
}
|
||||
}, [itemChangeYn, state.itemList])
|
||||
}, [itemChangeYn, estimateContextState.itemList])
|
||||
|
||||
//안건명 인풋 변경
|
||||
const handleBlurObjectName = (e) => {
|
||||
setState({ objectName: e.target.value })
|
||||
setEstimateContextState({ objectName: e.target.value })
|
||||
}
|
||||
|
||||
//담당자 인풋 변경
|
||||
const handleBlurCharger = (e) => {
|
||||
setState({ charger: e.target.value })
|
||||
setEstimateContextState({ charger: e.target.value })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
console.log('수정날짜시간???????????', state.lastEditDatetime)
|
||||
}, [state])
|
||||
//비고 인풋 변경
|
||||
const handleBlurRemarks = (e) => {
|
||||
setEstimateContextState({ remarks: e.target.value })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="sub-content estimate">
|
||||
@ -598,18 +599,21 @@ export default function Estimate({ params }) {
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.docNo')}</div>
|
||||
<div className="estimate-name">{state.docNo}</div>
|
||||
<div className="estimate-name">{estimateContextState.docNo}</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.drawingEstimateCreateDate')}</div>
|
||||
<div className="estimate-name">
|
||||
{state?.drawingEstimateCreateDate ? `${dayjs(state.drawingEstimateCreateDate).format('YYYY.MM.DD')}` : ''}
|
||||
{estimateContextState?.drawingEstimateCreateDate
|
||||
? `${dayjs(estimateContextState.drawingEstimateCreateDate).format('YYYY.MM.DD')}`
|
||||
: ''}
|
||||
</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.lastEditDatetime')}</div>
|
||||
{/* <div className="estimate-name">{state?.lastEditDatetime ? `${dayjs(state.lastEditDatetime).format('YYYY.MM.DD HH:mm')}` : ''}</div> */}
|
||||
<div className="estimate-name">{state?.lastEditDatetime ? `${dayjs(state?.lastEditDatetime).format('HH:mm:ss')}` : ''}</div>
|
||||
<div className="estimate-name">
|
||||
{estimateContextState?.lastEditDatetime ? `${dayjs(estimateContextState.lastEditDatetime).format('YYYY.MM.DD HH:mm')}` : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -635,7 +639,7 @@ export default function Estimate({ params }) {
|
||||
<tr>
|
||||
{/* 1차 판매점명 */}
|
||||
<th>{getMessage('estimate.detail.saleStoreId')}</th>
|
||||
<td>{state?.firstSaleStoreName}</td>
|
||||
<td>{estimateContextState?.firstSaleStoreName}</td>
|
||||
{/* 견적일 */}
|
||||
<th>
|
||||
{getMessage('estimate.detail.estimateDate')} <span className="important">*</span>
|
||||
@ -649,23 +653,14 @@ export default function Estimate({ params }) {
|
||||
<tr>
|
||||
{/* 2차 판매점명 */}
|
||||
<th>{getMessage('estimate.detail.otherSaleStoreId')}</th>
|
||||
<td>{state?.agencySaleStoreName}</td>
|
||||
<td>{estimateContextState?.agencySaleStoreName}</td>
|
||||
{/* 담당자 */}
|
||||
<th>
|
||||
{getMessage('estimate.detail.receiveUser')} <span className="important">*</span>
|
||||
</th>
|
||||
<td>
|
||||
<div className="input-wrap" style={{ width: '350px' }}>
|
||||
<input
|
||||
type="text"
|
||||
className="input-light"
|
||||
defaultValue={state?.charger}
|
||||
// onChange={(e) => {
|
||||
// //담당자 charger
|
||||
// setState({ charger: e.target.value })
|
||||
// }}
|
||||
onBlur={handleBlurCharger}
|
||||
/>
|
||||
<input type="text" className="input-light" defaultValue={estimateContextState?.charger} onBlur={handleBlurCharger} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -677,16 +672,7 @@ export default function Estimate({ params }) {
|
||||
<td colSpan={3}>
|
||||
<div className="form-flex-wrap">
|
||||
<div className="input-wrap mr5" style={{ width: '610px' }}>
|
||||
<input
|
||||
type="text"
|
||||
className="input-light"
|
||||
defaultValue={state?.objectName}
|
||||
// onChange={(e) => {
|
||||
// //안건명 objectName
|
||||
// setState({ objectName: e.target.value })
|
||||
// }}
|
||||
onBlur={handleBlurObjectName}
|
||||
/>
|
||||
<input type="text" className="input-light" defaultValue={estimateContextState?.objectName} onBlur={handleBlurObjectName} />
|
||||
</div>
|
||||
<div className="select-wrap" style={{ width: '200px' }}>
|
||||
<Select
|
||||
@ -698,9 +684,9 @@ export default function Estimate({ params }) {
|
||||
options={honorificCodeList}
|
||||
onChange={(e) => {
|
||||
if (isObjectNotEmpty(e)) {
|
||||
setState({ objectNameOmit: e.clCodeNm })
|
||||
setEstimateContextState({ objectNameOmit: e.clCodeNm })
|
||||
} else {
|
||||
setState({ objectNameOmit: '' })
|
||||
setEstimateContextState({ objectNameOmit: '' })
|
||||
}
|
||||
}}
|
||||
getOptionLabel={(x) => x.clCodeNm}
|
||||
@ -708,7 +694,7 @@ export default function Estimate({ params }) {
|
||||
isClearable={false}
|
||||
isSearchable={false}
|
||||
value={honorificCodeList.filter(function (option) {
|
||||
return option.clCodeNm === state.objectNameOmit
|
||||
return option.clCodeNm === estimateContextState.objectNameOmit
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
@ -718,7 +704,7 @@ export default function Estimate({ params }) {
|
||||
<tr>
|
||||
{/* 물건정보에서 입력한 메모 */}
|
||||
<th>{getMessage('estimate.detail.objectRemarks')}</th>
|
||||
<td colSpan={3}>{state?.objectRemarks}</td>
|
||||
<td colSpan={3}>{estimateContextState?.objectRemarks}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
{/* 주문분류 */}
|
||||
@ -733,13 +719,13 @@ export default function Estimate({ params }) {
|
||||
name="estimateType"
|
||||
id="YJSS"
|
||||
value={'YJSS'}
|
||||
checked={state?.estimateType === 'YJSS' ? true : false}
|
||||
checked={estimateContextState?.estimateType === 'YJSS' ? true : false}
|
||||
onChange={(e) => {
|
||||
//주문분류
|
||||
setState({ estimateType: e.target.value })
|
||||
setEstimateContextState({ estimateType: e.target.value })
|
||||
}}
|
||||
/>
|
||||
<label htmlFor="YJSS">住宅PKG</label>
|
||||
<label htmlFor="YJSS">{getMessage('estimate.detail.estimateType.yjss')}</label>
|
||||
</div>
|
||||
<div className="d-check-radio light">
|
||||
<input
|
||||
@ -747,12 +733,12 @@ export default function Estimate({ params }) {
|
||||
name="estimateType"
|
||||
id="YJOD"
|
||||
value={'YJOD'}
|
||||
checked={state?.estimateType === 'YJOD' ? true : false}
|
||||
checked={estimateContextState?.estimateType === 'YJOD' ? true : false}
|
||||
onChange={(e) => {
|
||||
setState({ estimateType: e.target.value })
|
||||
setEstimateContextState({ estimateType: e.target.value })
|
||||
}}
|
||||
/>
|
||||
<label htmlFor="YJOD">積上げ( YJOD )</label>
|
||||
<label htmlFor="YJOD">{getMessage('estimate.detail.estimateType.yjod')}</label>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -761,16 +747,16 @@ export default function Estimate({ params }) {
|
||||
{/* 지붕재・사양시공 최대4개*/}
|
||||
<th>{getMessage('estimate.detail.roofCns')}</th>
|
||||
<td colSpan={3}>
|
||||
{state?.roofMaterialIdMulti?.split('、').map((row, index) => {
|
||||
{estimateContextState?.roofMaterialIdMulti?.split('、').map((row, index) => {
|
||||
//지붕재
|
||||
let roofList = row
|
||||
let roofListLength = state?.roofMaterialIdMulti?.split('、').length
|
||||
let roofListLength = estimateContextState?.roofMaterialIdMulti?.split('、').length
|
||||
let style = 'mb5'
|
||||
if (roofListLength == index + 1) {
|
||||
style = ''
|
||||
}
|
||||
//사양시공
|
||||
let constructSpecificationMulti = state?.constructSpecificationMulti?.split('、')
|
||||
let constructSpecificationMulti = estimateContextState?.constructSpecificationMulti?.split('、')
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -792,15 +778,7 @@ export default function Estimate({ params }) {
|
||||
<th>{getMessage('estimate.detail.remarks')}</th>
|
||||
<td colSpan={3}>
|
||||
<div className="input-wrap">
|
||||
<input
|
||||
type="text"
|
||||
className="input-light"
|
||||
defaultValue={state?.remarks}
|
||||
onChange={(e) => {
|
||||
//비고
|
||||
setState({ remarks: e.target.value })
|
||||
}}
|
||||
/>
|
||||
<input type="text" className="input-light" defaultValue={estimateContextState?.remarks} onBlur={handleBlurRemarks} />
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -815,9 +793,9 @@ export default function Estimate({ params }) {
|
||||
<input
|
||||
type="checkbox"
|
||||
id="next"
|
||||
checked={state?.fileFlg === '0' ? false : true}
|
||||
checked={estimateContextState?.fileFlg === '0' ? false : true}
|
||||
onChange={(e) => {
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
fileFlg: e.target.checked ? '1' : '0',
|
||||
})
|
||||
}}
|
||||
@ -959,28 +937,28 @@ export default function Estimate({ params }) {
|
||||
<div className="estimate-list-wrap one">
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.sepcialEstimateProductInfo.totAmount')}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(state?.totAmount)}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(estimateContextState?.totAmount)}</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.sepcialEstimateProductInfo.totVolKw')}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(state?.totVolKw)}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(estimateContextState?.totVolKw)}</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.sepcialEstimateProductInfo.supplyPrice')}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(state?.supplyPrice)}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(estimateContextState?.supplyPrice)}</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.sepcialEstimateProductInfo.vatPrice')}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(state?.vatPrice)}</div>
|
||||
<div className="estimate-name blue">{convertNumberToPriceDecimal(estimateContextState?.vatPrice)}</div>
|
||||
</div>
|
||||
<div className="estimate-box">
|
||||
<div className="estimate-tit">{getMessage('estimate.detail.sepcialEstimateProductInfo.totPrice')}</div>
|
||||
<div className="estimate-name red">{convertNumberToPriceDecimal(state?.totPrice)}</div>
|
||||
<div className="estimate-name red">{convertNumberToPriceDecimal(estimateContextState?.totPrice)}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/* YJOD면 아래영역 숨김 */}
|
||||
<div className="common-table bt-able" style={{ display: state?.estimateType === 'YJSS' ? '' : 'none' }}>
|
||||
<div className="common-table bt-able" style={{ display: estimateContextState?.estimateType === 'YJSS' ? '' : 'none' }}>
|
||||
<table>
|
||||
<colgroup>
|
||||
<col style={{ width: '160px' }} />
|
||||
@ -1001,7 +979,7 @@ export default function Estimate({ params }) {
|
||||
<input
|
||||
type="text"
|
||||
className="input-light"
|
||||
value={state?.pkgAsp}
|
||||
value={estimateContextState?.pkgAsp}
|
||||
onChange={(e) => {
|
||||
onChangePkgAsp(e.target.value)
|
||||
}}
|
||||
@ -1009,9 +987,9 @@ export default function Estimate({ params }) {
|
||||
</div>
|
||||
</td>
|
||||
<th>{getMessage('estimate.detail.sepcialEstimateProductInfo.pkgWeight')}</th>
|
||||
<td>{convertNumberToPriceDecimal(state?.totVolKw)}</td>
|
||||
<td>{convertNumberToPriceDecimal(estimateContextState?.totVolKw)}</td>
|
||||
<th>{getMessage('estimate.detail.sepcialEstimateProductInfo.pkgPrice')}</th>
|
||||
<td>{convertNumberToPriceDecimal(state?.pkgTotPrice)}</td>
|
||||
<td>{convertNumberToPriceDecimal(estimateContextState?.pkgTotPrice)}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@ -1120,8 +1098,8 @@ export default function Estimate({ params }) {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{state?.itemList.length > 0 &&
|
||||
state.itemList.map((item, index) => {
|
||||
{estimateContextState?.itemList.length > 0 &&
|
||||
estimateContextState.itemList.map((item, index) => {
|
||||
if (item.delFlg === '0') {
|
||||
return (
|
||||
<tr key={item?.dispOrder || index}>
|
||||
@ -1209,7 +1187,7 @@ export default function Estimate({ params }) {
|
||||
className="input-light al-r"
|
||||
value={convertNumberToPriceDecimal(item?.salePrice.replaceAll(',', ''))}
|
||||
disabled={
|
||||
state?.estimateType === 'YJSS'
|
||||
estimateContextState?.estimateType === 'YJSS'
|
||||
? item?.paDispOrder
|
||||
? true
|
||||
: item.pkgMaterialFlg !== '1'
|
||||
|
||||
@ -9,27 +9,9 @@ import { useMessage } from '@/hooks/useMessage'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||
|
||||
const reducer = (prevState, nextState) => {
|
||||
return { ...prevState, ...nextState }
|
||||
}
|
||||
|
||||
// Constants
|
||||
const ESTIMATE_API_ENDPOINT = '/api/estimate' // API 엔드포인트 정의
|
||||
|
||||
const defaultEstimateData = {
|
||||
estimateDate: new Date(), //견적일
|
||||
charger: '', //담당자
|
||||
objectName: '', //안건명
|
||||
objectNameOmit: '', //경칭코드
|
||||
estimateType: '', //주문분류
|
||||
remarks: '', //비고
|
||||
estimateOption: '', //견적특이사항
|
||||
itemList: [],
|
||||
fileList: [],
|
||||
fileFlg: '0', //후일 자료 제출 (체크 1 노체크 0)
|
||||
priceCd: '',
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
const updateItemInList = (itemList, dispOrder, updates) => {
|
||||
return itemList.map((item) => (item.dispOrder === dispOrder ? { ...item, ...updates } : item))
|
||||
@ -44,11 +26,10 @@ export const useEstimateController = (planNo) => {
|
||||
|
||||
const { getMessage } = useMessage()
|
||||
|
||||
const { promiseGet, get, post, promisePost } = useAxios(globalLocaleState)
|
||||
const { promiseGet, post, promisePost } = useAxios(globalLocaleState)
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false)
|
||||
const [state, setState] = useReducer(reducer, defaultEstimateData)
|
||||
const [newState, setNewState] = useState({})
|
||||
const { estimateContextState, setEstimateContextState } = useContext(FloorPlanContext)
|
||||
|
||||
useEffect(() => {
|
||||
if (planNo && !isLoading) {
|
||||
@ -69,9 +50,7 @@ export const useEstimateController = (planNo) => {
|
||||
item.delFlg = '0'
|
||||
})
|
||||
}
|
||||
console.log('조회결과;', res.data)
|
||||
console.log('수정시간;', res.data.lastEditDatetime)
|
||||
setState(res.data)
|
||||
setEstimateContextState(res.data)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -83,17 +62,17 @@ export const useEstimateController = (planNo) => {
|
||||
}
|
||||
|
||||
const updateItem = (dispOrder, updates) => {
|
||||
setState({
|
||||
itemList: updateItemInList(state.itemList, dispOrder, updates),
|
||||
setEstimateContextState({
|
||||
itemList: updateItemInList(estimateContextState.itemList, dispOrder, updates),
|
||||
})
|
||||
}
|
||||
|
||||
const addItem = () => {
|
||||
let newItemDispOrder = Math.max(...state.itemList.map((item) => item.dispOrder))
|
||||
let newItemDispOrder = Math.max(...estimateContextState.itemList.map((item) => item.dispOrder))
|
||||
newItemDispOrder = (Math.floor(newItemDispOrder / 100) + 1) * 100
|
||||
setState({
|
||||
setEstimateContextState({
|
||||
itemList: [
|
||||
...state.itemList,
|
||||
...estimateContextState.itemList,
|
||||
{
|
||||
objectNo: objectRecoil.floorPlanObjectNo,
|
||||
planNo: planNo,
|
||||
@ -115,8 +94,8 @@ export const useEstimateController = (planNo) => {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setEstimateData({ ...state, userId: session.userId, sapSalesStoreCd: session.custCd })
|
||||
}, [state])
|
||||
setEstimateData({ ...estimateContextState, userId: session.userId, sapSalesStoreCd: session.custCd })
|
||||
}, [estimateContextState])
|
||||
|
||||
// 첨부파일 다운로드
|
||||
const handleEstimateFileDownload = async (originFile) => {
|
||||
@ -206,7 +185,7 @@ export const useEstimateController = (planNo) => {
|
||||
return alert(getMessage('estimate.detail.save.requiredItem'))
|
||||
}
|
||||
|
||||
// console.log('최종 정보::;', estimateData)
|
||||
console.log('최종 정보::;', estimateData)
|
||||
|
||||
//2. 상세데이터 저장
|
||||
// return
|
||||
@ -256,8 +235,8 @@ export const useEstimateController = (planNo) => {
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
setState,
|
||||
estimateContextState,
|
||||
setEstimateContextState,
|
||||
updateItem,
|
||||
addItem,
|
||||
handleEstimateSubmit,
|
||||
|
||||
@ -823,6 +823,8 @@
|
||||
"estimate.detail.objectName": "案件名",
|
||||
"estimate.detail.objectRemarks": "メモ",
|
||||
"estimate.detail.estimateType": "注文分類",
|
||||
"estimate.detail.estimateType.yjss": "住宅PKG",
|
||||
"estimate.detail.estimateType.yjod": "積上げ( YJOD )",
|
||||
"estimate.detail.roofCns": "屋根材・仕様施工",
|
||||
"estimate.detail.remarks": "備考",
|
||||
"estimate.detail.fileFlg": "後日資料提出",
|
||||
|
||||
@ -833,6 +833,8 @@
|
||||
"estimate.detail.objectName": "안건명",
|
||||
"estimate.detail.objectRemarks": "메모",
|
||||
"estimate.detail.estimateType": "주문분류",
|
||||
"estimate.detail.estimateType.yjss": "住宅PKG",
|
||||
"estimate.detail.estimateType.yjod": "積上げ( YJOD )",
|
||||
"estimate.detail.roofCns": "지붕재・사양시공",
|
||||
"estimate.detail.remarks": "비고",
|
||||
"estimate.detail.fileFlg": "후일자료제출",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user