지붕재 할당 컬럼 추가
This commit is contained in:
parent
08bcf1c858
commit
6c4bbbb63f
@ -48,8 +48,11 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('🚀 ~ useEffect ~ basicSetting:', currentRoof)
|
||||
setBasicSettings({
|
||||
...basicSetting,
|
||||
roofSizeSet: currentRoof.roofSizeSet,
|
||||
roofAngleSet: currentRoof.roofAngleSet,
|
||||
roofsData: {
|
||||
roofApply: true,
|
||||
roofSeq: 0,
|
||||
@ -61,12 +64,21 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
roofLayout: currentRoof.layout,
|
||||
},
|
||||
})
|
||||
}, [basicSetting.roofSizeSet, basicSetting.roofAngleSet, currentRoof])
|
||||
}, [currentRoof])
|
||||
|
||||
const handleRoofSizeSetChange = (value) => {
|
||||
setCurrentRoof({...currentRoof, roofSizeSet: value})
|
||||
}
|
||||
|
||||
const handleRoofAngleSetChange = (value) => {
|
||||
setCurrentRoof({...currentRoof, roofAngleSet: value})
|
||||
}
|
||||
|
||||
// Function to update the roofType and corresponding values
|
||||
const handleRoofTypeChange = (value) => {
|
||||
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value)
|
||||
setCurrentRoof({...selectedRoofMaterial, index: 0})
|
||||
console.log('🚀 ~ handleRoofTypeChange ~ selectedRoofMaterial:', selectedRoofMaterial)
|
||||
setCurrentRoof({...selectedRoofMaterial, index: 0, roofSizeSet: currentRoof.roofSizeSet, roofAngleSet: currentRoof.roofAngleSet})
|
||||
}
|
||||
|
||||
const changeInput = (value, e) => {
|
||||
@ -125,6 +137,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
roofHajebichi: currentRoof.hajebichi,
|
||||
roofGap: currentRoof.raft,
|
||||
roofLayout: currentRoof.layout,
|
||||
roofSizeSet: currentRoof.roofSizeSet,
|
||||
roofAngleSet: currentRoof.roofAngleSet,
|
||||
},
|
||||
})
|
||||
|
||||
@ -167,8 +181,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
name="roofSizeSet"
|
||||
id="ra01"
|
||||
value="1" // roofSizeSet 값이 '1'인 경우
|
||||
checked={basicSetting.roofSizeSet == '1'} // 선택 여부 확인
|
||||
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
checked={currentRoof.roofSizeSet === '1'} // 선택 여부 확인
|
||||
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
onClick={() => handleRoofSizeSetChange(1)}
|
||||
/>
|
||||
<label htmlFor="ra01">{getMessage('modal.placement.initial.setting.size.roof')}</label>
|
||||
</div>
|
||||
@ -178,8 +193,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
name="roofSizeSet"
|
||||
id="ra02"
|
||||
value="2" // roofSizeSet 값이 '2'인 경우
|
||||
checked={basicSetting.roofSizeSet == '2'} // 선택 여부 확인
|
||||
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
checked={currentRoof.roofSizeSet === '2'} // 선택 여부 확인
|
||||
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
onClick={() => handleRoofSizeSetChange(2)}
|
||||
/>
|
||||
<label htmlFor="ra02">{getMessage('modal.placement.initial.setting.size.actual')}</label>
|
||||
</div>
|
||||
@ -189,8 +205,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
name="roofSizeSet"
|
||||
id="ra03"
|
||||
value="3" // roofSizeSet 값이 '3'인 경우
|
||||
checked={basicSetting.roofSizeSet == '3'} // 선택 여부 확인
|
||||
onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
checked={currentRoof.roofSizeSet === '3'} // 선택 여부 확인
|
||||
//onChange={(e) => setBasicSettings({ ...basicSetting, roofSizeSet: e.target.value })} // 상태 업데이트
|
||||
onClick={() => handleRoofSizeSetChange(3)}
|
||||
/>
|
||||
<label htmlFor="ra03">{getMessage('modal.placement.initial.setting.size.none.pitch')}</label>
|
||||
</div>
|
||||
@ -207,8 +224,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
name="roofAngleSet"
|
||||
id="ra04"
|
||||
value="slope" // 첫 번째 라디오 버튼의 값
|
||||
checked={basicSetting.roofAngleSet == 'slope'} // 현재 선택된 값인지 확인
|
||||
onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트
|
||||
checked={currentRoof.roofAngleSet === 'slope'} // 현재 선택된 값인지 확인
|
||||
//onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트
|
||||
onClick={() => handleRoofAngleSetChange('slope')}
|
||||
/>
|
||||
<label htmlFor="ra04">{getMessage('modal.placement.initial.setting.roof.pitch')}</label>
|
||||
</div>
|
||||
@ -218,8 +236,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
name="roofAngleSet"
|
||||
id="ra05"
|
||||
value="flat" // 두 번째 라디오 버튼의 값
|
||||
checked={basicSetting.roofAngleSet == 'flat'} // 현재 선택된 값인지 확인
|
||||
onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트
|
||||
checked={currentRoof.roofAngleSet === 'flat'} // 현재 선택된 값인지 확인
|
||||
//onChange={(e) => setBasicSettings({ ...basicSetting, roofAngleSet: e.target.value })} // 상태 업데이트
|
||||
onClick={() => handleRoofAngleSetChange('flat')}
|
||||
/>
|
||||
<label htmlFor="ra05">{getMessage('modal.placement.initial.setting.roof.angle')}</label>
|
||||
</div>
|
||||
@ -237,17 +256,17 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
<div className="placement-option">
|
||||
<div className="grid-select no-flx" style={{ width: '171px' }}>
|
||||
<QSelectBox
|
||||
title={basicSetting.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : currentRoof.roofMatlNm}
|
||||
title={currentRoof.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : currentRoof.roofMatlNm}
|
||||
ref={roofRef.roofCd}
|
||||
options={roofMaterials.map((roof, index) => {
|
||||
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp }
|
||||
})}
|
||||
value={basicSetting.roofSizeSet == 3 ? null : currentRoof.roofMatlCd}
|
||||
value={currentRoof.roofSizeSet == 3 ? null : currentRoof.roofMatlCd}
|
||||
onChange={(e) => handleRoofTypeChange(e.roofMatlCd)}
|
||||
sourceKey="id"
|
||||
targetKey="id"
|
||||
showKey="name"
|
||||
disabled={basicSetting.roofSizeSet == 3}
|
||||
disabled={currentRoof.roofSizeSet == 3}
|
||||
/>
|
||||
{/* <select
|
||||
className="select-light dark"
|
||||
@ -267,7 +286,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
})}
|
||||
</select> */}
|
||||
</div>
|
||||
{basicSetting && ['R', 'C'].includes(currentRoof.widAuth) && (
|
||||
{currentRoof && ['R', 'C'].includes(currentRoof.widAuth) && (
|
||||
<div className="flex-ment">
|
||||
<span>W</span>
|
||||
<div className="input-grid" style={{ width: '84px' }}>
|
||||
@ -279,7 +298,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
value={parseInt(currentRoof.width)}
|
||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||
readOnly={currentRoof.widAuth === 'R'}
|
||||
disabled={basicSetting.roofSizeSet == 3}
|
||||
disabled={currentRoof.roofSizeSet == 3}
|
||||
/>
|
||||
</div>
|
||||
{/* <div className="input-grid" style={{ width: '63px' }}>
|
||||
@ -292,7 +311,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
</div> */}
|
||||
</div>
|
||||
)}
|
||||
{basicSetting && ['R', 'C'].includes(currentRoof.lenAuth) && (
|
||||
{currentRoof && ['R', 'C'].includes(currentRoof.lenAuth) && (
|
||||
<div className="flex-ment">
|
||||
<span>L</span>
|
||||
<div className="input-grid" style={{ width: '84px' }}>
|
||||
@ -304,7 +323,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
value={parseInt(currentRoof.length)}
|
||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||
readOnly={currentRoof.lenAuth === 'R'}
|
||||
disabled={basicSetting.roofSizeSet == 3}
|
||||
disabled={currentRoof.roofSizeSet == 3}
|
||||
/>
|
||||
</div>
|
||||
{/* <div className="input-grid" style={{ width: '63px' }}>
|
||||
@ -317,7 +336,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
</div> */}
|
||||
</div>
|
||||
)}
|
||||
{basicSetting && ['C', 'R'].includes(currentRoof.raftAuth) && (
|
||||
{currentRoof && ['C', 'R'].includes(currentRoof.raftAuth) && (
|
||||
<div className="flex-ment">
|
||||
<span>{getMessage('modal.placement.initial.setting.rafter')}</span>
|
||||
{raftCodes.length > 0 && (
|
||||
@ -331,7 +350,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
sourceKey="clCode"
|
||||
targetKey={currentRoof.raft ? 'raft' : 'raftBaseCd'}
|
||||
showKey="clCodeNm"
|
||||
disabled={basicSetting.roofSizeSet == 3}
|
||||
disabled={currentRoof.roofSizeSet == 3}
|
||||
/>
|
||||
{/* <select className="select-light dark" name="roofGap" ref={roofRef.rafter}>
|
||||
{raftCodes.map((raft, index) => {
|
||||
@ -346,7 +365,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{basicSetting && ['C', 'R'].includes(currentRoof.roofPchAuth) && (
|
||||
{currentRoof && ['C', 'R'].includes(currentRoof.roofPchAuth) && (
|
||||
<div className="flex-ment">
|
||||
<span>{getMessage('hajebichi')}</span>
|
||||
<div className="input-grid" style={{ width: '84px' }}>
|
||||
@ -358,7 +377,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
||||
value={parseInt(currentRoof.hajebichi)}
|
||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||
readOnly={currentRoof.roofPchAuth === 'R'}
|
||||
disabled={basicSetting.roofSizeSet == 3}
|
||||
disabled={currentRoof.roofSizeSet == 3}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -274,7 +274,7 @@ export function useCanvasSetting() {
|
||||
// 기본설정(PlacementShapeSetting) 조회 및 초기화
|
||||
const fetchBasicSettings = async () => {
|
||||
try {
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => {
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
||||
|
||||
let roofsRow = {}
|
||||
let roofsArray = {}
|
||||
@ -320,15 +320,6 @@ export function useCanvasSetting() {
|
||||
]
|
||||
}
|
||||
|
||||
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
|
||||
const patternData = {
|
||||
roofSizeSet: roofsRow[0].roofSizeSet,
|
||||
roofAngleSet: roofsRow[0].roofAngleSet,
|
||||
roofs: roofsArray, // 만들어진 roofs 배열
|
||||
}
|
||||
|
||||
//console.log('fetchBasicSettings patternData', patternData)
|
||||
|
||||
// 데이터 설정
|
||||
const addRoofs = []
|
||||
roofMaterials?.map((material) => {
|
||||
@ -340,6 +331,8 @@ export function useCanvasSetting() {
|
||||
, hajebichi: roofsArray[0].roofHajebichi
|
||||
, raft: roofsArray[0].roofGap
|
||||
, layout: roofsArray[0].roofLayout
|
||||
, roofSizeSet: roofsRow[0].roofSizeSet
|
||||
, roofAngleSet: roofsRow[0].roofAngleSet
|
||||
})
|
||||
|
||||
setAddedRoofs(addRoofs)
|
||||
@ -378,6 +371,8 @@ export function useCanvasSetting() {
|
||||
roofHajebichi: basicSetting.roofsData.roofHajebichi === null || basicSetting.roofsData.roofHajebichi === undefined ? 0 : basicSetting.roofsData.roofHajebichi,
|
||||
roofGap: basicSetting.roofsData.roofGap === null || basicSetting.roofsData.roofGap === undefined ? 'HEI_455' : basicSetting.roofsData.roofGap,
|
||||
roofLayout: basicSetting.roofsData.roofLayout === null || basicSetting.roofsData.roofLayout === undefined ? 'P' : basicSetting.roofsData.roofLayout,
|
||||
roofPitch: 4,
|
||||
roofAngle: 21.8,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@ -90,18 +90,13 @@ export function useRoofAllocationSetting(id) {
|
||||
closePopup(id)
|
||||
}
|
||||
|
||||
// console.log('🚀 ~ useEffect ~ roofMaterials >>>>>>>>>>>>> :', roofMaterials)
|
||||
// console.log('🚀 ~ useEffect ~ basicSetting >>>>>>>>>>>>> :', basicSetting)
|
||||
// console.log('🚀 ~ useEffect ~ roofList >>>>>>>>>>>>> :', roofList)
|
||||
// console.log('🚀 ~ useEffect ~ currentRoofList >>>>>>>>>>>>> :', currentRoofList)
|
||||
|
||||
fetchBasicSettings()
|
||||
}, [])
|
||||
|
||||
// 조회 및 초기화
|
||||
// 지붕면 할당 조회 및 초기화
|
||||
const fetchBasicSettings = async () => {
|
||||
try {
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => {
|
||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
||||
console.log('🚀 ~ useRoofAllocationSetting ~ fetchBasicSettings ~ res >>>>>>>>>>>>>>>>>>>>> :', res)
|
||||
let roofsArray = {}
|
||||
|
||||
@ -116,6 +111,8 @@ export function useRoofAllocationSetting(id) {
|
||||
roofHajebichi: item.roofHajebichi,
|
||||
roofGap: item.roofGap,
|
||||
roofLayout: item.roofLayout,
|
||||
roofPitch: item.roofPitch,
|
||||
roofAngle: item.roofAngle,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@ -129,15 +126,12 @@ export function useRoofAllocationSetting(id) {
|
||||
roofHajebichi: 0,
|
||||
roofGap: 'HEI_455',
|
||||
roofLayout: 'P',
|
||||
roofPitch: 4,
|
||||
roofAngle: 21.8,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
|
||||
const patternData = {
|
||||
roofs: roofsArray, // 만들어진 roofs 배열
|
||||
}
|
||||
|
||||
console.log('fetchBasicSettings roofsArray', roofsArray)
|
||||
|
||||
// 데이터 설정
|
||||
@ -155,6 +149,8 @@ export function useRoofAllocationSetting(id) {
|
||||
hajebichi: roofsArray[i].roofHajebichi,
|
||||
raft: roofsArray[i].roofGap,
|
||||
layout: roofsArray[i].roofLayout,
|
||||
pitch: roofsArray[i].roofPitch,
|
||||
angle: roofsArray[i].roofAngle,
|
||||
})
|
||||
setCurrentRoofList(selectRoofs)
|
||||
}
|
||||
@ -167,28 +163,30 @@ export function useRoofAllocationSetting(id) {
|
||||
}
|
||||
}
|
||||
|
||||
// 저장
|
||||
// 지붕면 할당 저장
|
||||
const basicSettingSave = async () => {
|
||||
const patternData = {
|
||||
objectNo: correntObjectNo,
|
||||
roofSizeSet: basicSetting.roofSizeSet,
|
||||
roofAngleSet: basicSetting.roofAngleSet,
|
||||
roofMaterialsAddList: currentRoofList.map((item) => ({
|
||||
roofMaterialsAddList: currentRoofList.map((item, index) => ({
|
||||
roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected,
|
||||
roofSeq: item.index === null || item.index === undefined ? 0 : item.index,
|
||||
roofSeq: index,
|
||||
roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd,
|
||||
roofWidth: item.width === null || item.width === undefined ? 0 : item.width,
|
||||
roofHeight: item.length === null || item.length === undefined ? 0 : item.length,
|
||||
roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi,
|
||||
roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft,
|
||||
roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout,
|
||||
roofPitch: item.pitch === null || item.pitch === undefined ? 4 : item.pitch,
|
||||
roofAngle: item.angle === null || item.angle === undefined ? 21.8 : item.angle,
|
||||
})),
|
||||
}
|
||||
|
||||
console.log('🚀 ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData)
|
||||
|
||||
// HTTP POST 요청 보내기
|
||||
await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData })
|
||||
await post({ url: `/api/canvas-management/roof-allocation-settings`, data: patternData })
|
||||
.then((res) => {
|
||||
swalFire({ text: getMessage(res.returnMessage) })
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user