Merge branch 'dev' of ssh://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into dev
This commit is contained in:
commit
462f8296f4
@ -42,7 +42,9 @@ export default function CanvasLayout({ children }) {
|
||||
{index !== 0 && (
|
||||
<i
|
||||
className="close"
|
||||
onClick={(e) =>
|
||||
onClick={(e) => {
|
||||
//삭제 아이콘 눌렀는데 handleCurrentPlan실행되서 추가
|
||||
e.stopPropagation()
|
||||
swalFire({
|
||||
text: `Plan ${plan.planNo} ` + getMessage('plan.message.confirm.delete'),
|
||||
type: 'confirm',
|
||||
@ -50,7 +52,7 @@ export default function CanvasLayout({ children }) {
|
||||
handleDeletePlan(e, plan)
|
||||
},
|
||||
})
|
||||
}
|
||||
}}
|
||||
></i>
|
||||
)}
|
||||
</button>
|
||||
|
||||
@ -156,6 +156,7 @@ export default function CanvasMenu(props) {
|
||||
text: getMessage('stuff.detail.move.confirmMsg'),
|
||||
type: 'confirm',
|
||||
confirmFn: () => {
|
||||
setIsGlobalLoading(true)
|
||||
router.push(`/management/stuff/detail?objectNo=${objectNo}`, { scroll: false })
|
||||
},
|
||||
})
|
||||
@ -187,7 +188,8 @@ export default function CanvasMenu(props) {
|
||||
|
||||
break
|
||||
case 5:
|
||||
// let pid = urlParams.get('pid')
|
||||
setIsGlobalLoading(true)
|
||||
//로딩바해제는 견적서 상세조회쪽(useEstimateController.js)에서 setIsGlobalLoading(false)
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => {
|
||||
if (res.status === 200) {
|
||||
const estimateDetail = res.data
|
||||
@ -198,12 +200,15 @@ export default function CanvasMenu(props) {
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
|
||||
router.push(`/floor-plan/estimate/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`)
|
||||
} else {
|
||||
setIsGlobalLoading(false)
|
||||
swalFire({ text: getMessage('estimate.menu.move.valid1') })
|
||||
}
|
||||
}
|
||||
})
|
||||
break
|
||||
case 6:
|
||||
setIsGlobalLoading(true)
|
||||
//로딩바해제는 발전시뮬레이션 조회쪽에서(Simulator.jsx) setIsGlobalLoading(false)
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => {
|
||||
if (res.status === 200) {
|
||||
const estimateDetail = res.data
|
||||
@ -212,6 +217,7 @@ export default function CanvasMenu(props) {
|
||||
setCurrentMenu(menu.title)
|
||||
router.push(`/floor-plan/simulator/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`)
|
||||
} else {
|
||||
setIsGlobalLoading(false)
|
||||
swalFire({ text: getMessage('simulator.menu.move.valid1') })
|
||||
}
|
||||
}
|
||||
@ -266,7 +272,7 @@ export default function CanvasMenu(props) {
|
||||
|
||||
// 저장버튼(btn08) 클릭 시 호출되는 함수
|
||||
const handleSaveCanvas = async () => {
|
||||
await saveCanvas()
|
||||
await saveCanvas(true)
|
||||
}
|
||||
|
||||
// 나가기 버튼 클릭
|
||||
@ -321,15 +327,15 @@ export default function CanvasMenu(props) {
|
||||
confirmFn: async () => {
|
||||
setIsGlobalLoading(true)
|
||||
const params = {
|
||||
objectNo: objectNo,
|
||||
planNo: pid,
|
||||
objectNo: estimateRecoilState.objectNo,
|
||||
planNo: estimateRecoilState.planNo,
|
||||
userId: sessionState.userId,
|
||||
}
|
||||
try {
|
||||
await promisePost({ url: '/api/estimate/reset-estimate', data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
swalFire({ text: getMessage('estimate.detail.reset.alertMsg'), type: 'alert' })
|
||||
fetchSetting(objectNo, pid, 'R')
|
||||
fetchSetting(estimateRecoilState.objectNo, estimateRecoilState.planNo, 'R')
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
@ -386,45 +392,108 @@ export default function CanvasMenu(props) {
|
||||
|
||||
useEffect(() => {
|
||||
if (isObjectNotEmpty(estimateRecoilState)) {
|
||||
if (estimateRecoilState?.createUser && estimateRecoilState?.tempFlg && estimateRecoilState.lockFlg) {
|
||||
if (estimateRecoilState?.createUser === 'T01') {
|
||||
const { createUser, tempFlg, lockFlg } = estimateRecoilState
|
||||
|
||||
if (createUser && tempFlg && lockFlg) {
|
||||
if (createUser === 'T01') {
|
||||
if (sessionState.storeId !== 'T01') {
|
||||
setButtonStyle1('none')
|
||||
setButtonStyle2('none')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('none')
|
||||
setButtonStyle5('none')
|
||||
setAllButtonStyles('none')
|
||||
} else {
|
||||
handleButtonStyles(tempFlg, lockFlg)
|
||||
}
|
||||
} else {
|
||||
if (isObjectNotEmpty(estimateRecoilState)) {
|
||||
if (estimateRecoilState?.tempFlg && estimateRecoilState.lockFlg) {
|
||||
if (estimateRecoilState?.tempFlg === '1') {
|
||||
setButtonStyle1('none')
|
||||
setButtonStyle2('')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('none')
|
||||
setButtonStyle5('none')
|
||||
} else {
|
||||
if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') {
|
||||
setButtonStyle1('')
|
||||
setButtonStyle2('')
|
||||
setButtonStyle3('')
|
||||
setButtonStyle4('')
|
||||
setButtonStyle5('')
|
||||
} else {
|
||||
setButtonStyle1('')
|
||||
setButtonStyle2('none')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('')
|
||||
setButtonStyle5('')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
handleButtonStyles(tempFlg, lockFlg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [estimateRecoilState?.createUser, estimateRecoilState?.tempFlg, estimateRecoilState?.lockFlg])
|
||||
}, [estimateRecoilState])
|
||||
|
||||
const setAllButtonStyles = (style) => {
|
||||
setButtonStyle1(style)
|
||||
setButtonStyle2(style)
|
||||
setButtonStyle3(style)
|
||||
setButtonStyle4(style)
|
||||
setButtonStyle5(style)
|
||||
}
|
||||
|
||||
const handleButtonStyles = (tempFlg, lockFlg) => {
|
||||
if (tempFlg === '1') {
|
||||
setAllButtonStyles('none')
|
||||
setButtonStyle2('')
|
||||
} else if (tempFlg === '0' && lockFlg === '0') {
|
||||
setAllButtonStyles('')
|
||||
} else {
|
||||
setButtonStyle1('')
|
||||
setButtonStyle2('none')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('')
|
||||
setButtonStyle5('')
|
||||
}
|
||||
}
|
||||
|
||||
// useEffect(() => {
|
||||
// if (isObjectNotEmpty(estimateRecoilState)) {
|
||||
// if (estimateRecoilState?.createUser && estimateRecoilState?.tempFlg && estimateRecoilState.lockFlg) {
|
||||
// if (estimateRecoilState?.createUser === 'T01') {
|
||||
// if (sessionState.storeId !== 'T01') {
|
||||
// setButtonStyle1('none')
|
||||
// setButtonStyle2('none')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('none')
|
||||
// setButtonStyle5('none')
|
||||
// } else {
|
||||
// if (estimateRecoilState?.tempFlg === '1') {
|
||||
// setButtonStyle1('none')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('none')
|
||||
// setButtonStyle5('none')
|
||||
// } else {
|
||||
// if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// } else {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('none')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (isObjectNotEmpty(estimateRecoilState)) {
|
||||
// if (estimateRecoilState?.tempFlg && estimateRecoilState.lockFlg) {
|
||||
// if (estimateRecoilState?.tempFlg === '1') {
|
||||
// setButtonStyle1('none')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('none')
|
||||
// setButtonStyle5('none')
|
||||
// } else {
|
||||
// if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// } else {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('none')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }, [estimateRecoilState])
|
||||
|
||||
/**
|
||||
* 견적서 잠금 / 해제
|
||||
@ -450,37 +519,49 @@ export default function CanvasMenu(props) {
|
||||
await promisePost({ url: '/api/estimate/save-estimate-lock', data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
estimateRecoilState.lockFlg = estimateRecoilState.lockFlg === '0' ? '1' : '0'
|
||||
if (estimateRecoilState?.createUser === 'T01') {
|
||||
if (sessionState.storeId !== 'T01') {
|
||||
setButtonStyle1('none')
|
||||
setButtonStyle2('none')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('none')
|
||||
setButtonStyle5('none')
|
||||
}
|
||||
} else {
|
||||
if (estimateRecoilState?.tempFlg === '1') {
|
||||
setButtonStyle1('none')
|
||||
setButtonStyle2('')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('none')
|
||||
setButtonStyle5('none')
|
||||
} else {
|
||||
if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') {
|
||||
setButtonStyle1('')
|
||||
setButtonStyle2('')
|
||||
setButtonStyle3('')
|
||||
setButtonStyle4('')
|
||||
setButtonStyle5('')
|
||||
const { createUser, tempFlg, lockFlg } = estimateRecoilState
|
||||
if (createUser && tempFlg && lockFlg) {
|
||||
if (createUser === 'T01') {
|
||||
if (sessionState.storeId !== 'T01') {
|
||||
setAllButtonStyles('none')
|
||||
} else {
|
||||
setButtonStyle1('')
|
||||
setButtonStyle2('none')
|
||||
setButtonStyle3('none')
|
||||
setButtonStyle4('')
|
||||
setButtonStyle5('')
|
||||
handleButtonStyles(tempFlg, lockFlg)
|
||||
}
|
||||
} else {
|
||||
handleButtonStyles(tempFlg, lockFlg)
|
||||
}
|
||||
}
|
||||
// if (estimateRecoilState?.createUser === 'T01') {
|
||||
// if (sessionState.storeId !== 'T01') {
|
||||
// setButtonStyle1('none')
|
||||
// setButtonStyle2('none')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('none')
|
||||
// setButtonStyle5('none')
|
||||
// }
|
||||
// } else {
|
||||
// if (estimateRecoilState?.tempFlg === '1') {
|
||||
// setButtonStyle1('none')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('none')
|
||||
// setButtonStyle5('none')
|
||||
// } else {
|
||||
// if (estimateRecoilState?.tempFlg === '0' && estimateRecoilState?.lockFlg === '0') {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('')
|
||||
// setButtonStyle3('')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// } else {
|
||||
// setButtonStyle1('')
|
||||
// setButtonStyle2('none')
|
||||
// setButtonStyle3('none')
|
||||
// setButtonStyle4('')
|
||||
// setButtonStyle5('')
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
setIsGlobalLoading(false)
|
||||
})
|
||||
|
||||
@ -30,7 +30,7 @@ const ALLOCATION_TYPE = {
|
||||
export default function CircuitTrestleSetting({ id }) {
|
||||
const { getMessage } = useMessage()
|
||||
const { closePopup } = usePopup()
|
||||
const { apply } = useTrestle()
|
||||
const { apply, setViewCircuitNumberTexts } = useTrestle()
|
||||
const { swalFire } = useSwal()
|
||||
const { saveEstimate } = useEstimate()
|
||||
const canvas = useRecoilValue(canvasState)
|
||||
@ -450,11 +450,18 @@ export default function CircuitTrestleSetting({ id }) {
|
||||
obj.pcses = getStepUpListData()
|
||||
})
|
||||
|
||||
setViewCircuitNumberTexts(false)
|
||||
|
||||
//TODO : 이미지 저장
|
||||
|
||||
const result = await apply()
|
||||
if (result) {
|
||||
// TODO : 이미지 저장
|
||||
|
||||
setViewCircuitNumberTexts(true)
|
||||
await saveEstimate(result)
|
||||
}
|
||||
removeNotAllocationModules()
|
||||
// removeNotAllocationModules()
|
||||
}
|
||||
|
||||
const removeNotAllocationModules = () => {
|
||||
|
||||
@ -18,6 +18,11 @@ export const useTrestle = () => {
|
||||
const isTrestleDisplay = useRecoilValue(trestleDisplaySelector)
|
||||
const { swalFire } = useSwal()
|
||||
const apply = () => {
|
||||
const notAllocationModules = canvas.getObjects().filter((obj) => obj.name === POLYGON_TYPE.MODULE && !obj.circuit)
|
||||
if (notAllocationModules.length > 0) {
|
||||
swalFire({ text: '回路番号が設定されていないモジュールがあります。 番号を設定しなおすか、 パネルを削除してください。', icon: 'error' })
|
||||
return null
|
||||
}
|
||||
try {
|
||||
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
|
||||
// exposedBottomPoints는 노출 최하면 들의 centerPoint 배열.
|
||||
@ -2227,5 +2232,15 @@ export const useTrestle = () => {
|
||||
})
|
||||
}
|
||||
|
||||
return { apply, getTrestleParams, clear }
|
||||
// 전모듈 의 회로번호 visible false 처리
|
||||
// 가대 설치 전 필요
|
||||
const setViewCircuitNumberTexts = (visible) => {
|
||||
const circuitNumberTexts = canvas.getObjects().filter((obj) => obj.name === 'circuitNumber')
|
||||
circuitNumberTexts.forEach((text) => {
|
||||
text.visible = visible
|
||||
})
|
||||
canvas.renderAll()
|
||||
}
|
||||
|
||||
return { apply, getTrestleParams, clear, setViewCircuitNumberTexts }
|
||||
}
|
||||
|
||||
@ -7,11 +7,13 @@ import { useAxios } from '@/hooks/useAxios'
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
import { usePlan } from '@/hooks/usePlan'
|
||||
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
||||
import { QcastContext } from '@/app/QcastProvider'
|
||||
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
||||
import { loginUserStore } from '@/store/commonAtom'
|
||||
|
||||
export function useEstimate() {
|
||||
const { managementStateLoaded } = useContext(GlobalDataContext)
|
||||
const { setIsGlobalLoading } = useContext(QcastContext)
|
||||
const router = useRouter()
|
||||
const loginUserState = useRecoilValue(loginUserStore)
|
||||
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
|
||||
@ -24,6 +26,9 @@ export function useEstimate() {
|
||||
* 도면 견적서 저장
|
||||
*/
|
||||
const saveEstimate = async (estimateParam) => {
|
||||
// 로딩 임시 주석
|
||||
// setIsGlobalLoading(true)
|
||||
|
||||
const userId = loginUserState.userId
|
||||
const saleStoreId = managementStateLoaded.saleStoreId
|
||||
const objectNo = currentCanvasPlan.objectNo
|
||||
@ -54,7 +59,7 @@ export function useEstimate() {
|
||||
await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData })
|
||||
.then(async () => {
|
||||
// 견적서 저장이 완료되면 캔버스 저장 후 견적서 페이지로 이동
|
||||
await saveCanvas()
|
||||
await saveCanvas(false)
|
||||
moveEstimate(planNo, objectNo)
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@ -11,10 +11,10 @@ export function useMouse() {
|
||||
const mouseLines = canvas.getObjects().filter((obj) => obj.name === 'mouseLine')
|
||||
|
||||
if (mouseLines.length < 2) {
|
||||
return pointer
|
||||
return { x: Math.round(pointer.x), y: Math.round(pointer.y) }
|
||||
}
|
||||
|
||||
return getInterSectionLineNotOverCoordinate(mouseLines[0], mouseLines[1]) || pointer
|
||||
return getInterSectionLineNotOverCoordinate(mouseLines[0], mouseLines[1]) || { x: Math.round(pointer.x), y: Math.round(pointer.y) }
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@ -120,9 +120,9 @@ export function usePlan(params = {}) {
|
||||
/**
|
||||
* 페이지 내 캔버스를 저장
|
||||
*/
|
||||
const saveCanvas = async () => {
|
||||
const saveCanvas = async (saveAlert = true) => {
|
||||
const canvasStatus = currentCanvasData('save')
|
||||
await putCanvasStatus(canvasStatus)
|
||||
await putCanvasStatus(canvasStatus, saveAlert)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -192,7 +192,7 @@ export function usePlan(params = {}) {
|
||||
/**
|
||||
* id에 해당하는 canvas 데이터를 수정
|
||||
*/
|
||||
const putCanvasStatus = async (canvasStatus) => {
|
||||
const putCanvasStatus = async (canvasStatus, saveAlert = true) => {
|
||||
const planData = {
|
||||
id: currentCanvasPlan.id,
|
||||
bgImageName: currentCanvasPlan?.bgImageName ?? null,
|
||||
@ -202,7 +202,7 @@ export function usePlan(params = {}) {
|
||||
await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData })
|
||||
.then((res) => {
|
||||
setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan)))
|
||||
swalFire({ text: getMessage('plan.message.save') })
|
||||
if (saveAlert) swalFire({ text: getMessage('plan.message.save') })
|
||||
})
|
||||
.catch((error) => {
|
||||
swalFire({ text: error.message, icon: 'error' })
|
||||
@ -283,7 +283,7 @@ export function usePlan(params = {}) {
|
||||
})
|
||||
} else {
|
||||
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
|
||||
await saveCanvas()
|
||||
await saveCanvas(true)
|
||||
}
|
||||
setCurrentCanvasPlan(plans.find((plan) => plan.id === newCurrentId))
|
||||
setPlans((plans) => plans.map((plan) => ({ ...plan, isCurrent: plan.id === newCurrentId })))
|
||||
@ -316,7 +316,7 @@ export function usePlan(params = {}) {
|
||||
*/
|
||||
const handleAddPlan = async (userId, objectNo) => {
|
||||
if (currentCanvasPlan?.id) {
|
||||
await saveCanvas()
|
||||
await saveCanvas(true)
|
||||
}
|
||||
JSON.parse(currentCanvasData()).objects.length > 0
|
||||
? swalFire({
|
||||
|
||||
@ -61,12 +61,18 @@ export const usePolygon = () => {
|
||||
|
||||
let left, top
|
||||
|
||||
if (line.direction === 'left' || line.direction === 'right') {
|
||||
if (line.direction === 'right') {
|
||||
left = (x1 + x2) / 2
|
||||
top = (y1 + y2) / 2 + 10
|
||||
} else if (line.direction === 'top' || line.direction === 'bottom') {
|
||||
} else if (line.direction === 'top') {
|
||||
left = (x1 + x2) / 2 + 10
|
||||
top = (y1 + y2) / 2
|
||||
} else if (line.direction === 'left') {
|
||||
left = (x1 + x2) / 2
|
||||
top = (y1 + y2) / 2 - 30
|
||||
} else if (line.direction === 'bottom') {
|
||||
left = (x1 + x2) / 2 - 50
|
||||
top = (y1 + y2) / 2
|
||||
}
|
||||
|
||||
const minX = line.left
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user