Merge branch 'dev' into dev-yj

This commit is contained in:
yjnoh 2024-11-21 15:22:23 +09:00
commit d1c7327fc9
17 changed files with 2180 additions and 2264 deletions

View File

@ -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')

View 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}` })
}

View File

@ -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) => {

View File

@ -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>

View File

@ -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 : () => {}}>
完了

View File

@ -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>

View File

@ -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')
})
}

View File

@ -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,
})
}
}

View File

@ -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>

View File

@ -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,

View File

@ -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) {

View File

@ -1,5 +1,10 @@
'use server'
/**
* Deprecated
* 개발후 삭제 예정
*/
import fs from 'fs/promises'
const imageSavePath = 'public/cadImages'

View File

@ -1,5 +1,10 @@
'use server'
/**
* Deprecated
* 개발후 삭제 예정
*/
// import { PrismaClient } from '@prisma/client'
import fs from 'fs/promises'

64
src/lib/fileAction.js Normal file
View 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 }

View File

@ -0,0 +1,8 @@
import { atom } from 'recoil'
export const pwrGnrSimTypeState = atom({
key: 'pwrGnrSimType',
default: {
type: 'D',
},
})

View File

@ -19,6 +19,8 @@ export const stuffSearchState = atom({
startRow: 1,
endRow: 100,
schSortType: 'R', //정렬조건 (R:최근등록일 U:최근수정일)
pageNo: 1,
pageSize: 100,
},
dangerouslyAllowMutability: true,
})

3768
yarn.lock

File diff suppressed because it is too large Load Diff