배치면초기설정 수정
This commit is contained in:
parent
371f1eb202
commit
477459d571
@ -42,11 +42,31 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
|
|
||||||
// 데이터를 최초 한 번만 조회
|
// 데이터를 최초 한 번만 조회
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// fetchBasicSettings()
|
fetchBasicSettings()
|
||||||
const raftCodeList = findCommonCode('203800')
|
const raftCodeList = findCommonCode('203800')
|
||||||
setRaftCodes(raftCodeList)
|
setRaftCodes(raftCodeList)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
console.log('currentRoofMaterial', currentRoofMaterial)
|
||||||
|
console.log('basicSetting', basicSetting)
|
||||||
|
|
||||||
|
setBasicSettings({
|
||||||
|
...basicSetting,
|
||||||
|
roofsData: {
|
||||||
|
roofApply: true,
|
||||||
|
roofSeq: 1,
|
||||||
|
roofMatlCd: currentRoofMaterial.roofMatlCd === null ? 'ROOF_ID_WA_53A' : currentRoofMaterial.roofMatlCd,
|
||||||
|
roofWidth: currentRoofMaterial.width === null ? 0 : currentRoofMaterial.width,
|
||||||
|
roofHeight: currentRoofMaterial.length === null ? 0 : currentRoofMaterial.length,
|
||||||
|
roofHajebichi: currentRoofMaterial.hajebichi === null ? 0 : currentRoofMaterial.hajebichi,
|
||||||
|
roofGap: currentRoofMaterial.raftBaseCd === null ? 'HEI_455' : currentRoofMaterial.raftBaseCd,
|
||||||
|
roofLayout: roofLayout,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}, [currentRoofMaterial, roofLayout, basicSetting.roofSizeSet, basicSetting.roofAngleSet ])
|
||||||
|
|
||||||
// Function to update the roofType and corresponding values
|
// Function to update the roofType and corresponding values
|
||||||
const handleRoofTypeChange = (value) => {
|
const handleRoofTypeChange = (value) => {
|
||||||
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value)
|
const selectedRoofMaterial = roofMaterials.find((roof) => roof.roofMatlCd === value)
|
||||||
@ -76,6 +96,16 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
roofInfo,
|
roofInfo,
|
||||||
},
|
},
|
||||||
roofs: addedRoofs,
|
roofs: addedRoofs,
|
||||||
|
roofsData: {
|
||||||
|
roofApply: true,
|
||||||
|
roofSeq: 1,
|
||||||
|
roofMatlCd: currentRoofMaterial.roofMatlCd === null ? 'ROOF_ID_WA_53A' : currentRoofMaterial.roofMatlCd,
|
||||||
|
roofWidth: currentRoofMaterial.width === null ? 0 : currentRoofMaterial.width,
|
||||||
|
roofHeight: currentRoofMaterial.length === null ? 0 : currentRoofMaterial.length,
|
||||||
|
roofHajebichi: currentRoofMaterial.hajebichi === null ? 0 : currentRoofMaterial.hajebichi,
|
||||||
|
roofGap: currentRoofMaterial.raftBaseCd === null ? 'HEI_455' : currentRoofMaterial.raftBaseCd,
|
||||||
|
roofLayout: roofLayout,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
basicSettingSave()
|
basicSettingSave()
|
||||||
}
|
}
|
||||||
@ -197,7 +227,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
/> */}
|
/> */}
|
||||||
<select
|
<select
|
||||||
className="select-light dark"
|
className="select-light dark"
|
||||||
name="roofType"
|
name="roofMatlCd"
|
||||||
ref={roofRef.roofCd}
|
ref={roofRef.roofCd}
|
||||||
value={currentRoofMaterial.roofMatlCd}
|
value={currentRoofMaterial.roofMatlCd}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@ -281,7 +311,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
type="text"
|
type="text"
|
||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
ref={roofRef.hajebichi}
|
ref={roofRef.hajebichi}
|
||||||
value={parseInt(currentRoofMaterial.hajebichi)}
|
defaultValue={parseInt(currentRoofMaterial.hajebichi)}
|
||||||
readOnly={currentRoofMaterial.roofPchAuth === 'R'}
|
readOnly={currentRoofMaterial.roofPchAuth === 'R'}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -120,7 +120,8 @@ export function useCanvasSetting() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { id } = selectedRoofMaterial
|
const { id } = selectedRoofMaterial
|
||||||
console.log(getModuleTypeItemList(id))
|
//console.log('id', id)
|
||||||
|
if (id !== undefined) console.log(getModuleTypeItemList(id))
|
||||||
}, [selectedRoofMaterial])
|
}, [selectedRoofMaterial])
|
||||||
|
|
||||||
//지붕재 초기세팅
|
//지붕재 초기세팅
|
||||||
@ -179,15 +180,6 @@ export function useCanvasSetting() {
|
|||||||
canvas?.renderAll()
|
canvas?.renderAll()
|
||||||
}, [corridorDimension])
|
}, [corridorDimension])
|
||||||
|
|
||||||
// 배치면 초기설정 변경 시
|
|
||||||
useEffect(() => {
|
|
||||||
//console.log('useCanvasSetting canvasSetting 실행', canvasSetting)
|
|
||||||
|
|
||||||
if (canvasSetting.flag) {
|
|
||||||
basicSettingSave()
|
|
||||||
}
|
|
||||||
}, [canvasSetting])
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('🚀 ~ useEffect ~ settingsDataSave:', settingsDataSave)
|
console.log('🚀 ~ useEffect ~ settingsDataSave:', settingsDataSave)
|
||||||
if (settingsDataSave !== undefined) onClickOption2()
|
if (settingsDataSave !== undefined) onClickOption2()
|
||||||
@ -269,57 +261,66 @@ export function useCanvasSetting() {
|
|||||||
try {
|
try {
|
||||||
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/${correntObjectNo}` }).then((res) => {
|
||||||
console.log('fetchBasicSettings res ', res)
|
console.log('fetchBasicSettings res ', res)
|
||||||
if (res.length == 0) return
|
//if (res.length == 0) return
|
||||||
|
|
||||||
// 'roofs' 배열을 생성하여 각 항목을 추가
|
let roofsRow = {}
|
||||||
const roofsRow = res.map((item) => {
|
let roofsArray = {}
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
roofsRow = res.map((item) => {
|
||||||
return {
|
return {
|
||||||
roofSizeSet: item.roofSizeSet,
|
roofSizeSet: item.roofSizeSet,
|
||||||
roofAngleSet: item.roofAngleSet,
|
roofAngleSet: item.roofAngleSet,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const roofsArray = res.some((item) => !item.roofSeq)
|
roofsArray = res.map((item) => {
|
||||||
? //최초 지붕재 추가 정보의 경우 roofsArray를 초기화 설정
|
return {
|
||||||
res.map(() => ({
|
|
||||||
flag: false,
|
|
||||||
roofApply: true,
|
|
||||||
roofSeq: 1,
|
|
||||||
roofType: 1,
|
|
||||||
roofWidth: 265,
|
|
||||||
roofHeight: 235,
|
|
||||||
roofHajebichi: 0,
|
|
||||||
roofGap: 455,
|
|
||||||
// roofType: 1,
|
|
||||||
// roofWidth: 200,
|
|
||||||
// roofHeight: 200,
|
|
||||||
// roofHajebichi: 200,
|
|
||||||
// roofGap: 0,
|
|
||||||
roofLayout: 'parallel',
|
|
||||||
}))
|
|
||||||
: res.map((item) => ({
|
|
||||||
flag: false,
|
|
||||||
roofApply: item.roofApply === '' || item.roofApply === false ? false : true,
|
roofApply: item.roofApply === '' || item.roofApply === false ? false : true,
|
||||||
roofSeq: item.roofSeq,
|
roofSeq: item.roofSeq,
|
||||||
roofType: item.roofType,
|
roofMatlCd: item.roofMatlCd,
|
||||||
roofWidth: item.roofWidth,
|
roofWidth: item.roofWidth,
|
||||||
roofHeight: item.roofHeight,
|
roofHeight: item.roofHeight,
|
||||||
roofHajebichi: item.roofHajebichi,
|
roofHajebichi: item.roofHajebichi,
|
||||||
roofGap: item.roofGap,
|
roofGap: item.roofGap,
|
||||||
roofLayout: item.roofLayout,
|
roofLayout: item.roofLayout,
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
roofsRow = {
|
||||||
|
roofSizeSet: 1,
|
||||||
|
roofAngleSet: 'slope',
|
||||||
|
}
|
||||||
|
|
||||||
|
roofsArray = {
|
||||||
|
roofApply: true,
|
||||||
|
roofSeq: 1,
|
||||||
|
roofMatlCd: 'ROOF_ID_WA_53A',
|
||||||
|
roofWidth: 265,
|
||||||
|
roofHeight: 235,
|
||||||
|
roofHajebichi: 0,
|
||||||
|
roofGap: 'HEI_455',
|
||||||
|
roofLayout: 'P',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('roofsRow ', roofsRow)
|
||||||
console.log('roofsArray ', roofsArray)
|
console.log('roofsArray ', roofsArray)
|
||||||
|
|
||||||
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
|
// 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음
|
||||||
const patternData = {
|
const patternData = {
|
||||||
roofSizeSet: roofsRow[0].roofSizeSet, // 첫 번째 항목의 값을 사용
|
roofSizeSet: roofsRow[0].roofSizeSet,
|
||||||
roofAngleSet: roofsRow[0].roofAngleSet, // 첫 번째 항목의 값을 사용
|
roofAngleSet: roofsRow[0].roofAngleSet,
|
||||||
roofs: roofsArray, // 만들어진 roofs 배열
|
roofs: roofsArray, // 만들어진 roofs 배열
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.error('patternData', patternData)
|
console.log('patternData', patternData)
|
||||||
|
|
||||||
// 데이터 설정
|
// 데이터 설정
|
||||||
setBasicSettings({ ...patternData })
|
setBasicSettings({ ...basicSetting, roofSizeSet: roofsRow[0].roofSizeSet, roofAngleSet: roofsRow[0].roofAngleSet, roofsData: roofsArray})
|
||||||
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Data fetching error:', error)
|
console.error('Data fetching error:', error)
|
||||||
@ -338,15 +339,26 @@ export function useCanvasSetting() {
|
|||||||
objectNo: correntObjectNo,
|
objectNo: correntObjectNo,
|
||||||
roofSizeSet: basicSetting.roofSizeSet,
|
roofSizeSet: basicSetting.roofSizeSet,
|
||||||
roofAngleSet: basicSetting.roofAngleSet,
|
roofAngleSet: basicSetting.roofAngleSet,
|
||||||
roofMaterialsAddList: basicSetting.roofs, // TODO : 선택된 roof로 변경해야함
|
roofMaterialsAddList: [{
|
||||||
|
roofApply: true,
|
||||||
|
roofSeq: 1,
|
||||||
|
roofMatlCd: basicSetting.roofsData.roofMatlCd === null ? 'ROOF_ID_WA_53A' : basicSetting.roofsData.roofMatlCd,
|
||||||
|
roofWidth: basicSetting.roofsData.roofWidth === null ? 0 : basicSetting.roofsData.roofWidth,
|
||||||
|
roofHeight: basicSetting.roofsData.roofHeight === null ? 0 : basicSetting.roofsData.roofHeight,
|
||||||
|
roofHajebichi: basicSetting.roofsData.roofHajebichi === null ? 0 : basicSetting.roofsData.roofHajebichi,
|
||||||
|
roofGap: basicSetting.roofsData.roofGap === null ? 'HEI_455' : basicSetting.roofsData.roofGap,
|
||||||
|
roofLayout: basicSetting.roofsData.roofLayout,
|
||||||
|
}],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('patternData 55', patternData)
|
||||||
|
|
||||||
await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }).then((res) => {
|
await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }).then((res) => {
|
||||||
swalFire({ text: getMessage(res.returnMessage) })
|
swalFire({ text: getMessage(res.returnMessage) })
|
||||||
})
|
})
|
||||||
|
|
||||||
//Recoil 설정
|
//Recoil 설정
|
||||||
setCanvasSetting({ ...basicSetting, flag: false })
|
setCanvasSetting({ ...basicSetting })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
swalFire({ text: getMessage(res.returnMessage), icon: 'error' })
|
swalFire({ text: getMessage(res.returnMessage), icon: 'error' })
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user