Compare commits
No commits in common. "df712657c3a4a62093609e2f20a1a8ef7cded309" and "0b27a161dbb142fb28bacc1fd7307620c4049c89" have entirely different histories.
df712657c3
...
0b27a161db
@ -2,8 +2,6 @@
|
|||||||
import { useEffect, useState, useContext, useRef } from 'react'
|
import { useEffect, useState, useContext, useRef } from 'react'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { useRecoilValue } from 'recoil'
|
|
||||||
import { globalLocaleStore } from '@/store/localeAtom'
|
|
||||||
import Select from 'react-select'
|
import Select from 'react-select'
|
||||||
import { SessionContext } from '@/app/SessionProvider'
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
import { isEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
|
import { isEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
|
||||||
@ -12,35 +10,24 @@ import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateCon
|
|||||||
export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { get } = useAxios()
|
const { get } = useAxios()
|
||||||
const globalLocale = useRecoilValue(globalLocaleStore)
|
|
||||||
const { handleEstimateCopy, estimateContextState } = useEstimateController(planNo, true)
|
const { handleEstimateCopy, estimateContextState } = useEstimateController(planNo, true)
|
||||||
|
|
||||||
const { session } = useContext(SessionContext)
|
const { session } = useContext(SessionContext)
|
||||||
|
|
||||||
// storeLvl 기반 동적 라벨
|
|
||||||
const lvl = session?.storeLvl || '1'
|
|
||||||
const nextLvl = Number(lvl) + 1
|
|
||||||
const saleStoreLabel = globalLocale === 'ko'
|
|
||||||
? `${lvl}차 판매점명 / ID`
|
|
||||||
: `${lvl}次販売店名/ID`
|
|
||||||
const otherSaleStoreLabel = globalLocale === 'ko'
|
|
||||||
? `${nextLvl}차+하위 판매점명 / ID`
|
|
||||||
: `${nextLvl}次下位販売店名/ID`
|
|
||||||
|
|
||||||
const [saleStoreList, setSaleStoreList] = useState([]) // 판매점 리스트
|
const [saleStoreList, setSaleStoreList] = useState([]) // 판매점 리스트
|
||||||
const [favoriteStoreList, setFavoriteStoreList] = useState([]) //즐겨찾기한 판매점목록
|
const [favoriteStoreList, setFavoriteStoreList] = useState([]) //즐겨찾기한 판매점목록
|
||||||
const [showSaleStoreList, setShowSaleStoreList] = useState([]) //보여줄 판매점목록
|
const [showSaleStoreList, setShowSaleStoreList] = useState([]) //보여줄 판매점목록
|
||||||
const [otherSaleStoreList, setOtherSaleStoreList] = useState([])
|
const [otherSaleStoreList, setOtherSaleStoreList] = useState([])
|
||||||
const [originOtherSaleStoreList, setOriginOtherSaleStoreList] = useState([])
|
const [originOtherSaleStoreList, setOriginOtherSaleStoreList] = useState([])
|
||||||
|
|
||||||
const [saleStoreId, setSaleStoreId] = useState('') //선택한 상위점
|
const [saleStoreId, setSaleStoreId] = useState('') //선택한 1차점
|
||||||
const [saleStoreName, setSaleStoreName] = useState('') //선택한 상위점명
|
const [otherSaleStoreId, setOtherSaleStoreId] = useState('') //선택한 1차점 이외
|
||||||
const [otherSaleStoreId, setOtherSaleStoreId] = useState('') //선택한 하위점
|
|
||||||
|
|
||||||
const [sendPlanNo, setSendPlanNo] = useState('1')
|
const [sendPlanNo, setSendPlanNo] = useState('1')
|
||||||
const [copyReceiveUser, setCopyReceiveUser] = useState('')
|
const [copyReceiveUser, setCopyReceiveUser] = useState('')
|
||||||
|
|
||||||
const ref = useRef() //하위점 자동완성 초기화용
|
const ref = useRef() //2차점 자동완성 초기화용
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let url
|
let url
|
||||||
@ -53,9 +40,8 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
if (session.storeLvl === '1') {
|
if (session.storeLvl === '1') {
|
||||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||||
} else {
|
} else {
|
||||||
// 2차+ 판매점: 자기 자신이 상위점, 하위점 목록 조회
|
//T01 or 1차점만 복사버튼 노출됨으로
|
||||||
setSaleStoreId(session?.storeId)
|
// url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||||
url = `/api/object/saleStore/${session?.storeId}/childList?storeLvl=${session?.storeLvl}&userId=${session?.userId}`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +91,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
|
|
||||||
setOtherSaleStoreList(otherList)
|
setOtherSaleStoreList(otherList)
|
||||||
} else {
|
} else {
|
||||||
// 2차+ 판매점: 자기 자신은 상위점명으로, 나머지는 하위점 선택 목록으로 설정
|
//T01 or 1차점만 복사버튼 노출됨으로
|
||||||
const myself = res.find((row) => row.saleStoreId === session?.storeId)
|
|
||||||
if (myself) {
|
|
||||||
setSaleStoreName(myself.saleStoreName)
|
|
||||||
}
|
|
||||||
otherList = res.filter((row) => row.saleStoreId !== session?.storeId)
|
|
||||||
setOtherSaleStoreList(otherList)
|
|
||||||
setOriginOtherSaleStoreList(otherList)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +119,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 상위점 변경 이벤트
|
// 1차점 변경 이벤트
|
||||||
const onSelectionChange = (key) => {
|
const onSelectionChange = (key) => {
|
||||||
if (isObjectNotEmpty(key)) {
|
if (isObjectNotEmpty(key)) {
|
||||||
if (key.saleStoreId === saleStoreId) {
|
if (key.saleStoreId === saleStoreId) {
|
||||||
@ -175,7 +154,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 하위점 변경 이벤트
|
// 2차점 변경 이벤트
|
||||||
const onSelectionChange2 = (key) => {
|
const onSelectionChange2 = (key) => {
|
||||||
if (isObjectNotEmpty(key)) {
|
if (isObjectNotEmpty(key)) {
|
||||||
if (key.saleStoreId === otherSaleStoreId) {
|
if (key.saleStoreId === otherSaleStoreId) {
|
||||||
@ -190,7 +169,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//하위점 자동완성 초기화
|
//2차점 자동완성 초기화
|
||||||
const handleClear = () => {
|
const handleClear = () => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
ref.current.clearValue()
|
ref.current.clearValue()
|
||||||
@ -219,7 +198,7 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
<div className="estimate-copy-info-wrap">
|
<div className="estimate-copy-info-wrap">
|
||||||
<div className="estimate-copy-info-item">
|
<div className="estimate-copy-info-item">
|
||||||
<div className="estimate-copy-info-tit">
|
<div className="estimate-copy-info-tit">
|
||||||
{saleStoreLabel} <span className="red">*</span>
|
{getMessage('estimate.detail.estimateCopyPopup.label.saleStoreId')} <span className="red">*</span>
|
||||||
</div>
|
</div>
|
||||||
{session.storeId === 'T01' && (
|
{session.storeId === 'T01' && (
|
||||||
<div className="estimate-copy-info-box">
|
<div className="estimate-copy-info-box">
|
||||||
@ -268,17 +247,9 @@ export default function EstimateCopyPop({ planNo, setEstimateCopyPopupOpen }) {
|
|||||||
<div className="estimate-copy-id">{saleStoreId}</div>
|
<div className="estimate-copy-id">{saleStoreId}</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{session.storeId !== 'T01' && session.storeLvl !== '1' && (
|
|
||||||
<div className="estimate-copy-info-box">
|
|
||||||
<div className="estimate-copy-sel">
|
|
||||||
<input type="text" className="input-light" value={saleStoreName || ''} disabled />
|
|
||||||
</div>
|
|
||||||
<div className="estimate-copy-id">{saleStoreId}</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="estimate-copy-info-item">
|
<div className="estimate-copy-info-item">
|
||||||
<div className="estimate-copy-info-tit">{otherSaleStoreLabel}</div>
|
<div className="estimate-copy-info-tit">{getMessage('estimate.detail.estimateCopyPopup.label.otherSaleStoreId')}</div>
|
||||||
<div className="estimate-copy-info-box">
|
<div className="estimate-copy-info-box">
|
||||||
<div className="estimate-copy-sel">
|
<div className="estimate-copy-sel">
|
||||||
<Select
|
<Select
|
||||||
|
|||||||
@ -455,7 +455,6 @@ export default function CanvasMenu(props) {
|
|||||||
if (createUser && tempFlg && lockFlg) {
|
if (createUser && tempFlg && lockFlg) {
|
||||||
if (createUser === 'T01' && sessionState.storeId !== 'T01') {
|
if (createUser === 'T01' && sessionState.storeId !== 'T01') {
|
||||||
setAllButtonStyles('none')
|
setAllButtonStyles('none')
|
||||||
setCopyButtonStyle('')
|
|
||||||
} else {
|
} else {
|
||||||
handleButtonStyles(tempFlg, lockFlg, docNo)
|
handleButtonStyles(tempFlg, lockFlg, docNo)
|
||||||
}
|
}
|
||||||
@ -517,7 +516,6 @@ export default function CanvasMenu(props) {
|
|||||||
if (createUser && tempFlg && lockFlg) {
|
if (createUser && tempFlg && lockFlg) {
|
||||||
if (createUser === 'T01' && sessionState.storeId !== 'T01') {
|
if (createUser === 'T01' && sessionState.storeId !== 'T01') {
|
||||||
setAllButtonStyles('none')
|
setAllButtonStyles('none')
|
||||||
setCopyButtonStyle('')
|
|
||||||
} else {
|
} else {
|
||||||
setEstimateContextState({
|
setEstimateContextState({
|
||||||
tempFlg: estimateRecoilState.tempFlg,
|
tempFlg: estimateRecoilState.tempFlg,
|
||||||
@ -695,7 +693,7 @@ export default function CanvasMenu(props) {
|
|||||||
<span className="name">{getMessage('plan.menu.estimate.reset')}</span>
|
<span className="name">{getMessage('plan.menu.estimate.reset')}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{estimateRecoilState?.docNo !== null && (sessionState.storeId === 'T01' || sessionState.storeLvl) && (
|
{estimateRecoilState?.docNo !== null && (sessionState.storeId === 'T01' || sessionState.storeLvl === '1') && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
style={{ display: copyButtonStyle }}
|
style={{ display: copyButtonStyle }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user