[1423] 設計依頼 import 매핑 정책 재정의 — 미매칭 시 로그인 초기값 reset

This commit is contained in:
ysCha 2026-05-14 16:29:38 +09:00
parent 7e9ec4e3f2
commit 91321745d4

View File

@ -23,6 +23,7 @@ import { QcastContext } from '@/app/QcastProvider'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { useSwal } from '@/hooks/useSwal'
import { sanitizeIntegerInputEvent } from '@/util/input-utils'
import { logger } from '@/util/logger'
import { CalculatorInput } from '@/components/common/input/CalcInput'
import Image from 'next/image'
@ -1045,42 +1046,76 @@ export default function StuffDetail() {
form.setValue('installHeight', installHeight)
form.setValue('remarks', info.remarks)
if (info.saleStoreLevel === '1') {
setSelOptions(info.saleStoreId)
form.setValue('saleStoreId', info.saleStoreId)
form.setValue('saleStoreName', info.saleStoreName)
form.setValue('saleStoreLevel', info.saleStoreLevel)
// [PLANREQ-MATCH 2026-05-12] list append , reset
// - (2 storeLvl='2'): 1 hidden· firstAgent 1 derive skip, 2 , 2 store reset
// - T01 / 1: 1 1 = . info.saleStoreLevel='2' firstAgent derive + 2 lookup set. 1,2 reset
const resetSaleStoresToLoginDefaults = () => {
if (session?.storeId === 'T01') {
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 {
setOtherSelOptions(info.saleStoreId)
form.setValue('otherSaleStoreId', info.saleStoreId)
form.setValue('otherSaleStoreName', info.saleStoreName)
form.setValue('otherSaleStoreLevel', info.saleStoreLevel)
// T01 / 1 + planreq 2 ID firstAgent derive + 2 lookup
const matched2 = otherSaleStoreList.some((o) => o.saleStoreId === info.saleStoreId)
get({ url: `/api/object/saleStore/${info.saleStoreId}/firstAgent` }).then((res) => {
if (res?.firstAgentId) {
const firstAgent = { saleStoreId: res.firstAgentId, saleStoreName: res.firstAgentName }
setSaleStoreList((prev) => {
const exists = prev.some((s) => s.saleStoreId === res.firstAgentId)
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)
const firstId = res?.firstAgentId
const matchedFirst = firstId && saleStoreList.some((s) => s.saleStoreId === firstId)
if (matched2 && matchedFirst) {
setSelOptions(firstId)
form.setValue('saleStoreId', firstId)
form.setValue('saleStoreName', res.firstAgentName)
form.setValue('saleStoreLevel', '1')
setOtherSelOptions(info.saleStoreId)
form.setValue('otherSaleStoreId', info.saleStoreId)
form.setValue('otherSaleStoreName', info.saleStoreName)
form.setValue('otherSaleStoreLevel', info.saleStoreLevel)
} else {
setSelOptions('')
form.setValue('saleStoreId', '')
form.setValue('saleStoreName', '')
form.setValue('saleStoreLevel', '')
resetSaleStoresToLoginDefaults()
}
}).catch(() => {
setSelOptions('')
form.setValue('saleStoreId', '')
form.setValue('saleStoreName', '')
form.setValue('saleStoreLevel', '')
resetSaleStoresToLoginDefaults()
})
}
}
@ -1271,7 +1306,6 @@ export default function StuffDetail() {
const onValid = async (actionType) => {
const formData = form.getValues();
if(actionType !== 'save') return false
console.log('Action type:', actionType); // 'save' 'tempSave'
let errors = {}
let fieldNm
@ -1474,7 +1508,7 @@ export default function StuffDetail() {
type: 'alert',
icon: 'error',
})
console.log('error::::::', error)
logger.error('error::::::', error)
})
} else {
// PUT
@ -1507,7 +1541,7 @@ export default function StuffDetail() {
type: 'alert',
icon: 'error',
})
console.log('error::::::', error)
logger.error('error::::::', error)
})
}
}
@ -1598,7 +1632,7 @@ export default function StuffDetail() {
type: 'alert',
icon: 'error',
})
console.log('error::::::', error)
logger.error('error::::::', error)
})
} else {
setIsGlobalLoading(true)
@ -1622,7 +1656,7 @@ export default function StuffDetail() {
type: 'alert',
icon: 'error',
})
console.error('error::::::', error)
logger.error('error::::::', error)
})
}
}
@ -1692,7 +1726,7 @@ export default function StuffDetail() {
type: 'alert',
icon: 'error',
})
console.log('error::::::', error)
logger.error('error::::::', error)
})
},
})
@ -2051,13 +2085,12 @@ export default function StuffDetail() {
getOptionLabel={(x) => x.saleStoreName}
getOptionValue={(x) => x.saleStoreId}
isDisabled={
session?.storeLvl === '1'
// [PLANREQ-MATCH 2026-05-11] T01 1 user(storeLvl='1') 2 enable, 2 user(storeLvl='2') disable
session?.storeId === 'T01' || session?.storeLvl === '1'
? otherSaleStoreList.length > 0
? false
: true
: otherSaleStoreList.length === 1
? true
: false
: true
}
isClearable={true}
value={otherSaleStoreList.filter(function (option) {
@ -2650,15 +2683,14 @@ export default function StuffDetail() {
getOptionLabel={(x) => x.saleStoreName}
getOptionValue={(x) => x.saleStoreId}
isDisabled={
// [PLANREQ-MATCH 2026-05-11] T01 1 user(storeLvl='1') 2 enable, 2 user(storeLvl='2') disable
managementState?.tempFlg === '0'
? true
: session?.storeLvl === '1'
: session?.storeId === 'T01' || session?.storeLvl === '1'
? otherSaleStoreList.length > 0
? false
: true
: otherSaleStoreList.length === 1
? true
: false
: true
}
isClearable={managementState?.tempFlg === '0' ? false : true}
value={otherSaleStoreList.filter(function (option) {