rebase
This commit is contained in:
parent
f71cc701c2
commit
3b76c53db8
@ -1,15 +1,20 @@
|
|||||||
import SizeGuide from '@/components/floor-plan/modal/placementShape/SizeGuide'
|
import { useContext, useEffect, useState } from 'react'
|
||||||
import MaterialGuide from '@/components/floor-plan/modal/placementShape/MaterialGuide'
|
|
||||||
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { Fragment, useEffect, useState } from 'react'
|
|
||||||
import { canvasSettingState } from '@/store/canvasAtom'
|
import { canvasSettingState } from '@/store/canvasAtom'
|
||||||
|
import { basicSettingState } from '@/store/settingAtom'
|
||||||
|
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { usePopup } from '@/hooks/usePopup'
|
import { usePopup } from '@/hooks/usePopup'
|
||||||
import { basicSettingState } from '@/store/settingAtom'
|
|
||||||
import useRefFiles from '@/hooks/common/useRefFiles'
|
import useRefFiles from '@/hooks/common/useRefFiles'
|
||||||
|
import { usePlan } from '@/hooks/usePlan'
|
||||||
|
|
||||||
|
import SizeGuide from '@/components/floor-plan/modal/placementShape/SizeGuide'
|
||||||
|
import MaterialGuide from '@/components/floor-plan/modal/placementShape/MaterialGuide'
|
||||||
|
import WithDraggable from '@/components/common/draggable/WithDraggable'
|
||||||
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
|
|
||||||
export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, setShowPlaceShapeModal }) {
|
export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, setShowPlaceShapeModal }) {
|
||||||
const [objectNo, setObjectNo] = useState('test123241008001') // 후에 삭제 필요
|
const [objectNo, setObjectNo] = useState('test123241008001') // 후에 삭제 필요
|
||||||
@ -19,7 +24,18 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
const [canvasSetting, setCanvasSetting] = useRecoilState(canvasSettingState)
|
const [canvasSetting, setCanvasSetting] = useRecoilState(canvasSettingState)
|
||||||
const { closePopup } = usePopup()
|
const { closePopup } = usePopup()
|
||||||
const [basicSetting, setBasicSettings] = useRecoilState(basicSettingState)
|
const [basicSetting, setBasicSettings] = useRecoilState(basicSettingState)
|
||||||
const { refImage, setRefImage, handleRefFile } = useRefFiles()
|
const {
|
||||||
|
refImage,
|
||||||
|
setRefImage,
|
||||||
|
handleRefFile,
|
||||||
|
refFileMethod,
|
||||||
|
setRefFileMethod,
|
||||||
|
handleRefFileMethod,
|
||||||
|
mapPositionAddress,
|
||||||
|
setMapPositionAddress,
|
||||||
|
handleFileDelete,
|
||||||
|
} = useRefFiles()
|
||||||
|
const { currentCanvasPlan } = usePlan()
|
||||||
|
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { get, post } = useAxios()
|
const { get, post } = useAxios()
|
||||||
@ -484,7 +500,70 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{getMessage('common.input.file')}</th>
|
<th>{getMessage('common.input.file')}</th>
|
||||||
<td>
|
<td>
|
||||||
<div className="flex-box">
|
<div className="pop-form-radio mb10">
|
||||||
|
<div className="d-check-radio pop">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="radio03"
|
||||||
|
id="ra06"
|
||||||
|
value={'1'}
|
||||||
|
onChange={(e) => handleRefFileMethod(e)}
|
||||||
|
checked={refFileMethod === '1'}
|
||||||
|
/>
|
||||||
|
<label htmlFor="ra06">ファイルを読み込む</label>
|
||||||
|
</div>
|
||||||
|
<div className="d-check-radio pop">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="radio03"
|
||||||
|
id="ra07"
|
||||||
|
value={'2'}
|
||||||
|
onChange={(e) => handleRefFileMethod(e)}
|
||||||
|
checked={refFileMethod === '2'}
|
||||||
|
/>
|
||||||
|
<label htmlFor="ra07">アドレスを読み込む</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 파일 불러오기 */}
|
||||||
|
{refFileMethod === '1' && (
|
||||||
|
<div className="flex-box">
|
||||||
|
<div className="img-edit-wrap">
|
||||||
|
<label className="img-edit-btn" htmlFor="img_file">
|
||||||
|
<span className="img-edit"></span>
|
||||||
|
{getMessage('common.input.file.load')}
|
||||||
|
</label>
|
||||||
|
<input type="file" id="img_file" style={{ display: 'none' }} onChange={(e) => handleRefFile(e.target.files[0])} />
|
||||||
|
</div>
|
||||||
|
<div className="img-name-wrap">
|
||||||
|
{currentCanvasPlan?.bgImageName === null ? (
|
||||||
|
<input type="text" className="input-origin al-l" defaultValue={''} value={refImage ? refImage.name : ''} readOnly />
|
||||||
|
) : (
|
||||||
|
<input type="text" className="input-origin al-l" value={currentCanvasPlan?.bgImageName} readOnly />
|
||||||
|
)}
|
||||||
|
{(refImage || currentCanvasPlan?.bgImageName) && <button className="img-check" onClick={handleFileDelete}></button>}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 주소 불러오기 */}
|
||||||
|
{refFileMethod === '2' && (
|
||||||
|
<div className="flex-box for-address">
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="input-origin al-l mr10"
|
||||||
|
placeholder={'住所入力'}
|
||||||
|
value={mapPositionAddress}
|
||||||
|
onChange={(e) => setMapPositionAddress(e.target.value)}
|
||||||
|
/>
|
||||||
|
<div className="img-edit-wrap mr5">
|
||||||
|
<button className="img-edit-btn">完了</button>
|
||||||
|
</div>
|
||||||
|
<span className="check-address fail"></span>
|
||||||
|
<span className="check-address success"></span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{/* <div className="flex-box">
|
||||||
<div className="img-edit-wrap">
|
<div className="img-edit-wrap">
|
||||||
<label className="img-edit-btn" htmlFor="img_file">
|
<label className="img-edit-btn" htmlFor="img_file">
|
||||||
<span className="img-edit"></span>
|
<span className="img-edit"></span>
|
||||||
@ -496,7 +575,7 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
|
|||||||
<input type="text" className="input-origin al-l" defaultValue={''} value={refImage ? refImage.name : ''} readOnly />
|
<input type="text" className="input-origin al-l" defaultValue={''} value={refImage ? refImage.name : ''} readOnly />
|
||||||
{refImage && <button className="img-check" onClick={() => setRefImage(null)}></button>}
|
{refImage && <button className="img-check" onClick={() => setRefImage(null)}></button>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> */}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -1,22 +1,46 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { convertDwgToPng } from '@/lib/cadAction'
|
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
|
import { usePlan } from '@/hooks/usePlan'
|
||||||
|
import { convertDwgToPng } from '@/lib/cadAction'
|
||||||
|
|
||||||
export default function useRefFiles() {
|
export default function useRefFiles() {
|
||||||
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
|
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
|
||||||
const [refImage, setRefImage] = useState(null)
|
const [refImage, setRefImage] = useState(null)
|
||||||
|
const [refFileMethod, setRefFileMethod] = useState('1')
|
||||||
|
const [mapPositionAddress, setMapPositionAddress] = useState('')
|
||||||
|
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
|
const { currentCanvasPlan, setCurrentCanvasPlan } = usePlan()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 파일 불러오기 버튼 컨트롤
|
||||||
|
* @param {*} file
|
||||||
|
*/
|
||||||
const handleRefFile = (file) => {
|
const handleRefFile = (file) => {
|
||||||
setRefImage(file)
|
setRefImage(file)
|
||||||
console.log('🚀 ~ handleRefFile ~ file:', file)
|
|
||||||
file.name.split('.').pop() === 'dwg' ? handleUploadRefFile(file) : () => {}
|
file.name.split('.').pop() === 'dwg' ? handleUploadRefFile(file) : () => {}
|
||||||
console.log("🚀 ~ handleRefFile ~ file.name.split('.').pop():", file.name.split('.').pop())
|
|
||||||
// handleUploadRefFile(file)
|
// handleUploadRefFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RefFile이 캐드 도면 파일일 경우 변환하여 이미지로 저장
|
/**
|
||||||
|
* 파일 삭제
|
||||||
|
*/
|
||||||
|
const handleFileDelete = () => {
|
||||||
|
setRefImage(null)
|
||||||
|
setCurrentCanvasPlan((prev) => ({ ...prev, bgFileName: null }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 주소 삭제
|
||||||
|
*/
|
||||||
|
const handleAddressDelete = () => {
|
||||||
|
setCurrentCanvasPlan((prev) => ({ ...prev, mapPositionAddress: null }))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RefFile이 캐드 도면 파일일 경우 변환하여 이미지로 저장
|
||||||
|
* @param {*} file
|
||||||
|
*/
|
||||||
const handleUploadRefFile = async (file) => {
|
const handleUploadRefFile = async (file) => {
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', file)
|
formData.append('file', file)
|
||||||
@ -31,9 +55,24 @@ export default function useRefFiles() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 라디오 버튼 컨트롤
|
||||||
|
* @param {*} e
|
||||||
|
*/
|
||||||
|
const handleRefFileMethod = (e) => {
|
||||||
|
setRefFileMethod(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
refImage,
|
refImage,
|
||||||
setRefImage,
|
setRefImage,
|
||||||
handleRefFile,
|
handleRefFile,
|
||||||
|
refFileMethod,
|
||||||
|
setRefFileMethod,
|
||||||
|
mapPositionAddress,
|
||||||
|
setMapPositionAddress,
|
||||||
|
handleRefFileMethod,
|
||||||
|
handleFileDelete,
|
||||||
|
handleAddressDelete,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -190,7 +190,7 @@ export function usePlan() {
|
|||||||
canvasStatus: dbToCanvasFormat(item.canvasStatus),
|
canvasStatus: dbToCanvasFormat(item.canvasStatus),
|
||||||
isCurrent: false,
|
isCurrent: false,
|
||||||
bgImageName: item.bgImageName,
|
bgImageName: item.bgImageName,
|
||||||
bgCadfileName: item.bgCadfileName,
|
mapPositionAddress: item.mapPositionAddress,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user