Merge pull request '[1237]모듈설정, 공법설정시에 미리 규정의 내용이 입력, 기본지붕설정 <=> 개뱔지붕설정[0]' (#308) from dev into dev-deploy

Reviewed-on: #308
This commit is contained in:
ysCha 2025-08-25 17:40:28 +09:00
commit 53f8e48333
4 changed files with 156 additions and 26 deletions

View File

@ -14,6 +14,7 @@ import { useMessage } from '@/hooks/useMessage'
* @param {string} targetKey - value에 있는
* @param {string} showKey - options 있는 키중 보여줄
* @param {object} params - 추가 파라미터
* @param {boolean} showFirstOptionWhenEmpty - value가 빈값일 번째 옵션을 보여줄지 여부
* @returns
*/
export default function QSelectBox({
@ -27,6 +28,7 @@ export default function QSelectBox({
showKey = '',
params = {},
tagTitle = '',
showFirstOptionWhenEmpty = false,
}) {
const { getMessage } = useMessage()
@ -39,7 +41,9 @@ export default function QSelectBox({
if (options.length === 0) return title !== '' ? title : getMessage('selectbox.title')
if (showKey !== '' && !value) {
//value showKey
// return options[0][showKey]
if (showFirstOptionWhenEmpty && options.length > 0) {
return options[0][showKey]
}
return title !== '' ? title : getMessage('selectbox.title')
} else if (showKey !== '' && value) {
//value sourceKey targetKey
@ -48,12 +52,18 @@ export default function QSelectBox({
return option[sourceKey] === value[targetKey]
})
if (!option) {
if (showFirstOptionWhenEmpty && options.length > 0) {
return options[0][showKey]
}
return title !== '' ? title : getMessage('selectbox.title')
} else {
return option[showKey]
}
} else {
// .
if (showFirstOptionWhenEmpty && options.length > 0) {
return showKey !== '' ? options[0][showKey] : options[0].name
}
return title !== '' ? title : getMessage('selectbox.title')
}
}
@ -74,7 +84,7 @@ export default function QSelectBox({
useEffect(() => {
// value && handleClickSelectOption(value)
setSelected(handleInitState())
}, [options, value, sourceKey, targetKey, showKey])
}, [options, value, sourceKey, targetKey, showKey, showFirstOptionWhenEmpty])
useOnClickOutside(ref, handleClose)

View File

@ -59,12 +59,21 @@ const Trestle = forwardRef((props, ref) => {
const { restoreModuleInstArea } = useModuleBasicSetting()
const [flag, setFlag] = useState(false)
const tempModuleSelectionData = useRef(null)
const [autoSelectStep, setAutoSelectStep] = useState(null) // 'raftBase', 'trestle', 'constMthd', 'roofBase', 'construction'
useEffect(() => {
if (roofs && !selectedRoof) {
console.log("roofs:::::", roofs.length)
setLengthBase(roofs[0].length);
setSelectedRoof(roofs[0])
}
if (selectedRoof && selectedRoof.lenAuth === "C") {
onChangeLength(selectedRoof.length);
}
if (selectedRoof && ["C", "R"].includes(selectedRoof.raftAuth)) {
onChangeRaftBase(roofs[0]);
}
//
restoreModuleInstArea()
}, [roofs])
@ -101,41 +110,86 @@ const Trestle = forwardRef((props, ref) => {
useEffect(() => {
if (trestleList.length > 0) {
setSelectedTrestle(trestleList.find((trestle) => trestle.trestleMkrCd === trestleState?.trestleMkrCd) ?? null)
const existingTrestle = trestleList.find(
(trestle) => trestle.trestleMkrCd === trestleState?.trestleMkrCd
);
if (existingTrestle) {
setSelectedTrestle(existingTrestle)
} else if (autoSelectStep === 'trestle') {
// :
console.log('Auto selecting first trestle:', trestleList[0])
const firstTrestle = trestleList[0]
onChangeTrestleMaker(firstTrestle)
// setAutoSelectStep onChangeTrestleMaker
}
} else {
setSelectedTrestle(null)
}
}, [trestleList])
useEffect(() => {
if (roofBaseList.length > 0) {
setSelectedRoofBase(roofBaseList.find((roofBase) => roofBase.roofBaseCd === trestleState?.roofBaseCd) ?? null)
} else {
setSelectedRoofBase(null)
}
}, [roofBaseList])
}, [trestleList, autoSelectStep])
useEffect(() => {
if (constMthdList.length > 0) {
setSelectedConstMthd(constMthdList.find((constMthd) => constMthd.constMthdCd === trestleState?.constMthdCd) ?? null)
const existingConstMthd = constMthdList.find((constMthd) => constMthd.constMthdCd === trestleState?.constMthdCd)
if (existingConstMthd) {
setSelectedConstMthd(existingConstMthd)
} else if (autoSelectStep === 'constMthd') {
// :
const firstConstMthd = constMthdList[0]
onChangeConstMthd(firstConstMthd)
setAutoSelectStep('roofBase') //
}
} else {
setSelectedConstMthd(null)
}
}, [constMthdList])
}, [constMthdList, autoSelectStep])
useEffect(() => {
if (roofBaseList.length > 0) {
const existingRoofBase = roofBaseList.find((roofBase) => roofBase.roofBaseCd === trestleState?.roofBaseCd)
if (existingRoofBase) {
setSelectedRoofBase(existingRoofBase)
} else if (autoSelectStep === 'roofBase') {
// :
const firstRoofBase = roofBaseList[0]
onChangeRoofBase(firstRoofBase)
setAutoSelectStep('construction') //
}
} else {
setSelectedRoofBase(null)
}
}, [roofBaseList, autoSelectStep])
useEffect(() => {
if (constructionList.length > 0) {
setSelectedConstruction(constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp) ?? null)
const existingConstruction = constructionList.find((construction) => construction.constTp === trestleState?.construction?.constTp)
if (existingConstruction) {
setSelectedConstruction(existingConstruction)
} else if (autoSelectStep === 'construction') {
// : construction
const availableConstructions = constructionList.filter((construction) => construction.constPossYn === 'Y')
if (availableConstructions.length > 0) {
const firstConstruction = availableConstructions[0]
const firstIndex = constructionList.findIndex((construction) => construction.constTp === firstConstruction.constTp)
handleConstruction(firstIndex)
setAutoSelectStep(null) //
} else {
Swal.fire({
title: getMessage('modal.module.basic.settting.module.error4', [selectedRoof?.nameJp]),
icon: 'warning',
})
}
}
if (constructionList.filter((construction) => construction.constPossYn === 'Y').length === 0) {
Swal.fire({
title: getMessage('modal.module.basic.settting.module.error4', [selectedRoof?.nameJp]), // .
title: getMessage('modal.module.basic.settting.module.error4', [selectedRoof?.nameJp]),
icon: 'warning',
})
}
} else {
setSelectedConstruction(null)
}
}, [constructionList])
}, [constructionList, autoSelectStep])
const getConstructionState = (index) => {
if (constructionList && constructionList.length > 0) {
@ -152,6 +206,13 @@ const Trestle = forwardRef((props, ref) => {
const onChangeLength = (e) => {
setLengthBase(e)
//
setSelectedRaftBase(null)
setSelectedTrestle(null)
setSelectedConstMthd(null)
setSelectedRoofBase(null)
setSelectedConstruction(null)
dispatch({
type: 'SET_LENGTH',
roof: {
@ -161,10 +222,24 @@ const Trestle = forwardRef((props, ref) => {
raft: selectedRaftBase?.clCode,
},
})
//
if (raftBaseList.length > 0) {
const inx = raftBaseList.findIndex((raft) => raft.clCode === selectedRoof?.raft) ?? 0
const firstRaftBase = raftBaseList[inx]
onChangeRaftBase(firstRaftBase)
}
}
const onChangeRaftBase = (e) => {
setSelectedRaftBase(e)
//
setSelectedTrestle(null)
setSelectedConstMthd(null)
setSelectedRoofBase(null)
setSelectedConstruction(null)
dispatch({
type: 'SET_RAFT_BASE',
roof: {
@ -173,10 +248,20 @@ const Trestle = forwardRef((props, ref) => {
raft: e.clCode,
},
})
// () -
setTimeout(() => {
setAutoSelectStep('trestle')
}, 500) // API
}
const onChangeHajebichi = (e) => {
setHajebichi(e)
//
setSelectedTrestle(null)
setSelectedConstMthd(null)
setSelectedRoofBase(null)
setSelectedConstruction(null)
// roofs selectedRoof.index
if (selectedRoof && selectedRoof.index !== undefined) {
@ -193,10 +278,20 @@ const Trestle = forwardRef((props, ref) => {
hajebichi: e,
},
})
// () -
setTimeout(() => {
setAutoSelectStep('trestle')
}, 500)
}
const onChangeTrestleMaker = (e) => {
setSelectedTrestle(e)
//
setSelectedConstMthd(null)
setSelectedRoofBase(null)
setSelectedConstruction(null)
dispatch({
type: 'SET_TRESTLE_MAKER',
roof: {
@ -206,32 +301,48 @@ const Trestle = forwardRef((props, ref) => {
trestleMkrCd: e.trestleMkrCd,
},
})
// API ()
setTimeout(() => {
setAutoSelectStep('constMthd')
}, 300)
}
const onChangeConstMthd = (e) => {
setSelectedConstMthd(e)
//
setSelectedRoofBase(null)
setSelectedConstruction(null)
dispatch({
type: 'SET_CONST_MTHD',
roof: {
moduleTpCd: selectedModules.itemTp ?? '',
roofMatlCd: selectedRoof?.roofMatlCd ?? '',
raft: selectedRaftBase?.clCode,
trestleMkrCd: selectedTrestle.trestleMkrCd,
trestleMkrCd: selectedTrestle?.trestleMkrCd,
constMthdCd: e.constMthdCd,
},
})
// API ()
setTimeout(() => {
setAutoSelectStep('roofBase')
}, 300)
}
const onChangeRoofBase = (e) => {
setSelectedRoofBase(e)
setSelectedConstruction(null)
dispatch({
type: 'SET_ROOF_BASE',
roof: {
moduleTpCd: selectedModules.itemTp ?? '',
roofMatlCd: selectedRoof?.roofMatlCd ?? '',
raft: selectedRaftBase?.clCode,
trestleMkrCd: selectedTrestle.trestleMkrCd,
constMthdCd: selectedConstMthd.constMthdCd,
trestleMkrCd: selectedTrestle?.trestleMkrCd,
constMthdCd: selectedConstMthd?.constMthdCd,
roofBaseCd: e.roofBaseCd,
illuminationTp: managementState?.surfaceTypeValue ?? '',
instHt: managementState?.installHeight ?? '',
@ -241,6 +352,11 @@ const Trestle = forwardRef((props, ref) => {
roofPitch: Math.round(hajebichi ?? 0),
},
})
// API (construction)
setTimeout(() => {
setAutoSelectStep('construction')
}, 300)
}
const handleConstruction = (index) => {
@ -594,6 +710,8 @@ const Trestle = forwardRef((props, ref) => {
showKey={'clCodeNm'}
disabled={selectedRoof.raftAuth === 'R'}
onChange={(e) => onChangeRaftBase(e)}
showFirstOptionWhenEmpty={true}
/>
)}
</div>
@ -644,6 +762,7 @@ const Trestle = forwardRef((props, ref) => {
targetKey={'trestleMkrCd'}
showKey={'trestleMkrCdJp'}
onChange={(e) => onChangeTrestleMaker(e)}
showFirstOptionWhenEmpty={true}
/>
)}
</div>
@ -662,6 +781,7 @@ const Trestle = forwardRef((props, ref) => {
targetKey={'constMthdCd'}
showKey={'constMthdCdJp'}
onChange={(e) => onChangeConstMthd(e)}
showFirstOptionWhenEmpty={true}
/>
)}
</div>
@ -680,6 +800,7 @@ const Trestle = forwardRef((props, ref) => {
showKey={'roofBaseCdJp'}
value={selectedRoofBase}
onChange={(e) => onChangeRoofBase(e)}
showFirstOptionWhenEmpty={true}
/>
)}
</div>

View File

@ -214,7 +214,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
width: roofRef.width.current?.value,
length: roofRef.length.current?.value,
hajebichi: roofRef.hajebichi.current?.value,
raft: roofRef.rafter.current?.value,
//raft: roofRef.rafter.current?.value,
selected: true,
layout: currentRoof.layout,
index: 0,
@ -419,10 +419,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, pla
<QSelectBox
options={raftCodes}
title={
raftCodes?.find((r) => r.clCode === (currentRoof?.raft === undefined ? currentRoof?.raftBaseCd : currentRoof?.raft))
.clCodeNm
raftCodes?.find((r) => r.clCode === ( currentRoof.raft?? currentRoof?.raftBaseCd))?.clCodeNm
}
value={currentRoof?.raft === undefined ? currentRoof?.raftBaseCd : currentRoof?.raft}
value={currentRoof?.raft??currentRoof?.raftBaseCd}
onChange={(e) => handleRafterChange(e.clCode)}
sourceKey="clCode"
targetKey={currentRoof?.raft ? 'raft' : 'raftBaseCd'}

View File

@ -101,7 +101,7 @@ export function useCanvasPopupStatusController(param = 1) {
popupType: popupType.toString(),
// popupStatus: popupType === 1 ? arg : JSON.stringify(arg).replace(/"/g, '\"'),
popupStatus: JSON.stringify(arg).replace(/"/g, '\"'),
hajebichi: arg.roofConstructions?.[0]?.addRoof?.hajebichi || '',
//hajebichi: arg.roofConstructions?.[0]?.addRoof?.hajebichi || '',
}
postFetcher(`/api/v1/canvas-popup-status`, params)
},