diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index 87159dee..5f33218f 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -20,7 +20,8 @@ import { useCommonCode } from '@/hooks/common/useCommonCode' export default function StuffDetail() { //공통코드 const { commonCode, findCommonCode } = useCommonCode() - const [selOptions, setSelOptions] = useState('') + const [selOptions, setSelOptions] = useState('') //선택한 1차점 + const [otherSelOptions, setOtherSelOptions] = useState('') //선택한 1차점외 const sessionState = useRecoilValue(sessionStore) @@ -113,23 +114,31 @@ export default function StuffDetail() { } }) - // 임시 1차점 판매점코드 saleStoreId=201TES01 - // T01 //1차점 : X167 T01 - // get({ url: `/api/object/saleStore/T01/list` }).then((res) => { - get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { + //2차점 : 10X22, 201X112 + get({ url: `/api/object/saleStore/T100/list` }).then((res) => { + // get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { if (!isEmptyArray(res)) { const firstList = res.filter((row) => row.saleStoreLevel === '1') const otherList = res.filter((row) => row.saleStoreLevel !== '1') + //1차점 셀렉트박스 setSaleStoreList(firstList) - setSelOptions(sessionState?.storeId) - form.setValue('saleStoreId', sessionState?.storeId) - form.setValue('saleStoreLevel', sessionState?.storeLvl) - //1차점 아닌 판매점 셀렉트박스 setOriginOtherSaleStoreList(otherList) setOtherSaleStoreList(otherList) + + if (sessionState?.storeLvl === '1') { + setSelOptions(sessionState?.storeId) + form.setValue('saleStoreId', sessionState?.storeId) + form.setValue('saleStoreLevel', sessionState?.storeLvl) + } else { + setSelOptions(firstList[0].saleStoreId) + setOtherSelOptions(sessionState?.storeId) + form.setValue('saleStoreId', firstList[0].saleStoreId) + form.setValue('otherSaleStoreId', sessionState?.storeId) + form.setValue('otherSaleStoreLevel', sessionState?.storeLvl) + } } }) } @@ -158,7 +167,6 @@ export default function StuffDetail() { // 도도부현API get({ url: '/api/object/prefecture/list' }).then((res) => { if (!isEmptyArray(res)) { - // console.log('도도부현API 결과:::', res) setPrefCodeList(res) } }) @@ -234,10 +242,12 @@ export default function StuffDetail() { //2차점 변경 이벤트 const onSelectionChange2 = (key) => { if (isObjectNotEmpty(key)) { + setOtherSelOptions(key.saleStoreId) form.setValue('otherSaleStoreId', key.saleStoreId) form.setValue('otherSaleStoreName', key.saleStoreName) form.setValue('otherSaleStoreLevel', key.saleStoreLevel) } else { + setOtherSelOptions('') form.setValue('otherSaleStoreId', '') form.setValue('otherSaleStoreName', '') form.setValue('otherSaleStoreLevel', '') @@ -268,7 +278,6 @@ export default function StuffDetail() { form.setValue('objectName', info.planReqName) form.setValue('zipNo', info.zipNo) form.setValue('address', info.address2) - // console.log('팝업에서 넘어온 설계의뢰 정보::: ', info) prefCodeList.map((row) => { if (row.prefName == info.address1) { @@ -277,19 +286,23 @@ export default function StuffDetail() { form.setValue('prefName', info.address1) } }) - - if (info.saleStoreLevel === '1') { - setSelOptions(info.saleStoreId) - form.setValue('saleStoreId', info.saleStoreName) - } else { - console.log('설계의뢰 정보가 2차점인경우::::::::::::', info) - } form.setValue('windSpeed', info.windSpeed) form.setValue('verticalSnowCover', info.verticalSnowCover) form.setValue('surfaceType', info.surfaceType) - //설치 높이 installHeight form.setValue('installHeight', info.installHeight) form.setValue('remarks', info.remarks) + + if (info.saleStoreLevel === '1') { + setSelOptions(info.saleStoreId) + form.setValue('saleStoreId', info.saleStoreId) + form.setValue('saleStoreName', key.saleStoreName) + form.setValue('saleStoreLevel', key.saleStoreLevel) + } else { + setOtherSelOptions(info.saleStoreId) + form.setValue('otherSaleStoreId', info.saleStoreId) + form.setValue('otherSaleStoreName', info.saleStoreName) + form.setValue('otherSaleStoreLevel', info.saleStoreLevel) + } } //팝업에서 넘어온 바람정보 @@ -636,9 +649,8 @@ export default function StuffDetail() { onChange={onSelectionChange} getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} - isClearable={true} + isClearable={sessionState?.storeLvl === '1' ? true : false} value={saleStoreList.filter(function (option) { - // console.log('1차점::::::', selOptions) return option.saleStoreId === selOptions })} /> @@ -672,12 +684,11 @@ export default function StuffDetail() { onChange={onSelectionChange2} getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} - isDisabled={form.watch('saleStoreId') !== '' ? false : true} - isClearable={true} - //value={otherSaleStoreList.filter(function (option) { - // console.log('2차점::::::', option) - // return option.saleStoreId === selOptions - //})} + isDisabled={sessionState?.storeLvl === '1' && form.watch('saleStoreId') != '' ? false : true} + isClearable={sessionState?.storeLvl === '1' ? true : false} + value={otherSaleStoreList.filter(function (option) { + return option.saleStoreId === otherSelOptions + })} />
diff --git a/src/components/management/popup/PlanRequestPop.jsx b/src/components/management/popup/PlanRequestPop.jsx index 3ecb4e76..cde86d6b 100644 --- a/src/components/management/popup/PlanRequestPop.jsx +++ b/src/components/management/popup/PlanRequestPop.jsx @@ -85,6 +85,7 @@ export default function PlanRequestPop(props) { // 조회 const onSubmit = (page, type) => { + //2차점 테스트 201X112 const params = { // saleStoreId: 'T100', // saleStoreLevel: '1',