Merge branch 'main' of github.com:hainatravel/GHHub

release
YCC 2 years ago
commit c4c940ee52

@ -108,7 +108,32 @@ class Reservation {
}); });
} }
fetchGuideList() { updateReservationGuide() {
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetCityGuide')
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
.append('GRI_SN', this.selectedReservation.reservationId)
.append('LGC', 1)
.build();
return fetchJSON(fetchUrl)
.then(json => {
if (json.errcode == 0) {
const reservationGuide = (json?.Result??[]).filter((data) => {
return data.TGI_SN != 0;
}).map((data) => {
return data.GuideName;
}).join(',');
runInAction(() => {
this.selectedReservation.guide = reservationGuide;
});
return reservationGuide;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
}
fetchAllGuideList() {
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetGuideList') const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetGuideList')
.append('VEI_SN', this.root.authStore.login.travelAgencyId) .append('VEI_SN', this.root.authStore.login.travelAgencyId)
.build(); .build();
@ -117,8 +142,7 @@ class Reservation {
.then(json => { .then(json => {
runInAction(() => { runInAction(() => {
if (json.errcode == 0) { if (json.errcode == 0) {
console.info(json.Result); this.cityGuideList = (json?.Result??[]).map((data, index) => {
this.guideList = (json?.Result??[]).map((data, index) => {
return { return {
guideId: data.TGI_SN, guideId: data.TGI_SN,
guideName: data.TGI2_Name, guideName: data.TGI2_Name,
@ -144,7 +168,9 @@ class Reservation {
return postForm(postUrl, formData) return postForm(postUrl, formData)
.then(json => { .then(json => {
console.info(json); if (json.errcode != 0) {
throw new Error(json.errmsg + ': ' + json.errcode);
}
}); });
} }
@ -183,7 +209,7 @@ class Reservation {
}); });
} }
guideList = []; cityGuideList = [];
cityList = []; cityList = [];
selectedReservation = null; selectedReservation = null;

@ -73,7 +73,7 @@ function Newest() {
allowClear allowClear
placeholder="Select a guide" placeholder="Select a guide"
optionFilterProp="children" optionFilterProp="children"
defaultValue={guideSelectOptions.length == 0 ? null : city.tourGuideId} defaultValue={(guideSelectOptions.length == 0 || city.tourGuideId == 0) ? null : city.tourGuideId}
onChange={(guideId) => { onChange={(guideId) => {
reservationStore.setupCityGuide(city.cityId, guideId); reservationStore.setupCityGuide(city.cityId, guideId);
}} }}
@ -90,11 +90,11 @@ function Newest() {
const location = useLocation(); const location = useLocation();
const { reservationStore } = useStore(); const { reservationStore } = useStore();
const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList, guideList } = reservationStore; const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList, cityGuideList } = reservationStore;
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false);
const [dataLoading, setDataLoading] = useState(false); const [dataLoading, setDataLoading] = useState(false);
const { notification } = App.useApp(); const { notification } = App.useApp();
const guideSelectOptions = guideList.map((data, index) => { const guideSelectOptions = cityGuideList.map((data, index) => {
return { return {
value: data.guideId, value: data.guideId,
label: data.guideName label: data.guideName
@ -110,11 +110,11 @@ function Newest() {
}; };
}, []); }, []);
const showCityGuideModal = (reservation) => { const showCityGuideModal = (reservation) => {
setDataLoading(true); setDataLoading(true);
setIsModalOpen(true); setIsModalOpen(true);
reservationStore.editReservation(reservation); reservationStore.editReservation(reservation);
reservationStore.fetchGuideList(); reservationStore.fetchAllGuideList();
reservationStore.fetchCityList(reservation.reservationId) reservationStore.fetchCityList(reservation.reservationId)
.catch(ex => { .catch(ex => {
notification.error({ notification.error({
@ -129,8 +129,11 @@ function Newest() {
}); });
}; };
const handleOk = () => { const handleOk = () => {
setIsModalOpen(false); reservationStore.updateReservationGuide()
setDataLoading(false); .finally(() => {
setIsModalOpen(false);
setDataLoading(false);
});
}; };
const handleCancel = () => { const handleCancel = () => {
setIsModalOpen(false); setIsModalOpen(false);
@ -222,7 +225,7 @@ function Newest() {
simple: true simple: true
}} }}
onChange={(pagination, filters, sorter, extra) => {onSearchClick(pagination.current);}} onChange={(pagination, filters, sorter, extra) => {onSearchClick(pagination.current);}}
columns={reservationListColumns} dataSource={toJS(reservationList)} columns={reservationListColumns} dataSource={reservationList}
/> />
</Col> </Col>
</Row> </Row>

Loading…
Cancel
Save