Qcast-100 물건현황
This commit is contained in:
parent
11e40caaa7
commit
bc080a0855
@ -2,6 +2,7 @@ NEXT_PUBLIC_TEST="테스트변수입니다. development"
|
||||
|
||||
NEXT_PUBLIC_API_SERVER_PATH="http://1.248.227.176:38080"
|
||||
# NEXT_PUBLIC_API_SERVER_PATH="http://localhost:8080"
|
||||
# NEXT_PUBLIC_API_SERVER_PATH="http://172.30.1.60:8080"
|
||||
|
||||
DATABASE_URL="sqlserver://mssql.devgrr.kr:1433;database=qcast;user=qcast;password=Qwertqaz12345;trustServerCertificate=true"
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import { useMessage } from '@/hooks/useMessage'
|
||||
import StuffQGrid from './StuffQGrid'
|
||||
import { useRecoilValue } from 'recoil'
|
||||
import { stuffSearchState } from '@/store/stuffAtom'
|
||||
import { queryStringFormatter } from '@/util/common-utils'
|
||||
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
||||
import dayjs from 'dayjs'
|
||||
import isLeapYear from 'dayjs/plugin/isLeapYear' // 윤년 판단 플러그인
|
||||
dayjs.extend(isLeapYear)
|
||||
@ -288,13 +288,13 @@ export default function Stuff() {
|
||||
// let size
|
||||
// let pageCount
|
||||
|
||||
const apiUrl = `/api/object/v1.0/object?saleStoreId=201TES01&${queryStringFormatter(params)}`
|
||||
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(params)}`
|
||||
|
||||
await get({
|
||||
url: apiUrl,
|
||||
}).then((res) => {
|
||||
if (res.length > 0) {
|
||||
console.log('API결과:::::::', res)
|
||||
if (!isEmptyArray(res)) {
|
||||
console.log('화면진입API결과::', res)
|
||||
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
||||
setGridCount(res.length)
|
||||
}
|
||||
@ -308,11 +308,13 @@ export default function Stuff() {
|
||||
if (stuffSearchParams?.code === 'E') {
|
||||
console.log('조회 눌럿을때 ::::::::::::::', stuffSearchParams)
|
||||
async function fetchData() {
|
||||
const apiUrl = `/api/object/v1.0/object?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
||||
const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}`
|
||||
await get({ url: apiUrl }).then((res) => {
|
||||
console.log('API결과:::::::', res)
|
||||
if (!isEmptyArray(res)) {
|
||||
setGridProps({ ...gridProps, gridData: res, count: res.length })
|
||||
setGridCount(res.length)
|
||||
}
|
||||
})
|
||||
}
|
||||
fetchData()
|
||||
|
||||
@ -5,7 +5,7 @@ import { useRouter, useSearchParams } from 'next/navigation'
|
||||
import { Input, RadioGroup, Radio, Button, Autocomplete, AutocompleteItem, Select, SelectItem, Checkbox, Textarea, button } from '@nextui-org/react'
|
||||
import Link from 'next/link'
|
||||
import { get } from '@/lib/Axios'
|
||||
import { queryStringFormatter } from '@/util/common-utils'
|
||||
import { queryStringFormatter, isEmptyArray } from '@/util/common-utils'
|
||||
import dayjs from 'dayjs'
|
||||
import { useForm } from 'react-hook-form'
|
||||
export default function StuffDetail() {
|
||||
@ -29,10 +29,10 @@ export default function StuffDetail() {
|
||||
windSpeed: '', //기준풍속
|
||||
snowCover: '', //수직적설량
|
||||
coldAreaChk: false, //한랭지대책시행
|
||||
surfaceType: '', //면조도구분(Ⅲ・Ⅳ / Ⅱ)
|
||||
surfaceType: 'Ⅲ・Ⅳ', //면조도구분(Ⅲ・Ⅳ / Ⅱ)
|
||||
saltAreaChk: false, //염해지역용아이템사용
|
||||
installHeight: '', //설치높이
|
||||
powerConTerms: '', //계약조건
|
||||
powerConTerms: '0', //계약조건(잉여 / 전량)
|
||||
remark: '', //메모
|
||||
tempFlag: 'T', //임시저장(1) 저장(0)
|
||||
}
|
||||
@ -42,6 +42,9 @@ export default function StuffDetail() {
|
||||
|
||||
const form = { register, setValue, getValues, handleSubmit, resetField, control, watch }
|
||||
|
||||
const [prefCodeList, setPrefCodeList] = useState([]) //도도부현 코트 리스트
|
||||
const [prefValue, setPrefValue] = useState('')
|
||||
|
||||
const [receiveUser, setReceiveUser] = useState('') //담당자
|
||||
const [name2, setName2] = useState('') //물건명
|
||||
const [name3, setName3] = useState('') //물건명후리가나
|
||||
@ -74,18 +77,21 @@ export default function StuffDetail() {
|
||||
const [detailData, setDetailData] = useState({})
|
||||
|
||||
useEffect(() => {
|
||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
console.log('도도부현API 결과:::', res)
|
||||
setPrefCodeList(res)
|
||||
}
|
||||
})
|
||||
// console.log('상세화면진입:::::::::', searchParams.get('objectNo'))
|
||||
console.log('물건번호::::', objectNo)
|
||||
// console.log('물건번호::::', objectNo)
|
||||
|
||||
if (objectNo) {
|
||||
// console.log('상세::', objectNo)
|
||||
setEditMode('EDIT')
|
||||
if (objectNo.substring(0, 1) === 'R') {
|
||||
setIsFormValid(true)
|
||||
}
|
||||
//일단 플랜번호 무조건 1로
|
||||
//API 호출
|
||||
get({ url: `/api/object/v1.0/object/${objectNo}/1` }).then((res) => {
|
||||
get({ url: `/api/object/${objectNo}/detail` }).then((res) => {
|
||||
if (res != null) {
|
||||
// console.log('res:::::::', res)
|
||||
setDetailData(res)
|
||||
@ -101,9 +107,7 @@ export default function StuffDetail() {
|
||||
// 우편번호 숫자만 체크
|
||||
const _zipNo = watch('zipNo')
|
||||
useEffect(() => {
|
||||
console.log('실시간이니:::::', _zipNo)
|
||||
if (_zipNo !== '' && _zipNo.length === 7 && !_zipNo.match(/\D/g)) {
|
||||
console.log('벨리통과했군')
|
||||
setButtonValid(true)
|
||||
} else {
|
||||
setButtonValid(false)
|
||||
@ -167,26 +171,29 @@ export default function StuffDetail() {
|
||||
setIsFormValid(Object.keys(errors).length === 0)
|
||||
}
|
||||
|
||||
// 우편번호 API
|
||||
// 주소검색 API
|
||||
const onSearchPostNumber = () => {
|
||||
const params = {
|
||||
zipcode: _zipNo,
|
||||
}
|
||||
get({ url: `https://zipcloud.ibsnet.co.jp/api/search?${queryStringFormatter(params)}` }).then((res) => {
|
||||
console.log('우편API RES::::::::', res)
|
||||
//7830060
|
||||
if (res.status === 200) {
|
||||
if (res.results?.length > 0) {
|
||||
// setAddress1(res.results[0].address1)
|
||||
// setAddress2(res.results[0].address2)
|
||||
// setAddress3(res.results[0].address3)
|
||||
// setPrefCode(res.results[0].prefcode)
|
||||
console.log('res.results::', res.results)
|
||||
if (res.results != null) {
|
||||
console.log('res.results::', res.results)
|
||||
// prefId: '', //도도부현
|
||||
// address: '', //주소
|
||||
console.log('prefcode::', res.results[0].prefcode)
|
||||
console.log('address::', res.results[0].address2 + res.results[0].address3)
|
||||
setPrefValue(res.results[0].prefcode)
|
||||
form.setValue('prefId', res.results[0].prefcode)
|
||||
form.setValue('address', res.results[0].address2 + res.results[0].address3)
|
||||
} else {
|
||||
alert('등록된 우편번호에서 주소를 찾을 수 없습니다. 다시 입력해주세요.')
|
||||
form.setValue('prefId', '')
|
||||
form.setValue('address', '')
|
||||
setPrefValue('')
|
||||
}
|
||||
} else {
|
||||
alert(res.message)
|
||||
@ -218,11 +225,18 @@ export default function StuffDetail() {
|
||||
const _dispCompanyName = watch('dispCompanyName')
|
||||
const _objectStatusId = watch('objectStatusId')
|
||||
const _objectNameOmit = watch('objectNameOmit')
|
||||
const _zipno = watch('zipno')
|
||||
const _zipNo = watch('zipNo')
|
||||
const _prefId = watch('prefId')
|
||||
const _address = watch('address')
|
||||
const _coldAreaChk = watch('coldAreaChk')
|
||||
console.log(_dispCompanyName)
|
||||
console.log(_objectStatusId)
|
||||
console.log(_objectNameOmit)
|
||||
console.log(_zipno)
|
||||
console.log(_zipNo)
|
||||
console.log(_prefId)
|
||||
console.log('prefValue::', prefValue)
|
||||
console.log(_address)
|
||||
console.log('_coldAreaChk::', _coldAreaChk)
|
||||
}
|
||||
|
||||
//필수값 안넣었을때
|
||||
@ -285,11 +299,87 @@ export default function StuffDetail() {
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>도도부현 / 주소</label>
|
||||
<div className="flex w-full flex-wrap items-end md:flex-nowrap mb-6 md:mb-0 gap-4">
|
||||
{prefCodeList?.length > 0 && (
|
||||
<Select className="max-w-xs" selectedKeys={prefValue} isDisabled {...form.register('prefId', { required: true })}>
|
||||
{prefCodeList.map((row) => {
|
||||
return <SelectItem key={row.prefId}>{row.prefName}</SelectItem>
|
||||
})}
|
||||
</Select>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<input type="text" className="input-origin" value={form.watch('address')} {...form.register('address')} />
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>발전량시뮬레이션지역</label>
|
||||
</div>
|
||||
<button type="submit">저장!!!!!!!!!</button>
|
||||
<div className="form-input">
|
||||
<label>기준풍속</label>
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>수직적설량</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-origin"
|
||||
maxLength={3}
|
||||
{...form.register('snowCover', {
|
||||
required: true,
|
||||
pattern: { value: /^[0-9]*$/g, message: '정수만 입력' },
|
||||
})}
|
||||
/>{' '}
|
||||
cm
|
||||
<Checkbox
|
||||
onValueChange={(e) => {
|
||||
form.setValue('coldAreaChk', e)
|
||||
}}
|
||||
{...form.register('coldAreaChk')}
|
||||
>
|
||||
한랭지대책시행
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>면조도구분</label>
|
||||
<input type="radio" name="surfaceType" value="Ⅲ・Ⅳ" id="surfaceType0" {...form.register('surfaceType')} />
|
||||
<label htmlFor="surfaceType0">Ⅲ・Ⅳ</label>
|
||||
<input type="radio" name="surfaceType" value="Ⅱ" id="surfaceType1" {...form.register('surfaceType')} />
|
||||
<label htmlFor="surfaceType1">Ⅱ</label>
|
||||
<Checkbox
|
||||
{...form.register('saltAreaChk')}
|
||||
onValueChange={(e) => {
|
||||
form.setValue('saltAreaChk', e)
|
||||
}}
|
||||
>
|
||||
염해지역용아이템사용
|
||||
</Checkbox>
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>설치높이 installHeight</label>
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>계약조건</label>
|
||||
<input type="radio" name="powerConTerms" value="0" id="powerConTerms0" {...form.register('powerConTerms')} />
|
||||
<label htmlFor="powerConTerms0">잉여</label>
|
||||
<input type="radio" name="powerConTerms" value="1" id="powerConTerms1" {...form.register('powerConTerms')} />
|
||||
<label htmlFor="powerConTerms1">전량</label>
|
||||
</div>
|
||||
<div className="form-input">
|
||||
<label>메모</label>
|
||||
<Textarea
|
||||
disableAutosize
|
||||
classNames={{
|
||||
base: 'max-w-xs',
|
||||
input: 'resize-y min-h-[40px]',
|
||||
}}
|
||||
{...form.register('remark')}
|
||||
onValueChange={(e) => {
|
||||
// console.log('e::::', e)
|
||||
form.setValue('remark', e)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit">신규화면임시저장!!!!!!!!!</button>
|
||||
</form>
|
||||
)) || <div>상세:::::::::::</div>}
|
||||
|
||||
|
||||
@ -10,6 +10,14 @@ export const isObjectNotEmpty = (obj) => {
|
||||
return Object.keys(obj).length > 0
|
||||
}
|
||||
|
||||
export const isNotEmptyArray = (array) => {
|
||||
return Array.isArray(array) && array.length
|
||||
}
|
||||
|
||||
export const isEmptyArray = (array) => {
|
||||
return !isNotEmptyArray(array)
|
||||
}
|
||||
|
||||
/**
|
||||
* ex) const params = {page:10, searchDvsnCd: 20}
|
||||
* @param {*} params
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user