Merge branch 'dev' into dev-yj
This commit is contained in:
commit
d1c7327fc9
@ -5,7 +5,7 @@ import fs from 'fs/promises'
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
export async function GET(req) {
|
||||
const path = 'public/mapImages'
|
||||
const path = 'public/plan-map-images'
|
||||
const q = req.nextUrl.searchParams.get('q')
|
||||
const fileNm = req.nextUrl.searchParams.get('fileNm')
|
||||
const zoom = req.nextUrl.searchParams.get('zoom')
|
||||
|
||||
25
src/app/api/image-upload/route.js
Normal file
25
src/app/api/image-upload/route.js
Normal file
@ -0,0 +1,25 @@
|
||||
'use server'
|
||||
|
||||
import fs from 'fs/promises'
|
||||
|
||||
import { NextResponse } from 'next/server'
|
||||
|
||||
export async function POST(req) {
|
||||
const path = 'public/plan-bg-images'
|
||||
|
||||
const formData = await req.formData()
|
||||
const file = formData.get('file')
|
||||
const arrayBuffer = await file.arrayBuffer()
|
||||
const buffer = Buffer.from(arrayBuffer)
|
||||
// const buffer = new Uint8Array(arrayBuffer)
|
||||
|
||||
try {
|
||||
await fs.readdir(path)
|
||||
} catch {
|
||||
await fs.mkdir(path)
|
||||
} finally {
|
||||
await fs.writeFile(`${path}/${file.name}`, buffer)
|
||||
}
|
||||
|
||||
return NextResponse.json({ fileNm: `${file.name}` })
|
||||
}
|
||||
@ -17,7 +17,7 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
|
||||
const [schDisplayFlg, setSchSchDisplayFlg] = useState('0')
|
||||
//가대 중량표 포함(포함:1 미포함 : 0)
|
||||
const [schWeightFlg, setSchWeightFlg] = useState('1')
|
||||
//도면/시뮬레이션 파일 포함(포함:1 미포함 : 0)
|
||||
//도면/시뮬레이션 파일 포함
|
||||
const [schDrawingFlg, setSchDrawingFlg] = useState('1')
|
||||
|
||||
// recoil 물건번호
|
||||
@ -37,6 +37,18 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
|
||||
sendUnitPriceFlg = '1'
|
||||
}
|
||||
|
||||
//schDrawingFlg 선택값은 의미없어짐
|
||||
//가대중량표 포함, 도면/시뮬레이션 파일 포함 선택값에따라 schDrawingFlg에 |구분자로 보냄
|
||||
//SchDrawingFlg (1 : 견적서,2 : 발전시뮬레이션, 3 : 도면, 4 : 가대)
|
||||
// ex) 1|2|3|4
|
||||
let defaultSchDrawingFlg = '1'
|
||||
if (schWeightFlg === '1') {
|
||||
defaultSchDrawingFlg = defaultSchDrawingFlg.concat('|', '4')
|
||||
}
|
||||
if (schDrawingFlg === '1') {
|
||||
defaultSchDrawingFlg = defaultSchDrawingFlg.concat('|', '2', '|', '3')
|
||||
}
|
||||
|
||||
const params = {
|
||||
objectNo: objectRecoil.floorPlanObjectNo,
|
||||
planNo: planNo,
|
||||
@ -44,8 +56,10 @@ export default function DocDownOptionPop({ planNo, setEstimatePopupOpen }) {
|
||||
schUnitPriceFlg: sendUnitPriceFlg,
|
||||
schDisplayFlg: schDisplayFlg,
|
||||
schWeightFlg: schWeightFlg,
|
||||
schDrawingFlg: schDrawingFlg,
|
||||
schDrawingFlg: defaultSchDrawingFlg,
|
||||
pwrGnrSimType: 'D', //default 화면에 안보여줌
|
||||
}
|
||||
|
||||
const options = { responseType: 'blob' }
|
||||
await promisePost({ url: url, data: params, option: options })
|
||||
.then((resultData) => {
|
||||
|
||||
@ -38,6 +38,10 @@ import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
|
||||
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
|
||||
import EstimateCopyPop from '../estimate/popup/EstimateCopyPop'
|
||||
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
|
||||
export default function CanvasMenu(props) {
|
||||
const { menuNumber, setMenuNumber } = props
|
||||
const pathname = usePathname()
|
||||
@ -189,6 +193,54 @@ export default function CanvasMenu(props) {
|
||||
return ([2, 3].some((num) => num === 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.')
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={`canvas-menu-wrap ${[2, 3, 4].some((num) => num === menuNumber) ? 'active' : ''}`}>
|
||||
<div className="canvas-menu-inner">
|
||||
@ -299,11 +351,11 @@ export default function CanvasMenu(props) {
|
||||
{menuNumber === 6 && (
|
||||
<>
|
||||
<div className="ico-btn-from">
|
||||
<button className="btn-frame gray ico-flx">
|
||||
<button type="button" className="btn-frame gray ico-flx" onClick={() => handleExcelPdfFileDown('EXCEL', '2')}>
|
||||
<span className="ico ico01"></span>
|
||||
<span>{getMessage('plan.menu.simulation.excel')}</span>
|
||||
</button>
|
||||
<button className="btn-frame gray ico-flx">
|
||||
<button type="button" className="btn-frame gray ico-flx" onClick={() => handleExcelPdfFileDown('PDF', '2')}>
|
||||
<span className="ico ico01"></span>
|
||||
<span>{getMessage('plan.menu.simulation.pdf')}</span>
|
||||
</button>
|
||||
|
||||
@ -95,7 +95,14 @@ export default function ImgLoad() {
|
||||
<label htmlFor="ra07">アドレスを読み込む</label>
|
||||
</div>
|
||||
<div className="img-flex-box for-address">
|
||||
<input type="text" className="input-origin al-l mr10" placeholder={'住所入力'} value={currentCanvasPlan?.mapPositionAddress} />
|
||||
<input
|
||||
type="text"
|
||||
ref={queryRef}
|
||||
className="input-origin al-l mr10"
|
||||
placeholder={'住所入力'}
|
||||
value={mapPositionAddress}
|
||||
onChange={(e) => setMapPositionAddress(e.target.value)}
|
||||
/>
|
||||
<div className="img-edit-wrap">
|
||||
<button className="img-edit-btn" onClick={refFileMethod === '2' ? handleMapImageDown : () => {}}>
|
||||
完了
|
||||
|
||||
@ -172,8 +172,7 @@ export default function Stuff() {
|
||||
schDateType: stuffSearchParams.schDateType,
|
||||
schFromDt: dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'),
|
||||
schToDt: dayjs(new Date()).format('YYYY-MM-DD'),
|
||||
startRow: (pageNo - 1) * pageSize + 1,
|
||||
// endRow: pageNo * pageSize,
|
||||
startRow: (stuffSearch.pageNo - 1) * stuffSearchParams.pageSize + 1,
|
||||
endRow: stuffSearchParams?.endRow,
|
||||
schSelSaleStoreId: stuffSearchParams?.schSelSaleStoreId ? stuffSearchParams.schSelSaleStoreId : '',
|
||||
schOtherSelSaleStoreId: stuffSearchParams?.schOtherSelSaleStoreId ? stuffSearchParams.schOtherSelSaleStoreId : '',
|
||||
@ -219,6 +218,7 @@ export default function Stuff() {
|
||||
stuffSearchParams.endRow = 1 * pageSize
|
||||
stuffSearchParams.schSortType = defaultSortType
|
||||
setPageNo(1)
|
||||
stuffSearchParams.pageNo = 1
|
||||
|
||||
async function fetchData() {
|
||||
const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
@ -241,6 +241,7 @@ export default function Stuff() {
|
||||
stuffSearchParams.endRow = 1 * pageSize
|
||||
stuffSearchParams.schSortType = defaultSortType
|
||||
setPageNo(1)
|
||||
|
||||
async function fetchData() {
|
||||
const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
await get({ url: apiUrl }).then((res) => {
|
||||
@ -262,31 +263,31 @@ export default function Stuff() {
|
||||
const onChangePerPage = (e) => {
|
||||
let startRow = (1 - 1) * e.target.value + 1
|
||||
stuffSearchParams.startRow = startRow
|
||||
stuffSearchParams.endRow = 1 * e.target.value
|
||||
stuffSearchParams.endRow = stuffSearchParams.pageNo * e.target.value
|
||||
stuffSearchParams.schSelSaleStoreId = stuffSearchParams?.schOtherSelSaleStoreId
|
||||
? stuffSearchParams.schOtherSelSaleStoreId
|
||||
: stuffSearchParams.schSelSaleStoreId
|
||||
setPageSize(e.target.value)
|
||||
setStuffSearch({
|
||||
// ...stuffSearchParams,
|
||||
...stuffSearch,
|
||||
code: 'S',
|
||||
startRow: startRow,
|
||||
endRow: 1 * e.target.value,
|
||||
endRow: stuffSearchParams.pageNo * e.target.value,
|
||||
pageSize: e.target.value,
|
||||
})
|
||||
|
||||
setPageNo(1)
|
||||
|
||||
const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
get({ url: apiUrl }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setGridProps({ ...gridProps, gridData: res, count: res[0].totCnt })
|
||||
setTotalCount(res[0].totCnt)
|
||||
} else {
|
||||
setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||
setTotalCount(0)
|
||||
}
|
||||
})
|
||||
// const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
// get({ url: apiUrl }).then((res) => {
|
||||
// if (!isEmptyArray(res)) {
|
||||
// setGridProps({ ...gridProps, gridData: res, count: res[0].totCnt })
|
||||
// setTotalCount(res[0].totCnt)
|
||||
// } else {
|
||||
// setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||
// setTotalCount(0)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
//최근 등록일 수정일 정렬 이벤트
|
||||
@ -309,16 +310,16 @@ export default function Stuff() {
|
||||
})
|
||||
|
||||
setPageNo(1)
|
||||
const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
get({ url: apiUrl }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setGridProps({ ...gridProps, gridData: res, count: res[0].totCnt })
|
||||
setTotalCount(res[0].totCnt)
|
||||
} else {
|
||||
setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||
setTotalCount(0)
|
||||
}
|
||||
})
|
||||
// const apiUrl = `/api/object/list?saleStoreId=${session?.storeId}&${queryStringFormatter(stuffSearchParams)}`
|
||||
// get({ url: apiUrl }).then((res) => {
|
||||
// if (!isEmptyArray(res)) {
|
||||
// setGridProps({ ...gridProps, gridData: res, count: res[0].totCnt })
|
||||
// setTotalCount(res[0].totCnt)
|
||||
// } else {
|
||||
// setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||
// setTotalCount(0)
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
@ -340,6 +341,7 @@ export default function Stuff() {
|
||||
code: 'S',
|
||||
startRow: (page - 1) * pageSize + 1,
|
||||
endRow: page * pageSize,
|
||||
pageNo: page,
|
||||
})
|
||||
|
||||
setPageNo(page)
|
||||
@ -368,7 +370,8 @@ export default function Stuff() {
|
||||
</select>
|
||||
</div>
|
||||
<div className="select-box" style={{ width: '80px' }}>
|
||||
<select className="select-light black" onChange={onChangePerPage} defaultValue={stuffSearch.endRow}>
|
||||
<select className="select-light black" onChange={onChangePerPage} defaultValue={stuffSearch.pageSize}>
|
||||
{/* <select className="select-light black" onChange={onChangePerPage} defaultValue={stuffSearch.endRow}> */}
|
||||
<option value="100">100</option>
|
||||
<option value="200">200</option>
|
||||
<option value="300">300</option>
|
||||
@ -380,7 +383,14 @@ export default function Stuff() {
|
||||
<div className="q-grid">
|
||||
<StuffQGrid {...gridProps} getCellDoubleClicked={getCellDoubleClicked} gridRef={gridRef} />
|
||||
<div className="pagination-wrap">
|
||||
<QPagination pageNo={pageNo} pageSize={pageSize} pagePerBlock={10} totalCount={totalCount} handleChangePage={handleChangePage} />
|
||||
{/* <QPagination pageNo={pageNo} pageSize={pageSize} pagePerBlock={10} totalCount={totalCount} handleChangePage={handleChangePage} /> */}
|
||||
<QPagination
|
||||
pageNo={stuffSearch.pageNo}
|
||||
pageSize={stuffSearch.pageSize}
|
||||
pagePerBlock={10}
|
||||
totalCount={totalCount}
|
||||
handleChangePage={handleChangePage}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -10,7 +10,7 @@ import { globalLocaleStore } from '@/store/localeAtom'
|
||||
import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil'
|
||||
import { useRecoilValue, useSetRecoilState, useResetRecoilState, useRecoilState } from 'recoil'
|
||||
import { SessionContext } from '@/app/SessionProvider'
|
||||
import FindAddressPop from './popup/FindAddressPop'
|
||||
import PlanRequestPop from './popup/PlanRequestPop'
|
||||
@ -20,8 +20,12 @@ import StuffPlanQGrid from './StuffPlanQGrid'
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
import { ManagementContext } from '@/app/management/ManagementProvider'
|
||||
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
|
||||
import { stuffSearchState } from '@/store/stuffAtom'
|
||||
|
||||
export default function StuffDetail() {
|
||||
const resetStuffRecoil = useResetRecoilState(stuffSearchState)
|
||||
const stuffSearchParams = useRecoilValue(stuffSearchState)
|
||||
|
||||
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //견적서 화면용 물건번호리코일
|
||||
|
||||
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
|
||||
@ -433,158 +437,160 @@ export default function StuffDetail() {
|
||||
}, [commonCode])
|
||||
|
||||
useEffect(() => {
|
||||
if (isObjectNotEmpty(managementState)) {
|
||||
// 도도부현API
|
||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setPrefCodeList(res)
|
||||
}
|
||||
})
|
||||
if (objectNo) {
|
||||
if (isObjectNotEmpty(managementState)) {
|
||||
// 도도부현API
|
||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setPrefCodeList(res)
|
||||
}
|
||||
})
|
||||
|
||||
//1차점 : X167 T01
|
||||
//2차점 : 10X22, 201X112
|
||||
let url
|
||||
let firstList
|
||||
let otherList
|
||||
let favList
|
||||
//1차점 : X167 T01
|
||||
//2차점 : 10X22, 201X112
|
||||
let url
|
||||
let firstList
|
||||
let otherList
|
||||
let favList
|
||||
|
||||
if (session?.storeId === 'T01') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
||||
} else {
|
||||
if (session.storeLvl === '1') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
if (session?.storeId === 'T01') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
||||
} else {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
}
|
||||
}
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
if (session?.storeId === 'T01') {
|
||||
firstList = res.filter((row) => row.saleStoreLevel === '1')
|
||||
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
|
||||
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(favList)
|
||||
setShowSaleStoreList(favList)
|
||||
|
||||
if (managementState.firstAgentId != null) {
|
||||
form.setValue('saleStoreId', managementState.firstAgentId)
|
||||
setSelOptions(managementState.firstAgentId)
|
||||
} else {
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
}
|
||||
|
||||
//상세데이터의 1차점 아이디로 2차점 목록 조회하기
|
||||
|
||||
let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
|
||||
url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
|
||||
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
res.map((row) => {
|
||||
row.value = row.saleStoreId
|
||||
row.label = row.saleStoreName
|
||||
})
|
||||
|
||||
otherList = res
|
||||
setOriginOtherSaleStoreList(otherList)
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
})
|
||||
if (session.storeLvl === '1') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
} else {
|
||||
//1차점 셀렉트박스
|
||||
if (session?.storeLvl === '1') {
|
||||
firstList = res
|
||||
favList = res.filter((row) => row.priority !== 'B')
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(firstList)
|
||||
setShowSaleStoreList(firstList)
|
||||
|
||||
setOtherSaleStoreList(otherList)
|
||||
} else {
|
||||
setSelOptions(res[0].saleStoreId)
|
||||
form.setValue('saleStoreId', res[0].saleStoreId)
|
||||
form.setValue('saleStoreLevel', res[0].storeLvl)
|
||||
setSaleStoreList(res)
|
||||
setFavoriteStoreList(res)
|
||||
setShowSaleStoreList(res)
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
}
|
||||
}
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
if (session?.storeId === 'T01') {
|
||||
firstList = res.filter((row) => row.saleStoreLevel === '1')
|
||||
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
|
||||
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(favList)
|
||||
setShowSaleStoreList(favList)
|
||||
|
||||
//상세데이터가 1차점이면 1차점에 세팅
|
||||
//상세데이터가 2차점이면 2차점에 세팅하고 세션으로 1차점 세팅
|
||||
if (managementState.saleStoreLevel === '1') {
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
form.setValue('saleStoreLevel', managementState.saleStoreLevel)
|
||||
} else {
|
||||
setOtherSelOptions(managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreId', managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
|
||||
if (managementState.firstAgentId != null) {
|
||||
form.setValue('saleStoreId', managementState.firstAgentId)
|
||||
setSelOptions(managementState.firstAgentId)
|
||||
} else {
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
}
|
||||
|
||||
form.setValue('saleStoreLevel', '1')
|
||||
}
|
||||
//상세데이터의 1차점 아이디로 2차점 목록 조회하기
|
||||
|
||||
//설계의뢰No.
|
||||
form.setValue('planReqNo', managementState.planReqNo)
|
||||
//담당자
|
||||
form.setValue('receiveUser', managementState.receiveUser)
|
||||
let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
|
||||
url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
|
||||
|
||||
//물건구분objectStatusId
|
||||
setSelectObjectStatusId(managementState.objectStatusId)
|
||||
form.setValue('objectStatusId', managementState.objectStatusId)
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
res.map((row) => {
|
||||
row.value = row.saleStoreId
|
||||
row.label = row.saleStoreName
|
||||
})
|
||||
|
||||
//물건명
|
||||
form.setValue('objectName', managementState.objectName)
|
||||
otherList = res
|
||||
setOriginOtherSaleStoreList(otherList)
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//1차점 셀렉트박스
|
||||
if (session?.storeLvl === '1') {
|
||||
firstList = res
|
||||
favList = res.filter((row) => row.priority !== 'B')
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
|
||||
//경칭코드
|
||||
setSelHonorificCode(managementState.objectNameOmit)
|
||||
form.setValue('objectNameOmit', managementState.objectNameOmit)
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(firstList)
|
||||
setShowSaleStoreList(firstList)
|
||||
|
||||
//물건명 후리가나
|
||||
form.setValue('objectNameKana', managementState.objectNameKana)
|
||||
setOtherSaleStoreList(otherList)
|
||||
} else {
|
||||
setSelOptions(res[0].saleStoreId)
|
||||
form.setValue('saleStoreId', res[0].saleStoreId)
|
||||
form.setValue('saleStoreLevel', res[0].storeLvl)
|
||||
setSaleStoreList(res)
|
||||
setFavoriteStoreList(res)
|
||||
setShowSaleStoreList(res)
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//우편번호
|
||||
form.setValue('zipNo', managementState.zipNo)
|
||||
//상세데이터가 1차점이면 1차점에 세팅
|
||||
//상세데이터가 2차점이면 2차점에 세팅하고 세션으로 1차점 세팅
|
||||
if (managementState.saleStoreLevel === '1') {
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
form.setValue('saleStoreLevel', managementState.saleStoreLevel)
|
||||
} else {
|
||||
setOtherSelOptions(managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreId', managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
|
||||
|
||||
//도도부현 / 주소
|
||||
setPrefValue(managementState.prefId)
|
||||
form.setValue('prefId', managementState.prefId)
|
||||
form.setValue('prefName', managementState.prefName)
|
||||
form.setValue('address', managementState.address)
|
||||
//발전시뮬
|
||||
form.setValue('areaId', managementState.areaId)
|
||||
form.setValue('saleStoreLevel', '1')
|
||||
}
|
||||
|
||||
//기준풍속
|
||||
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId)
|
||||
//수직적설량
|
||||
form.setValue('verticalSnowCover', managementState.verticalSnowCover)
|
||||
//한랭지대책시행 coldRegionFlg 1이면 true
|
||||
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
|
||||
//설계의뢰No.
|
||||
form.setValue('planReqNo', managementState.planReqNo)
|
||||
//담당자
|
||||
form.setValue('receiveUser', managementState.receiveUser)
|
||||
|
||||
//면조도구분 surfaceType null로 내려오면 셋팅 안하고 저장할때 필수값 체크하도록
|
||||
// form.setValue('surfaceType', 'Ⅱ')
|
||||
// form.setValue('surfaceType', 'Ⅲ・Ⅳ')
|
||||
form.setValue('surfaceType', managementState.surfaceType)
|
||||
//염해지역용아이템사용 saltAreaFlg 1이면 true
|
||||
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false)
|
||||
//설치높이
|
||||
form.setValue('installHeight', managementState.installHeight)
|
||||
//계약조건 null로 내려오면 0으로 디폴트셋팅
|
||||
if (managementState.conType === null) {
|
||||
form.setValue('conType', '0')
|
||||
} else {
|
||||
form.setValue('conType', managementState.conType)
|
||||
}
|
||||
//메모
|
||||
form.setValue('remarks', managementState.remarks)
|
||||
})
|
||||
//물건구분objectStatusId
|
||||
setSelectObjectStatusId(managementState.objectStatusId)
|
||||
form.setValue('objectStatusId', managementState.objectStatusId)
|
||||
|
||||
//물건명
|
||||
form.setValue('objectName', managementState.objectName)
|
||||
|
||||
//경칭코드
|
||||
setSelHonorificCode(managementState.objectNameOmit)
|
||||
form.setValue('objectNameOmit', managementState.objectNameOmit)
|
||||
|
||||
//물건명 후리가나
|
||||
form.setValue('objectNameKana', managementState.objectNameKana)
|
||||
|
||||
//우편번호
|
||||
form.setValue('zipNo', managementState.zipNo)
|
||||
|
||||
//도도부현 / 주소
|
||||
setPrefValue(managementState.prefId)
|
||||
form.setValue('prefId', managementState.prefId)
|
||||
form.setValue('prefName', managementState.prefName)
|
||||
form.setValue('address', managementState.address)
|
||||
//발전시뮬
|
||||
form.setValue('areaId', managementState.areaId)
|
||||
|
||||
//기준풍속
|
||||
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId)
|
||||
//수직적설량
|
||||
form.setValue('verticalSnowCover', managementState.verticalSnowCover)
|
||||
//한랭지대책시행 coldRegionFlg 1이면 true
|
||||
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
|
||||
|
||||
//면조도구분 surfaceType null로 내려오면 셋팅 안하고 저장할때 필수값 체크하도록
|
||||
// form.setValue('surfaceType', 'Ⅱ')
|
||||
// form.setValue('surfaceType', 'Ⅲ・Ⅳ')
|
||||
form.setValue('surfaceType', managementState.surfaceType)
|
||||
//염해지역용아이템사용 saltAreaFlg 1이면 true
|
||||
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false)
|
||||
//설치높이
|
||||
form.setValue('installHeight', managementState.installHeight)
|
||||
//계약조건 null로 내려오면 0으로 디폴트셋팅
|
||||
if (managementState.conType === null) {
|
||||
form.setValue('conType', '0')
|
||||
} else {
|
||||
form.setValue('conType', managementState.conType)
|
||||
}
|
||||
//메모
|
||||
form.setValue('remarks', managementState.remarks)
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [managementState])
|
||||
|
||||
@ -1267,7 +1273,7 @@ export default function StuffDetail() {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`)
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@ -1276,8 +1282,7 @@ export default function StuffDetail() {
|
||||
if (res.status === 201) {
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
// router.refresh()
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`)
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1312,6 +1317,7 @@ export default function StuffDetail() {
|
||||
tempFlg: '1',
|
||||
workNo: null,
|
||||
workName: null,
|
||||
objectNo: objectNo ? objectNo : '',
|
||||
}
|
||||
|
||||
//1차점 or 2차점 안고르고 임시저장하면
|
||||
@ -1320,16 +1326,27 @@ export default function StuffDetail() {
|
||||
params.saleStoreLevel = session.storeLvl
|
||||
}
|
||||
|
||||
await promisePost({ url: '/api/object/save-object', data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.tempSave.message1'))
|
||||
router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`)
|
||||
}
|
||||
})
|
||||
const apiUrl = '/api/object/save-object'
|
||||
if (objectNo) {
|
||||
await promisePut({ url: apiUrl, data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
await promisePost({ url: apiUrl, data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 물건삭제
|
||||
const onDelete = () => {
|
||||
// console.log('검색조건리코일값:::::', stuffSearchParams)
|
||||
const specificationConfirmDate = managementState.specificationConfirmDate
|
||||
if (specificationConfirmDate != null) {
|
||||
alert(getMessage('stuff.detail.delete.message1'))
|
||||
@ -1337,6 +1354,12 @@ export default function StuffDetail() {
|
||||
if (confirm(getMessage('common.message.data.delete'))) {
|
||||
del({ url: `/api/object/${objectNo}` }).then(() => {
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: '' })
|
||||
// console.log('초기화::::::::::')
|
||||
// resetStuffRecoil()
|
||||
// stuffSearchParams.code = 'DELETE'
|
||||
// stuffSearchParams.schSelSaleStoreId = ''
|
||||
// stuffSearchParams.schOtherSelSaleStoreId = ''
|
||||
// console.log('판매점 초기화도')
|
||||
router.push('/management/stuff')
|
||||
})
|
||||
}
|
||||
|
||||
@ -69,10 +69,15 @@ export default function StuffSearchCondition() {
|
||||
// 조회
|
||||
const onSubmit = () => {
|
||||
let diff = dayjs(endDate).diff(startDate, 'day')
|
||||
|
||||
if (diff > 366) {
|
||||
return alert(getMessage('stuff.message.periodError'))
|
||||
}
|
||||
|
||||
if (isNaN(diff)) {
|
||||
return alert(getMessage('stuff.message.periodError'))
|
||||
}
|
||||
|
||||
if (stuffSearch.code === 'S') {
|
||||
setStuffSearch({
|
||||
schObjectNo: objectNo ? objectNo : stuffSearch.schObjectNo,
|
||||
@ -84,12 +89,14 @@ export default function StuffSearchCondition() {
|
||||
schOtherSelSaleStoreId: stuffSearch?.schOtherSelSaleStoreId ? stuffSearch.schOtherSelSaleStoreId : '',
|
||||
schReceiveUser: receiveUser ? receiveUser : '',
|
||||
schDateType: dateType,
|
||||
schFromDt: dayjs(startDate).format('YYYY-MM-DD'),
|
||||
schToDt: dayjs(endDate).format('YYYY-MM-DD'),
|
||||
schFromDt: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '',
|
||||
schToDt: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '',
|
||||
code: 'E',
|
||||
startRow: stuffSearch?.startRow ? stuffSearch.startRow : 1,
|
||||
endRow: stuffSearch?.endRow ? stuffSearch.endRow : 100,
|
||||
schSortType: stuffSearch?.schSortType ? stuffSearch.schSortType : 'R',
|
||||
pageNo: stuffSearch?.pageNo,
|
||||
pageSize: stuffSearch?.pageSize,
|
||||
})
|
||||
} else if (stuffSearch.code === 'FINISH') {
|
||||
setStuffSearch({
|
||||
@ -102,8 +109,8 @@ export default function StuffSearchCondition() {
|
||||
schOtherSelSaleStoreId: otherSaleStoreId,
|
||||
schReceiveUser: receiveUser,
|
||||
schDateType: dateType,
|
||||
schFromDt: dayjs(startDate).format('YYYY-MM-DD'),
|
||||
schToDt: dayjs(endDate).format('YYYY-MM-DD'),
|
||||
schFromDt: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '',
|
||||
schToDt: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '',
|
||||
code: 'E',
|
||||
startRow: 1,
|
||||
endRow: 100,
|
||||
@ -120,12 +127,14 @@ export default function StuffSearchCondition() {
|
||||
schOtherSelSaleStoreId: otherSaleStoreId,
|
||||
schReceiveUser: receiveUser,
|
||||
schDateType: dateType,
|
||||
schFromDt: dayjs(startDate).format('YYYY-MM-DD'),
|
||||
schToDt: dayjs(endDate).format('YYYY-MM-DD'),
|
||||
schFromDt: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '',
|
||||
schToDt: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '',
|
||||
code: 'E',
|
||||
startRow: 1,
|
||||
endRow: 100,
|
||||
startRow: stuffSearch?.startRow ? stuffSearch.startRow : 1,
|
||||
endRow: stuffSearch?.endRow ? stuffSearch.endRow : 100,
|
||||
schSortType: stuffSearch?.schSortType ? stuffSearch.schSortType : 'R',
|
||||
pageNo: stuffSearch?.pageNo,
|
||||
pageSize: stuffSearch?.pageSize,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,9 @@ import { Bar } from 'react-chartjs-2'
|
||||
import dayjs from 'dayjs'
|
||||
|
||||
import { useEffect, useState, useRef } from 'react'
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { useRecoilValue, useRecoilState } from 'recoil'
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
import { pwrGnrSimTypeState } from '@/store/simulatorAtom'
|
||||
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
@ -107,6 +108,8 @@ export default function Simulator() {
|
||||
if (objectNo) {
|
||||
fetchObjectDetail(objectNo)
|
||||
fetchSimulatorNotice()
|
||||
setPwrGnrSimType('D')
|
||||
setPwrRecoil({ ...pwrRecoil, type: 'D' })
|
||||
}
|
||||
}, [objectNo, plan])
|
||||
|
||||
@ -168,8 +171,10 @@ export default function Simulator() {
|
||||
|
||||
// 차트 데이터 변경 시, list type 셋팅
|
||||
const [pwrGnrSimType, setPwrGnrSimType] = useState('D')
|
||||
const [pwrRecoil, setPwrRecoil] = useRecoilState(pwrGnrSimTypeState)
|
||||
|
||||
const handleChartChangeData = (type) => {
|
||||
setPwrGnrSimType(type)
|
||||
setPwrRecoil({ ...pwrRecoil, type: type })
|
||||
switch (type) {
|
||||
case 'A':
|
||||
setChartData(hatsudenryouAll)
|
||||
@ -251,9 +256,11 @@ export default function Simulator() {
|
||||
<select
|
||||
style={{ width: '30%' }}
|
||||
className="select-light"
|
||||
value={pwrGnrSimType}
|
||||
defaultValue={`D`}
|
||||
onChange={(e) => {
|
||||
handleChartChangeData(e.target.value)
|
||||
setPwrGnrSimType(e.target.value)
|
||||
}}
|
||||
>
|
||||
<option value={`A`}>積雪考慮なし(ピークカットなし発電量)</option>
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useRecoilState } from 'recoil'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
import { convertDwgToPng } from '@/lib/cadAction'
|
||||
import { useAxios } from '../useAxios'
|
||||
import { currentCanvasPlanState } from '@/store/canvasAtom'
|
||||
import { convertDwgToPng, writeImageBuffer } from '@/lib/fileAction'
|
||||
|
||||
export function useRefFiles() {
|
||||
const converterUrl = process.env.NEXT_PUBLIC_CONVERTER_API_URL
|
||||
@ -16,7 +16,7 @@ export function useRefFiles() {
|
||||
const queryRef = useRef(null)
|
||||
|
||||
const { swalFire } = useSwal()
|
||||
const { get, promisePut } = useAxios()
|
||||
const { get, promisePut, promisePost } = useAxios()
|
||||
// const { currentCanvasPlan, setCurrentCanvasPlan } = usePlan()
|
||||
|
||||
/**
|
||||
@ -25,7 +25,11 @@ export function useRefFiles() {
|
||||
*/
|
||||
const handleRefFile = (file) => {
|
||||
setRefImage(file)
|
||||
file.name.split('.').pop() === 'dwg' ? handleUploadRefFile(file) : () => {}
|
||||
/**
|
||||
* 파일 확장자가 dwg일 경우 변환하여 이미지로 저장
|
||||
* 파일 확장자가 이미지일 경우 이미지 저장
|
||||
*/
|
||||
file.name.split('.').pop() === 'dwg' ? handleUploadConvertRefFile(file) : handleUploadImageRefFile(file)
|
||||
// handleUploadRefFile(file)
|
||||
}
|
||||
|
||||
@ -58,22 +62,29 @@ export function useRefFiles() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 플랜이 변경되면 플랜 상태 저장
|
||||
* 이미지 파일 업로드
|
||||
* @param {*} file
|
||||
*/
|
||||
// useEffect(() => {
|
||||
// const handleCurrentPlan = async () => {
|
||||
// await promisePut({ url: '/api/canvas-management/canvas-statuses', data: currentCanvasPlan }).then((res) => {
|
||||
// console.log('🚀 ~ awaitpromisePut ~ res:', res)
|
||||
// })
|
||||
// }
|
||||
// handleCurrentPlan()
|
||||
// }, [currentCanvasPlan])
|
||||
const handleUploadImageRefFile = async (file) => {
|
||||
console.log('🚀 ~ handleUploadImageRefFile ~ file:', file)
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
const response = await fetch('http://localhost:3000/api/image-upload', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
|
||||
const result = await response.json()
|
||||
console.log('🚀 ~ handleUploadImageRefFile ~ res:', result)
|
||||
// writeImageBuffer(file)
|
||||
}
|
||||
|
||||
/**
|
||||
* RefFile이 캐드 도면 파일일 경우 변환하여 이미지로 저장
|
||||
* @param {*} file
|
||||
*/
|
||||
const handleUploadRefFile = async (file) => {
|
||||
const handleUploadConvertRefFile = async (file) => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
@ -95,6 +106,19 @@ export function useRefFiles() {
|
||||
setRefFileMethod(e.target.value)
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 플랜이 변경되면 플랜 상태 저장
|
||||
*/
|
||||
useEffect(() => {
|
||||
console.log('🚀 ~ useRefFiles ~ currentCanvasPlan:', currentCanvasPlan)
|
||||
// const handleCurrentPlan = async () => {
|
||||
// await promisePut({ url: '/api/canvas-management/canvas-statuses', data: currentCanvasPlan }).then((res) => {
|
||||
// console.log('🚀 ~ awaitpromisePut ~ res:', res)
|
||||
// })
|
||||
// }
|
||||
// handleCurrentPlan()
|
||||
}, [currentCanvasPlan])
|
||||
|
||||
return {
|
||||
refImage,
|
||||
queryRef,
|
||||
|
||||
@ -637,7 +637,7 @@ export function useModuleBasicSetting() {
|
||||
module.tempIndex = index
|
||||
const { x, y } = module.getCenterPoint()
|
||||
const { width, height } = module
|
||||
centerPoints.push({ x, y, width, height })
|
||||
centerPoints.push({ x, y, width, height, index })
|
||||
const circle = new fabric.Circle({
|
||||
radius: 5,
|
||||
fill: 'red',
|
||||
@ -662,7 +662,6 @@ export function useModuleBasicSetting() {
|
||||
let touchDimension = 0
|
||||
//반접면
|
||||
let halfTouchDimension = 0
|
||||
|
||||
// 노출하면 체크
|
||||
centerPoints.forEach((centerPoint, index) => {
|
||||
const { x, y, width, height } = centerPoint
|
||||
@ -673,12 +672,15 @@ export function useModuleBasicSetting() {
|
||||
return
|
||||
}
|
||||
|
||||
const bottomLeftPoint = { x: x - width / 2, y: y + height }
|
||||
const bottomRightPoint = { x: x + width / 2, y: y + height }
|
||||
|
||||
// 바로 아래에 셀이 없는 경우 물떼세 배치가 왼쪽 되어있는 셀을 찾는다.
|
||||
const leftBottomCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x - width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2,
|
||||
(centerPoint) => Math.abs(centerPoint.x - bottomLeftPoint.x) < 2 && Math.abs(centerPoint.y - bottomLeftPoint.y) < 2,
|
||||
).length
|
||||
const rightBottomCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x + width / 2)) < 2 && Math.abs(centerPoint.y - (y + height)) < 2,
|
||||
(centerPoint) => Math.abs(centerPoint.x - bottomRightPoint.x) < 2 && Math.abs(centerPoint.y - bottomRightPoint.y) < 2,
|
||||
).length
|
||||
if (leftBottomCnt + rightBottomCnt === 2) {
|
||||
touchDimension++
|
||||
@ -703,11 +705,14 @@ export function useModuleBasicSetting() {
|
||||
return
|
||||
}
|
||||
|
||||
const topLeftPoint = { x: x - width / 2, y: y - height }
|
||||
const topRightPoint = { x: x + width / 2, y: y - height }
|
||||
|
||||
const leftTopCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x - width) < 2) && Math.abs(centerPoint.y - (y - height)) < 2,
|
||||
(centerPoint) => Math.abs(centerPoint.x - topLeftPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2,
|
||||
).length
|
||||
const rightTopCnt = centerPoints.filter(
|
||||
(centerPoint) => Math.abs(centerPoint.x - (x + width / 2) < 2) && Math.abs(centerPoint.y - (y - height)) < 2,
|
||||
(centerPoint) => Math.abs(centerPoint.x - topRightPoint.x) < 2 && Math.abs(centerPoint.y - topRightPoint.y) < 2,
|
||||
).length
|
||||
|
||||
if (leftTopCnt + rightTopCnt === 1) {
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
'use server'
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
* 개발후 삭제 예정
|
||||
*/
|
||||
|
||||
import fs from 'fs/promises'
|
||||
|
||||
const imageSavePath = 'public/cadImages'
|
||||
|
||||
@ -1,5 +1,10 @@
|
||||
'use server'
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
* 개발후 삭제 예정
|
||||
*/
|
||||
|
||||
// import { PrismaClient } from '@prisma/client'
|
||||
import fs from 'fs/promises'
|
||||
|
||||
|
||||
64
src/lib/fileAction.js
Normal file
64
src/lib/fileAction.js
Normal file
@ -0,0 +1,64 @@
|
||||
'use server'
|
||||
|
||||
import fs from 'fs/promises'
|
||||
|
||||
const CAD_FILE_PATH = 'public/cad-images'
|
||||
const IMAGE_FILE_PATH = 'public/plan-bg-images'
|
||||
|
||||
/**
|
||||
* 파일 변환 & 저장
|
||||
* @param {*} fileName
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
const convertDwgToPng = async (fileName, data) => {
|
||||
console.log('fileName', fileName)
|
||||
try {
|
||||
await fs.readdir(CAD_FILE_PATH)
|
||||
} catch {
|
||||
await fs.mkdir(CAD_FILE_PATH)
|
||||
}
|
||||
|
||||
return await fs.writeFile(`${CAD_FILE_PATH}/${fileName}`, data, 'base64')
|
||||
}
|
||||
|
||||
/**
|
||||
* 이미지 저장
|
||||
* base64 형식으로 저장
|
||||
* @param {*} title
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
const writeImageBase64 = async (title, data) => {
|
||||
// 해당 경로에 Directory 가 없다면 생성
|
||||
try {
|
||||
await fs.readdir(IMAGE_FILE_PATH)
|
||||
} catch {
|
||||
await fs.mkdir(IMAGE_FILE_PATH)
|
||||
}
|
||||
|
||||
return fs.writeFile(`${IMAGE_FILE_PATH}/${title}.png`, data, 'base64')
|
||||
}
|
||||
|
||||
/**
|
||||
* 이미지 저장
|
||||
* Buffer 형식으로 저장
|
||||
* @param {*} title
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
const writeImageBuffer = async (file) => {
|
||||
// 해당 경로에 Directory 가 없다면 생성
|
||||
try {
|
||||
await fs.readdir(IMAGE_FILE_PATH)
|
||||
} catch {
|
||||
await fs.mkdir(IMAGE_FILE_PATH)
|
||||
}
|
||||
|
||||
const arrayBuffer = await fileURLToPath.arrayBuffer()
|
||||
const buffer = new Uint8Array(arrayBuffer)
|
||||
|
||||
return fs.writeFile(`${IMAGE_FILE_PATH}/${file.fileName}`, buffer)
|
||||
}
|
||||
|
||||
export { convertDwgToPng, writeImageBase64, writeImageBuffer }
|
||||
8
src/store/simulatorAtom.js
Normal file
8
src/store/simulatorAtom.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { atom } from 'recoil'
|
||||
|
||||
export const pwrGnrSimTypeState = atom({
|
||||
key: 'pwrGnrSimType',
|
||||
default: {
|
||||
type: 'D',
|
||||
},
|
||||
})
|
||||
@ -19,6 +19,8 @@ export const stuffSearchState = atom({
|
||||
startRow: 1,
|
||||
endRow: 100,
|
||||
schSortType: 'R', //정렬조건 (R:최근등록일 U:최근수정일)
|
||||
pageNo: 1,
|
||||
pageSize: 100,
|
||||
},
|
||||
dangerouslyAllowMutability: true,
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user