|
|
|
@ -1,4 +1,3 @@
|
|
|
|
|
import { makeAutoObservable, runInAction } from "mobx"
|
|
|
|
|
import { create } from 'zustand'
|
|
|
|
|
import { fetchJSON, postForm } from '@/utils/request'
|
|
|
|
|
import { HT_HOST } from "@/config"
|
|
|
|
@ -211,88 +210,65 @@ const useReservationStore = create((set, get) => ({
|
|
|
|
|
return json
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
export default useReservationStore
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
export class Reservation {
|
|
|
|
|
setupCityGuide: (cityId, guideId) => {
|
|
|
|
|
const { selectedReservation } = get()
|
|
|
|
|
const { userId, travelAgencyId } = usingStorage()
|
|
|
|
|
const formData = new FormData()
|
|
|
|
|
formData.append('GRI_SN', selectedReservation.reservationId)
|
|
|
|
|
formData.append('VEI_SN', travelAgencyId)
|
|
|
|
|
formData.append('TGI_SN', guideId)
|
|
|
|
|
formData.append('CII_SN', cityId)
|
|
|
|
|
formData.append('GetDate', selectedReservation.reservationDate)
|
|
|
|
|
formData.append('LMI_SN', userId)
|
|
|
|
|
const postUrl = HT_HOST + '/service-cusservice/PTAddGuide'
|
|
|
|
|
|
|
|
|
|
constructor(root) {
|
|
|
|
|
makeAutoObservable(this, { rootStore: false });
|
|
|
|
|
this.root = root;
|
|
|
|
|
return postForm(postUrl, formData)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode != 0) {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode)
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateReservationGuide() {
|
|
|
|
|
|
|
|
|
|
updateReservationGuide: () => {
|
|
|
|
|
const { selectedReservation } = get()
|
|
|
|
|
const { travelAgencyId } = usingStorage()
|
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetCityGuide')
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
.append('GRI_SN', this.selectedReservation.reservationId)
|
|
|
|
|
.append('VEI_SN', travelAgencyId)
|
|
|
|
|
.append('GRI_SN', selectedReservation.reservationId)
|
|
|
|
|
.append('LGC', 1)
|
|
|
|
|
.append("token", this.root.authStore.login.token)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
return fetchJSON(fetchUrl)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
const reservationGuide = (json?.Result??[]).filter((data) => {
|
|
|
|
|
return data.TGI_SN != 0;
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return data.GuideName
|
|
|
|
|
}).join(',')
|
|
|
|
|
|
|
|
|
|
setupCityGuide(cityId, guideId) {
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
formData.append('GRI_SN', this.selectedReservation.reservationId);
|
|
|
|
|
formData.append('VEI_SN', this.root.authStore.login.travelAgencyId);
|
|
|
|
|
formData.append('TGI_SN', guideId);
|
|
|
|
|
formData.append('CII_SN', cityId);
|
|
|
|
|
formData.append('GetDate', this.selectedReservation.reservationDate);
|
|
|
|
|
formData.append('LMI_SN', this.root.authStore.login.userId);
|
|
|
|
|
formData.append("token", this.root.authStore.login.token);
|
|
|
|
|
const postUrl = HT_HOST + '/service-cusservice/PTAddGuide';
|
|
|
|
|
|
|
|
|
|
return postForm(postUrl, formData)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode != 0) {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePropertyValue(name, value) {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
this[name] = value;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cityList = [];
|
|
|
|
|
|
|
|
|
|
selectedReservation = null;
|
|
|
|
|
selectedConfirmation = null;
|
|
|
|
|
arrivalDateRange = [];
|
|
|
|
|
referenceNo = '';
|
|
|
|
|
|
|
|
|
|
reservationList = [];
|
|
|
|
|
selectedReservation.guide = reservationGuide
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
reservationDetail = {
|
|
|
|
|
referenceNumber: '', arrivalDate: '', tourGuide: ''
|
|
|
|
|
};
|
|
|
|
|
set((state) => ({
|
|
|
|
|
selectedReservation: {
|
|
|
|
|
...state.selectedReservation,
|
|
|
|
|
guide: reservationGuide,
|
|
|
|
|
},
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
reservationPage = {
|
|
|
|
|
current: 1,
|
|
|
|
|
size: 10,
|
|
|
|
|
total: 0
|
|
|
|
|
return reservationGuide
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
confirmationList = [
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
export default useReservationStore
|