diff --git a/src/stores/Reservation.js b/src/stores/Reservation.js index 451af59..ba53c10 100644 --- a/src/stores/Reservation.js +++ b/src/stores/Reservation.js @@ -93,6 +93,9 @@ class Reservation { .append('LGC', 1) .build(); + runInAction(() => { + this.cityList = []; + }); return fetchJSON(fetchUrl) .then(json => { runInAction(() => { @@ -145,19 +148,18 @@ class Reservation { return fetchJSON(fetchUrl) .then(json => { - runInAction(() => { - if (json.errcode == 0) { - this.cityGuideList = (json?.Result??[]).map((data, index) => { - return { - guideId: data.TGI_SN, - guideName: data.TGI2_Name, - mobileNo: data.TGI_Mobile - } - }); - } else { - throw new Error(json.errmsg + ': ' + json.errcode); - } - }); + if (json.errcode == 0) { + const guideList = (json?.Result??[]).map((data, index) => { + return { + guideId: data.TGI_SN, + guideName: data.TGI2_Name, + mobileNo: data.TGI_Mobile + } + }); + return guideList; + } else { + throw new Error(json.errmsg + ': ' + json.errcode); + } }); } @@ -211,7 +213,6 @@ class Reservation { }); } - cityGuideList = []; cityList = []; selectedReservation = null; diff --git a/src/views/reservation/Newest.jsx b/src/views/reservation/Newest.jsx index fa3972c..7043fd7 100644 --- a/src/views/reservation/Newest.jsx +++ b/src/views/reservation/Newest.jsx @@ -98,22 +98,27 @@ function Newest() { } const location = useLocation(); - const { reservationStore } = useStore(); - const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList, cityGuideList } = reservationStore; const [isModalOpen, setIsModalOpen] = useState(false); const [dataLoading, setDataLoading] = useState(false); + const [guideSelectOptions, setGuideSelectOptions] = useState([]); + const { reservationStore } = useStore(); + const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList } = reservationStore; const { notification } = App.useApp(); - const guideSelectOptions = cityGuideList.map((data, index) => { - return { - value: data.guideId, - label: data.guideName - } - }); useEffect (() => { if (location.search !== '?back') { // 第一页,未确认计划 - onSearchClick(1, 1); + onSearchClick(1, 1); + reservationStore.fetchAllGuideList() + .then((guideList) => { + const selectOptions = guideList.map((data, index) => { + return { + value: data.guideId, + label: data.guideName + } + }); + setGuideSelectOptions(selectOptions); + }); } return () => { // unmount... @@ -124,7 +129,6 @@ function Newest() { setDataLoading(true); setIsModalOpen(true); reservationStore.editReservation(reservation); - reservationStore.fetchAllGuideList(); reservationStore.fetchCityList(reservation.reservationId) .catch(ex => { notification.error({