견적서 복사

This commit is contained in:
basssy 2024-11-19 18:19:44 +09:00
parent 1c8007e96d
commit 88a64282eb
2 changed files with 47 additions and 15 deletions

View File

@ -8,14 +8,15 @@ import Select, { components } from 'react-select'
import { SessionContext } from '@/app/SessionProvider' import { SessionContext } from '@/app/SessionProvider'
import { isEmptyArray } from '@/util/common-utils' import { isEmptyArray } from '@/util/common-utils'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController' import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
import { ManagementContext } from '@/app/management/ManagementProvider'
import { estimateState } from '@/store/floorPlanObjectAtom' import { estimateState } from '@/store/floorPlanObjectAtom'
export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) { export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { get, promisePost } = useAxios() const { get, promisePost } = useAxios()
const { managementState } = useContext(ManagementContext)
const [selOptions, setSelOptions] = useState('') // 1
const { handleEstimateCopy, state } = useEstimateController(planNo) const { handleEstimateCopy, state } = useEstimateController(planNo)
const { session } = useContext(SessionContext) const { session } = useContext(SessionContext)
@ -35,15 +36,6 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
const [sendPlanNo, setSendPlanNo] = useState('1') const [sendPlanNo, setSendPlanNo] = useState('1')
const [sendCharger, setSendCharger] = useState('') const [sendCharger, setSendCharger] = useState('')
// useEffect(() => {
// console.log(originState)
// }, [originState])
useEffect(() => {
if (state) {
console.log('state::::::::', state)
}
}, [state])
useEffect(() => { useEffect(() => {
let url let url
let firstList let firstList
@ -72,6 +64,15 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
} else { } else {
if (session.storeLvl === '1') { if (session.storeLvl === '1') {
console.log('T01아닌 1차점', res) console.log('T01아닌 1차점', res)
firstList = res
favList = res.filter((row) => row.priority !== 'B')
otherList = res.filter((row) => row.firstAgentYn === 'N')
setSaleStoreList(firstList)
setFavoriteStoreList(firstList)
setShowSaleStoreList(firstList)
setSelOptions(firstList[0].saleStoreId)
setOtherSaleStoreList(otherList)
} else { } else {
console.log('1차점 아님::::::::', res) console.log('1차점 아님::::::::', res)
} }
@ -85,6 +86,28 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
setSendPlanNo(planNo) setSendPlanNo(planNo)
} }
}, [planNo]) }, [planNo])
useEffect(() => {
if (state?.charger) {
setSendCharger(state.charger)
}
}, [state.charger])
// 1
const onSelectionChange = (key) => {
if (isObjectNotEmpty(key)) {
if (key.saleStoreId === selOptions) {
return
}
}
if (isObjectNotEmpty(key)) {
console.log('KEY::', key)
} else {
console.log('XXXXXXXXXXX')
}
}
return ( return (
<div className="modal-popup"> <div className="modal-popup">
<div className="modal-dialog"> <div className="modal-dialog">
@ -132,6 +155,15 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
className="react-select-custom" className="react-select-custom"
classNamePrefix="custom" classNamePrefix="custom"
placeholder="Select" placeholder="Select"
options={showSaleStoreList[0]}
onChange={onSelectionChange}
getOptionLabel={(x) => x.saleStoreName}
getOptionValue={(x) => x.saleStoreId}
isClearable={false}
isDisabled={session?.storeLvl !== '1' ? true : session?.storeId !== 'T01' ? true : false}
value={showSaleStoreList.filter(function (option) {
return option.saleStoreId === selOptions
})}
/> />
</div> </div>
<div className="estimate-copy-id">로그인 1차점 선택한 1차점 아이디</div> <div className="estimate-copy-id">로그인 1차점 선택한 1차점 아이디</div>
@ -194,7 +226,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
type="button" type="button"
className="btn-origin navy" className="btn-origin navy"
onClick={() => { onClick={() => {
handleEstimateCopy(sendPlanNo, sendCharger) handleEstimateCopy(sendPlanNo, sendCharger, selOptions)
}} }}
> >
{getMessage('estimate.detail.estimateCopyPopup.copyBtn')} {getMessage('estimate.detail.estimateCopyPopup.copyBtn')}

View File

@ -206,14 +206,14 @@ export const useEstimateController = (planNo) => {
* (견적서 번호(estimateData.docNo) 생성된 이후 버튼 활성화 ) * (견적서 번호(estimateData.docNo) 생성된 이후 버튼 활성화 )
* T01관리자 계정 1차판매점에게만 제공 * T01관리자 계정 1차판매점에게만 제공
*/ */
const handleEstimateCopy = async (sendPlanNo, sendCharger) => { const handleEstimateCopy = async (sendPlanNo, sendCharger, selOptions) => {
console.log('입력한 값들!@@@@@', sendPlanNo, sendCharger) console.log('입력한 값들!@@@@@', sendPlanNo, sendCharger, selOptions)
const params = { const params = {
saleStoreId: session.storeId, saleStoreId: session.storeId,
sapSalesStoreCd: session.custCd, sapSalesStoreCd: session.custCd,
objectNo: objectRecoil.floorPlanObjectNo, objectNo: objectRecoil.floorPlanObjectNo,
planNo: sendPlanNo, planNo: sendPlanNo,
copySaleStoreId: 'X11', copySaleStoreId: selOptions,
copyReceiveUser: sendCharger, copyReceiveUser: sendCharger,
userId: session.userId, userId: session.userId,
} }