배치면초기설정 수정
This commit is contained in:
parent
4daa92b39e
commit
3f99f15b05
@ -30,7 +30,8 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
const globalLocale = useRecoilValue(globalLocaleStore)
|
const globalLocale = useRecoilValue(globalLocaleStore)
|
||||||
const { basicSetting, setBasicSettings, fetchBasicSettings, basicSettingSave, addedRoofs, setAddedRoofs } = useCanvasSetting()
|
const { basicSetting, setBasicSettings, fetchBasicSettings, basicSettingSave, addedRoofs, setAddedRoofs } = useCanvasSetting()
|
||||||
const { findCommonCode } = useCommonCode()
|
const { findCommonCode } = useCommonCode()
|
||||||
const [raftCodes, setRaftCodes] = useState([]) //서까래 정보
|
const [raftCodes, setRaftCodes] = useState([]) // 서까래 정보
|
||||||
|
const [currentRoof, setCurrentRoof] = useState(addedRoofs[0]) // 현재 선택된 지붕재 정보
|
||||||
|
|
||||||
const roofRef = {
|
const roofRef = {
|
||||||
roofCd: useRef(null),
|
roofCd: useRef(null),
|
||||||
@ -42,67 +43,58 @@ 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(() => {
|
useEffect(() => {
|
||||||
if (addedRoofs.length > 0) {
|
if (currentRoof.roofMatlCd.length > 0) {
|
||||||
setBasicSettings({
|
setBasicSettings({
|
||||||
...basicSetting,
|
...basicSetting,
|
||||||
roofsData: {
|
roofsData: {
|
||||||
roofApply: true,
|
roofApply: true,
|
||||||
roofSeq: 0,
|
roofSeq: 0,
|
||||||
roofMatlCd: addedRoofs[0].roofMatlCd,
|
roofMatlCd: currentRoof.roofMatlCd,
|
||||||
roofWidth: addedRoofs[0].width,
|
roofWidth: currentRoof.width,
|
||||||
roofHeight: addedRoofs[0].length,
|
roofHeight: currentRoof.length,
|
||||||
roofHajebichi: addedRoofs[0].hajebichi,
|
roofHajebichi: currentRoof.hajebichi,
|
||||||
roofGap: addedRoofs[0].raft,
|
roofGap: currentRoof.raft,
|
||||||
roofLayout: addedRoofs[0].layout,
|
roofLayout: currentRoof.layout,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [basicSetting.roofSizeSet, basicSetting.roofAngleSet, addedRoofs])
|
}, [basicSetting.roofSizeSet, basicSetting.roofAngleSet, currentRoof])
|
||||||
|
|
||||||
const changeInput = (value, e) => {
|
|
||||||
const { name } = e.target
|
|
||||||
setAddedRoofs(addedRoofs.map((roof) => ({
|
|
||||||
...roof,
|
|
||||||
[name]: Number(value),
|
|
||||||
})))
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
||||||
setAddedRoofs([selectedRoofMaterial])
|
setCurrentRoof({...selectedRoofMaterial, index: 0})
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeInput = (value, e) => {
|
||||||
|
const { name } = e.target
|
||||||
|
setCurrentRoof({...currentRoof, [name]: Number(value)})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRafterChange = (value) => {
|
const handleRafterChange = (value) => {
|
||||||
setAddedRoofs(addedRoofs.map((roof) => ({
|
setCurrentRoof({...currentRoof, raft: value})
|
||||||
...roof,
|
|
||||||
raft: value,
|
|
||||||
})))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRoofLayoutChange = (value) => {
|
const handleRoofLayoutChange = (value) => {
|
||||||
setAddedRoofs(addedRoofs.map((roof) => ({
|
setCurrentRoof({...currentRoof, layout: value})
|
||||||
...roof,
|
|
||||||
layout: value,
|
|
||||||
})))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSaveBtn = () => {
|
const handleSaveBtn = () => {
|
||||||
const roofInfo = {
|
const roofInfo = {
|
||||||
...addedRoofs,
|
...currentRoof,
|
||||||
roofCd: roofRef.roofCd.current?.value,
|
roofCd: roofRef.roofCd.current?.value,
|
||||||
width: roofRef.width.current?.value,
|
width: roofRef.width.current?.value,
|
||||||
length: roofRef.length.current?.value,
|
length: roofRef.length.current?.value,
|
||||||
hajebichi: roofRef.hajebichi.current?.value,
|
hajebichi: roofRef.hajebichi.current?.value,
|
||||||
//raft: roofRef.rafter.current?.value,
|
raft: roofRef.rafter.current?.value,
|
||||||
selected: true,
|
selected: true,
|
||||||
layout: addedRoofs[0].layout,
|
layout: currentRoof.layout,
|
||||||
index: 0,
|
index: 0,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,12 +122,12 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
roofsData: {
|
roofsData: {
|
||||||
roofApply: true,
|
roofApply: true,
|
||||||
roofSeq: 0,
|
roofSeq: 0,
|
||||||
roofMatlCd: addedRoofs[0].roofMatlCd,
|
roofMatlCd: currentRoof.roofMatlCd,
|
||||||
roofWidth: addedRoofs[0].width,
|
roofWidth: currentRoof.width,
|
||||||
roofHeight: addedRoofs[0].length,
|
roofHeight: currentRoof.length,
|
||||||
roofHajebichi: addedRoofs[0].hajebichi,
|
roofHajebichi: currentRoof.hajebichi,
|
||||||
roofGap: addedRoofs[0].raft,
|
roofGap: currentRoof.raft,
|
||||||
roofLayout: addedRoofs[0].layout,
|
roofLayout: currentRoof.layout,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -248,14 +240,14 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
<div className="placement-option">
|
<div className="placement-option">
|
||||||
<div className="grid-select no-flx" style={{ width: '171px' }}>
|
<div className="grid-select no-flx" style={{ width: '171px' }}>
|
||||||
<QSelectBox
|
<QSelectBox
|
||||||
title={basicSetting.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : addedRoofs[0]?.roofMatlNm}
|
title={basicSetting.roofSizeSet == 3 ? getMessage('modal.placement.initial.setting.size.none.pitch') : currentRoof.roofMatlNm}
|
||||||
ref={roofRef.roofCd}
|
ref={roofRef.roofCd}
|
||||||
options={roofMaterials.map((roof, index) => {
|
options={roofMaterials.map((roof, index) => {
|
||||||
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp }
|
return { ...roof, name: globalLocale === 'ko' ? roof.roofMatlNm : roof.roofMatlNmJp }
|
||||||
})}
|
})}
|
||||||
//value={roofMaterials.find((r) => r.roofMatlCd === basicSetting.roofs[0]?.roofMatlCd)}
|
//value={roofMaterials.find((r) => r.roofMatlCd === basicSetting.roofs[0]?.roofMatlCd)}
|
||||||
//title={basicSetting.roofs[0]?.roofMatlNm}
|
//title={basicSetting.roofs[0]?.roofMatlNm}
|
||||||
value={basicSetting.roofSizeSet == 3 ? null : addedRoofs[0]?.roofMatlCd}
|
value={basicSetting.roofSizeSet == 3 ? null : currentRoof.roofMatlCd}
|
||||||
onChange={(e) => handleRoofTypeChange(e.roofMatlCd)}
|
onChange={(e) => handleRoofTypeChange(e.roofMatlCd)}
|
||||||
//sourceKey="id"
|
//sourceKey="id"
|
||||||
//targetKey="id"
|
//targetKey="id"
|
||||||
@ -280,7 +272,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
})}
|
})}
|
||||||
</select> */}
|
</select> */}
|
||||||
</div>
|
</div>
|
||||||
{basicSetting && ['R', 'C'].includes(addedRoofs[0]?.widAuth) && (
|
{basicSetting && ['R', 'C'].includes(currentRoof.widAuth) && (
|
||||||
<div className="flex-ment">
|
<div className="flex-ment">
|
||||||
<span>W</span>
|
<span>W</span>
|
||||||
<div className="input-grid" style={{ width: '84px' }}>
|
<div className="input-grid" style={{ width: '84px' }}>
|
||||||
@ -289,9 +281,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
name={`width`}
|
name={`width`}
|
||||||
ref={roofRef.width}
|
ref={roofRef.width}
|
||||||
value={parseInt(addedRoofs[0]?.width)}
|
value={parseInt(currentRoof.width)}
|
||||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||||
readOnly={addedRoofs[0]?.widAuth === 'R'}
|
readOnly={currentRoof.widAuth === 'R'}
|
||||||
disabled={basicSetting.roofSizeSet == 3}
|
disabled={basicSetting.roofSizeSet == 3}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -305,7 +297,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
</div> */}
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{basicSetting && ['R', 'C'].includes(addedRoofs[0]?.lenAuth) && (
|
{basicSetting && ['R', 'C'].includes(currentRoof.lenAuth) && (
|
||||||
<div className="flex-ment">
|
<div className="flex-ment">
|
||||||
<span>L</span>
|
<span>L</span>
|
||||||
<div className="input-grid" style={{ width: '84px' }}>
|
<div className="input-grid" style={{ width: '84px' }}>
|
||||||
@ -314,9 +306,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
name={`length`}
|
name={`length`}
|
||||||
ref={roofRef.length}
|
ref={roofRef.length}
|
||||||
value={parseInt(addedRoofs[0]?.length)}
|
value={parseInt(currentRoof.length)}
|
||||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||||
readOnly={addedRoofs[0]?.lenAuth === 'R'}
|
readOnly={currentRoof.lenAuth === 'R'}
|
||||||
disabled={basicSetting.roofSizeSet == 3}
|
disabled={basicSetting.roofSizeSet == 3}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -330,18 +322,19 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
</div> */}
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{basicSetting && ['C', 'R'].includes(addedRoofs[0]?.raftAuth) && (
|
{basicSetting && ['C', 'R'].includes(currentRoof.raftAuth) && (
|
||||||
<div className="flex-ment">
|
<div className="flex-ment">
|
||||||
<span>{getMessage('modal.placement.initial.setting.rafter')}</span>
|
<span>{getMessage('modal.placement.initial.setting.rafter')}</span>
|
||||||
{raftCodes.length > 0 && (
|
{raftCodes.length > 0 && (
|
||||||
<div className="select-wrap" style={{ width: '160px' }}>
|
<div className="select-wrap" style={{ width: '160px' }}>
|
||||||
<QSelectBox
|
<QSelectBox
|
||||||
options={raftCodes}
|
options={raftCodes}
|
||||||
title={raftCodes.find((r) => r.clCode === (addedRoofs[0]?.raft === undefined ? addedRoofs[0]?.raftBaseCd : addedRoofs[0]?.raft))?.clCodeNm}
|
ref={roofRef.rafter}
|
||||||
value={addedRoofs[0]?.raft === undefined ? addedRoofs[0]?.raftBaseCd : addedRoofs[0]?.raft}
|
title={raftCodes.find((r) => r.clCode === (currentRoof.raft === undefined ? currentRoof.raftBaseCd : currentRoof.raft)).clCodeNm}
|
||||||
|
value={currentRoof.raft === undefined ? currentRoof.raftBaseCd : currentRoof.raft}
|
||||||
onChange={(e) => handleRafterChange(e.clCode)}
|
onChange={(e) => handleRafterChange(e.clCode)}
|
||||||
sourceKey="clCode"
|
sourceKey="clCode"
|
||||||
targetKey={addedRoofs[0]?.raft ? 'raft' : 'raftBaseCd'}
|
targetKey={currentRoof.raft ? 'raft' : 'raftBaseCd'}
|
||||||
showKey="clCodeNm"
|
showKey="clCodeNm"
|
||||||
disabled={basicSetting.roofSizeSet == 3}
|
disabled={basicSetting.roofSizeSet == 3}
|
||||||
/>
|
/>
|
||||||
@ -358,7 +351,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{basicSetting && ['C', 'R'].includes(addedRoofs[0]?.roofPchAuth) && (
|
{basicSetting && ['C', 'R'].includes(currentRoof.roofPchAuth) && (
|
||||||
<div className="flex-ment">
|
<div className="flex-ment">
|
||||||
<span>{getMessage('hajebichi')}</span>
|
<span>{getMessage('hajebichi')}</span>
|
||||||
<div className="input-grid" style={{ width: '84px' }}>
|
<div className="input-grid" style={{ width: '84px' }}>
|
||||||
@ -367,9 +360,9 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
className="input-origin block"
|
className="input-origin block"
|
||||||
name={`hajebichi`}
|
name={`hajebichi`}
|
||||||
ref={roofRef.hajebichi}
|
ref={roofRef.hajebichi}
|
||||||
value={parseInt(addedRoofs[0]?.hajebichi)}
|
value={parseInt(currentRoof.hajebichi)}
|
||||||
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
onChange={(e) => onlyNumberInputChange(e, changeInput)}
|
||||||
readOnly={addedRoofs[0]?.roofPchAuth === 'R'}
|
readOnly={currentRoof.roofPchAuth === 'R'}
|
||||||
disabled={basicSetting.roofSizeSet == 3}
|
disabled={basicSetting.roofSizeSet == 3}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -379,7 +372,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
<div className="placement-roof-btn-wrap">
|
<div className="placement-roof-btn-wrap">
|
||||||
<div className="icon-btn-wrap mt10">
|
<div className="icon-btn-wrap mt10">
|
||||||
<button
|
<button
|
||||||
className={`${addedRoofs[0]?.layout === ROOF_MATERIAL_LAYOUT.PARALLEL && 'act'}`}
|
className={`${currentRoof.layout === ROOF_MATERIAL_LAYOUT.PARALLEL && 'act'}`}
|
||||||
value={ROOF_MATERIAL_LAYOUT.PARALLEL}
|
value={ROOF_MATERIAL_LAYOUT.PARALLEL}
|
||||||
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.PARALLEL)}
|
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.PARALLEL)}
|
||||||
>
|
>
|
||||||
@ -387,7 +380,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
<i className="allocation01"></i>
|
<i className="allocation01"></i>
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className={`${addedRoofs[0]?.layout === ROOF_MATERIAL_LAYOUT.STAIRS && 'act'}`}
|
className={`${currentRoof.layout === ROOF_MATERIAL_LAYOUT.STAIRS && 'act'}`}
|
||||||
value={ROOF_MATERIAL_LAYOUT.STAIRS}
|
value={ROOF_MATERIAL_LAYOUT.STAIRS}
|
||||||
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.STAIRS)}
|
onClick={() => handleRoofLayoutChange(ROOF_MATERIAL_LAYOUT.STAIRS)}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -145,6 +145,10 @@ export function useCanvasSetting() {
|
|||||||
setBasicSettings({ ...basicSetting, selectedRoofMaterial: selectedRoofMaterial })
|
setBasicSettings({ ...basicSetting, selectedRoofMaterial: selectedRoofMaterial })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchBasicSettings()
|
||||||
|
}, [roofMaterials])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!canvas) {
|
if (!canvas) {
|
||||||
return
|
return
|
||||||
@ -255,8 +259,6 @@ export function useCanvasSetting() {
|
|||||||
const fetchBasicSettings = async () => {
|
const fetchBasicSettings = async () => {
|
||||||
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)
|
|
||||||
//if (res.length == 0) return
|
|
||||||
|
|
||||||
let roofsRow = {}
|
let roofsRow = {}
|
||||||
let roofsArray = {}
|
let roofsArray = {}
|
||||||
@ -309,14 +311,12 @@ export function useCanvasSetting() {
|
|||||||
roofs: roofsArray, // 만들어진 roofs 배열
|
roofs: roofsArray, // 만들어진 roofs 배열
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('fetchBasicSettings patternData', patternData)
|
//console.log('fetchBasicSettings patternData', patternData)
|
||||||
|
|
||||||
// 데이터 설정
|
// 데이터 설정
|
||||||
//setBasicSettings({ ...basicSetting, roofSizeSet: roofsRow[0].roofSizeSet, roofAngleSet: roofsRow[0].roofAngleSet, roofsData: roofsArray})
|
|
||||||
const addRoofs = []
|
const addRoofs = []
|
||||||
roofMaterials.map((material) => {
|
roofMaterials?.map((material) => {
|
||||||
if (material.id === roofsArray[0].roofMatlCd) {
|
if (material.roofMatlCd === roofsArray[0].roofMatlCd) {
|
||||||
//setRoofMaterials({ ...roofMaterials, layout: roofsArray[0].roofLayout })
|
|
||||||
addRoofs.push({ ...material, selected: true
|
addRoofs.push({ ...material, selected: true
|
||||||
, index: 0
|
, index: 0
|
||||||
, width: roofsArray[0].roofWidth
|
, width: roofsArray[0].roofWidth
|
||||||
@ -334,7 +334,6 @@ export function useCanvasSetting() {
|
|||||||
, selectedRoofMaterial: addRoofs[0] })
|
, selectedRoofMaterial: addRoofs[0] })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Data fetching error:', error)
|
console.error('Data fetching error:', error)
|
||||||
@ -375,6 +374,7 @@ export function useCanvasSetting() {
|
|||||||
|
|
||||||
//Recoil 설정
|
//Recoil 설정
|
||||||
setCanvasSetting({ ...basicSetting })
|
setCanvasSetting({ ...basicSetting })
|
||||||
|
fetchBasicSettings()
|
||||||
} 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