Merge branch 'dev' of ssh://git.jetbrains.space/nalpari/q-cast-iii/qcast-front into dev

This commit is contained in:
yoosangwook 2025-02-06 16:55:24 +09:00
commit 462f8296f4
8 changed files with 197 additions and 81 deletions

View File

@ -42,7 +42,9 @@ export default function CanvasLayout({ children }) {
{index !== 0 && ( {index !== 0 && (
<i <i
className="close" className="close"
onClick={(e) => onClick={(e) => {
// handleCurrentPlan
e.stopPropagation()
swalFire({ swalFire({
text: `Plan ${plan.planNo} ` + getMessage('plan.message.confirm.delete'), text: `Plan ${plan.planNo} ` + getMessage('plan.message.confirm.delete'),
type: 'confirm', type: 'confirm',
@ -50,7 +52,7 @@ export default function CanvasLayout({ children }) {
handleDeletePlan(e, plan) handleDeletePlan(e, plan)
}, },
}) })
} }}
></i> ></i>
)} )}
</button> </button>

View File

@ -156,6 +156,7 @@ export default function CanvasMenu(props) {
text: getMessage('stuff.detail.move.confirmMsg'), text: getMessage('stuff.detail.move.confirmMsg'),
type: 'confirm', type: 'confirm',
confirmFn: () => { confirmFn: () => {
setIsGlobalLoading(true)
router.push(`/management/stuff/detail?objectNo=${objectNo}`, { scroll: false }) router.push(`/management/stuff/detail?objectNo=${objectNo}`, { scroll: false })
}, },
}) })
@ -187,7 +188,8 @@ export default function CanvasMenu(props) {
break break
case 5: case 5:
// let pid = urlParams.get('pid') setIsGlobalLoading(true)
// (useEstimateController.js) setIsGlobalLoading(false)
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => { promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => {
if (res.status === 200) { if (res.status === 200) {
const estimateDetail = res.data const estimateDetail = res.data
@ -198,12 +200,15 @@ export default function CanvasMenu(props) {
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
router.push(`/floor-plan/estimate/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`) router.push(`/floor-plan/estimate/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`)
} else { } else {
setIsGlobalLoading(false)
swalFire({ text: getMessage('estimate.menu.move.valid1') }) swalFire({ text: getMessage('estimate.menu.move.valid1') })
} }
} }
}) })
break break
case 6: case 6:
setIsGlobalLoading(true)
// (Simulator.jsx) setIsGlobalLoading(false)
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => { promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan.planNo}/detail` }).then((res) => {
if (res.status === 200) { if (res.status === 200) {
const estimateDetail = res.data const estimateDetail = res.data
@ -212,6 +217,7 @@ export default function CanvasMenu(props) {
setCurrentMenu(menu.title) setCurrentMenu(menu.title)
router.push(`/floor-plan/simulator/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`) router.push(`/floor-plan/simulator/${menu.index}?pid=${selectedPlan.planNo}&objectNo=${objectNo}`)
} else { } else {
setIsGlobalLoading(false)
swalFire({ text: getMessage('simulator.menu.move.valid1') }) swalFire({ text: getMessage('simulator.menu.move.valid1') })
} }
} }
@ -266,7 +272,7 @@ export default function CanvasMenu(props) {
// (btn08) // (btn08)
const handleSaveCanvas = async () => { const handleSaveCanvas = async () => {
await saveCanvas() await saveCanvas(true)
} }
// //
@ -321,15 +327,15 @@ export default function CanvasMenu(props) {
confirmFn: async () => { confirmFn: async () => {
setIsGlobalLoading(true) setIsGlobalLoading(true)
const params = { const params = {
objectNo: objectNo, objectNo: estimateRecoilState.objectNo,
planNo: pid, planNo: estimateRecoilState.planNo,
userId: sessionState.userId, userId: sessionState.userId,
} }
try { try {
await promisePost({ url: '/api/estimate/reset-estimate', data: params }).then((res) => { await promisePost({ url: '/api/estimate/reset-estimate', data: params }).then((res) => {
if (res.status === 201) { if (res.status === 201) {
swalFire({ text: getMessage('estimate.detail.reset.alertMsg'), type: 'alert' }) swalFire({ text: getMessage('estimate.detail.reset.alertMsg'), type: 'alert' })
fetchSetting(objectNo, pid, 'R') fetchSetting(estimateRecoilState.objectNo, estimateRecoilState.planNo, 'R')
} }
}) })
} catch (error) { } catch (error) {
@ -386,45 +392,108 @@ export default function CanvasMenu(props) {
useEffect(() => { useEffect(() => {
if (isObjectNotEmpty(estimateRecoilState)) { if (isObjectNotEmpty(estimateRecoilState)) {
if (estimateRecoilState?.createUser && estimateRecoilState?.tempFlg && estimateRecoilState.lockFlg) { const { createUser, tempFlg, lockFlg } = estimateRecoilState
if (estimateRecoilState?.createUser === 'T01') {
if (createUser && tempFlg && lockFlg) {
if (createUser === 'T01') {
if (sessionState.storeId !== 'T01') { if (sessionState.storeId !== 'T01') {
setButtonStyle1('none') setAllButtonStyles('none')
setButtonStyle2('none') } else {
setButtonStyle3('none') handleButtonStyles(tempFlg, lockFlg)
setButtonStyle4('none')
setButtonStyle5('none')
} }
} else { } else {
if (isObjectNotEmpty(estimateRecoilState)) { handleButtonStyles(tempFlg, lockFlg)
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?.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) => { await promisePost({ url: '/api/estimate/save-estimate-lock', data: params }).then((res) => {
if (res.status === 201) { if (res.status === 201) {
estimateRecoilState.lockFlg = estimateRecoilState.lockFlg === '0' ? '1' : '0' estimateRecoilState.lockFlg = estimateRecoilState.lockFlg === '0' ? '1' : '0'
if (estimateRecoilState?.createUser === 'T01') { const { createUser, tempFlg, lockFlg } = estimateRecoilState
if (sessionState.storeId !== 'T01') { if (createUser && tempFlg && lockFlg) {
setButtonStyle1('none') if (createUser === 'T01') {
setButtonStyle2('none') if (sessionState.storeId !== 'T01') {
setButtonStyle3('none') setAllButtonStyles('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 { } else {
setButtonStyle1('') handleButtonStyles(tempFlg, lockFlg)
setButtonStyle2('none')
setButtonStyle3('none')
setButtonStyle4('')
setButtonStyle5('')
} }
} 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) setIsGlobalLoading(false)
}) })

View File

@ -30,7 +30,7 @@ const ALLOCATION_TYPE = {
export default function CircuitTrestleSetting({ id }) { export default function CircuitTrestleSetting({ id }) {
const { getMessage } = useMessage() const { getMessage } = useMessage()
const { closePopup } = usePopup() const { closePopup } = usePopup()
const { apply } = useTrestle() const { apply, setViewCircuitNumberTexts } = useTrestle()
const { swalFire } = useSwal() const { swalFire } = useSwal()
const { saveEstimate } = useEstimate() const { saveEstimate } = useEstimate()
const canvas = useRecoilValue(canvasState) const canvas = useRecoilValue(canvasState)
@ -450,11 +450,18 @@ export default function CircuitTrestleSetting({ id }) {
obj.pcses = getStepUpListData() obj.pcses = getStepUpListData()
}) })
setViewCircuitNumberTexts(false)
//TODO :
const result = await apply() const result = await apply()
if (result) { if (result) {
// TODO :
setViewCircuitNumberTexts(true)
await saveEstimate(result) await saveEstimate(result)
} }
removeNotAllocationModules() // removeNotAllocationModules()
} }
const removeNotAllocationModules = () => { const removeNotAllocationModules = () => {

View File

@ -18,6 +18,11 @@ export const useTrestle = () => {
const isTrestleDisplay = useRecoilValue(trestleDisplaySelector) const isTrestleDisplay = useRecoilValue(trestleDisplaySelector)
const { swalFire } = useSwal() const { swalFire } = useSwal()
const apply = () => { 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 { try {
//처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함. //처마력바가 체크되어 있는 경우 exposedBottomPoints를 이용해 처마력바 그려줘야함.
// exposedBottomPoints는 노출 최하면 들의 centerPoint 배열. // 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 }
} }

View File

@ -7,11 +7,13 @@ import { useAxios } from '@/hooks/useAxios'
import { useSwal } from '@/hooks/useSwal' import { useSwal } from '@/hooks/useSwal'
import { usePlan } from '@/hooks/usePlan' import { usePlan } from '@/hooks/usePlan'
import { GlobalDataContext } from '@/app/GlobalDataProvider' import { GlobalDataContext } from '@/app/GlobalDataProvider'
import { QcastContext } from '@/app/QcastProvider'
import { currentCanvasPlanState } from '@/store/canvasAtom' import { currentCanvasPlanState } from '@/store/canvasAtom'
import { loginUserStore } from '@/store/commonAtom' import { loginUserStore } from '@/store/commonAtom'
export function useEstimate() { export function useEstimate() {
const { managementStateLoaded } = useContext(GlobalDataContext) const { managementStateLoaded } = useContext(GlobalDataContext)
const { setIsGlobalLoading } = useContext(QcastContext)
const router = useRouter() const router = useRouter()
const loginUserState = useRecoilValue(loginUserStore) const loginUserState = useRecoilValue(loginUserStore)
const currentCanvasPlan = useRecoilValue(currentCanvasPlanState) const currentCanvasPlan = useRecoilValue(currentCanvasPlanState)
@ -24,6 +26,9 @@ export function useEstimate() {
* 도면 견적서 저장 * 도면 견적서 저장
*/ */
const saveEstimate = async (estimateParam) => { const saveEstimate = async (estimateParam) => {
// 로딩 임시 주석
// setIsGlobalLoading(true)
const userId = loginUserState.userId const userId = loginUserState.userId
const saleStoreId = managementStateLoaded.saleStoreId const saleStoreId = managementStateLoaded.saleStoreId
const objectNo = currentCanvasPlan.objectNo const objectNo = currentCanvasPlan.objectNo
@ -54,7 +59,7 @@ export function useEstimate() {
await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData }) await promisePost({ url: '/api/estimate/save-estimate', data: saveEstimateData })
.then(async () => { .then(async () => {
// 견적서 저장이 완료되면 캔버스 저장 후 견적서 페이지로 이동 // 견적서 저장이 완료되면 캔버스 저장 후 견적서 페이지로 이동
await saveCanvas() await saveCanvas(false)
moveEstimate(planNo, objectNo) moveEstimate(planNo, objectNo)
}) })
.catch((error) => { .catch((error) => {

View File

@ -11,10 +11,10 @@ export function useMouse() {
const mouseLines = canvas.getObjects().filter((obj) => obj.name === 'mouseLine') const mouseLines = canvas.getObjects().filter((obj) => obj.name === 'mouseLine')
if (mouseLines.length < 2) { 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 { return {

View File

@ -120,9 +120,9 @@ export function usePlan(params = {}) {
/** /**
* 페이지 캔버스를 저장 * 페이지 캔버스를 저장
*/ */
const saveCanvas = async () => { const saveCanvas = async (saveAlert = true) => {
const canvasStatus = currentCanvasData('save') const canvasStatus = currentCanvasData('save')
await putCanvasStatus(canvasStatus) await putCanvasStatus(canvasStatus, saveAlert)
} }
/** /**
@ -192,7 +192,7 @@ export function usePlan(params = {}) {
/** /**
* id에 해당하는 canvas 데이터를 수정 * id에 해당하는 canvas 데이터를 수정
*/ */
const putCanvasStatus = async (canvasStatus) => { const putCanvasStatus = async (canvasStatus, saveAlert = true) => {
const planData = { const planData = {
id: currentCanvasPlan.id, id: currentCanvasPlan.id,
bgImageName: currentCanvasPlan?.bgImageName ?? null, bgImageName: currentCanvasPlan?.bgImageName ?? null,
@ -202,7 +202,7 @@ export function usePlan(params = {}) {
await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData }) await promisePut({ url: '/api/canvas-management/canvas-statuses', data: planData })
.then((res) => { .then((res) => {
setPlans((plans) => plans.map((plan) => (plan.id === currentCanvasPlan.id ? { ...plan, canvasStatus: canvasStatus } : plan))) 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) => { .catch((error) => {
swalFire({ text: error.message, icon: 'error' }) swalFire({ text: error.message, icon: 'error' })
@ -283,7 +283,7 @@ export function usePlan(params = {}) {
}) })
} else { } else {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) { if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
await saveCanvas() await saveCanvas(true)
} }
setCurrentCanvasPlan(plans.find((plan) => plan.id === newCurrentId)) setCurrentCanvasPlan(plans.find((plan) => plan.id === newCurrentId))
setPlans((plans) => plans.map((plan) => ({ ...plan, isCurrent: 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) => { const handleAddPlan = async (userId, objectNo) => {
if (currentCanvasPlan?.id) { if (currentCanvasPlan?.id) {
await saveCanvas() await saveCanvas(true)
} }
JSON.parse(currentCanvasData()).objects.length > 0 JSON.parse(currentCanvasData()).objects.length > 0
? swalFire({ ? swalFire({

View File

@ -61,12 +61,18 @@ export const usePolygon = () => {
let left, top let left, top
if (line.direction === 'left' || line.direction === 'right') { if (line.direction === 'right') {
left = (x1 + x2) / 2 left = (x1 + x2) / 2
top = (y1 + y2) / 2 + 10 top = (y1 + y2) / 2 + 10
} else if (line.direction === 'top' || line.direction === 'bottom') { } else if (line.direction === 'top') {
left = (x1 + x2) / 2 + 10 left = (x1 + x2) / 2 + 10
top = (y1 + y2) / 2 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 const minX = line.left