Merge branch 'dev' of https://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into dev
This commit is contained in:
commit
e65b765b10
@ -3,8 +3,11 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { handleFileDown } from '@/util/board-utils'
|
import { handleFileDown } from '@/util/board-utils'
|
||||||
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
|
|
||||||
export default function BoardDetailModal({ noticeNo, setOpen }) {
|
export default function BoardDetailModal({ noticeNo, setOpen }) {
|
||||||
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
// api 조회 관련
|
// api 조회 관련
|
||||||
const { get } = useAxios()
|
const { get } = useAxios()
|
||||||
const [boardDetail, setBoardDetail] = useState({})
|
const [boardDetail, setBoardDetail] = useState({})
|
||||||
@ -46,7 +49,7 @@ export default function BoardDetailModal({ noticeNo, setOpen }) {
|
|||||||
setOpen(false)
|
setOpen(false)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
닫기
|
{getMessage('board.sub.btn.close')}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
@ -55,7 +58,7 @@ export default function BoardDetailModal({ noticeNo, setOpen }) {
|
|||||||
|
|
||||||
{boardDetail.listFile && (
|
{boardDetail.listFile && (
|
||||||
<dl className="community_detail-file-wrap">
|
<dl className="community_detail-file-wrap">
|
||||||
<dt>첨부파일 목록</dt>
|
<dt>{getMessage('board.sub.fileList')}</dt>
|
||||||
{boardDetail.listFile.map((boardFile) => (
|
{boardDetail.listFile.map((boardFile) => (
|
||||||
<dd key={boardFile.encodeFileNo}>
|
<dd key={boardFile.encodeFileNo}>
|
||||||
<button type="button" className="down" onClick={() => handleFileDown(boardFile)}>
|
<button type="button" className="down" onClick={() => handleFileDown(boardFile)}>
|
||||||
|
|||||||
@ -172,7 +172,7 @@ export const QPolygon = fabric.util.createClass(fabric.Polygon, {
|
|||||||
addLengthText() {
|
addLengthText() {
|
||||||
this.canvas
|
this.canvas
|
||||||
?.getObjects()
|
?.getObjects()
|
||||||
.filter((obj) => obj.name === 'lengthText' && obj.parent === this)
|
.filter((obj) => obj.name === 'lengthText' && obj.parentId === this.id)
|
||||||
.forEach((text) => {
|
.forEach((text) => {
|
||||||
this.canvas.remove(text)
|
this.canvas.remove(text)
|
||||||
})
|
})
|
||||||
|
|||||||
@ -2,18 +2,20 @@
|
|||||||
|
|
||||||
import { useEffect, useRef } from 'react'
|
import { useEffect, useRef } from 'react'
|
||||||
|
|
||||||
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
|
|
||||||
import { useCanvas } from '@/hooks/useCanvas'
|
import { useCanvas } from '@/hooks/useCanvas'
|
||||||
import { useEvent } from '@/hooks/useEvent'
|
import { useEvent } from '@/hooks/useEvent'
|
||||||
import { usePlan } from '@/hooks/usePlan'
|
import { usePlan } from '@/hooks/usePlan'
|
||||||
import { useContextMenu } from '@/hooks/useContextMenu'
|
import { useContextMenu } from '@/hooks/useContextMenu'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { currentObjectState, modifiedPlanFlagState } from '@/store/canvasAtom'
|
||||||
import { currentObjectState } from '@/store/canvasAtom'
|
|
||||||
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
|
import { useCanvasEvent } from '@/hooks/useCanvasEvent'
|
||||||
import QContextMenu from '@/components/common/context-menu/QContextMenu'
|
import QContextMenu from '@/components/common/context-menu/QContextMenu'
|
||||||
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
|
import { useCanvasConfigInitialize } from '@/hooks/common/useCanvasConfigInitialize'
|
||||||
|
|
||||||
export default function CanvasFrame({ plan }) {
|
export default function CanvasFrame({ plan }) {
|
||||||
const canvasRef = useRef(null)
|
const canvasRef = useRef(null)
|
||||||
|
const [modifiedPlanFlag, setModifiedPlanFlag] = useRecoilState(modifiedPlanFlagState)
|
||||||
const { canvas } = useCanvas('canvas')
|
const { canvas } = useCanvas('canvas')
|
||||||
const { handleZoomClear } = useCanvasEvent()
|
const { handleZoomClear } = useCanvasEvent()
|
||||||
const { contextMenu, currentContextMenu, setCurrentContextMenu, handleClick } = useContextMenu({
|
const { contextMenu, currentContextMenu, setCurrentContextMenu, handleClick } = useContextMenu({
|
||||||
@ -21,7 +23,7 @@ export default function CanvasFrame({ plan }) {
|
|||||||
handleZoomClear,
|
handleZoomClear,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const { checkCanvasObjectEvent, checkUnsavedCanvasPlan } = usePlan()
|
const { checkCanvasObjectEvent, resetModifiedPlans } = usePlan()
|
||||||
const { canvasLoadInit, gridInit } = useCanvasConfigInitialize()
|
const { canvasLoadInit, gridInit } = useCanvasConfigInitialize()
|
||||||
const currentObject = useRecoilValue(currentObjectState)
|
const currentObject = useRecoilValue(currentObjectState)
|
||||||
|
|
||||||
@ -40,8 +42,15 @@ export default function CanvasFrame({ plan }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (modifiedPlanFlag && plan?.id) {
|
||||||
|
checkCanvasObjectEvent(plan.id)
|
||||||
|
}
|
||||||
|
}, [modifiedPlanFlag])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadCanvas()
|
loadCanvas()
|
||||||
|
resetModifiedPlans()
|
||||||
}, [plan, canvas])
|
}, [plan, canvas])
|
||||||
|
|
||||||
const onClickContextMenu = (index) => {}
|
const onClickContextMenu = (index) => {}
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useContext, useEffect, useState } from 'react'
|
import { useContext, useEffect, useState } from 'react'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import CanvasFrame from './CanvasFrame'
|
import CanvasFrame from './CanvasFrame'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
import { usePlan } from '@/hooks/usePlan'
|
import { usePlan } from '@/hooks/usePlan'
|
||||||
|
import { modifiedPlansState } from '@/store/canvasAtom'
|
||||||
import { globalLocaleStore } from '@/store/localeAtom'
|
import { globalLocaleStore } from '@/store/localeAtom'
|
||||||
import { SessionContext } from '@/app/SessionProvider'
|
import { SessionContext } from '@/app/SessionProvider'
|
||||||
|
|
||||||
@ -13,11 +14,12 @@ export default function CanvasLayout(props) {
|
|||||||
const { menuNumber } = props
|
const { menuNumber } = props
|
||||||
const { session } = useContext(SessionContext)
|
const { session } = useContext(SessionContext)
|
||||||
const [objectNo, setObjectNo] = useState('test123240822001') // 이후 삭제 필요
|
const [objectNo, setObjectNo] = useState('test123240822001') // 이후 삭제 필요
|
||||||
|
const [modifiedPlans, setModifiedPlans] = useRecoilState(modifiedPlansState) // 변경된 canvas plan
|
||||||
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
const globalLocaleState = useRecoilValue(globalLocaleStore)
|
||||||
|
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { plans, modifiedPlans, loadCanvasPlanData, handleCurrentPlan, handleAddPlan, handleDeletePlan } = usePlan()
|
const { plans, loadCanvasPlanData, handleCurrentPlan, handleAddPlan, handleDeletePlan } = usePlan()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadCanvasPlanData(session.userId, objectNo)
|
loadCanvasPlanData(session.userId, objectNo)
|
||||||
|
|||||||
@ -136,7 +136,7 @@ export default function MainContents() {
|
|||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
) : (
|
) : (
|
||||||
<MainSkeleton />
|
<MainSkeleton count={6} />
|
||||||
)}
|
)}
|
||||||
</ProductItem>
|
</ProductItem>
|
||||||
<ProductItem num={2} name={getMessage('main.content.notice')}>
|
<ProductItem num={2} name={getMessage('main.content.notice')}>
|
||||||
@ -147,7 +147,9 @@ export default function MainContents() {
|
|||||||
<div className="notice-title">{recentNoticeList[0]?.title}</div>
|
<div className="notice-title">{recentNoticeList[0]?.title}</div>
|
||||||
<div className="notice-contents">{recentNoticeList[0]?.contents}</div>
|
<div className="notice-contents">{recentNoticeList[0]?.contents}</div>
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : (
|
||||||
|
<MainSkeleton count={5} />
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</ProductItem>
|
</ProductItem>
|
||||||
</div>
|
</div>
|
||||||
@ -168,7 +170,9 @@ export default function MainContents() {
|
|||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : (
|
||||||
|
<MainSkeleton count={2} />
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</ProductItem>
|
</ProductItem>
|
||||||
<ProductItem num={4} name={'Data Download'}>
|
<ProductItem num={4} name={'Data Download'}>
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { AgGridReact } from 'ag-grid-react'
|
import { AgGridReact } from 'ag-grid-react'
|
||||||
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
|
|
||||||
import 'ag-grid-community/styles/ag-grid.css'
|
import 'ag-grid-community/styles/ag-grid.css'
|
||||||
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
||||||
|
|
||||||
export default function StuffQGrid(props) {
|
export default function StuffQGrid(props) {
|
||||||
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
const { gridData, gridColumns, isPageable = true, count, gridRef } = props
|
const { gridData, gridColumns, isPageable = true, count, gridRef } = props
|
||||||
/**
|
/**
|
||||||
* 행 데이터를 설정할 때 useState을 사용하여 렌더링 전반에 걸쳐 일관된 배열 참조를 유지하는 것이 좋습니다
|
* 행 데이터를 설정할 때 useState을 사용하여 렌더링 전반에 걸쳐 일관된 배열 참조를 유지하는 것이 좋습니다
|
||||||
@ -95,7 +98,7 @@ export default function StuffQGrid(props) {
|
|||||||
onSelectionChanged={onSelectionChanged}
|
onSelectionChanged={onSelectionChanged}
|
||||||
onCellDoubleClicked={onCellDoubleClicked}
|
onCellDoubleClicked={onCellDoubleClicked}
|
||||||
pagination={isPageable}
|
pagination={isPageable}
|
||||||
overlayNoRowsTemplate={'<span className="ag-overlay-loading-center">물건 목록이 없습니다.</span>'}
|
overlayNoRowsTemplate={`<span className="ag-overlay-loading-center">${getMessage('stuff.grid.noData')}</span>`}
|
||||||
getRowClass={getRowClass}
|
getRowClass={getRowClass}
|
||||||
autoSizeAllColumns={true}
|
autoSizeAllColumns={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { AgGridReact } from 'ag-grid-react'
|
import { AgGridReact } from 'ag-grid-react'
|
||||||
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
|
|
||||||
import 'ag-grid-community/styles/ag-grid.css'
|
import 'ag-grid-community/styles/ag-grid.css'
|
||||||
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
||||||
|
|
||||||
export default function FindAddressPopGrid(props) {
|
export default function FindAddressPopGrid(props) {
|
||||||
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
const { gridData, gridColumns, isPageable = true } = props
|
const { gridData, gridColumns, isPageable = true } = props
|
||||||
|
|
||||||
const [rowData, setRowData] = useState(null)
|
const [rowData, setRowData] = useState(null)
|
||||||
@ -46,7 +49,7 @@ export default function FindAddressPopGrid(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ag-theme-quartz" style={{ height: 500 }}>
|
<div className="ag-theme-quartz" style={{ height: 400 }}>
|
||||||
<AgGridReact
|
<AgGridReact
|
||||||
onGridReady={onGridReady}
|
onGridReady={onGridReady}
|
||||||
rowBuffer={rowBuffer}
|
rowBuffer={rowBuffer}
|
||||||
@ -56,6 +59,7 @@ export default function FindAddressPopGrid(props) {
|
|||||||
rowSelection={'singleRow'}
|
rowSelection={'singleRow'}
|
||||||
pagination={isPageable}
|
pagination={isPageable}
|
||||||
onSelectionChanged={onSelectionChanged}
|
onSelectionChanged={onSelectionChanged}
|
||||||
|
overlayNoRowsTemplate={`<span className="ag-overlay-loading-center">${getMessage('stuff.grid.noData')}</span>`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -253,6 +253,12 @@ export default function PlanRequestPop(props) {
|
|||||||
}
|
}
|
||||||
}, [commonCode])
|
}, [commonCode])
|
||||||
|
|
||||||
|
// 숫자만 입력 가능
|
||||||
|
const handleKeyUp = (e) => {
|
||||||
|
let input = e.target
|
||||||
|
input.value = input.value.replace(/[^0-9]/g, '')
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-popup">
|
<div className="modal-popup">
|
||||||
<div className="modal-dialog big">
|
<div className="modal-dialog big">
|
||||||
@ -301,6 +307,7 @@ export default function PlanRequestPop(props) {
|
|||||||
type="text"
|
type="text"
|
||||||
className="input-light"
|
className="input-light"
|
||||||
value={schPlanReqNo}
|
value={schPlanReqNo}
|
||||||
|
onKeyUp={handleKeyUp}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSchPlanReqNo(e.target.value)
|
setSchPlanReqNo(e.target.value)
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -1,11 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { AgGridReact } from 'ag-grid-react'
|
import { AgGridReact } from 'ag-grid-react'
|
||||||
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
|
|
||||||
import 'ag-grid-community/styles/ag-grid.css'
|
import 'ag-grid-community/styles/ag-grid.css'
|
||||||
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
import 'ag-grid-community/styles/ag-theme-quartz.css'
|
||||||
|
|
||||||
export default function PlanRequestPopQGrid(props) {
|
export default function PlanRequestPopQGrid(props) {
|
||||||
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
const { gridData, gridColumns, isPageable = true } = props
|
const { gridData, gridColumns, isPageable = true } = props
|
||||||
|
|
||||||
const [rowData, setRowData] = useState(null)
|
const [rowData, setRowData] = useState(null)
|
||||||
@ -56,6 +59,7 @@ export default function PlanRequestPopQGrid(props) {
|
|||||||
rowSelection={'singleRow'}
|
rowSelection={'singleRow'}
|
||||||
pagination={isPageable}
|
pagination={isPageable}
|
||||||
onSelectionChanged={onSelectionChanged}
|
onSelectionChanged={onSelectionChanged}
|
||||||
|
overlayNoRowsTemplate={`<span className="ag-overlay-loading-center">${getMessage('stuff.grid.noData')}</span>`}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
import Skeleton from 'react-loading-skeleton'
|
import Skeleton from 'react-loading-skeleton'
|
||||||
import 'react-loading-skeleton/dist/skeleton.css'
|
import 'react-loading-skeleton/dist/skeleton.css'
|
||||||
|
|
||||||
export default function MainSkeleton() {
|
export default function MainSkeleton({ count }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
<Skeleton height={`50px`} />
|
<Skeleton height={`50px`} />
|
||||||
</div>
|
</div>
|
||||||
<Skeleton count={5} />
|
<Skeleton count={count} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,15 @@
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { canvasSizeState, canvasState, canvasZoomState, currentObjectState, fontFamilyState, fontSizeState } from '@/store/canvasAtom'
|
import {
|
||||||
|
canvasSizeState,
|
||||||
|
canvasState,
|
||||||
|
canvasZoomState,
|
||||||
|
currentObjectState,
|
||||||
|
fontFamilyState,
|
||||||
|
fontSizeState,
|
||||||
|
modifiedPlanFlagState,
|
||||||
|
} from '@/store/canvasAtom'
|
||||||
import { QPolygon } from '@/components/fabric/QPolygon'
|
import { QPolygon } from '@/components/fabric/QPolygon'
|
||||||
|
|
||||||
// 캔버스에 필요한 이벤트
|
// 캔버스에 필요한 이벤트
|
||||||
@ -13,6 +21,7 @@ export function useCanvasEvent() {
|
|||||||
const fontSize = useRecoilValue(fontSizeState)
|
const fontSize = useRecoilValue(fontSizeState)
|
||||||
const fontFamily = useRecoilValue(fontFamilyState)
|
const fontFamily = useRecoilValue(fontFamilyState)
|
||||||
const [canvasZoom, setCanvasZoom] = useRecoilState(canvasZoomState)
|
const [canvasZoom, setCanvasZoom] = useRecoilState(canvasZoomState)
|
||||||
|
const [modifiedPlanFlag, setModifiedPlanFlag] = useRecoilState(modifiedPlanFlagState)
|
||||||
|
|
||||||
// 기본적인 이벤트 필요시 추가
|
// 기본적인 이벤트 필요시 추가
|
||||||
const attachDefaultEventOnCanvas = () => {
|
const attachDefaultEventOnCanvas = () => {
|
||||||
@ -34,14 +43,32 @@ export function useCanvasEvent() {
|
|||||||
onChange: (e) => {
|
onChange: (e) => {
|
||||||
const target = e.target
|
const target = e.target
|
||||||
|
|
||||||
|
if (target.name !== 'mouseLine') {
|
||||||
|
if (!modifiedPlanFlag) {
|
||||||
|
setModifiedPlanFlag((prev) => !prev)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target) {
|
if (target) {
|
||||||
target.uuid = uuidv4()
|
|
||||||
// settleDown(target)
|
// settleDown(target)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addEvent: (e) => {
|
addEvent: (e) => {
|
||||||
const target = e.target
|
const target = e.target
|
||||||
|
|
||||||
|
if (!target.id) {
|
||||||
|
target.id = uuidv4()
|
||||||
|
}
|
||||||
|
if (!target.uuid) {
|
||||||
|
target.uuid = uuidv4()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target.name !== 'mouseLine') {
|
||||||
|
if (!modifiedPlanFlag) {
|
||||||
|
setModifiedPlanFlag((prev) => !prev)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (target.type === 'QPolygon' || target.type === 'QLine') {
|
if (target.type === 'QPolygon' || target.type === 'QLine') {
|
||||||
const textObjs = canvas?.getObjects().filter((obj) => obj.name === 'lengthText')
|
const textObjs = canvas?.getObjects().filter((obj) => obj.name === 'lengthText')
|
||||||
textObjs.forEach((obj) => {
|
textObjs.forEach((obj) => {
|
||||||
@ -141,6 +168,9 @@ export function useCanvasEvent() {
|
|||||||
})*/
|
})*/
|
||||||
|
|
||||||
target.on('moving', (e) => {
|
target.on('moving', (e) => {
|
||||||
|
target.uuid = uuidv4()
|
||||||
|
setModifiedPlanFlag((prev) => !prev)
|
||||||
|
|
||||||
if (target.parentDirection === 'left' || target.parentDirection === 'right') {
|
if (target.parentDirection === 'left' || target.parentDirection === 'right') {
|
||||||
const minX = target.minX
|
const minX = target.minX
|
||||||
const maxX = target.maxX
|
const maxX = target.maxX
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState } from 'recoil'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4, validate as isValidUUID } from 'uuid'
|
||||||
import { canvasState, currentCanvasPlanState, initCanvasPlansState, plansState, modifiedPlansState } from '@/store/canvasAtom'
|
import { canvasState, currentCanvasPlanState, initCanvasPlansState, plansState, modifiedPlansState, modifiedPlanFlagState } from '@/store/canvasAtom'
|
||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useSwal } from '@/hooks/useSwal'
|
import { useSwal } from '@/hooks/useSwal'
|
||||||
@ -14,6 +14,7 @@ export function usePlan() {
|
|||||||
const [initCanvasPlans, setInitCanvasPlans] = useRecoilState(initCanvasPlansState) // DB에 저장된 plan
|
const [initCanvasPlans, setInitCanvasPlans] = useRecoilState(initCanvasPlansState) // DB에 저장된 plan
|
||||||
const [plans, setPlans] = useRecoilState(plansState) // 전체 plan (DB에 저장된 plan + 저장 안된 새로운 plan)
|
const [plans, setPlans] = useRecoilState(plansState) // 전체 plan (DB에 저장된 plan + 저장 안된 새로운 plan)
|
||||||
const [modifiedPlans, setModifiedPlans] = useRecoilState(modifiedPlansState) // 변경된 canvas plan
|
const [modifiedPlans, setModifiedPlans] = useRecoilState(modifiedPlansState) // 변경된 canvas plan
|
||||||
|
const [modifiedPlanFlag, setModifiedPlanFlag] = useRecoilState(modifiedPlanFlagState) // 캔버스 실시간 오브젝트 이벤트 감지 flag
|
||||||
|
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
@ -90,30 +91,29 @@ export function usePlan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 캔버스에서 발생하는 실시간 오브젝트 이벤트를 감지하여 수정 여부를 판단
|
* 캔버스에서 발생하는 실시간 오브젝트 이벤트를 감지하여 수정 여부를 확인 후 관리
|
||||||
*/
|
*/
|
||||||
const checkCanvasObjectEvent = (e, planId) => {
|
const checkCanvasObjectEvent = (planId) => {
|
||||||
if (!modifiedPlans.some((modifiedPlan) => modifiedPlan === planId) && checkModifiedCanvasPlan(planId)) {
|
if (!modifiedPlans.some((modifiedPlan) => modifiedPlan === planId) && checkModifiedCanvasPlan(planId)) {
|
||||||
setModifiedPlans([...modifiedPlans, planId])
|
setModifiedPlans((prev) => [...prev, planId])
|
||||||
|
setModifiedPlanFlag(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 현재 캔버스 상태와 DB에 저장된 캔버스 상태를 비교하여 수정 여부를 판단
|
* 현재 캔버스 상태와 DB에 저장된 캔버스 상태를 비교하여 수정 여부를 판단
|
||||||
*/
|
*/
|
||||||
const checkModifiedCanvasPlan = (planId) => {
|
const checkModifiedCanvasPlan = (planId) => {
|
||||||
const canvasStatus = currentCanvasData()
|
const canvasStatus = currentCanvasData()
|
||||||
const initPlanData = initCanvasPlans.find((plan) => plan.id === planId)
|
if (isValidUUID(planId)) {
|
||||||
|
|
||||||
if (!initPlanData) {
|
|
||||||
// 새로운 캔버스
|
// 새로운 캔버스
|
||||||
return JSON.parse(canvasStatus).objects.length > 0
|
return JSON.parse(canvasStatus).objects.length > 0
|
||||||
} else {
|
} else {
|
||||||
// 저장된 캔버스
|
// 저장된 캔버스
|
||||||
// 각각 object들의 uuid 목록을 추출하여 비교
|
// 각각 object들의 uuid 목록을 추출하여 비교
|
||||||
const canvasObjsUuids = getObjectUuids(JSON.parse(canvasStatus).objects)
|
const canvasObjsUuids = getObjectUuids(JSON.parse(canvasStatus).objects)
|
||||||
|
const initPlanData = initCanvasPlans.find((plan) => plan.id === planId)
|
||||||
const dbObjsUuids = getObjectUuids(JSON.parse(initPlanData.canvasStatus).objects)
|
const dbObjsUuids = getObjectUuids(JSON.parse(initPlanData.canvasStatus).objects)
|
||||||
return canvasObjsUuids.length !== dbObjsUuids.length || !canvasObjsUuids.every((id, index) => id === dbObjsUuids[index])
|
return canvasObjsUuids.length !== dbObjsUuids.length || !canvasObjsUuids.every((uuid, index) => uuid === dbObjsUuids[index])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const getObjectUuids = (objects) => {
|
const getObjectUuids = (objects) => {
|
||||||
@ -122,10 +122,12 @@ export function usePlan() {
|
|||||||
.map((obj) => obj.uuid)
|
.map((obj) => obj.uuid)
|
||||||
.sort()
|
.sort()
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* 캔버스에 저장되지 않은 변경사항이 있는 경우 저장 여부를 확인 후 저장
|
const resetModifiedPlans = () => {
|
||||||
*/
|
setModifiedPlans([])
|
||||||
const checkUnsavedCanvasPlan = async () => {
|
setModifiedPlanFlag(false)
|
||||||
|
}
|
||||||
|
const checkUnsavedCanvasPlan = (str) => {
|
||||||
if (modifiedPlans.length > 0) {
|
if (modifiedPlans.length > 0) {
|
||||||
swalFire({
|
swalFire({
|
||||||
text: `${currentCanvasPlan.name} ` + getMessage('plan.message.confirm.save'),
|
text: `${currentCanvasPlan.name} ` + getMessage('plan.message.confirm.save'),
|
||||||
@ -365,7 +367,7 @@ export function usePlan() {
|
|||||||
plans,
|
plans,
|
||||||
modifiedPlans,
|
modifiedPlans,
|
||||||
checkCanvasObjectEvent,
|
checkCanvasObjectEvent,
|
||||||
checkUnsavedCanvasPlan,
|
resetModifiedPlans,
|
||||||
saveCanvas,
|
saveCanvas,
|
||||||
handleCurrentPlan,
|
handleCurrentPlan,
|
||||||
handleAddPlan,
|
handleAddPlan,
|
||||||
|
|||||||
@ -376,6 +376,7 @@
|
|||||||
"board.sub.total": "全体",
|
"board.sub.total": "全体",
|
||||||
"board.sub.fileList": "添付ファイル一覧",
|
"board.sub.fileList": "添付ファイル一覧",
|
||||||
"board.sub.updDt": "更新日",
|
"board.sub.updDt": "更新日",
|
||||||
|
"board.sub.btn.close": "閉じる",
|
||||||
"myinfo.title": "マイプロフィール",
|
"myinfo.title": "マイプロフィール",
|
||||||
"myinfo.info.userId": "ユーザーID",
|
"myinfo.info.userId": "ユーザーID",
|
||||||
"myinfo.info.nameKana": "担当者名ふりがな",
|
"myinfo.info.nameKana": "担当者名ふりがな",
|
||||||
@ -587,6 +588,7 @@
|
|||||||
"stuff.detail.planGridHeader.management": "管理",
|
"stuff.detail.planGridHeader.management": "管理",
|
||||||
"stuff.detail.planGrid.btn1": "見積書の照会",
|
"stuff.detail.planGrid.btn1": "見積書の照会",
|
||||||
"stuff.detail.planGrid.btn2": "Excel",
|
"stuff.detail.planGrid.btn2": "Excel",
|
||||||
|
"stuff.grid.noData": "照会されたデータがありません",
|
||||||
"length": "長さ",
|
"length": "長さ",
|
||||||
"height": "高さ",
|
"height": "高さ",
|
||||||
"output": "出力",
|
"output": "出力",
|
||||||
|
|||||||
@ -381,6 +381,7 @@
|
|||||||
"board.sub.total": "전체",
|
"board.sub.total": "전체",
|
||||||
"board.sub.fileList": "첨부파일 목록",
|
"board.sub.fileList": "첨부파일 목록",
|
||||||
"board.sub.updDt": "업데이트",
|
"board.sub.updDt": "업데이트",
|
||||||
|
"board.sub.btn.close": "닫기",
|
||||||
"myinfo.title": "My profile",
|
"myinfo.title": "My profile",
|
||||||
"myinfo.info.userId": "사용자ID",
|
"myinfo.info.userId": "사용자ID",
|
||||||
"myinfo.info.nameKana": "담당자명 후리가나",
|
"myinfo.info.nameKana": "담당자명 후리가나",
|
||||||
@ -592,6 +593,7 @@
|
|||||||
"stuff.detail.planGridHeader.management": "관리",
|
"stuff.detail.planGridHeader.management": "관리",
|
||||||
"stuff.detail.planGrid.btn1": "견적서 조회",
|
"stuff.detail.planGrid.btn1": "견적서 조회",
|
||||||
"stuff.detail.planGrid.btn2": "Excel",
|
"stuff.detail.planGrid.btn2": "Excel",
|
||||||
|
"stuff.grid.noData": "조회된 데이터가 없습니다",
|
||||||
"length": "길이",
|
"length": "길이",
|
||||||
"height": "높이",
|
"height": "높이",
|
||||||
"output": "출력",
|
"output": "출력",
|
||||||
|
|||||||
@ -275,6 +275,11 @@ export const modifiedPlansState = atom({
|
|||||||
key: 'modifiedPlansState',
|
key: 'modifiedPlansState',
|
||||||
default: [],
|
default: [],
|
||||||
})
|
})
|
||||||
|
// 변경감지 flag
|
||||||
|
export const modifiedPlanFlagState = atom({
|
||||||
|
key: 'modifiedPlanFlagState',
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
|
||||||
export const tempGridModeState = atom({
|
export const tempGridModeState = atom({
|
||||||
key: 'tempGridModeState',
|
key: 'tempGridModeState',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user