From 8b4550d442b1acd956ca48df2aeb9d67bf9da6b6 Mon Sep 17 00:00:00 2001 From: basssy Date: Fri, 13 Sep 2024 13:37:59 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=BC=EA=B1=B4=ED=98=84=ED=99=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/management/stuff/detail/page.jsx | 4 + src/app/management/stuff/tempdetail/page.jsx | 15 + src/components/management/Stuff.jsx | 12 +- src/components/management/StuffDetail.jsx | 353 ++++++------------- 4 files changed, 143 insertions(+), 241 deletions(-) create mode 100644 src/app/management/stuff/tempdetail/page.jsx diff --git a/src/app/management/stuff/detail/page.jsx b/src/app/management/stuff/detail/page.jsx index 8b84287a..6759b282 100644 --- a/src/app/management/stuff/detail/page.jsx +++ b/src/app/management/stuff/detail/page.jsx @@ -1,11 +1,15 @@ import React from 'react' import Hero from '@/components/Hero' import StuffDetail from '@/components/management/StuffDetail' +import Link from 'next/link' export default function ManagementStuffDetailPage() { return ( <>

물건정보

+ +

도면작성

+
diff --git a/src/app/management/stuff/tempdetail/page.jsx b/src/app/management/stuff/tempdetail/page.jsx new file mode 100644 index 00000000..8b84287a --- /dev/null +++ b/src/app/management/stuff/tempdetail/page.jsx @@ -0,0 +1,15 @@ +import React from 'react' +import Hero from '@/components/Hero' +import StuffDetail from '@/components/management/StuffDetail' +export default function ManagementStuffDetailPage() { + return ( + <> +
+

물건정보

+
+
+ +
+ + ) +} diff --git a/src/components/management/Stuff.jsx b/src/components/management/Stuff.jsx index e445fa1d..6f615c3c 100644 --- a/src/components/management/Stuff.jsx +++ b/src/components/management/Stuff.jsx @@ -269,7 +269,8 @@ export default function Stuff() { // let size // let pageCount - const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(params)}` + // const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(params)}` + const apiUrl = `/api/object/list?saleStoreId=X167&${queryStringFormatter(params)}` await get({ url: apiUrl, @@ -292,7 +293,8 @@ export default function Stuff() { stuffSearchParams.schSortType = defaultSortType console.log('조회 눌럿을때 ::::::::::::::', stuffSearchParams) async function fetchData() { - const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + // const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + const apiUrl = `/api/object/list?saleStoreId=X167&${queryStringFormatter(stuffSearchParams)}` await get({ url: apiUrl }).then((res) => { console.log('API결과:::::::', res) if (!isEmptyArray(res)) { @@ -322,7 +324,8 @@ export default function Stuff() { }) console.log('셋팅된 검색조건:::', stuffSearchParams) //조회API호출 - const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + // const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + const apiUrl = `/api/object/list?saleStoreId=X167&${queryStringFormatter(stuffSearchParams)}` get({ url: apiUrl }).then((res) => { console.log('보여줄개수바꿨을때 조회 ::::::::::', res) if (!isEmptyArray(res)) { @@ -345,7 +348,8 @@ export default function Stuff() { code: 'S', schSortType: e.target.value, }) - const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + // const apiUrl = `/api/object/list?saleStoreId=201TES01&${queryStringFormatter(stuffSearchParams)}` + const apiUrl = `/api/object/list?saleStoreId=X167&${queryStringFormatter(stuffSearchParams)}` // console.log('apiUrl::', apiUrl) get({ url: apiUrl }).then((res) => { console.log('정렬바꿨을때 조회 ::::::::::', res) diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index 6e455876..66baf8e3 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -4,7 +4,7 @@ import React, { useState, useEffect } from 'react' 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 { del, get } from '@/lib/Axios' +import { del, get, post } from '@/lib/Axios' import { queryStringFormatter, isEmptyArray } from '@/util/common-utils' import dayjs from 'dayjs' import { useMessage } from '@/hooks/useMessage' @@ -24,8 +24,11 @@ export default function StuffDetail() { objectNameKana: '', //물건명 후리가나 saleStoreId: '', //판매점ID saleStoreName: '', //판매점명 + otherSaleStoreId: '', + otherSaleStoreName: '', zipNo: '', //우편번호 prefId: '', //도도부현 + prefName: '', address: '', //주소 powerSimArea: '', //발전량시뮬레이션지역 windSpeed: '', //기준풍속 @@ -35,7 +38,7 @@ export default function StuffDetail() { saltAreaChk: false, //염해지역용아이템사용 installHeight: '', //설치높이 powerConTerms: '0', //계약조건(잉여 / 전량) - remark: '', //메모 + remarks: '', //메모 tempFlag: 'T', //임시저장(1) 저장(0) } const { register, setValue, getValues, handleSubmit, resetField, control, watch } = useForm({ @@ -47,6 +50,7 @@ export default function StuffDetail() { const [prefCodeList, setPrefCodeList] = useState([]) //도도부현 코트 리스트 const [prefValue, setPrefValue] = useState('') const [saleStoreList, setSaleStoreList] = useState([]) // 판매점 리스트 + const [otherSaleStoreList, setOtherSaleStoreList] = useState([]) const [powerSimAreaList, setPowerSimAreaList] = useState([]) //발전시뮬레이션 리스트 @@ -59,6 +63,7 @@ export default function StuffDetail() { useEffect(() => { if (objectNo) { + console.log('수정화면') setEditMode('EDIT') if (objectNo.substring(0, 1) === 'R') { @@ -66,9 +71,9 @@ export default function StuffDetail() { setIsFormValid(true) } get({ url: `/api/object/${objectNo}/detail` }).then((res) => { - console.log('물건번호로 상세 API 호출') + // console.log('물건번호로 상세 API 호출') if (res != null) { - console.log('상세res:::::::', res) + // console.log('상세res:::::::', res) setDetailData(res) // 신규 상세 공통APi @@ -83,7 +88,7 @@ export default function StuffDetail() { // 임시 1차점 판매점코드 saleStoreId=201TES01 // T01 //1차점 : X167 - get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => { + get({ url: `/api/object/saleStore/X167/list` }).then((res) => { if (!isEmptyArray(res)) { console.log('판매점 결과:::::', res) setSaleStoreList(res) @@ -91,6 +96,7 @@ export default function StuffDetail() { form.setValue('saleStoreId', res[0].saleStoreId) //1차 판매점 번호 셋팅 form.setValue('saleStoreName', res[0].saleStoreId) + setOtherSaleStoreList([]) } }) } else { @@ -99,7 +105,7 @@ export default function StuffDetail() { } }) } else { - console.log('신규일떄 공통코드세팅') + console.log('신규화면') // 신규 상세 공통APi // 도도부현API get({ url: '/api/object/prefecture/list' }).then((res) => { @@ -112,14 +118,22 @@ export default function StuffDetail() { // 임시 1차점 판매점코드 saleStoreId=201TES01 // T01 //1차점 : X167 - get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => { + get({ url: `/api/object/saleStore/X167/list` }).then((res) => { if (!isEmptyArray(res)) { console.log('판매점 결과:::::', res) - setSaleStoreList(res) + const firstList = res.filter((row) => row.saleStoreLevel === '1') + const otherList = res.filter((row) => row.saleStoreLevel !== '1') + console.log('first:::::', firstList) + console.log('otherList:::::', otherList) + //1차점 셀렉트박스 + setSaleStoreList(firstList) //1차 판매점 자동완성 값 셋팅 - form.setValue('saleStoreId', res[0].saleStoreId) + form.setValue('saleStoreId', firstList[0].saleStoreId) //1차 판매점 번호 셋팅 - form.setValue('saleStoreName', res[0].saleStoreId) + form.setValue('saleStoreName', firstList[0].saleStoreId) + + //1차점 아닌 판매점 셀렉트박스 + setOtherSaleStoreList(otherList) } }) } @@ -135,6 +149,11 @@ export default function StuffDetail() { form.setValue('saleStoreName', key) } } + + //2차점 변경 이벤트 + const onSelectionChange2 = (key) => { + console.log(key) + } // 우편번호 숫자만 체크 const _zipNo = watch('zipNo') useEffect(() => { @@ -161,7 +180,7 @@ export default function StuffDetail() { // saltAreaChk: false, //염해지역용아이템사용 // installHeight: '', //설치높이 // powerConTerms: '0', //계약조건(잉여 / 전량) - // remark: '', //메모 + // remarks: '', //메모 // tempFlag: 'T', //임시저장(1) 저장(0) const _dispCompanyName = watch('dispCompanyName') const _objectName = watch('objectName') @@ -174,10 +193,10 @@ export default function StuffDetail() { const _snowCover = watch('snowCover') const _installHeight = watch('installHeight') useEffect(() => { - console.log('mode:::::', editMode) + // console.log('mode:::::', editMode) if (editMode === 'NEW') { const formData = form.getValues() - console.log('폼::::::::::::', formData) + // console.log('폼::::::::::::', formData) let errors = {} if (!_dispCompanyName || _dispCompanyName.trim().length === 0) { errors.dispCompanyName = true @@ -220,10 +239,10 @@ export default function StuffDetail() { errors.installHeight = true } - console.log('errors::', errors) + // console.log('errors::', errors) setIsFormValid(Object.keys(errors).length === 0) } else { - console.log('상세일때 폼체크') + // console.log('상세일때 폼체크') } }, [_dispCompanyName, _objectName, _objectNameOmit, _saleStoreId, _zipNo, _prefId, _address, _powerSimArea, _windSpeed, _snowCover, _installHeight]) @@ -237,17 +256,17 @@ export default function StuffDetail() { //9302226 if (res.status === 200) { if (res.results != null) { - console.log('주소검색::', res.results) - // prefId: '', //도도부현 - // address: '', //주소 - console.log('prefcode::', res.results[0].prefcode) - console.log('address::', res.results[0].address2 + res.results[0].address3) + // console.log('주소검색::', res.results) + // 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('prefName', res.results[0].address1) form.setValue('address', res.results[0].address2 + res.results[0].address3) } else { alert('등록된 우편번호에서 주소를 찾을 수 없습니다. 다시 입력해주세요.') form.setValue('prefId', '') + form.setValue('prefName', '') form.setValue('address', '') form.setValue('zipNo', '') setPrefValue('') @@ -262,12 +281,12 @@ export default function StuffDetail() { useEffect(() => { if (prefValue !== '') { - console.log('우편번호 검색해서 도도부현골랐을때::::', prefValue) + // console.log('우편번호 검색해서 도도부현골랐을때::::', prefValue) // 발전량시뮬레이션 지역 목록 // /api/object/prefecture/도도부현코드/list get({ url: `/api/object/prefecture/${prefValue}/list` }).then((res) => { if (!isEmptyArray(res)) { - console.log('발전시뮬레이션::::::::', res) + // console.log('발전시뮬레이션::::::::', res) setPowerSimAreaList(res) } }) @@ -276,10 +295,11 @@ export default function StuffDetail() { //필수값 다 입력했을때 const onValid = (data) => { - console.log('필수값 다 있고 저장') - console.log('data::::::', data) + // 수정모드일때는 PUT + // console.log('필수값 다 있고 저장') + // console.log('data::::::', data) const formData = form.getValues() - console.log('formData::::', formData) + // console.log('formData::::', formData) // const _dispCompanyName = watch('dispCompanyName') // const _objectStatusId = watch('objectStatusId') // const _objectNameOmit = watch('objectNameOmit') @@ -297,15 +317,52 @@ export default function StuffDetail() { // console.log('_coldAreaChk::', _coldAreaChk) } - //필수값 안넣었을때 임시저장 - const onInvalid = (errors) => { + //필수값 안넣었을때 임시저장 form required사용시 + // const onInvalid = (errors) => { + // console.log('22222222222222222222222') + // const formData = form.getValues() + // console.log('임시저장formData::::', formData) + // } + + // 임시저장 + const onTempSave = async () => { const formData = form.getValues() - console.log('임시저장formData::::', formData) + //console.log('임시저장::::::::', formData) + + const params = { + saleStoreId: formData.saleStoreId, + saleStoreName: formData.saleStoreName, + objectStatusId: formData.objectStatusId, + objectName: formData.objectName, + objectNameOmit: formData.objectNameOmit, + objectNameKana: formData.objectNameKana, + zipNo: formData.zipNo, + prefId: formData.prefId, + prefName: formData.prefName, + address: formData.address, + powerSimArea: formData.powerSimArea, + receiveUser: formData.dispCompanyName, + installHeight: formData.installHeight, + windSpeed: formData.windSpeed, + snowCover: formData.snowCover, + surfaceType: formData.surfaceType, + powerConTerms: formData.powerConTerms, + saltAreaChk: formData.saltAreaChk, + coldAreaChk: formData.coldAreaChk, + tempFlg: '1', + workNo: null, + workName: null, + } + console.log('임시저장params::', params) + return + await post({ url: '/api/object/save-object', data: params }).then((res) => { + console.log('res::::::', res) + }) } // 발전량 시뮬레이션 변경 const handlePowerSimAreaOnChange = (e) => { - console.log('가지고있는 도도부현코드:::::::::', prefValue) + // console.log('가지고있는 도도부현코드:::::::::', prefValue) // console.log('발전량시뮬레이션변경:::::::::', e.target.value) //값 set해주고 그거 useEffect로 api호출 } @@ -313,13 +370,13 @@ export default function StuffDetail() { // 물건삭제 const onDelete = () => { //http://localhost:8080/api/object/R201TES01240910023 - console.log('물건번호::::::::', objectNo) + // console.log('물건번호::::::::', objectNo) alert('사양확정일이 있으면 삭제 불가') if (confirm(getMessage('common.message.data.delete'))) { let testobj = '10' del({ url: `/api/object/${testobj}` }).then((res) => { - console.log('삭제 결과:::', res) + // console.log('삭제 결과:::', res) router.push('/management/stuff') }) } @@ -328,12 +385,12 @@ export default function StuffDetail() { return ( <> {(editMode === 'NEW' && ( -
+
(*필수 입력항목)
- +
@@ -341,9 +398,9 @@ export default function StuffDetail() { - +
- @@ -353,7 +410,7 @@ export default function StuffDetail() {
- +
@@ -363,9 +420,8 @@ export default function StuffDetail() { className="max-w-xs" defaultItems={saleStoreList} label="판매점ID자동완성" - // selectedKey={saleStoreValue} selectedKey={form.watch('saleStoreId')} - {...form.register('saleStoreId', { required: true })} + {...form.register('saleStoreId')} onSelectionChange={onSelectionChange} > {(option) => {option.saleStoreName}} @@ -376,6 +432,19 @@ export default function StuffDetail() {
+
+ {otherSaleStoreList?.length > 0 && ( + + {(option) => {option.saleStoreName}} + + )} +
@@ -384,7 +453,6 @@ export default function StuffDetail() { className="input-origin" maxLength={7} {...form.register('zipNo', { - required: true, minLength: { value: 7, message: '7자리만가능' }, pattern: { value: /^[0-9]*$/g, message: '숫자만 입력' }, })} @@ -398,7 +466,7 @@ export default function StuffDetail() {
{prefCodeList?.length > 0 && ( - {prefCodeList.map((row) => { return {row.prefName} })} @@ -414,7 +482,7 @@ export default function StuffDetail() { + + setName2(e.target.value)} /> -
-
- -
-
- 물건명 후리가나 - setName3(e.target.value)} /> -
-
*/} - {/*
- 판매점명 /ID * -
- - {(option) => {option.name}} - -
-
*/} - {/*
- 우편번호* - - - *우편번호 7자리를 입력한 후, 주소검색 버튼을 클릭해 주십시오 -
*/} - {/*
- 도도부현 / 주소* - -
*/} - {/*
- 발전량시뮬레이션지역* - -
-
- 기준풍속* - - m/s이하 -
-
- 수직적설량* - cm - - 한랭지대책시행 - -
*/} - {/*
- 면조도구분* - { - setGubun2(e.target.value) - }} - /> - - { - setGubun2(e.target.value) - }} - /> - - - 염해지역용아이템사용 - -
-
- 설치높이* - - m -
-
- 계약조건 - { - setGubun3(e.target.value) - }} - /> - - { - setGubun3(e.target.value) - }} - /> - -
-
- 메모 -