Merge remote-tracking branch 'origin/main'

feature/price_manager
Lei OT 1 year ago
commit a608c457b8

@ -29,19 +29,17 @@ const useReservationStore = create((set, get) => ({
], ],
fetchReservationList: (travelAgencyId, formVal, current=1) => { fetchReservationList: (travelAgencyId, formVal, current=1) => {
const fromDate = null //this.arrivalDateRange.length == 0 ? null : this.arrivalDateRange[0].format('YYYY-MM-DD'); const { reservationPage } = get()
const thruDate = null //this.arrivalDateRange.length == 0 ? null : this.arrivalDateRange[1].format('YYYY-MM-DD');
// this.reservationPage.current = current;
// 设置为 0后端会重新计算总数当跳转第 X 页时可用原来的总数。 // 设置为 0后端会重新计算总数当跳转第 X 页时可用原来的总数。
const totalNum = 0//current == 1 ? 0 : this.reservationPage.total; const totalNum = current == 1 ? 0 : reservationPage.total;
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/GetPlanSearchList') const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/GetPlanSearchList')
.append('VEI_SN', travelAgencyId) .append('VEI_SN', travelAgencyId)
.append('GroupNo', formVal.referenceNo) .append('GroupNo', formVal.referenceNo)
.append('DateStart', formVal.fromDate) .append('DateStart', formVal.startdate)
.append('DateEnd', formVal.thruDate) .append('DateEnd', formVal.enddate)
.append('NotConfirm', '')//status) .append('NotConfirm', '')//status)
.append('TotalNum', totalNum) .append('TotalNum', totalNum)
.append('PageSize', 5)//this.reservationPage.size) .append('PageSize', reservationPage.size)
.append('PageIndex', current) .append('PageIndex', current)
.build(); .build();
@ -60,12 +58,12 @@ const useReservationStore = create((set, get) => ({
guide: data.Guide guide: data.Guide
} }
}) })
set((state) => ({ set((state) => ({
reservationList: mapReservationList, reservationList: mapReservationList,
reservationPage: { reservationPage: {
... ...
state.reservationPage, state.reservationPage,
current: current,
total: (json?.Result??[{RsTotal: 0}])[0].RsTotal total: (json?.Result??[{RsTotal: 0}])[0].RsTotal
} }
})) }))

