물건 등록화면

This commit is contained in:
basssy 2024-10-16 17:53:57 +09:00
parent 82f3af907f
commit c3f56caaa6
6 changed files with 185 additions and 21 deletions

View File

@ -14,6 +14,7 @@ import { useRecoilValue } from 'recoil'
import { sessionStore } from '@/store/commonAtom'
import FindAddressPop from './popup/FindAddressPop'
import PlanRequestPop from './popup/PlanRequestPop'
import WindSelectPop from './popup/WindSelectPop'
export default function StuffDetail() {
const sessionState = useRecoilValue(sessionStore)
@ -43,7 +44,6 @@ export default function StuffDetail() {
prefName: '',
address: '', //
areaId: '', //id
// areaName: '', //
windSpeed: '', //
verticalSnowCover: '', //NEW
coldRegionFlg: false, //(true : 1 / false : 0)
@ -68,10 +68,11 @@ export default function StuffDetail() {
const [areaIdList, setAreaIdList] = useState([]) //
const [windSpeedList, setWindSpeedList] = useState([]) //
// const [windSpeedList, setWindSpeedList] = useState([]) //
const [isFormValid, setIsFormValid] = useState(false) //,
const [showAddressButtonValid, setShowAddressButtonValid] = useState(false) //
const [showDesignRequestButtonValid, setShowDesignRequestButtonValid] = useState(false) //
const [showWindSpeedButtonValid, setShowWindSpeedButtonValid] = useState(false) //
const objectNo = searchParams.get('objectNo') //url set
const [editMode, setEditMode] = useState('NEW')
@ -208,6 +209,14 @@ export default function StuffDetail() {
form.setValue('zipNo', info.zipNo)
}
//
const setPlanReqInfo = (info) => {}
//
const setWindSppedInfo = (info) => {
form.setValue('windSpeed', info.windSpeed)
}
//
// dispCompanyName: '', //
// objectName: '', //
@ -307,6 +316,16 @@ export default function StuffDetail() {
setShowDesignRequestButtonValid(true)
}
//
const onSearchWindSpeedPopOpen = () => {
const prefName = form.watch('prefName')
if (prefName === '') {
alert(getMessage('stuff.windSelectPopup.error.message1'))
} else {
setShowWindSpeedButtonValid(true)
}
}
useEffect(() => {
if (prefValue !== '') {
//
@ -326,18 +345,18 @@ export default function StuffDetail() {
form.setValue('areaId', e.target.value)
}
useEffect(() => {
if (!isEmptyArray(areaIdList)) {
let _prefName = form.watch('prefName')
// console.log(' API', _prefName)
get({ url: `/api/object/windSpeed/${_prefName}/list` }).then((res) => {
// console.log('res::', res)
if (!isEmptyArray(res)) {
setWindSpeedList(res)
}
})
}
}, [areaIdList])
// useEffect(() => {
// if (!isEmptyArray(areaIdList)) {
// let _prefName = form.watch('prefName')
// // console.log(' API', _prefName)
// get({ url: `/api/object/windSpeed/${_prefName}/list` }).then((res) => {
// // console.log('res::', res)
// if (!isEmptyArray(res)) {
// setWindSpeedList(res)
// }
// })
// }
// }, [areaIdList])
//
const onValid = (data) => {
@ -643,7 +662,10 @@ export default function StuffDetail() {
</th>
<td>
<div className="flx-box">
<div className="select-wrap mr10" style={{ width: '200px' }}>
<div className="input-wrap mr5">
<input type="text" className="input-light" readOnly value={form.watch('windSpeed')} {...register('windSpeed')} />
</div>
{/* <div className="select-wrap mr10" style={{ width: '200px' }}>
<select className="select-light" name="windSpeed" {...register('windSpeed')}>
{windSpeedList.map((row) => {
return (
@ -653,9 +675,11 @@ export default function StuffDetail() {
)
})}
</select>
</div>
</div> */}
<span className="mr10">{getMessage('stuff.detail.windSpeedSpan')}</span>
<button className="btn-origin grey">{getMessage('stuff.detail.btn.windSpeedPop')}</button>
<button className="btn-origin grey" onClick={onSearchWindSpeedPopOpen}>
{getMessage('stuff.detail.btn.windSpeedPop')}
</button>
</div>
</td>
</tr>
@ -803,7 +827,7 @@ export default function StuffDetail() {
</tr>
<tr>
<th>
물건구분/물건명 <span className="importatn">*</span>
{getMessage('stuff.detail.objectStatusId')} <span className="importatn">*</span>
</th>
<td>
<div className="flx-box">
@ -906,7 +930,12 @@ export default function StuffDetail() {
</>
)}
{showAddressButtonValid && <FindAddressPop setShowAddressButtonValid={setShowAddressButtonValid} zipInfo={setZipInfo} />}
{showDesignRequestButtonValid && <PlanRequestPop setShowDesignRequestButtonValid={setShowDesignRequestButtonValid} />}
{showDesignRequestButtonValid && (
<PlanRequestPop setShowDesignRequestButtonValid={setShowDesignRequestButtonValid} planReqInfo={setPlanReqInfo} />
)}
{showWindSpeedButtonValid && (
<WindSelectPop setShowWindSpeedButtonValid={setShowWindSpeedButtonValid} prefName={form.watch('prefName')} windSpeedInfo={setWindSppedInfo} />
)}
</>
)
}

View File

@ -68,6 +68,7 @@ export default function FindAddressPop(props) {
if (isNotEmptyArray(res.results)) {
setGridProps({ ...gridProps, gridData: res.results })
} else {
alert(getMessage('stuff.addressPopup.error.message1'))
setGridProps({ ...gridProps, gridData: [] })
}
} else {
@ -80,7 +81,7 @@ export default function FindAddressPop(props) {
const applyAddress = () => {
// console.log(' :::::::::', prefId, address1, address2, address3, zipNo)
if (prefId == null) {
alert('stuff.addressPopup.error.message2')
alert(getMessage('stuff.addressPopup.error.message2'))
} else {
props.zipInfo({
zipNo: zipNo,
@ -99,6 +100,10 @@ export default function FindAddressPop(props) {
const handleKeyUp = (e) => {
let input = e.target
input.value = input.value.replace(/[^0-9]/g, '')
if (e.key === 'Enter') {
searchPostNum()
}
}
//

View File

@ -12,7 +12,6 @@ import dayjs from 'dayjs'
import PlanRequestPopQGrid from './PlanRequestPopQGrid'
import { sessionStore } from '@/store/commonAtom'
import { planReqSearchState } from '@/store/planReqAtom'
import Select from 'react-dropdown-select'
export default function PlanRequestPop(props) {
const sessionState = useRecoilValue(sessionStore)

View File

@ -0,0 +1,115 @@
import React, { useState, useEffect } from 'react'
import { useMessage } from '@/hooks/useMessage'
import { useAxios } from '@/hooks/useAxios'
import { globalLocaleStore } from '@/store/localeAtom'
import { useRecoilValue } from 'recoil'
import { isEmptyArray, isNotEmptyArray } from '@/util/common-utils'
export default function WindSelectPop(props) {
const globalLocaleState = useRecoilValue(globalLocaleStore)
const { promiseGet } = useAxios(globalLocaleState)
const [windSpeedList, setWindSpeedList] = useState([])
const [windSpeed, setWindSpeed] = useState(null)
const { getMessage } = useMessage()
//
const handleChangeRadio = (e) => {
setWindSpeed(e.target.value)
}
//
const applyWindSpeed = () => {
if (windSpeed == null) {
alert(getMessage('stuff.windSelectPopup.error.message2'))
} else {
props.windSpeedInfo({ windSpeed: windSpeed })
//
props.setShowWindSpeedButtonValid(false)
}
}
useEffect(() => {
if (props.prefName !== '') {
promiseGet({ url: `/api/object/windSpeed/${props.prefName}/list` }).then((res) => {
if (res.status === 200) {
if (!isEmptyArray(res.data)) {
setWindSpeedList(res.data)
}
}
})
}
}, [props])
return (
<div className="modal-popup">
<div className="modal-dialog middle">
<div className="modal-content">
<div className="modal-header">
<h1 className="title">{getMessage('stuff.windSelectPopup.title')}</h1>
<button className="modal-close" onClick={() => props.setShowWindSpeedButtonValid(false)}>
닫기
</button>
</div>
<div className="modal-body">
<div className="modal-body-inner">
<div className="common-table">
<table>
<colgroup>
<col style={{ width: '70px' }} />
<col />
</colgroup>
<tbody>
<tr>
<th>{getMessage('stuff.windSelectPopup.search.address1')}</th>
<td>
<div className="input-wrap">
<input type="text" className="input-light" defaultValue={props.prefName} readOnly />
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div className="wind-table">
<table>
<thead>
<tr>
<th style={{ width: '50px' }}>{getMessage('stuff.windSelectPopup.table.selected')}</th>
<th style={{ width: '110px' }}>{getMessage('stuff.windSelectPopup.table.windspeed')}</th>
<th>Remarks</th>
</tr>
</thead>
<tbody>
{windSpeedList.map((row, index) => {
// console.log('row:::', row)
return (
<tr key={index}>
<td className="al-c">
<div className="d-check-radio light no-text">
<input type="radio" value={row.windSpeed} name="windS" id={row.windSpeed} onChange={handleChangeRadio} />
<label htmlFor={row.windSpeed}></label>
</div>
</td>
<td className="al-c">{row.windSpeed}</td>
<td>{row.remarks}</td>
</tr>
)
})}
</tbody>
</table>
</div>
</div>
<div className="footer-btn-wrap">
<button className="btn-origin grey mr5" onClick={() => props.setShowWindSpeedButtonValid(false)}>
{getMessage('stuff.windSelectPopup.btn1')}
</button>
<button className="btn-origin navy" onClick={applyWindSpeed}>
{getMessage('stuff.windSelectPopup.btn2')}
</button>
</div>
</div>
</div>
</div>
</div>
)
}

View File

@ -508,6 +508,14 @@
"stuff.search.period": "期間検索",
"stuff.search.schDateTypeU": "更新日",
"stuff.search.schDateTypeR": "登録日",
"stuff.windSelectPopup.title": "風速選択",
"stuff.windSelectPopup.table.selected": "選択",
"stuff.windSelectPopup.table.windspeed": "風速",
"stuff.windSelectPopup.error.message1": "住所を先に検索してください",
"stuff.windSelectPopup.error.message2": "風速を選択してください。",
"stuff.windSelectPopup.search.address1": "県",
"stuff.windSelectPopup.btn1": "閉じる",
"stuff.windSelectPopup.btn2": "選択",
"length": "長さ",
"height": "高さ",
"output": "出力",

View File

@ -513,6 +513,14 @@
"stuff.search.period": "기간검색",
"stuff.search.schDateTypeU": "갱신일",
"stuff.search.schDateTypeR": "등록일",
"stuff.windSelectPopup.title": "풍속선택",
"stuff.windSelectPopup.table.selected": "선택",
"stuff.windSelectPopup.table.windspeed": "풍속",
"stuff.windSelectPopup.error.message1": "주소를 먼저 검색해주세요.",
"stuff.windSelectPopup.error.message2": "풍속을 선택해주세요.",
"stuff.windSelectPopup.search.address1": "현",
"stuff.windSelectPopup.btn1": "닫기",
"stuff.windSelectPopup.btn2": "선택",
"length": "길이",
"height": "높이",
"output": "출력",