물건현황
This commit is contained in:
parent
d3958665f2
commit
b59bdd0645
@ -1,11 +1,15 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Hero from '@/components/Hero'
|
import Hero from '@/components/Hero'
|
||||||
import StuffDetail from '@/components/management/StuffDetail'
|
import StuffDetail from '@/components/management/StuffDetail'
|
||||||
|
import Link from 'next/link'
|
||||||
export default function ManagementStuffDetailPage() {
|
export default function ManagementStuffDetailPage() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="pt-48 flex justify-left">
|
<div className="pt-48 flex justify-left">
|
||||||
<h1 className="text-4xl archivo-black-regular">물건정보</h1>
|
<h1 className="text-4xl archivo-black-regular">물건정보</h1>
|
||||||
|
<Link href="/management/plan">
|
||||||
|
<h1 className="text-4xl archivo-black-regular">도면작성</h1>
|
||||||
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
<div className="m2">
|
<div className="m2">
|
||||||
<StuffDetail />
|
<StuffDetail />
|
||||||
|
|||||||
15
src/app/[locale]/management/stuff/tempdetail/page.jsx
Normal file
15
src/app/[locale]/management/stuff/tempdetail/page.jsx
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import Hero from '@/components/Hero'
|
||||||
|
import StuffDetail from '@/components/management/StuffDetail'
|
||||||
|
export default function ManagementStuffDetailPage() {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div className="pt-48 flex justify-left">
|
||||||
|
<h1 className="text-4xl archivo-black-regular">물건정보</h1>
|
||||||
|
</div>
|
||||||
|
<div className="m2">
|
||||||
|
<StuffDetail />
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@ import { Button } from '@nextui-org/react'
|
|||||||
import { useAxios } from '@/hooks/useAxios'
|
import { useAxios } from '@/hooks/useAxios'
|
||||||
import { useMessage } from '@/hooks/useMessage'
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import StuffQGrid from './StuffQGrid'
|
import StuffQGrid from './StuffQGrid'
|
||||||
import { useRecoilValue } from 'recoil'
|
import { useRecoilValue, useRecoilState } from 'recoil'
|
||||||
import { stuffSearchState } from '@/store/stuffAtom'
|
import { stuffSearchState } from '@/store/stuffAtom'
|
||||||
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
@ -15,10 +15,12 @@ dayjs.extend(isLeapYear)
|
|||||||
|
|
||||||
export default function Stuff() {
|
export default function Stuff() {
|
||||||
const stuffSearchParams = useRecoilValue(stuffSearchState)
|
const stuffSearchParams = useRecoilValue(stuffSearchState)
|
||||||
|
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const [curPage, setCurPage] = useState(1) //현재 페이지 번호
|
const [curPage, setCurPage] = useState(1) //현재 페이지 번호
|
||||||
const [size, setSize] = useState(100) //페이지 당 게시물 수
|
const [defaultSize, setDefaultSize] = useState(100) //페이지 당 게시물 수
|
||||||
const { get, del } = useAxios()
|
const [defaultSortType, setDefaultSortType] = useState('R')
|
||||||
|
const { get } = useAxios()
|
||||||
const gridRef = useRef()
|
const gridRef = useRef()
|
||||||
|
|
||||||
const [gridCount, setGridCount] = useState(0)
|
const [gridCount, setGridCount] = useState(0)
|
||||||
@ -38,13 +40,26 @@ export default function Stuff() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//물건번호 복사버튼 옆에 영역
|
||||||
|
const onDoubleClick = (e) => {
|
||||||
|
let objectNo = e.target.innerText
|
||||||
|
console.log(objectNo)
|
||||||
|
if (objectNo.substring(0, 1) === 'R') {
|
||||||
|
console.log('진짜')
|
||||||
|
router.push(`${pathname}/detail?objectNo=${objectNo.toString()}`)
|
||||||
|
} else {
|
||||||
|
console.log('임시')
|
||||||
|
router.push(`${pathname}/tempdetail?objectNo=${objectNo.toString()}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const [gridProps, setGridProps] = useState({
|
const [gridProps, setGridProps] = useState({
|
||||||
gridData: [],
|
gridData: [],
|
||||||
isPageable: false,
|
isPageable: false,
|
||||||
// sets 10 rows per page (default is 100)
|
// sets 10 rows per page (default is 100)
|
||||||
paginationPageSize: 100,
|
// paginationPageSize: 100,
|
||||||
// allows the user to select the page size from a predefined list of page sizes
|
// allows the user to select the page size from a predefined list of page sizes
|
||||||
paginationPageSizeSelector: [100, 200, 300, 400],
|
// paginationPageSizeSelector: [100, 200, 300, 400],
|
||||||
gridColumns: [
|
gridColumns: [
|
||||||
{
|
{
|
||||||
field: 'lastEditDatetime',
|
field: 'lastEditDatetime',
|
||||||
@ -82,7 +97,6 @@ export default function Stuff() {
|
|||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
size="sm"
|
size="sm"
|
||||||
// isDisabled={params.data.successful ? false : true}
|
|
||||||
color="default"
|
color="default"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
copyNo(params.value)
|
copyNo(params.value)
|
||||||
@ -90,7 +104,7 @@ export default function Stuff() {
|
|||||||
>
|
>
|
||||||
복사
|
복사
|
||||||
</Button>
|
</Button>
|
||||||
<span>{params.value}</span>
|
<span onDoubleClick={onDoubleClick}>{params.value}</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -148,8 +162,15 @@ export default function Stuff() {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
console.log(' 상세이동::::::::', event.data)
|
console.log(' 상세이동::::::::', event.data)
|
||||||
|
//T 면 임시 R은 진짜
|
||||||
if (event.data.objectNo) {
|
if (event.data.objectNo) {
|
||||||
|
if (event.data.objectNo.substring(0, 1) === 'R') {
|
||||||
|
console.log('진짜:::::::::')
|
||||||
router.push(`${pathname}/detail?objectNo=${event.data.objectNo.toString()}`)
|
router.push(`${pathname}/detail?objectNo=${event.data.objectNo.toString()}`)
|
||||||
|
} else {
|
||||||
|
console.log('임시:::::::::::::::::')
|
||||||
|
router.push(`${pathname}/tempdetail?objectNo=${event.data.objectNo.toString()}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,45 +196,6 @@ export default function Stuff() {
|
|||||||
errCount++
|
errCount++
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
async function fetchDelete(data) {
|
|
||||||
console.log('물건삭제API호출!!!!!!!!!', data)
|
|
||||||
//행추가말고 api데이터만 보냄
|
|
||||||
// let newData = data.filter((item) => item.company != null)
|
|
||||||
// console.log('삭제에 전송되는 데이타::', newData)
|
|
||||||
// await del({ url: '', data:newData })
|
|
||||||
await get({ url: 'https://www.ag-grid.com/example-assets/space-mission-data.json' })
|
|
||||||
// try {
|
|
||||||
// const res = await del({url:'', data:newData})
|
|
||||||
|
|
||||||
// if(!res || res.length === 0) {
|
|
||||||
|
|
||||||
// } else {
|
|
||||||
fetchData()
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error('Data Delete error:', error);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// 삭제API 완료 후 fetchData Api호출
|
|
||||||
async function fetchData() {
|
|
||||||
console.log('물건삭제후 조회API호출!!!!!!!!!!!!!', stuffSearchParams)
|
|
||||||
const data = await get({ url: 'https://www.ag-grid.com/example-assets/space-mission-data.json' })
|
|
||||||
setGridProps({ ...gridProps, gridData: data, count: data.length })
|
|
||||||
setGridCount(data.length)
|
|
||||||
//data.length = 10
|
|
||||||
//setGridProps({ ...gridProps, gridData: data, count: data.length-1})
|
|
||||||
//setGridCount(data.length - 1 )
|
|
||||||
}
|
|
||||||
|
|
||||||
if (errCount === 0) {
|
|
||||||
// console.log('errCount::::::::', errCount)
|
|
||||||
fetchDelete(data)
|
|
||||||
// fetchData()
|
|
||||||
} else {
|
|
||||||
alert('물건정보가 있는 행만 선택해주세요')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//행추가
|
//행추가
|
||||||
@ -265,15 +247,14 @@ export default function Stuff() {
|
|||||||
schDateType: 'U',
|
schDateType: 'U',
|
||||||
schFromDt: dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'),
|
schFromDt: dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'),
|
||||||
schToDt: dayjs(new Date()).format('YYYY-MM-DD'),
|
schToDt: dayjs(new Date()).format('YYYY-MM-DD'),
|
||||||
startRow: (curPage - 1) * size + 1,
|
startRow: (curPage - 1) * defaultSize + 1,
|
||||||
endRow: curPage * size,
|
endRow: curPage * defaultSize,
|
||||||
|
schSelSaleStoreId: '',
|
||||||
|
schSortType: 'R',
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
console.log('화면진입:::::::::::::', params)
|
console.log('화면진입:::::::::::::', params)
|
||||||
console.log('현재페이지::::::', curPage)
|
|
||||||
console.log('페이지당 게시물수::::::', size)
|
|
||||||
|
|
||||||
//api에 넘길값 startRow, endRow
|
//api에 넘길값 startRow, endRow
|
||||||
// let startRow
|
// let startRow
|
||||||
// let endRow
|
// let endRow
|
||||||
@ -306,6 +287,9 @@ export default function Stuff() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (stuffSearchParams?.code === 'E') {
|
if (stuffSearchParams?.code === 'E') {
|
||||||
|
stuffSearchParams.startRow = (curPage - 1) * defaultSize + 1
|
||||||
|
stuffSearchParams.endRow = curPage * defaultSize
|
||||||
|
stuffSearchParams.schSortType = defaultSortType
|
||||||
console.log('조회 눌럿을때 ::::::::::::::', stuffSearchParams)
|
console.log('조회 눌럿을때 ::::::::::::::', stuffSearchParams)
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
||||||
@ -314,6 +298,9 @@ export default function Stuff() {
|
|||||||
if (!isEmptyArray(res)) {
|
if (!isEmptyArray(res)) {
|
||||||
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
||||||
setGridCount(res.length)
|
setGridCount(res.length)
|
||||||
|
} else {
|
||||||
|
setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||||
|
setGridCount(0)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -321,6 +308,56 @@ export default function Stuff() {
|
|||||||
}
|
}
|
||||||
}, [stuffSearchParams])
|
}, [stuffSearchParams])
|
||||||
|
|
||||||
|
//페이지 갯수 변경 이벤트
|
||||||
|
const onChangePerPage = (e) => {
|
||||||
|
let startRow = (curPage - 1) * e.target.value + 1
|
||||||
|
stuffSearchParams.startRow = startRow
|
||||||
|
stuffSearchParams.endRow = curPage * e.target.value
|
||||||
|
setDefaultSize(e.target.value)
|
||||||
|
setStuffSearch({
|
||||||
|
...stuffSearch,
|
||||||
|
code: 'S',
|
||||||
|
startRow: startRow,
|
||||||
|
endRow: curPage * e.target.value,
|
||||||
|
})
|
||||||
|
console.log('셋팅된 검색조건:::', stuffSearchParams)
|
||||||
|
//조회API호출
|
||||||
|
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
||||||
|
get({ url: apiUrl }).then((res) => {
|
||||||
|
console.log('보여줄개수바꿨을때 조회 ::::::::::', res)
|
||||||
|
if (!isEmptyArray(res)) {
|
||||||
|
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
||||||
|
setGridCount(res.length)
|
||||||
|
} else {
|
||||||
|
setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||||
|
setGridCount(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//최근 등록일 수정일 정렬 이벤트
|
||||||
|
const onChangeSortType = (e) => {
|
||||||
|
stuffSearchParams.schSortType = e.target.value
|
||||||
|
console.log('셋팅된 검색조건:::', stuffSearchParams)
|
||||||
|
setDefaultSortType(e.target.value)
|
||||||
|
setStuffSearch({
|
||||||
|
...stuffSearch,
|
||||||
|
code: 'S',
|
||||||
|
schSortType: e.target.value,
|
||||||
|
})
|
||||||
|
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
||||||
|
// console.log('apiUrl::', apiUrl)
|
||||||
|
get({ url: apiUrl }).then((res) => {
|
||||||
|
console.log('정렬바꿨을때 조회 ::::::::::', res)
|
||||||
|
if (!isEmptyArray(res)) {
|
||||||
|
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
||||||
|
setGridCount(res.length)
|
||||||
|
} else {
|
||||||
|
setGridProps({ ...gridProps, gridData: [], count: 0 })
|
||||||
|
setGridCount(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="text-2xl">
|
<div className="text-2xl">
|
||||||
@ -328,6 +365,15 @@ export default function Stuff() {
|
|||||||
<span>
|
<span>
|
||||||
전체 : {gridCount} // 선택 : {selectedRowDataCount}
|
전체 : {gridCount} // 선택 : {selectedRowDataCount}
|
||||||
</span>
|
</span>
|
||||||
|
<select className="select" onChange={onChangePerPage}>
|
||||||
|
<option value="100">100</option>
|
||||||
|
<option value="200">200</option>
|
||||||
|
<option value="300">300</option>
|
||||||
|
</select>
|
||||||
|
<select className="select" onChange={onChangeSortType}>
|
||||||
|
<option value="R">최근 등록일</option>
|
||||||
|
<option value="U">최근 수정일</option>
|
||||||
|
</select>
|
||||||
<div align="right">
|
<div align="right">
|
||||||
{/* <Button
|
{/* <Button
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
@ -4,13 +4,15 @@ import React, { useState, useEffect } from 'react'
|
|||||||
import { useRouter, useSearchParams } from 'next/navigation'
|
import { useRouter, useSearchParams } from 'next/navigation'
|
||||||
import { Input, RadioGroup, Radio, Button, Autocomplete, AutocompleteItem, Select, SelectItem, Checkbox, Textarea, button } from '@nextui-org/react'
|
import { Input, RadioGroup, Radio, Button, Autocomplete, AutocompleteItem, Select, SelectItem, Checkbox, Textarea, button } from '@nextui-org/react'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import { get } from '@/lib/Axios'
|
import { del, get } from '@/lib/Axios'
|
||||||
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import { useMessage } from '@/hooks/useMessage'
|
||||||
import { useForm } from 'react-hook-form'
|
import { useForm } from 'react-hook-form'
|
||||||
export default function StuffDetail() {
|
export default function StuffDetail() {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
|
const { getMessage } = useMessage()
|
||||||
|
|
||||||
//form
|
//form
|
||||||
const formInitValue = {
|
const formInitValue = {
|
||||||
@ -56,6 +58,20 @@ export default function StuffDetail() {
|
|||||||
const [detailData, setDetailData] = useState({})
|
const [detailData, setDetailData] = useState({})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (objectNo) {
|
||||||
|
setEditMode('EDIT')
|
||||||
|
|
||||||
|
if (objectNo.substring(0, 1) === 'R') {
|
||||||
|
//진짜
|
||||||
|
setIsFormValid(true)
|
||||||
|
}
|
||||||
|
get({ url: `/api/object/${objectNo}/detail` }).then((res) => {
|
||||||
|
console.log('물건번호로 상세 API 호출')
|
||||||
|
if (res != null) {
|
||||||
|
console.log('상세res:::::::', res)
|
||||||
|
setDetailData(res)
|
||||||
|
|
||||||
|
// 신규 상세 공통APi
|
||||||
// 도도부현API
|
// 도도부현API
|
||||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||||
if (!isEmptyArray(res)) {
|
if (!isEmptyArray(res)) {
|
||||||
@ -64,9 +80,9 @@ export default function StuffDetail() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// 판매점목록 API /api/object/saleStore/판매점코드/list - 판매점 목록 조회
|
// 판매점목록 API /api/object/saleStore/판매점코드/list - 판매점 목록 조회
|
||||||
// salesStoreLevel 추가되면 붙여서 보내기
|
|
||||||
// 임시 1차점 판매점코드 saleStoreId=201TES01
|
// 임시 1차점 판매점코드 saleStoreId=201TES01
|
||||||
// T01
|
// T01
|
||||||
|
//1차점 : X167
|
||||||
get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => {
|
get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => {
|
||||||
if (!isEmptyArray(res)) {
|
if (!isEmptyArray(res)) {
|
||||||
console.log('판매점 결과:::::', res)
|
console.log('판매점 결과:::::', res)
|
||||||
@ -77,18 +93,33 @@ export default function StuffDetail() {
|
|||||||
form.setValue('saleStoreName', res[0].saleStoreId)
|
form.setValue('saleStoreName', res[0].saleStoreId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// console.log('상세화면진입:::::::::', searchParams.get('objectNo'))
|
} else {
|
||||||
// console.log('물건번호::::', objectNo)
|
alert('삭제된 물건입니다')
|
||||||
|
router.push('/management/stuff')
|
||||||
if (objectNo) {
|
|
||||||
setEditMode('EDIT')
|
|
||||||
if (objectNo.substring(0, 1) === 'R') {
|
|
||||||
setIsFormValid(true)
|
|
||||||
}
|
}
|
||||||
get({ url: `/api/object/${objectNo}/detail` }).then((res) => {
|
})
|
||||||
if (res != null) {
|
} else {
|
||||||
// console.log('res:::::::', res)
|
console.log('신규일떄 공통코드세팅')
|
||||||
setDetailData(res)
|
// 신규 상세 공통APi
|
||||||
|
// 도도부현API
|
||||||
|
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||||
|
if (!isEmptyArray(res)) {
|
||||||
|
//console.log('도도부현API 결과:::', res)
|
||||||
|
setPrefCodeList(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// 판매점목록 API /api/object/saleStore/판매점코드/list - 판매점 목록 조회
|
||||||
|
// 임시 1차점 판매점코드 saleStoreId=201TES01
|
||||||
|
// T01
|
||||||
|
//1차점 : X167
|
||||||
|
get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => {
|
||||||
|
if (!isEmptyArray(res)) {
|
||||||
|
console.log('판매점 결과:::::', res)
|
||||||
|
setSaleStoreList(res)
|
||||||
|
//1차 판매점 자동완성 값 셋팅
|
||||||
|
form.setValue('saleStoreId', res[0].saleStoreId)
|
||||||
|
//1차 판매점 번호 셋팅
|
||||||
|
form.setValue('saleStoreName', res[0].saleStoreId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -143,6 +174,8 @@ export default function StuffDetail() {
|
|||||||
const _snowCover = watch('snowCover')
|
const _snowCover = watch('snowCover')
|
||||||
const _installHeight = watch('installHeight')
|
const _installHeight = watch('installHeight')
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log('mode:::::', editMode)
|
||||||
|
if (editMode === 'NEW') {
|
||||||
const formData = form.getValues()
|
const formData = form.getValues()
|
||||||
console.log('폼::::::::::::', formData)
|
console.log('폼::::::::::::', formData)
|
||||||
let errors = {}
|
let errors = {}
|
||||||
@ -187,8 +220,11 @@ export default function StuffDetail() {
|
|||||||
errors.installHeight = true
|
errors.installHeight = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('errors::', errors)
|
console.log('errors::', errors)
|
||||||
setIsFormValid(Object.keys(errors).length === 0)
|
setIsFormValid(Object.keys(errors).length === 0)
|
||||||
|
} else {
|
||||||
|
console.log('상세일때 폼체크')
|
||||||
|
}
|
||||||
}, [_dispCompanyName, _objectName, _objectNameOmit, _saleStoreId, _zipNo, _prefId, _address, _powerSimArea, _windSpeed, _snowCover, _installHeight])
|
}, [_dispCompanyName, _objectName, _objectNameOmit, _saleStoreId, _zipNo, _prefId, _address, _powerSimArea, _windSpeed, _snowCover, _installHeight])
|
||||||
|
|
||||||
// 주소검색 API
|
// 주소검색 API
|
||||||
@ -198,6 +234,7 @@ export default function StuffDetail() {
|
|||||||
}
|
}
|
||||||
get({ url: `https://zipcloud.ibsnet.co.jp/api/search?${queryStringFormatter(params)}` }).then((res) => {
|
get({ url: `https://zipcloud.ibsnet.co.jp/api/search?${queryStringFormatter(params)}` }).then((res) => {
|
||||||
//7830060
|
//7830060
|
||||||
|
//9302226
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
if (res.results != null) {
|
if (res.results != null) {
|
||||||
console.log('주소검색::', res.results)
|
console.log('주소검색::', res.results)
|
||||||
@ -226,30 +263,17 @@ export default function StuffDetail() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (prefValue !== '') {
|
if (prefValue !== '') {
|
||||||
console.log('우편번호 검색해서 도도부현골랐을때::::', prefValue)
|
console.log('우편번호 검색해서 도도부현골랐을때::::', prefValue)
|
||||||
// 발전시뮬레이션 지역 목록
|
// 발전량시뮬레이션 지역 목록
|
||||||
// /api/object/prefecture/도도부현코드/list
|
// /api/object/prefecture/도도부현코드/list
|
||||||
get({ url: `/api/object/prefecture/${prefValue}/list` }).then((res) => {
|
get({ url: `/api/object/prefecture/${prefValue}/list` }).then((res) => {
|
||||||
if (!isEmptyArray(res)) {
|
if (!isEmptyArray(res)) {
|
||||||
console.log('발전시뮬레이션::::::::', res)
|
console.log('발전시뮬레이션::::::::', res)
|
||||||
setPowerSimAreaList(res)
|
setPowerSimAreaList(res)
|
||||||
// form.setValue('powerSimArea', res[0].prefId)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, [prefValue])
|
}, [prefValue])
|
||||||
|
|
||||||
const onTempSave = () => {
|
|
||||||
console.log('임시저장::', isFormValid)
|
|
||||||
}
|
|
||||||
|
|
||||||
const onSave = () => {
|
|
||||||
console.log('진짜저장isFormValid:::', isFormValid)
|
|
||||||
}
|
|
||||||
|
|
||||||
const moveList = () => {
|
|
||||||
router.push('/management/stuff')
|
|
||||||
}
|
|
||||||
|
|
||||||
//필수값 다 입력했을때
|
//필수값 다 입력했을때
|
||||||
const onValid = (data) => {
|
const onValid = (data) => {
|
||||||
console.log('필수값 다 있고 저장')
|
console.log('필수값 다 있고 저장')
|
||||||
@ -279,6 +303,28 @@ export default function StuffDetail() {
|
|||||||
console.log('임시저장formData::::', formData)
|
console.log('임시저장formData::::', formData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 발전량 시뮬레이션 변경
|
||||||
|
const handlePowerSimAreaOnChange = (e) => {
|
||||||
|
console.log('가지고있는 도도부현코드:::::::::', prefValue)
|
||||||
|
// console.log('발전량시뮬레이션변경:::::::::', e.target.value)
|
||||||
|
//값 set해주고 그거 useEffect로 api호출
|
||||||
|
}
|
||||||
|
|
||||||
|
// 물건삭제
|
||||||
|
const onDelete = () => {
|
||||||
|
//http://localhost:8080/api/object/R201TES01240910023
|
||||||
|
console.log('물건번호::::::::', objectNo)
|
||||||
|
alert('사양확정일이 있으면 삭제 불가')
|
||||||
|
if (confirm(getMessage('common.message.data.delete'))) {
|
||||||
|
let testobj = '10'
|
||||||
|
|
||||||
|
del({ url: `/api/object/${testobj}` }).then((res) => {
|
||||||
|
console.log('삭제 결과:::', res)
|
||||||
|
router.push('/management/stuff')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{(editMode === 'NEW' && (
|
{(editMode === 'NEW' && (
|
||||||
@ -365,20 +411,21 @@ export default function StuffDetail() {
|
|||||||
<div className="form-input">
|
<div className="form-input">
|
||||||
<label>발전량시뮬레이션지역</label>
|
<label>발전량시뮬레이션지역</label>
|
||||||
{powerSimAreaList?.length > 0 && (
|
{powerSimAreaList?.length > 0 && (
|
||||||
<select name="powerSimArea" {...register('powerSimArea', { required: true })}>
|
<Select
|
||||||
|
className="max-w-xs"
|
||||||
|
selectedKeys={form.watch('powerSimArea')}
|
||||||
|
{...form.register('powerSimArea', { required: true })}
|
||||||
|
onChange={handlePowerSimAreaOnChange}
|
||||||
|
>
|
||||||
{powerSimAreaList.map((row) => {
|
{powerSimAreaList.map((row) => {
|
||||||
|
// console.log('row::', row)
|
||||||
return (
|
return (
|
||||||
<option key={row.prefName} value={row.prefId}>
|
<SelectItem key={row.prefName} value={row.prefId}>
|
||||||
{row.prefName}
|
{row.prefName}
|
||||||
</option>
|
</SelectItem>
|
||||||
)
|
)
|
||||||
})}
|
})}
|
||||||
</select>
|
</Select>
|
||||||
// <Select className="max-w-xs" selectedKeys={form.watch('powerSimArea')} {...form.register('powerSimArea', { required: true })}>
|
|
||||||
// {powerSimAreaList.map((row) => {
|
|
||||||
// return <SelectItem key={row.prefName}>{row.prefName}</SelectItem>
|
|
||||||
// })}
|
|
||||||
// </Select>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="form-input">
|
<div className="form-input">
|
||||||
@ -386,9 +433,9 @@ export default function StuffDetail() {
|
|||||||
<div className="flex w-full max-w-xs flex-col gap-2">
|
<div className="flex w-full max-w-xs flex-col gap-2">
|
||||||
<select name="windSpeed" {...register('windSpeed', { required: true })}>
|
<select name="windSpeed" {...register('windSpeed', { required: true })}>
|
||||||
<option value="">기준풍속</option>
|
<option value="">기준풍속</option>
|
||||||
<option value="11">111</option>
|
<option value="30">30</option>
|
||||||
<option value="22">222</option>
|
<option value="50">50</option>
|
||||||
<option value="33">333</option>
|
<option value="60">60</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -464,23 +511,48 @@ export default function StuffDetail() {
|
|||||||
</div>
|
</div>
|
||||||
{!isFormValid ? (
|
{!isFormValid ? (
|
||||||
<>
|
<>
|
||||||
{/* <button type="submit">신규화면임시저장!!!!!!!!!</button> */}
|
<Button type="submit">NEW화면임시저장</Button>
|
||||||
<Button type="submit">신규화면임시저장!!!!!</Button>
|
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<button type="submit">저장</button>
|
<button type="submit">NEW화면 저장</button>
|
||||||
)}
|
)}
|
||||||
<Link href="/management/stuff">
|
<Link href="/management/stuff">
|
||||||
<button type="button">물건목록</button>
|
<button type="button">NEW화면 물건목록이동</button>
|
||||||
</Link>
|
</Link>
|
||||||
</form>
|
</form>
|
||||||
)) || (
|
)) || (
|
||||||
<div>
|
<>
|
||||||
상세:::::::::::
|
{objectNo.substring(0, 1) === 'R' ? (
|
||||||
|
<>
|
||||||
<Link href="/management/stuff">
|
<Link href="/management/stuff">
|
||||||
<button type="button">물건목록</button>
|
<button type="button">R상세:물건목록</button>
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
<button type="submit">R상세:저장</button>
|
||||||
|
<button type="submit" onClick={onDelete}>
|
||||||
|
R상세:물건삭제
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<Link href="/management/stuff">
|
||||||
|
<button type="button">T상세:물건목록</button>
|
||||||
|
</Link>
|
||||||
|
<button type="submit">T상세:저장</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
// <div>
|
||||||
|
// EDIT모드
|
||||||
|
|
||||||
|
// {/* {objectNo.substring(0,1) ? 'R' ? <><Link>RRRRRRR</Link></> : <><Link>TTTTTTTT</Link></>} */}
|
||||||
|
// {/* <Link href="/management/stuff">
|
||||||
|
// <button type="button">상세:물건목록</button>
|
||||||
|
// </Link>
|
||||||
|
// <button type="submit">상세:저장</button>
|
||||||
|
// <button type="submit" onClick={onDelete}>
|
||||||
|
// 상세:물건삭제
|
||||||
|
// </button> */}
|
||||||
|
// </div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* <div className="flex w-full flex-wrap md:flex-nowrap gap-4">
|
{/* <div className="flex w-full flex-wrap md:flex-nowrap gap-4">
|
||||||
|
|||||||
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
import React, { useEffect } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Input, RadioGroup, Radio, Button } from '@nextui-org/react'
|
import { Input, RadioGroup, Radio, Button, Autocomplete, AutocompleteItem } from '@nextui-org/react'
|
||||||
import RangeDatePicker from '@/components/common/datepicker/RangeDatePicker'
|
import RangeDatePicker from '@/components/common/datepicker/RangeDatePicker'
|
||||||
import { useRecoilState, useResetRecoilState } from 'recoil'
|
import { useRecoilState, useResetRecoilState } from 'recoil'
|
||||||
import { stuffSearchState } from '@/store/stuffAtom'
|
import { stuffSearchState } from '@/store/stuffAtom'
|
||||||
|
import { isEmptyArray } from '@/util/common-utils'
|
||||||
|
import { get } from '@/lib/Axios'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import isLeapYear from 'dayjs/plugin/isLeapYear' // 윤년 판단 플러그인
|
import isLeapYear from 'dayjs/plugin/isLeapYear' // 윤년 판단 플러그인
|
||||||
dayjs.extend(isLeapYear)
|
dayjs.extend(isLeapYear)
|
||||||
@ -33,13 +35,16 @@ export default function StuffSearchCondition() {
|
|||||||
const [receiveUser, setReceiveUser] = useState('') //담당자
|
const [receiveUser, setReceiveUser] = useState('') //담당자
|
||||||
const [dispCompanyName, setDispCompanyName] = useState('') //견적처
|
const [dispCompanyName, setDispCompanyName] = useState('') //견적처
|
||||||
const [dateType, setDateType] = useState('U') //갱신일(U)/등록일(R)
|
const [dateType, setDateType] = useState('U') //갱신일(U)/등록일(R)
|
||||||
|
const [schSelSaleStoreId, setSchSelSaleStoreId] = useState('') //판매대리점 선택
|
||||||
|
|
||||||
|
const [schSelSaleStoreList, setSchSelSaleStoreList] = useState([]) //판매대리점 자동완성 SELECT
|
||||||
// 조회
|
// 조회
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
let diff = dayjs(endRangeDate).diff(startRangeDate, 'day')
|
let diff = dayjs(endRangeDate).diff(startRangeDate, 'day')
|
||||||
if (diff > 366) {
|
if (diff > 366) {
|
||||||
return alert('최대1년 조회 가능합니다.')
|
return alert('최대1년 조회 가능합니다.')
|
||||||
}
|
}
|
||||||
|
|
||||||
setStuffSearch({
|
setStuffSearch({
|
||||||
schObjectNo: stuffSearch?.schObjectNo ? stuffSearch.schObjectNo : objectNo,
|
schObjectNo: stuffSearch?.schObjectNo ? stuffSearch.schObjectNo : objectNo,
|
||||||
schSaleStoreId: stuffSearch?.schSaleStoreId ? stuffSearch.schSaleStoreId : saleStoreId,
|
schSaleStoreId: stuffSearch?.schSaleStoreId ? stuffSearch.schSaleStoreId : saleStoreId,
|
||||||
@ -53,6 +58,10 @@ export default function StuffSearchCondition() {
|
|||||||
schFromDt: dayjs(startRangeDate).format('YYYY-MM-DD'),
|
schFromDt: dayjs(startRangeDate).format('YYYY-MM-DD'),
|
||||||
schToDt: dayjs(endRangeDate).format('YYYY-MM-DD'),
|
schToDt: dayjs(endRangeDate).format('YYYY-MM-DD'),
|
||||||
code: 'E',
|
code: 'E',
|
||||||
|
schSelSaleStoreId: stuffSearch?.schSelSaleStoreId ? stuffSearch.schSelSaleStoreId : schSelSaleStoreId,
|
||||||
|
startRow: stuffSearch?.startRow ? stuffSearch.startRow : 1,
|
||||||
|
endRow: stuffSearch?.endRow ? stuffSearch.endRow : 100,
|
||||||
|
schSortType: stuffSearch?.schSortType ? stuffSearch.schSortType : 'R',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,9 +77,31 @@ export default function StuffSearchCondition() {
|
|||||||
setDispCompanyName('')
|
setDispCompanyName('')
|
||||||
setDateType('U')
|
setDateType('U')
|
||||||
setDateRange([dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'), dayjs(new Date()).format('YYYY-MM-DD')])
|
setDateRange([dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'), dayjs(new Date()).format('YYYY-MM-DD')])
|
||||||
|
setSchSelSaleStoreId('')
|
||||||
resetStuffRecoil()
|
resetStuffRecoil()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => {
|
||||||
|
if (!isEmptyArray(res)) {
|
||||||
|
// console.log('판매점 결과:::::', res)
|
||||||
|
setSchSelSaleStoreList(res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
//판매대리점 자동완성 변경
|
||||||
|
const onSelectionChange = (key) => {
|
||||||
|
// console.log('자동완성값변경', key)
|
||||||
|
if (key == null) {
|
||||||
|
setSchSelSaleStoreId('')
|
||||||
|
setStuffSearch({ ...stuffSearch, schSelSaleStoreId: '' })
|
||||||
|
} else {
|
||||||
|
setSchSelSaleStoreId(key)
|
||||||
|
setStuffSearch({ ...stuffSearch, schSelSaleStoreId: key })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//x로 날짜 비웠을때 기본값으로 셋팅
|
//x로 날짜 비웠을때 기본값으로 셋팅
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!startRangeDate && !endRangeDate) {
|
if (!startRangeDate && !endRangeDate) {
|
||||||
@ -88,7 +119,7 @@ export default function StuffSearchCondition() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div align="right">
|
<div align="right">
|
||||||
<Link href="/management/stuff/detail">
|
<Link href="/management/stuff/tempdetail">
|
||||||
<button type="button">물건신규등록</button>
|
<button type="button">물건신규등록</button>
|
||||||
</Link>
|
</Link>
|
||||||
<Button size="sm" onClick={onSubmit}>
|
<Button size="sm" onClick={onSubmit}>
|
||||||
@ -126,10 +157,10 @@ export default function StuffSearchCondition() {
|
|||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="물건주소 입력"
|
placeholder="물건주소 입력"
|
||||||
value={stuffSearch?.address ? stuffSearch.address : address}
|
value={stuffSearch?.schAddress ? stuffSearch.schAddress : address}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setAddress(e.target.value)
|
setAddress(e.target.value)
|
||||||
setStuffSearch({ ...stuffSearch, code: 'S', address: e.target.value })
|
setStuffSearch({ ...stuffSearch, code: 'S', schAddress: e.target.value })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -220,6 +251,17 @@ export default function StuffSearchCondition() {
|
|||||||
setStuffSearch({ ...stuffSearch, code: 'S', schDispCompanyName: e.target.value })
|
setStuffSearch({ ...stuffSearch, code: 'S', schDispCompanyName: e.target.value })
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{schSelSaleStoreList?.length > 0 && (
|
||||||
|
<Autocomplete
|
||||||
|
className="max-w-xs"
|
||||||
|
label="판매대리점선택"
|
||||||
|
defaultItems={schSelSaleStoreList}
|
||||||
|
selectedKey={stuffSearch?.schSelSaleStoreId ? stuffSearch.schSelSaleStoreId : schSelSaleStoreId}
|
||||||
|
onSelectionChange={onSelectionChange}
|
||||||
|
>
|
||||||
|
{(option) => <AutocompleteItem key={option.saleStoreId}>{option.saleStoreName}</AutocompleteItem>}
|
||||||
|
</Autocomplete>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -118,7 +118,7 @@
|
|||||||
"common.message.multi.insert": "Total {0} cases ({1} successes, {2} failures {3})",
|
"common.message.multi.insert": "Total {0} cases ({1} successes, {2} failures {3})",
|
||||||
"common.message.error": "Error occurred, please contact site administrator.",
|
"common.message.error": "Error occurred, please contact site administrator.",
|
||||||
"common.message.data.save": "Do you want to save it?",
|
"common.message.data.save": "Do you want to save it?",
|
||||||
"common.message.data.delete": "Do you want to delete it?",
|
"common.message.data.delete": "정말로 삭제하시겠습니까?",
|
||||||
"common.message.data.exists": "{0} is data that already exists.",
|
"common.message.data.exists": "{0} is data that already exists.",
|
||||||
"common.message.data.no.exists": "{0} is data that does not exist.",
|
"common.message.data.no.exists": "{0} is data that does not exist.",
|
||||||
"common.message.all": "All",
|
"common.message.all": "All",
|
||||||
|
|||||||
@ -17,6 +17,10 @@ export const stuffSearchState = atom({
|
|||||||
schFromDt: dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'), //시작일
|
schFromDt: dayjs(new Date()).add(-1, 'year').format('YYYY-MM-DD'), //시작일
|
||||||
schToDt: dayjs(new Date()).format('YYYY-MM-DD'), //종료일
|
schToDt: dayjs(new Date()).format('YYYY-MM-DD'), //종료일
|
||||||
code: 'S',
|
code: 'S',
|
||||||
|
schSelSaleStoreId: '', //판매대리점 선택
|
||||||
|
startRow: 1,
|
||||||
|
endRow: 100,
|
||||||
|
schSortType: 'R', //정렬조건 (R:최근등록일 U:최근수정일)
|
||||||
},
|
},
|
||||||
dangerouslyAllowMutability: true,
|
dangerouslyAllowMutability: true,
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user