@ -1,22 +1,18 @@
import { NavLink, useLocation } from "react-router-dom"; import { NavLink, useLocation } from 'react-router-dom'
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react'
import { observer } from "mobx-react"; import { Row, Col, Space, Button, Table, Typography, Modal, App, Select } from 'antd'
import { toJS } from "mobx"; import dayjs from 'dayjs'
import { Row, Col, Space, Button, Table, Input, Typography, DatePicker, Modal, App, Select } from 'antd'; import { isEmpty } from '@/utils/commons'
import dayjs from "dayjs"; import { useTranslation } from 'react-i18next'
import { useStore } from '@/stores/StoreContext.js';
import { isEmpty, objectMapper } from "@/utils/commons";
import { useTranslation } from 'react-i18next';
import usePresets from '@/hooks/usePresets';
import useAuthStore from '@/stores/Auth' import useAuthStore from '@/stores/Auth'
import useFormStore from '@/stores/Form'
import useReservationStore from '@/stores/Reservation' import useReservationStore from '@/stores/Reservation'
import SearchForm from '@/components/SearchForm'; import SearchForm from '@/components/SearchForm'
const { Title } = Typography; const { Title } = Typography
function Newest() { function Newest() {
const { t } = useTranslation(); const { t } = useTranslation()
const presets = usePresets();
const reservationListColumns = [ const reservationListColumns = [
{ {
title: t('group:RefNo'), title: t('group:RefNo'),
@ -66,17 +62,17 @@ function Newest() {
function guideRender(text, reservation) { function guideRender(text, reservation) {
if (reservation.guide === '') { if (reservation.guide === '') {
return ( return (
<Space size="middle"> <Space size='middle'>
<Button type="link" onClick={() => showCityGuideModal(reservation)}>{t('Add')}</Button> <Button type='link' onClick={() => showCityGuideModal(reservation)}>{t('Add')}</Button>
</Space> </Space>
); );
} else { } else {
return ( return (
<Space size="middle"> <Space size='middle'>
<span>{reservation.guide}</span> <span>{reservation.guide}</span>
<Button type="link" onClick={() => showCityGuideModal(reservation)}>{t('Edit')}</Button> <Button type='link' onClick={() => showCityGuideModal(reservation)}>{t('Edit')}</Button>
</Space> </Space>
); )
} }
} }
@ -89,8 +85,8 @@ function Newest() {
}} }}
bordered={false} bordered={false}
allowClear allowClear
placeholder="Select a guide" placeholder='Select a guide'
optionFilterProp="children" optionFilterProp='children'
defaultValue={(guideSelectOptions.length == 0 || city.tourGuideId == 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);
@ -103,26 +99,26 @@ function Newest() {
} }
options={toJS(guideSelectOptions)} options={toJS(guideSelectOptions)}
/> />
); )
} }
const location = useLocation(); const location = useLocation()
const [isModalOpen, setIsModalOpen] = useState(false); const [isModalOpen, setIsModalOpen] = useState(false)
const [dataLoading, setDataLoading] = useState(false); const [dataLoading, setDataLoading] = useState(false)
const [guideSelectOptions, setGuideSelectOptions] = useState([]); const [guideSelectOptions, setGuideSelectOptions] = useState([])
const { reservationStore } = useStore();
const loginUser = useAuthStore((state) => state.loginUser)
const [fetchAllGuideList, fetchReservationList, reservationList] = const formValues = useFormStore((state) => state.formValues);
useReservationStore((state) => [state.fetchAllGuideList, state.fetchReservationList, state.reservationList]) const loginUser = useAuthStore((state) => state.loginUser)
const [fetchAllGuideList, fetchReservationList, reservationList, reservationPage, cityList] =
useReservationStore((state) =>
[state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList])
const { reservationPage, cityList } = reservationStore;
const { notification } = App.useApp(); const { notification } = App.useApp();
useEffect (() => { useEffect (() => {
if (location.search !== '?back') { if (location.search !== '?back') {
// //
onSearchClick(1, 1); onSearchClick(1, 1)
} }
fetchAllGuideList(loginUser.travelAgencyId) fetchAllGuideList(loginUser.travelAgencyId)
.then((guideList) => { .then((guideList) => {
@ -131,17 +127,17 @@ function Newest() {
value: data.guideId, value: data.guideId,
label: data.guideName label: data.guideName
} }
}); })
// setGuideSelectOptions(selectOptions); setGuideSelectOptions(selectOptions)
}); })
return () => { return () => {
// unmount... // unmount...
}; };
}, []); }, [])
const showCityGuideModal = (reservation) => { const showCityGuideModal = (reservation) => {
setDataLoading(true); setDataLoading(true)
setIsModalOpen(true); setIsModalOpen(true)
reservationStore.editReservation(reservation); reservationStore.editReservation(reservation);
reservationStore.fetchCityList(reservation.reservationId) reservationStore.fetchCityList(reservation.reservationId)
.catch(ex => { .catch(ex => {
@ -150,28 +146,28 @@ function Newest() {
description: ex.message, description: ex.message,
placement: 'top', placement: 'top',
duration: 4, duration: 4,
}); })
}) })
.finally(() => { .finally(() => {
setDataLoading(false); setDataLoading(false);
}); })
}; };
const handleOk = () => { const handleOk = () => {
reservationStore.updateReservationGuide() reservationStore.updateReservationGuide()
.finally(() => { .finally(() => {
setIsModalOpen(false); setIsModalOpen(false);
setDataLoading(false); setDataLoading(false);
}); })
}; };
const handleCancel = () => { const handleCancel = () => {
setIsModalOpen(false); setIsModalOpen(false);
setDataLoading(false); setDataLoading(false);
}; }
// //
const onSearchClick = (current=1, status=null) => { const onSearchClick = (current=1, status=null) => {
setDataLoading(true) setDataLoading(true)
fetchReservationList(loginUser.travelAgencyId, current, status) fetchReservationList(loginUser.travelAgencyId, formValues, current)
.catch(ex => { .catch(ex => {
notification.error({ notification.error({
message: `Notification`, message: `Notification`,
@ -191,7 +187,7 @@ function Newest() {
centered centered
open={isModalOpen} onOk={handleOk} onCancel={handleCancel} open={isModalOpen} onOk={handleOk} onCancel={handleCancel}
> >
<Space direction="vertical" style={{ width: '100%' }}> <Space direction='vertical' style={{ width: '100%' }}>
<Row> <Row>
<Col span={24}> <Col span={24}>
<Table <Table
@ -211,13 +207,13 @@ function Newest() {
render: cityGuideRender, render: cityGuideRender,
} }
]} ]}
dataSource={toJS(cityList)} dataSource={cityList}
/> />
</Col> </Col>
</Row> </Row>
</Space> </Space>
</Modal> </Modal>
<Space direction="vertical" style={{ width: '100%' }}> <Space direction='vertical' style={{ width: '100%' }}>
<Title level={3}></Title> <Title level={3}></Title>
<SearchForm <SearchForm
// initialValue={ // initialValue={
@ -235,7 +231,7 @@ function Newest() {
fetchReservationList(loginUser.travelAgencyId, formVal) fetchReservationList(loginUser.travelAgencyId, formVal)
.catch(ex => { .catch(ex => {
notification.error({ notification.error({
message: `Notification`, message: 'Notification',
description: ex.message, description: ex.message,
placement: 'top', placement: 'top',
duration: 4, duration: 4,
@ -267,7 +263,7 @@ function Newest() {
</Row> </Row>
</Space> </Space>
</> </>
); )
} }
export default observer(Newest); export default Newest

Loading…
Cancel
Save