|
|
|
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
|
|
|
import { fetchJSON, postForm } from '@/utils/request';
|
|
|
|
|
import { HT_HOST } from "@/config";
|
|
|
|
|
import { prepareUrl } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
class Reservation {
|
|
|
|
|
|
|
|
|
|
constructor(root) {
|
|
|
|
|
makeAutoObservable(this, { rootStore: false });
|
|
|
|
|
this.root = root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchReservationList(current, status=null) {
|
|
|
|
|
const fromDate = this.arrivalDateRange.length == 0 ? null : this.arrivalDateRange[0].format('YYYY-MM-DD');
|
|
|
|
|
const thruDate = this.arrivalDateRange.length == 0 ? null : this.arrivalDateRange[1].format('YYYY-MM-DD');
|
|
|
|
|
this.reservationPage.current = current;
|
|
|
|
|
// 设置为 0,后端会重新计算总数,当跳转第 X 页时可用原来的总数。
|
|
|
|
|
const totalNum = current == 1 ? 0 : this.reservationPage.total;
|
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/GetPlanSearchList')
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
.append('GroupNo', this.referenceNo)
|
|
|
|
|
.append('DateStart', fromDate)
|
|
|
|
|
.append('DateEnd', thruDate)
|
|
|
|
|
.append('NotConfirm', status)
|
|
|
|
|
.append('TotalNum', totalNum)
|
|
|
|
|
.append('PageSize', this.reservationPage.size)
|
|
|
|
|
.append('PageIndex', this.reservationPage.current)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
return fetchJSON(fetchUrl)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
this.reservationList = (json?.Result??[]).map((data, index) => {
|
|
|
|
|
return {
|
|
|
|
|
key: data.vas_gri_sn,
|
|
|
|
|
reservationId: data.vas_gri_sn,
|
|
|
|
|
referenceNumber: data.GriName,
|
|
|
|
|
arrivalDate: data.GetGDate,
|
|
|
|
|
pax: data.PersonNum,
|
|
|
|
|
status: data.GState,
|
|
|
|
|
reservationDate: data.SendDate,
|
|
|
|
|
guide: data.Guide
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.reservationPage.total = (json?.Result??[{RsTotal: 0}])[0].RsTotal;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchReservation(reservationId) {
|
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/GetPlanInfo')
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
.append('GRI_SN', reservationId)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
return fetchJSON(fetchUrl)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
this.reservationDetail = {
|
|
|
|
|
referenceNumber: json.PlanDetail[0].GRI_Name,
|
|
|
|
|
tourGuide: json.PlanDetail[0].Guide,
|
|
|
|
|
arrivalDate: json.PlanDetail[0].eoi_getdate,
|
|
|
|
|
reservationId: reservationId
|
|
|
|
|
};
|
|
|
|
|
this.confirmationList = (json?.PlanChange??[]).map((data, index) => {
|
|
|
|
|
return {
|
|
|
|
|
key: data.PCI_SN,
|
|
|
|
|
PCI_Changetext: data.PCI_Changetext,
|
|
|
|
|
PCI_SendDate: data.PCI_SendDate,
|
|
|
|
|
ConfirmPerson: data.ConfirmPerson,
|
|
|
|
|
PCI_ConfirmText: data.PCI_ConfirmText,
|
|
|
|
|
PCI_ConfirmDate: data.PCI_ConfirmDate,
|
|
|
|
|
VAS_SN: data.PCI_VAS_SN
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
return json;
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fetchCityList(reservationId) {
|
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetCityGuide')
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
.append('GRI_SN', reservationId)
|
|
|
|
|
.append('LGC', 1)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
return fetchJSON(fetchUrl)
|
|
|
|
|
.then(json => {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
this.cityList = (json?.Result??[]).map((data, index) => {
|
|
|
|
|
return {
|
|
|
|
|
key: data.CII_SN,
|
|
|
|
|
cityId: data.CII_SN,
|
|
|
|
|
cityName: data.CityName,
|
|
|
|
|
tourGuideId: data.TGI_SN,
|
|
|
|
|
tourGuide: data.GuideName
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
const postUrl = HT_HOST + '/service-cusservice/PTAddGuide';
|
|
|
|
|
|
|
|
|
|
return postForm(postUrl, formData)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode != 0) {
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submitConfirmation(confirmText) {
|
|
|
|
|
let formData = new FormData();
|
|
|
|
|
formData.append('PCI_SN', this.selectedConfirmation.key);
|
|
|
|
|
formData.append('OPSN', this.root.authStore.login.userId);
|
|
|
|
|
formData.append('ConfirmText', confirmText);
|
|
|
|
|
formData.append('VAS_SN', this.selectedConfirmation.VAS_SN);
|
|
|
|
|
|
|
|
|
|
const postUrl = HT_HOST + '/service-cusservice/PTConfirmPlanChange';
|
|
|
|
|
|
|
|
|
|
return postForm(postUrl, formData)
|
|
|
|
|
.then(json => {
|
|
|
|
|
if (json.errcode == 0 && json.Result.length == 1) {
|
|
|
|
|
this.fetchReservation(this.reservationDetail.reservationId);
|
|
|
|
|
return json;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
editReservation(reservation) {
|
|
|
|
|
this.selectedReservation = reservation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
editConfirmation(confirmation) {
|
|
|
|
|
this.selectedConfirmation = confirmation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updatePropertyValue(name, value) {
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
this[name] = value;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cityGuideList = [];
|
|
|
|
|
cityList = [];
|
|
|
|
|
|
|
|
|
|
selectedReservation = null;
|
|
|
|
|
selectedConfirmation = null;
|
|
|
|
|
arrivalDateRange = [];
|
|
|
|
|
referenceNo = '';
|
|
|
|
|
|
|
|
|
|
reservationList = [];
|
|
|
|
|
|
|
|
|
|
reservationDetail = {
|
|
|
|
|
referenceNumber: '', arrivalDate: '', tourGuide: ''
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reservationPage = {
|
|
|
|
|
current: 1,
|
|
|
|
|
size: 10,
|
|
|
|
|
total: 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
confirmationList = [
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Reservation;
|