[1423] 設計依頼 import 매핑 정책 롤백 — StuffDetail.jsx 7e9ec4e3 복원 #857
@ -23,7 +23,6 @@ import { QcastContext } from '@/app/QcastProvider'
|
|||||||
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
|
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { sanitizeIntegerInputEvent } from '@/util/input-utils'
|
import { sanitizeIntegerInputEvent } from '@/util/input-utils'
|
||||||
import { logger } from '@/util/logger'
|
|
||||||
import { CalculatorInput } from '@/components/common/input/CalcInput'
|
import { CalculatorInput } from '@/components/common/input/CalcInput'
|
||||||
import Image from 'next/image'
|
import Image from 'next/image'
|
||||||
|
|
||||||
@ -1046,76 +1045,42 @@ export default function StuffDetail() {
|
|||||||
form.setValue('installHeight', installHeight)
|
form.setValue('installHeight', installHeight)
|
||||||
form.setValue('remarks', info.remarks)
|
form.setValue('remarks', info.remarks)
|
||||||
|
|
||||||
// [PLANREQ-MATCH 2026-05-12] 매핑 정책 재정의 — 미매칭 시 list append 폐지, 로그인 초기값 reset 으로 전환
|
if (info.saleStoreLevel === '1') {
|
||||||
// - 진입 가드 (2차점 로그인 storeLvl='2'): 1차 hidden·본인 firstAgent 고정 → 1차 derive skip, 2차 매핑만 검증, 실패 시 2차만 본인 store 로 reset
|
setSelOptions(info.saleStoreId)
|
||||||
// - T01 / 1차점: 1차 게이트 — 1차 매핑 실패 = 전체 실패. info.saleStoreLevel='2' 케이스는 firstAgent derive + 2차 lookup 둘 다 성공해야 set. 한쪽이라도 실패 시 1,2차 모두 로그인 초기값으로 reset
|
form.setValue('saleStoreId', info.saleStoreId)
|
||||||
const resetSaleStoresToLoginDefaults = () => {
|
form.setValue('saleStoreName', info.saleStoreName)
|
||||||
if (session?.storeId === 'T01') {
|
form.setValue('saleStoreLevel', info.saleStoreLevel)
|
||||||
setSelOptions('T01')
|
|
||||||
form.setValue('saleStoreId', 'T01')
|
|
||||||
form.setValue('saleStoreLevel', session?.storeLvl)
|
|
||||||
setOtherSelOptions('')
|
|
||||||
form.setValue('otherSaleStoreId', '')
|
|
||||||
form.setValue('otherSaleStoreLevel', '')
|
|
||||||
} else if (session?.storeLvl === '1') {
|
|
||||||
setSelOptions(session?.storeId)
|
|
||||||
form.setValue('saleStoreId', session?.storeId)
|
|
||||||
form.setValue('saleStoreLevel', session?.storeLvl)
|
|
||||||
setOtherSelOptions('')
|
|
||||||
form.setValue('otherSaleStoreId', '')
|
|
||||||
form.setValue('otherSaleStoreLevel', '')
|
|
||||||
}
|
|
||||||
// storeLvl='2' 는 별도 처리 — resetSaleStoresToLoginDefaults() 호출되지 않음
|
|
||||||
}
|
|
||||||
|
|
||||||
if (session?.storeId !== 'T01' && session?.storeLvl === '2') {
|
|
||||||
// 2차점 로그인: 1차 derive skip, 2차 매핑만 검증
|
|
||||||
const matched2 = otherSaleStoreList.some((o) => o.saleStoreId === info.saleStoreId)
|
|
||||||
if (matched2) {
|
|
||||||
setOtherSelOptions(info.saleStoreId)
|
|
||||||
form.setValue('otherSaleStoreId', info.saleStoreId)
|
|
||||||
form.setValue('otherSaleStoreName', info.saleStoreName)
|
|
||||||
form.setValue('otherSaleStoreLevel', info.saleStoreLevel)
|
|
||||||
} else {
|
|
||||||
// 2차 매핑 실패 → 2차만 본인 store 로 reset
|
|
||||||
setOtherSelOptions(session?.storeId)
|
|
||||||
form.setValue('otherSaleStoreId', session?.storeId)
|
|
||||||
form.setValue('otherSaleStoreLevel', session?.storeLvl)
|
|
||||||
}
|
|
||||||
} else if (info.saleStoreLevel === '1') {
|
|
||||||
// T01 / 1차점 + planreq 가 1차 ID — 1차 매핑만 시도
|
|
||||||
const matched1 = saleStoreList.some((s) => s.saleStoreId === info.saleStoreId)
|
|
||||||
if (matched1) {
|
|
||||||
setSelOptions(info.saleStoreId)
|
|
||||||
form.setValue('saleStoreId', info.saleStoreId)
|
|
||||||
form.setValue('saleStoreName', info.saleStoreName)
|
|
||||||
form.setValue('saleStoreLevel', info.saleStoreLevel)
|
|
||||||
setOtherSelOptions('')
|
|
||||||
form.setValue('otherSaleStoreId', '')
|
|
||||||
form.setValue('otherSaleStoreLevel', '')
|
|
||||||
} else {
|
|
||||||
resetSaleStoresToLoginDefaults()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// T01 / 1차점 + planreq 가 2차 ID — firstAgent derive + 2차 lookup 동시 필요
|
setOtherSelOptions(info.saleStoreId)
|
||||||
const matched2 = otherSaleStoreList.some((o) => o.saleStoreId === info.saleStoreId)
|
form.setValue('otherSaleStoreId', info.saleStoreId)
|
||||||
|
form.setValue('otherSaleStoreName', info.saleStoreName)
|
||||||
|
form.setValue('otherSaleStoreLevel', info.saleStoreLevel)
|
||||||
get({ url: `/api/object/saleStore/${info.saleStoreId}/firstAgent` }).then((res) => {
|
get({ url: `/api/object/saleStore/${info.saleStoreId}/firstAgent` }).then((res) => {
|
||||||
const firstId = res?.firstAgentId
|
if (res?.firstAgentId) {
|
||||||
const matchedFirst = firstId && saleStoreList.some((s) => s.saleStoreId === firstId)
|
const firstAgent = { saleStoreId: res.firstAgentId, saleStoreName: res.firstAgentName }
|
||||||
if (matched2 && matchedFirst) {
|
setSaleStoreList((prev) => {
|
||||||
setSelOptions(firstId)
|
const exists = prev.some((s) => s.saleStoreId === res.firstAgentId)
|
||||||
form.setValue('saleStoreId', firstId)
|
return exists ? prev : [...prev, firstAgent]
|
||||||
|
})
|
||||||
|
setShowSaleStoreList((prev) => {
|
||||||
|
const exists = prev.some((s) => s.saleStoreId === res.firstAgentId)
|
||||||
|
return exists ? prev : [...prev, firstAgent]
|
||||||
|
})
|
||||||
|
setSelOptions(res.firstAgentId)
|
||||||
|
form.setValue('saleStoreId', res.firstAgentId)
|
||||||
form.setValue('saleStoreName', res.firstAgentName)
|
form.setValue('saleStoreName', res.firstAgentName)
|
||||||
form.setValue('saleStoreLevel', '1')
|
form.setValue('saleStoreLevel', '1')
|
||||||
setOtherSelOptions(info.saleStoreId)
|
|
||||||
form.setValue('otherSaleStoreId', info.saleStoreId)
|
|
||||||
form.setValue('otherSaleStoreName', info.saleStoreName)
|
|
||||||
form.setValue('otherSaleStoreLevel', info.saleStoreLevel)
|
|
||||||
} else {
|
} else {
|
||||||
resetSaleStoresToLoginDefaults()
|
setSelOptions('')
|
||||||
|
form.setValue('saleStoreId', '')
|
||||||
|
form.setValue('saleStoreName', '')
|
||||||
|
form.setValue('saleStoreLevel', '')
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
resetSaleStoresToLoginDefaults()
|
setSelOptions('')
|
||||||
|
form.setValue('saleStoreId', '')
|
||||||
|
form.setValue('saleStoreName', '')
|
||||||
|
form.setValue('saleStoreLevel', '')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1306,6 +1271,7 @@ export default function StuffDetail() {
|
|||||||
const onValid = async (actionType) => {
|
const onValid = async (actionType) => {
|
||||||
const formData = form.getValues();
|
const formData = form.getValues();
|
||||||
if(actionType !== 'save') return false
|
if(actionType !== 'save') return false
|
||||||
|
console.log('Action type:', actionType); // 'save' 또는 'tempSave'
|
||||||
let errors = {}
|
let errors = {}
|
||||||
let fieldNm
|
let fieldNm
|
||||||
|
|
||||||
@ -1508,7 +1474,7 @@ export default function StuffDetail() {
|
|||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
})
|
})
|
||||||
logger.error('error::::::', error)
|
console.log('error::::::', error)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 수정모드일때는 PUT
|
// 수정모드일때는 PUT
|
||||||
@ -1541,7 +1507,7 @@ export default function StuffDetail() {
|
|||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
})
|
})
|
||||||
logger.error('error::::::', error)
|
console.log('error::::::', error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1632,7 +1598,7 @@ export default function StuffDetail() {
|
|||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
})
|
})
|
||||||
logger.error('error::::::', error)
|
console.log('error::::::', error)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
setIsGlobalLoading(true)
|
setIsGlobalLoading(true)
|
||||||
@ -1656,7 +1622,7 @@ export default function StuffDetail() {
|
|||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
})
|
})
|
||||||
logger.error('error::::::', error)
|
console.error('error::::::', error)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1726,7 +1692,7 @@ export default function StuffDetail() {
|
|||||||
type: 'alert',
|
type: 'alert',
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
})
|
})
|
||||||
logger.error('error::::::', error)
|
console.log('error::::::', error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -2085,12 +2051,13 @@ export default function StuffDetail() {
|
|||||||
getOptionLabel={(x) => x.saleStoreName}
|
getOptionLabel={(x) => x.saleStoreName}
|
||||||
getOptionValue={(x) => x.saleStoreId}
|
getOptionValue={(x) => x.saleStoreId}
|
||||||
isDisabled={
|
isDisabled={
|
||||||
// [PLANREQ-MATCH 2026-05-11] T01 또는 1차 user(storeLvl='1') 은 2차 enable, 2차 user(storeLvl='2') 만 disable
|
session?.storeLvl === '1'
|
||||||
session?.storeId === 'T01' || session?.storeLvl === '1'
|
|
||||||
? otherSaleStoreList.length > 0
|
? otherSaleStoreList.length > 0
|
||||||
? false
|
? false
|
||||||
: true
|
: true
|
||||||
: true
|
: otherSaleStoreList.length === 1
|
||||||
|
? true
|
||||||
|
: false
|
||||||
}
|
}
|
||||||
isClearable={true}
|
isClearable={true}
|
||||||
value={otherSaleStoreList.filter(function (option) {
|
value={otherSaleStoreList.filter(function (option) {
|
||||||
@ -2683,14 +2650,15 @@ export default function StuffDetail() {
|
|||||||
getOptionLabel={(x) => x.saleStoreName}
|
getOptionLabel={(x) => x.saleStoreName}
|
||||||
getOptionValue={(x) => x.saleStoreId}
|
getOptionValue={(x) => x.saleStoreId}
|
||||||
isDisabled={
|
isDisabled={
|
||||||
// [PLANREQ-MATCH 2026-05-11] T01 또는 1차 user(storeLvl='1') 은 2차 enable, 2차 user(storeLvl='2') 만 disable
|
|
||||||
managementState?.tempFlg === '0'
|
managementState?.tempFlg === '0'
|
||||||
? true
|
? true
|
||||||
: session?.storeId === 'T01' || session?.storeLvl === '1'
|
: session?.storeLvl === '1'
|
||||||
? otherSaleStoreList.length > 0
|
? otherSaleStoreList.length > 0
|
||||||
? false
|
? false
|
||||||
: true
|
: true
|
||||||
: true
|
: otherSaleStoreList.length === 1
|
||||||
|
? true
|
||||||
|
: false
|
||||||
}
|
}
|
||||||
isClearable={managementState?.tempFlg === '0' ? false : true}
|
isClearable={managementState?.tempFlg === '0' ? false : true}
|
||||||
value={otherSaleStoreList.filter(function (option) {
|
value={otherSaleStoreList.filter(function (option) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user