발전 시뮬레이션 캔버스 메뉴 이동 수정, 공지사항 번호 수정, 사용자정보 조회 팝업 수정

This commit is contained in:
leeyongjae 2025-01-07 16:48:36 +09:00
parent 2929c0cb03
commit c4592faf0c
6 changed files with 86 additions and 71 deletions

View File

@ -79,7 +79,7 @@ export default function Table({ clsCode }) {
>
<td className="al-c">
{/* 번호 */}
{board.rowNumber}
{board.totCnt - board.rowNumber + 1}
</td>
<td>
{/* 제목 */}

View File

@ -34,9 +34,10 @@ import { addedRoofsState, basicSettingState, selectedRoofMaterialSelector, setti
import { placementShapeDrawingPointsState } from '@/store/placementShapeDrawingAtom'
import { commonUtilsState } from '@/store/commonUtilsAtom'
import { menusState, menuTypeState } from '@/store/menuAtom'
import { estimateState, floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import { estimateState } from '@/store/floorPlanObjectAtom'
import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
import { isObjectNotEmpty } from '@/util/common-utils'
import { useSearchParams } from 'next/navigation'
import KO from '@/locales/ko.json'
import JA from '@/locales/ja.json'
@ -86,14 +87,61 @@ export default function CanvasMenu(props) {
//
const [buttonStyle, setButtonStyle] = useState('')
const onClickNav = (menu) => {
setMenuNumber(menu.index)
setCurrentMenu(menu.title)
//
const searchParams = useSearchParams()
const objectNo = searchParams.get('objectNo')
const pid = searchParams.get('pid')
// Excel/PDF
const { promiseGet, promisePost } = useAxios(globalLocale)
const pwrGnrSimTypeRecoil = useRecoilValue(pwrGnrSimTypeState)
const handleExcelPdfFileDown = async (donwloadType, drawingFlg) => {
const url = '/api/estimate/excel-download'
const params = {
objectNo: objectNo,
planNo: pid,
schDownload: donwloadType,
schDrawingFlg: drawingFlg,
pwrGnrSimType: pwrGnrSimTypeRecoil.type,
}
const options = { responseType: 'blob' }
await promisePost({ url: url, data: params, option: options })
.then((resultData) => {
if (resultData) {
let fileName = 'unknow'
const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' })
const fileUrl = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = fileUrl
//
const contentDisposition = resultData.headers['content-disposition']
if (contentDisposition) {
fileName = contentDisposition.split('filename=')[1].replace(/['"]/g, '')
}
link.download = fileName
document.body.appendChild(link)
link.click()
link.remove()
window.URL.revokeObjectURL(fileUrl)
}
})
.catch((error) => {
alert('File does not exist.')
})
}
const onClickNav = (menu) => {
switch (menu.index) {
case 1:
setType('placementShape')
onClickPlacementInitialMenu()
break
case 2:
setType('outline')
@ -109,11 +157,31 @@ export default function CanvasMenu(props) {
setType('module')
break
case 6:
router.push(`/floor-plan/simulator/${menu.index}`)
promiseGet({ url: `/api/object/${objectNo}/detail` }).then((res) => {
if (res.status === 200) {
const planList = res.data.planList
const objectPlanDetail = planList.filter((row) => row.objectNo === objectNo && row.planNo === pid)
if (objectPlanDetail) {
if (objectPlanDetail[0].estimateDate) {
router.push(`/floor-plan/simulator/${menu.index}?pid=${pid}&objectNo=${objectNo}`)
setMenuNumber(menu.index)
setCurrentMenu(menu.title)
} else {
alert(getMessage('simulator.menu.move.valid1'))
}
}
}
})
break
}
if (pathname !== '/floor-plan') router.push('/floor-plan')
if (menu.index !== 6) {
setMenuNumber(menu.index)
setCurrentMenu(menu.title)
}
if (pathname !== '/floor-plan') router.push(`/floor-plan?pid=${pid}&objectNo=${objectNo}`)
}
const changeSelectedRoofMaterial = (e) => {
@ -215,54 +283,6 @@ export default function CanvasMenu(props) {
return (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) || (menuNumber === 4 && menu.index === 2)
}
// Excel/PDF
const { promisePost } = useAxios(globalLocale)
const objectRecoil = useRecoilValue(floorPlanObjectState)
const pwrGnrSimTypeRecoil = useRecoilValue(pwrGnrSimTypeState)
const { plans } = usePlan()
const plan = plans.find((plan) => plan.isCurrent === true)
const handleExcelPdfFileDown = async (donwloadType, drawingFlg) => {
const url = '/api/estimate/excel-download'
const params = {
objectNo: objectRecoil.floorPlanObjectNo,
planNo: plan?.id,
schDownload: donwloadType,
schDrawingFlg: drawingFlg,
pwrGnrSimType: pwrGnrSimTypeRecoil.type,
}
const options = { responseType: 'blob' }
await promisePost({ url: url, data: params, option: options })
.then((resultData) => {
if (resultData) {
let fileName = 'unknow'
const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' })
const fileUrl = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = fileUrl
//
const contentDisposition = resultData.headers['content-disposition']
if (contentDisposition) {
fileName = contentDisposition.split('filename=')[1].replace(/['"]/g, '')
}
link.download = fileName
document.body.appendChild(link)
link.click()
link.remove()
window.URL.revokeObjectURL(fileUrl)
}
})
.catch((error) => {
alert('File does not exist.')
})
}
useEffect(() => {
if (isObjectNotEmpty(estimateRecoilState)) {
if (estimateRecoilState?.createUser === 'T01') {

View File

@ -39,6 +39,7 @@ export default function UserInfoModal({ userId, userInfoModal, setUserInfoModal
if (resultData) {
setInfo(resultData)
setPassword(resultData.password)
} else {
alert(getMessage('common.message.no.data'))
}

View File

@ -5,31 +5,23 @@ import { Bar } from 'react-chartjs-2'
import dayjs from 'dayjs'
import { useEffect, useState, useRef } from 'react'
import { useRecoilValue, useRecoilState } from 'recoil'
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
import { useRecoilState } from 'recoil'
import { useSearchParams } from 'next/navigation'
import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
import { useAxios } from '@/hooks/useAxios'
import { useMessage } from '@/hooks/useMessage'
import { usePlan } from '@/hooks/usePlan'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { convertNumberToPriceDecimal } from '@/util/common-utils'
export default function Simulator() {
const { plans } = usePlan()
const plan = plans.find((plan) => plan.isCurrent === true)
const searchParams = useSearchParams()
const objectNo = searchParams.get('objectNo')
const pid = searchParams.get('pid')
const chartRef = useRef(null)
// recoil
const objectRecoil = useRecoilValue(floorPlanObjectState)
const [objectNo, setObjectNo] = useState('')
useEffect(() => {
setObjectNo(objectRecoil.floorPlanObjectNo)
}, [objectRecoil])
//
const { setMenuNumber } = useCanvasMenu()
@ -111,7 +103,7 @@ export default function Simulator() {
setPwrGnrSimType('D')
setPwrRecoil({ ...pwrRecoil, type: 'D' })
}
}, [objectNo, plan])
}, [objectNo, pid])
//
const [objectDetail, setObjectDetail] = useState({})
@ -129,7 +121,7 @@ export default function Simulator() {
const [hatsudenryouPeakcutAllSnow, setHatsudenryouPeakcutAllSnow] = useState([])
const fetchObjectDetail = async (objectNo) => {
const apiUrl = `/api/pwrGnrSimulation/calculations?objectNo=${objectNo}&planNo=${plan?.id}`
const apiUrl = `/api/pwrGnrSimulation/calculations?objectNo=${objectNo}&planNo=${pid}`
const resultData = await get({ url: apiUrl })
if (resultData) {
@ -201,7 +193,7 @@ export default function Simulator() {
<div className="estimate-box">
<div className="estimate-tit">{getMessage('simulator.title.sub1')}</div>
<div className="estimate-name">
{objectDetail.objectNo} (Plan No: {plan?.id})
{objectDetail.objectNo} (Plan No: {pid})
</div>
</div>
{/* 작성일 */}

View File

@ -945,6 +945,7 @@
"simulator.table.sub9": "予測発電量 (kWh)",
"simulator.notice.sub1": "Hanwha Japan 年間発電量",
"simulator.notice.sub2": "シミュレーション案内事項",
"simulator.menu.move.valid1": "見積書を作成した後に、発電シミュレーションの結果を照会することができます。",
"master.moduletypeitem.message.error": "지붕재 코드를 입력하세요.",
"can.not.move.module": "모듈을 이동할 수 없습니다.(JA)",
"can.not.copy.module": "모듈을 복사할 수 없습니다.(JA)",

View File

@ -955,6 +955,7 @@
"simulator.table.sub9": "예측발전량 (kWh)",
"simulator.notice.sub1": "Hanwha Japan 연간 발전량",
"simulator.notice.sub2": "시뮬레이션 안내사항",
"simulator.menu.move.valid1": "견적서를 생성한 후에, 발전시뮬레이션 결과를 조회할 수 있습니다.",
"master.moduletypeitem.message.error": "지붕재 코드를 입력하세요.",
"can.not.move.module": "모듈을 이동할 수 없습니다.",
"can.not.copy.module": "모듈을 복사할 수 없습니다.",