[1423] 設計依頼 import 매핑 정책 롤백 — StuffDetail.jsx 7e9ec4e3 복원 #857

Merged
ysCha merged 1 commits from dev into prd-deploy 2026-05-15 10:05:39 +09:00

View File

@ -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) {