|
|
@ -1,8 +1,39 @@
|
|
|
|
import { makeAutoObservable, runInAction } from "mobx";
|
|
|
|
import { makeAutoObservable, runInAction } from "mobx"
|
|
|
|
import { fetchJSON, postForm } from '@/utils/request';
|
|
|
|
|
|
|
|
import { HT_HOST } from "@/config";
|
|
|
|
|
|
|
|
import { prepareUrl } from '@/utils/commons';
|
|
|
|
|
|
|
|
import { create } from 'zustand'
|
|
|
|
import { create } from 'zustand'
|
|
|
|
|
|
|
|
import { fetchJSON, postForm } from '@/utils/request'
|
|
|
|
|
|
|
|
import { HT_HOST } from "@/config"
|
|
|
|
|
|
|
|
import { prepareUrl } from '@/utils/commons'
|
|
|
|
|
|
|
|
import { useStorage } from '@/hooks/useStorage'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const fetchCityList = async (travelAgencyId, reservationId) => {
|
|
|
|
|
|
|
|
const { errcode, Result } = await fetchJSON(
|
|
|
|
|
|
|
|
`${HT_HOST}/service-cusservice/PTGetCityGuide`,
|
|
|
|
|
|
|
|
{ VEI_SN: travelAgencyId, GRI_SN: reservationId, LGC: 1 })
|
|
|
|
|
|
|
|
return errcode !== 0 ? {} : Result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const fetchPlanDetail = async (travelAgencyId, reservationId) => {
|
|
|
|
|
|
|
|
const json = await fetchJSON(
|
|
|
|
|
|
|
|
`${HT_HOST}/service-cusservice/GetPlanInfo`,
|
|
|
|
|
|
|
|
{ VEI_SN: travelAgencyId, GRI_SN: reservationId })
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
planDetail: json.PlanDetail[0],
|
|
|
|
|
|
|
|
planChangeList: json.PlanChange??[]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const fetchAttachList = async (reservationId) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { errcode, result } = await fetchJSON(
|
|
|
|
|
|
|
|
`${HT_HOST}/service-fileServer/PlanChangeFileList`,
|
|
|
|
|
|
|
|
{ GRI_SN: reservationId })
|
|
|
|
|
|
|
|
return errcode !== 0 ? {} : result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const useReservationStore = create((set, get) => ({
|
|
|
|
const useReservationStore = create((set, get) => ({
|
|
|
|
|
|
|
|
|
|
|
@ -28,7 +59,41 @@ const useReservationStore = create((set, get) => ({
|
|
|
|
confirmationList: [
|
|
|
|
confirmationList: [
|
|
|
|
],
|
|
|
|
],
|
|
|
|
|
|
|
|
|
|
|
|
fetchReservationList: (travelAgencyId, formVal, current=1) => {
|
|
|
|
getCityListByReservationId: async (reservationId) => {
|
|
|
|
|
|
|
|
const { travelAgencyId } = useStorage()
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
|
|
|
cityList: []
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cityListJson = await fetchCityList(travelAgencyId, reservationId)
|
|
|
|
|
|
|
|
const mapCityList = cityListJson.map((data) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
key: data.CII_SN,
|
|
|
|
|
|
|
|
cityId: data.CII_SN,
|
|
|
|
|
|
|
|
cityName: data.CityName,
|
|
|
|
|
|
|
|
tourGuideId: data.TGI_SN,
|
|
|
|
|
|
|
|
tourGuide: data.GuideName
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
|
|
|
cityList: mapCityList
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectReservation: (reservation) => {
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
|
|
|
selectedReservation: reservation
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectConfirmation: (confirmation) => {
|
|
|
|
|
|
|
|
set(() => ({
|
|
|
|
|
|
|
|
selectedConfirmation: confirmation
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchReservationList: (formVal, current=1) => {
|
|
|
|
|
|
|
|
const { travelAgencyId } = useStorage()
|
|
|
|
const { reservationPage } = get()
|
|
|
|
const { reservationPage } = get()
|
|
|
|
// 设置为 0,后端会重新计算总数,当跳转第 X 页时可用原来的总数。
|
|
|
|
// 设置为 0,后端会重新计算总数,当跳转第 X 页时可用原来的总数。
|
|
|
|
const totalNum = current == 1 ? 0 : reservationPage.total;
|
|
|
|
const totalNum = current == 1 ? 0 : reservationPage.total;
|
|
|
@ -37,7 +102,7 @@ const useReservationStore = create((set, get) => ({
|
|
|
|
.append('GroupNo', formVal.referenceNo)
|
|
|
|
.append('GroupNo', formVal.referenceNo)
|
|
|
|
.append('DateStart', formVal.startdate)
|
|
|
|
.append('DateStart', formVal.startdate)
|
|
|
|
.append('DateEnd', formVal.enddate)
|
|
|
|
.append('DateEnd', formVal.enddate)
|
|
|
|
.append('NotConfirm', '')//status)
|
|
|
|
.append('NotConfirm', '')//status)// Todo: 待解决
|
|
|
|
.append('TotalNum', totalNum)
|
|
|
|
.append('TotalNum', totalNum)
|
|
|
|
.append('PageSize', reservationPage.size)
|
|
|
|
.append('PageSize', reservationPage.size)
|
|
|
|
.append('PageIndex', current)
|
|
|
|
.append('PageIndex', current)
|
|
|
@ -73,7 +138,8 @@ const useReservationStore = create((set, get) => ({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
fetchAllGuideList: (travelAgencyId) => {
|
|
|
|
fetchAllGuideList: () => {
|
|
|
|
|
|
|
|
const { userId, travelAgencyId } = useStorage()
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetGuideList')
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetGuideList')
|
|
|
|
.append('VEI_SN', travelAgencyId)
|
|
|
|
.append('VEI_SN', travelAgencyId)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
@ -94,103 +160,13 @@ const useReservationStore = create((set, get) => ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default useReservationStore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export 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)
|
|
|
|
|
|
|
|
.append("token", this.root.authStore.login.token)
|
|
|
|
|
|
|
|
.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 fetchDetailUrl = prepareUrl(HT_HOST + '/service-cusservice/GetPlanInfo')
|
|
|
|
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
|
|
|
|
.append('GRI_SN', reservationId)
|
|
|
|
|
|
|
|
.append("token", this.root.authStore.login.token)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
// https://p9axztuwd7x8a7.mycht.cn/service-fileServer/PlanChangeFileList
|
|
|
|
|
|
|
|
const fetchAttachmentUrl = prepareUrl(HT_HOST + '/service-fileServer/PlanChangeFileList')
|
|
|
|
|
|
|
|
.append('GRI_SN', reservationId)
|
|
|
|
|
|
|
|
.append("token", this.root.authStore.login.token)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const attachmentPromise = fetchJSON(fetchAttachmentUrl)
|
|
|
|
|
|
|
|
.then(json => {
|
|
|
|
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const detailPromise = fetchJSON(fetchDetailUrl)
|
|
|
|
getReservationDetail: async (travelAgencyId, reservationId) => {
|
|
|
|
.then(json => {
|
|
|
|
const { planDetail, planChangeList } = await fetchPlanDetail(travelAgencyId, reservationId)
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
const attachListJson = await fetchAttachList(reservationId)
|
|
|
|
return json;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw new Error(json.errmsg + ': ' + json.errcode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.all([attachmentPromise, detailPromise])
|
|
|
|
const mapConfirmationList = planChangeList.map((data) => {
|
|
|
|
.then(results => {
|
|
|
|
const filterAttchList = attachListJson.filter(attch => {
|
|
|
|
const attachList = results[0].result;
|
|
|
|
|
|
|
|
const planDetail = results[1].PlanDetail[0];
|
|
|
|
|
|
|
|
const planChange = results[1]?.PlanChange??[];
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
|
|
|
this.reservationDetail = {
|
|
|
|
|
|
|
|
referenceNumber: planDetail.GRI_Name,
|
|
|
|
|
|
|
|
tourGuide: planDetail.Guide,
|
|
|
|
|
|
|
|
arrivalDate: planDetail.eoi_getdate,
|
|
|
|
|
|
|
|
reservationId: reservationId
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
this.confirmationList = planChange.map((data, index) => {
|
|
|
|
|
|
|
|
const filterAttchList = attachList.filter(attch => {
|
|
|
|
|
|
|
|
return attch.PCI_SN === data.PCI_SN;
|
|
|
|
return attch.PCI_SN === data.PCI_SN;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
return {
|
|
|
@ -203,40 +179,47 @@ export class Reservation {
|
|
|
|
VAS_SN: data.PCI_VAS_SN,
|
|
|
|
VAS_SN: data.PCI_VAS_SN,
|
|
|
|
attachmentList: filterAttchList
|
|
|
|
attachmentList: filterAttchList
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchCityList(reservationId) {
|
|
|
|
set(() => ({
|
|
|
|
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetCityGuide')
|
|
|
|
reservationDetail: {
|
|
|
|
.append('VEI_SN', this.root.authStore.login.travelAgencyId)
|
|
|
|
referenceNumber: planDetail.GRI_Name,
|
|
|
|
.append('GRI_SN', reservationId)
|
|
|
|
tourGuide: planDetail.Guide,
|
|
|
|
.append('LGC', 1)
|
|
|
|
arrivalDate: planDetail.eoi_getdate,
|
|
|
|
.append("token", this.root.authStore.login.token)
|
|
|
|
reservationId: reservationId
|
|
|
|
.build();
|
|
|
|
},
|
|
|
|
|
|
|
|
confirmationList: mapConfirmationList
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
runInAction(() => {
|
|
|
|
submitConfirmation: (userId, travelAgencyId, confirmText) => {
|
|
|
|
this.cityList = [];
|
|
|
|
const { selectedConfirmation, getReservationDetail, reservationDetail } = get()
|
|
|
|
});
|
|
|
|
const formData = new FormData()
|
|
|
|
return fetchJSON(fetchUrl)
|
|
|
|
formData.append('PCI_SN', selectedConfirmation.key)
|
|
|
|
|
|
|
|
formData.append('OPSN', userId)
|
|
|
|
|
|
|
|
formData.append('ConfirmText', confirmText)
|
|
|
|
|
|
|
|
formData.append('VAS_SN', selectedConfirmation.VAS_SN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const postUrl = HT_HOST + '/service-cusservice/PTConfirmPlanChange'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return postForm(postUrl, formData)
|
|
|
|
.then(json => {
|
|
|
|
.then(json => {
|
|
|
|
runInAction(() => {
|
|
|
|
if (json.errcode == 0 && json.Result.length == 1) {
|
|
|
|
if (json.errcode == 0) {
|
|
|
|
// this.fetchReservation(this.reservationDetail.reservationId);
|
|
|
|
this.cityList = (json?.Result??[]).map((data, index) => {
|
|
|
|
getReservationDetail(travelAgencyId, reservationDetail.reservationId)
|
|
|
|
return {
|
|
|
|
return json
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}))
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
export default useReservationStore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class Reservation {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(root) {
|
|
|
|
|
|
|
|
makeAutoObservable(this, { rootStore: false });
|
|
|
|
|
|
|
|
this.root = root;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
updateReservationGuide() {
|
|
|
|
updateReservationGuide() {
|
|
|
@ -284,33 +267,6 @@ export class Reservation {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
formData.append("token", this.root.authStore.login.token);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
updatePropertyValue(name, value) {
|
|
|
|
runInAction(() => {
|
|
|
|
runInAction(() => {
|
|
|
|
this[name] = value;
|
|
|
|
this[name] = value;
|
|
|
|