견적서 상세화면
This commit is contained in:
parent
287f7f9c39
commit
23a5e2d2a7
@ -1,9 +1,9 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useState, useRef } from 'react'
|
import { useEffect, useState, useContext } from 'react'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue } from 'recoil'
|
||||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||||
import { sessionStore } from '@/store/commonAtom'
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
|
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
|
||||||
import SingleDatePicker from '../common/datepicker/SingleDatePicker'
|
import SingleDatePicker from '../common/datepicker/SingleDatePicker'
|
||||||
@ -21,10 +21,6 @@ export default function Estimate({ params }) {
|
|||||||
const [planNo, setPlanNo] = useState('') //플랜번호
|
const [planNo, setPlanNo] = useState('') //플랜번호
|
||||||
const [files, setFiles] = useState([]) // 보내는 첨부파일
|
const [files, setFiles] = useState([]) // 보내는 첨부파일
|
||||||
|
|
||||||
//체크박스
|
|
||||||
const [checkItems, setCheckItems] = useState(new Set())
|
|
||||||
const [checkedList, setCheckedList] = useState([])
|
|
||||||
|
|
||||||
const [showContentCode, setShowContentCode] = useState('ATTR001')
|
const [showContentCode, setShowContentCode] = useState('ATTR001')
|
||||||
|
|
||||||
//견적특이사항 접고 펼치기
|
//견적특이사항 접고 펼치기
|
||||||
@ -40,7 +36,7 @@ export default function Estimate({ params }) {
|
|||||||
setStartDate,
|
setStartDate,
|
||||||
}
|
}
|
||||||
|
|
||||||
const sessionState = useRecoilValue(sessionStore)
|
const { session } = useContext(SessionContext)
|
||||||
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
||||||
|
|
||||||
//견적서 상세데이터
|
//견적서 상세데이터
|
||||||
@ -127,6 +123,19 @@ export default function Estimate({ params }) {
|
|||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 첨부파일 state에 넣기
|
||||||
|
useEffect(() => {
|
||||||
|
// console.log(files)
|
||||||
|
if (files.length > 0) {
|
||||||
|
files.map((row) => {
|
||||||
|
setState({ fileList: row.data })
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
console.log('첨부파일 없음')
|
||||||
|
setState({ fileList: [] })
|
||||||
|
}
|
||||||
|
}, [files])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="sub-content estimate">
|
<div className="sub-content estimate">
|
||||||
<div className="sub-content-inner">
|
<div className="sub-content-inner">
|
||||||
@ -206,7 +215,6 @@ export default function Estimate({ params }) {
|
|||||||
defaultValue={state?.charger}
|
defaultValue={state?.charger}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
//담당자 charger
|
//담당자 charger
|
||||||
// console.log('담당자:::::', e.target.value)
|
|
||||||
setState({ charger: e.target.value })
|
setState({ charger: e.target.value })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -227,7 +235,6 @@ export default function Estimate({ params }) {
|
|||||||
defaultValue={state?.objectName}
|
defaultValue={state?.objectName}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
//안건명 objectName
|
//안건명 objectName
|
||||||
// console.log('안건명::::', e.target.value)
|
|
||||||
setState({ objectName: e.target.value })
|
setState({ objectName: e.target.value })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -244,7 +251,6 @@ export default function Estimate({ params }) {
|
|||||||
if (isObjectNotEmpty(e)) {
|
if (isObjectNotEmpty(e)) {
|
||||||
setState({ objectNameOmit: e.clCodeNm })
|
setState({ objectNameOmit: e.clCodeNm })
|
||||||
} else {
|
} else {
|
||||||
// console.log('XXX')
|
|
||||||
setState({ objectNameOmit: '' })
|
setState({ objectNameOmit: '' })
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@ -342,7 +348,6 @@ export default function Estimate({ params }) {
|
|||||||
defaultValue={state?.remarks}
|
defaultValue={state?.remarks}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
//비고
|
//비고
|
||||||
// console.log('비고:::::', e.target.value)
|
|
||||||
setState({ remarks: e.target.value })
|
setState({ remarks: e.target.value })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-u
|
|||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
import { useRecoilValue, useSetRecoilState } from 'recoil'
|
import { useRecoilValue, useSetRecoilState } from 'recoil'
|
||||||
import { sessionStore } from '@/store/commonAtom'
|
|
||||||
import { SessionContext } from '@/app/SessionProvider'
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
import FindAddressPop from './popup/FindAddressPop'
|
import FindAddressPop from './popup/FindAddressPop'
|
||||||
import PlanRequestPop from './popup/PlanRequestPop'
|
import PlanRequestPop from './popup/PlanRequestPop'
|
||||||
@ -28,7 +27,6 @@ export default function StuffDetail() {
|
|||||||
const [selOptions, setSelOptions] = useState('') //선택한 1차점
|
const [selOptions, setSelOptions] = useState('') //선택한 1차점
|
||||||
const [otherSelOptions, setOtherSelOptions] = useState('') //선택한 1차점외
|
const [otherSelOptions, setOtherSelOptions] = useState('') //선택한 1차점외
|
||||||
|
|
||||||
const sessionState = useRecoilValue(sessionStore)
|
|
||||||
const { session } = useContext(SessionContext)
|
const { session } = useContext(SessionContext)
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@ -320,12 +318,11 @@ export default function StuffDetail() {
|
|||||||
let firstList
|
let firstList
|
||||||
let otherList
|
let otherList
|
||||||
let favList
|
let favList
|
||||||
// if (sessionState?.storeId === 'T01') {
|
|
||||||
if (session?.storeId === 'T01') {
|
if (session?.storeId === 'T01') {
|
||||||
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
||||||
} else {
|
} else {
|
||||||
if (session.storeLvl === '1') {
|
if (session.storeLvl === '1') {
|
||||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${sessionState?.userId}`
|
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||||
} else {
|
} else {
|
||||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||||
}
|
}
|
||||||
@ -400,7 +397,6 @@ export default function StuffDetail() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// }, [objectNo, sessionState])
|
|
||||||
}, [objectNo, session])
|
}, [objectNo, session])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -1279,9 +1275,7 @@ export default function StuffDetail() {
|
|||||||
|
|
||||||
//1차점 or 2차점 안고르고 임시저장하면
|
//1차점 or 2차점 안고르고 임시저장하면
|
||||||
if (params.saleStoreId == '') {
|
if (params.saleStoreId == '') {
|
||||||
// params.saleStoreId = sessionState.storeId
|
|
||||||
params.saleStoreId = session.storeId
|
params.saleStoreId = session.storeId
|
||||||
// params.saleStoreLevel = sessionState.storeLvl
|
|
||||||
params.saleStoreLevel = session.storeLvl
|
params.saleStoreLevel = session.storeLvl
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1445,7 +1439,6 @@ export default function StuffDetail() {
|
|||||||
</th>
|
</th>
|
||||||
<td>
|
<td>
|
||||||
<div className="flx-box">
|
<div className="flx-box">
|
||||||
{/* {sessionState?.storeId === 'T01' && ( */}
|
|
||||||
{session?.storeId === 'T01' && (
|
{session?.storeId === 'T01' && (
|
||||||
<>
|
<>
|
||||||
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
||||||
@ -1479,7 +1472,6 @@ export default function StuffDetail() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* {sessionState?.storeId !== 'T01' && sessionState?.storeLvl === '1' && ( */}
|
|
||||||
{session?.storeId !== 'T01' && session?.storeLvl === '1' && (
|
{session?.storeId !== 'T01' && session?.storeLvl === '1' && (
|
||||||
<>
|
<>
|
||||||
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
||||||
@ -1511,7 +1503,6 @@ export default function StuffDetail() {
|
|||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{/* {sessionState?.storeId !== 'T01' && sessionState?.storeLvl !== '1' && ( */}
|
|
||||||
{session?.storeId !== 'T01' && session?.storeLvl !== '1' && (
|
{session?.storeId !== 'T01' && session?.storeLvl !== '1' && (
|
||||||
<>
|
<>
|
||||||
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
<div className="select-wrap mr5" style={{ width: '567px' }}>
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { useEffect, useReducer, useState } from 'react'
|
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 } from '@/util/common-utils'
|
import { isObjectNotEmpty } from '@/util/common-utils'
|
||||||
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
|
|
||||||
const reducer = (prevState, nextState) => {
|
const reducer = (prevState, nextState) => {
|
||||||
return { ...prevState, ...nextState }
|
return { ...prevState, ...nextState }
|
||||||
}
|
}
|
||||||
@ -41,6 +43,7 @@ const defaultEstimateData = {
|
|||||||
unit: '',
|
unit: '',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
fileList: [],
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper functions
|
// Helper functions
|
||||||
@ -51,14 +54,14 @@ const updateItemInList = (itemList, itemId, updates) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useEstimateController = (planNo) => {
|
export const useEstimateController = (planNo) => {
|
||||||
|
const { session } = useContext(SessionContext)
|
||||||
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
||||||
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
||||||
const [estimateData, setEstimateData] = useRecoilState(estimateState)
|
const [estimateData, setEstimateData] = useRecoilState(estimateState)
|
||||||
|
|
||||||
const { get, post } = useAxios(globalLocaleState)
|
const { get, post, promisePost } = useAxios(globalLocaleState)
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const { promisePost } = useAxios()
|
|
||||||
const [state, setState] = useReducer(reducer, defaultEstimateData)
|
const [state, setState] = useReducer(reducer, defaultEstimateData)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -123,12 +126,32 @@ export const useEstimateController = (planNo) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEstimateData({ ...state })
|
setEstimateData({ ...state, userId: session.userId })
|
||||||
|
//sapSalesStoreCd 추가예정 필수값
|
||||||
|
// setEstimateData({ ...state, userId: session.userId, sapSalesStoreCd : session.sapSalesStoreCd })
|
||||||
}, [state])
|
}, [state])
|
||||||
|
|
||||||
//견적서 저장
|
//견적서 저장
|
||||||
const handleEstimateSubmit = async () => {
|
const handleEstimateSubmit = async () => {
|
||||||
console.log('::담긴 estimateData:::', estimateData)
|
console.log('::담긴 estimateData:::', estimateData)
|
||||||
|
//1. 첨부파일 저장
|
||||||
|
const formData = new FormData()
|
||||||
|
formData.append('file', estimateData.fileList)
|
||||||
|
formData.append('objectNo', estimateData.objectNo)
|
||||||
|
formData.append('planNo', estimateData.planNo)
|
||||||
|
formData.append('category', '10')
|
||||||
|
formData.append('userId', estimateData.userId)
|
||||||
|
for (const value of formData.values()) {
|
||||||
|
console.log('formData::', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
await promisePost({ url: '/api/file/fileUpload', data: formData }).then((res) => {
|
||||||
|
console.log('파일저장::::::::::', res)
|
||||||
|
})
|
||||||
|
|
||||||
|
//2. 상세데이터 저장
|
||||||
|
|
||||||
|
console.log('상세저장시작!!')
|
||||||
return
|
return
|
||||||
try {
|
try {
|
||||||
const result = await promisePost({
|
const result = await promisePost({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user