diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index 4e21c0f5..c480b055 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -16,6 +16,8 @@ import FindAddressPop from './popup/FindAddressPop' import PlanRequestPop from './popup/PlanRequestPop' import WindSelectPop from './popup/WindSelectPop' export default function StuffDetail() { + const [selOptions, setSelOptions] = useState('') + const sessionState = useRecoilValue(sessionStore) const router = useRouter() @@ -107,14 +109,18 @@ export default function StuffDetail() { // 임시 1차점 판매점코드 saleStoreId=201TES01 // T01 - //1차점 : X167 - get({ url: `/api/object/saleStore/T01/list` }).then((res) => { - // get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { + //1차점 : X167 T01 + // get({ url: `/api/object/saleStore/TEMP02/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) @@ -125,8 +131,6 @@ export default function StuffDetail() { useEffect(() => { if (isObjectNotEmpty(detailData)) { - console.log('상세데이타:::::::', detailData) - // 도도부현API get({ url: '/api/object/prefecture/list' }).then((res) => { if (!isEmptyArray(res)) { @@ -151,6 +155,8 @@ export default function StuffDetail() { setOtherSaleStoreList(otherList) } }) + + console.log('상세데이타::세팅:::::', detailData) } }, [detailData]) @@ -161,12 +167,14 @@ export default function StuffDetail() { form.setValue('saleStoreId', key.saleStoreId) form.setValue('saleStoreName', key.saleStoreName) form.setValue('saleStoreLevel', key.saleStoreLevel) + setSelOptions(key.saleStoreId) //선택한 1차점 정보로 2차점 list 추리기 //長府工産株式会社 大阪支社 let newOtherSaleStoreList = originOtherSaleStoreList.filter((row) => row.firstAgentId === key.saleStoreId) setOtherSaleStoreList(newOtherSaleStoreList) } else { //X누름 + setSelOptions('') form.setValue('saleStoreId', '') form.setValue('saleStoreName', '') form.setValue('saleStoreLevel', '') @@ -212,6 +220,12 @@ export default function StuffDetail() { //팝업에서 넘어온 설계의뢰 정보로 바꾸기 const setPlanReqInfo = (info) => { console.log('팝업에서 넘어온 설계의뢰 정보::: ', info) + //building : 신축 기축 + //planReqName : 물건명 + //zipNo : 우편번호 + //도도부현 :address1 주소 : address2 미세팅 + //기준풍속 팝업열려면 setPrefValue(info.prefId) 필요 + //기준풍속 : // form.setValue('dispCompanyName', info.planReqName) } @@ -549,6 +563,9 @@ export default function StuffDetail() { getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} isClearable={true} + value={saleStoreList.filter(function (option) { + return option.saleStoreId === selOptions + })} />
diff --git a/src/components/management/StuffSearchCondition.jsx b/src/components/management/StuffSearchCondition.jsx index b33608cf..3717e43f 100644 --- a/src/components/management/StuffSearchCondition.jsx +++ b/src/components/management/StuffSearchCondition.jsx @@ -18,7 +18,6 @@ import { useMessage } from '@/hooks/useMessage' import { isObjectNotEmpty } from '@/util/common-utils' export default function StuffSearchCondition() { const sessionState = useRecoilValue(sessionStore) - const [appMessageState, setAppMessageState] = useRecoilState(appMessageStore) const globalLocaleState = useRecoilValue(globalLocaleStore) const { getMessage } = useMessage() @@ -74,10 +73,6 @@ export default function StuffSearchCondition() { startRow: stuffSearch?.startRow ? stuffSearch.startRow : 1, endRow: stuffSearch?.endRow ? stuffSearch.endRow : 100, schSortType: stuffSearch?.schSortType ? stuffSearch.schSortType : 'R', - selObject: { - label: stuffSearch.selObject.label, - value: stuffSearch.selObject.value, - }, }) } @@ -100,7 +95,7 @@ export default function StuffSearchCondition() { useEffect(() => { if (isObjectNotEmpty(sessionState)) { // storeId가 T01 이거나 1차점일때만 판매대리점 선택 활성화 - // get({ url: `/api/object/saleStore/201TES01/list` }).then((res) => { + // get({ url: `/api/object/saleStore/TEMP02/list` }).then((res) => { get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { if (!isEmptyArray(res)) { res.map((row) => { @@ -128,7 +123,6 @@ export default function StuffSearchCondition() { ...stuffSearch, code: 'S', schSelSaleStoreId: key.saleStoreId, - selObject: { value: key.saleStoreId, label: key.saleStoreName }, }) } else { setSchSelSaleStoreId('') @@ -268,7 +262,21 @@ export default function StuffSearchCondition() { onChange={onSelectionChange} getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} - defaultValue={stuffSearch?.selObject?.value ? stuffSearch?.selObject : null} + value={schSelSaleStoreList.filter(function (option) { + if (stuffSearch?.code === 'S' && schSelSaleStoreId === '') { + return false + } else if (stuffSearch?.code === 'S' && schSelSaleStoreId !== '') { + return option.saleStoreId === schSelSaleStoreId + } else if (stuffSearch?.code === 'E' && schSelSaleStoreId !== '') { + return option.saleStoreId === schSelSaleStoreId + } else { + if (stuffSearch?.schSelSaleStoreId !== '') { + return option.saleStoreId === stuffSearch.schSelSaleStoreId + } else { + return false + } + } + })} isDisabled={sessionState?.storeLvl === '1' ? false : true} isClearable={true} /> diff --git a/src/store/stuffAtom.js b/src/store/stuffAtom.js index ceb5def0..c47321ae 100644 --- a/src/store/stuffAtom.js +++ b/src/store/stuffAtom.js @@ -18,10 +18,6 @@ export const stuffSearchState = atom({ startRow: 1, endRow: 100, schSortType: 'R', //정렬조건 (R:최근등록일 U:최근수정일) - selObject: { - value: '', - label: '', - }, }, dangerouslyAllowMutability: true, })