feat:完成团计划全部迁移 zustand;

增加分页中英文;
feature/price_manager
Jimmy Liow 1 year ago
parent 5913970154
commit bff5197765

@ -18,6 +18,7 @@
"Download": "Download", "Download": "Download",
"Upload": "Upload", "Upload": "Upload",
"preview": "Preview", "preview": "Preview",
"Total": "Total",
"Login": "Login", "Login": "Login",
"Username": "Username", "Username": "Username",

@ -18,6 +18,7 @@
"Download": "下载", "Download": "下载",
"Upload": "上传", "Upload": "上传",
"preview": "预览", "preview": "预览",
"Total": "总数",
"Login": "登录", "Login": "登录",
"Username": "账号", "Username": "账号",

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

@ -1,11 +1,9 @@
import { makeAutoObservable } from "mobx"; import { makeAutoObservable } from "mobx";
import { Reservation } from "./Reservation";
import { Auth } from "./Auth"; import { Auth } from "./Auth";
import {Invoice} from "./Invoice"; import {Invoice} from "./Invoice";
class Root { class Root {
constructor() { constructor() {
this.reservationStore = new Reservation(this);
this.authStore = new Auth(this); this.authStore = new Auth(this);
this.invoiceStore = new Invoice(this); this.invoiceStore = new Invoice(this);
makeAutoObservable(this); makeAutoObservable(this);

@ -147,9 +147,9 @@ function App() {
items: [...[ items: [...[
{ label: <Link to='/account/change-password'>{t('ChangePassword')}</Link>, key: '0' }, { label: <Link to='/account/change-password'>{t('ChangePassword')}</Link>, key: '0' },
{ label: <Link to='/account/profile'>{t('Profile')}</Link>, key: '1' }, { label: <Link to='/account/profile'>{t('Profile')}</Link>, key: '1' },
{ label: <Link to='/account/management'>{t('account:management.tile')}</Link>, key: '1' }, { label: <Link to='/account/management'>{t('account:management.tile')}</Link>, key: '3' },
{ type: 'divider' }, { type: 'divider' },
{ label: <Link to='/logout'>{t('Logout')}</Link>, key: '3' }, { label: <Link to='/logout'>{t('Logout')}</Link>, key: '4' },
], ],
{ type: 'divider' }, { type: 'divider' },
{ label: <>v{BUILD_VERSION}</>, key: 'BUILD_VERSION' }, { label: <>v{BUILD_VERSION}</>, key: 'BUILD_VERSION' },

@ -1,42 +1,37 @@
import { Outlet, Link, useHref, useLocation } from "react-router-dom"; import { Outlet } from 'react-router-dom'
import { useEffect } from "react"; import { Layout, ConfigProvider, theme, Typography, Row, Col, App as AntApp } from 'antd'
import { observer } from "mobx-react"; import 'antd/dist/reset.css'
import { Layout, Menu, ConfigProvider, theme, Typography, Space, Row, Col, Alert, App as AntApp } from "antd"; import AppLogo from '@/assets/logo-gh.png'
import { DownOutlined } from "@ant-design/icons"; import Language from '../i18n/LanguageSwitcher'
import "antd/dist/reset.css";
import AppLogo from "@/assets/logo-gh.png";
import { useStore } from "@/stores/StoreContext.js";
import Language from "../i18n/LanguageSwitcher";
const { Title } = Typography; const { Title } = Typography
const { Header, Content, Footer } = Layout; const { Header, Content, Footer } = Layout
function Standlone() { function Standlone() {
const { authStore } = useStore();
const { const {
token: { colorBgContainer }, token: { colorBgContainer },
} = theme.useToken(); } = theme.useToken()
return ( return (
<ConfigProvider <ConfigProvider
theme={{ theme={{
token: { token: {
colorPrimary: "#00b96b", colorPrimary: '#00b96b',
}, },
algorithm: theme.defaultAlgorithm, algorithm: theme.defaultAlgorithm,
}}> }}>
<AntApp> <AntApp>
<Layout <Layout
style={{ style={{
minHeight: "100vh", minHeight: '100vh',
}}> }}>
<Header className="header" style={{ position: "sticky", top: 0, zIndex: 1, width: "100%" }}> <Header className='header' style={{ position: 'sticky', top: 0, zIndex: 1, width: '100%' }}>
<Row gutter={{ md: 24 }} justify="center"> <Row gutter={{ md: 24 }} justify='center'>
<Col span={4}> <Col span={4}>
<img src={AppLogo} className="logo" alt="App logo" /> <img src={AppLogo} className='logo' alt='App logo' />
</Col> </Col>
<Col span={18}><Title style={{ color: "white", marginTop: "3.5px" }}>Global Highlights Hub</Title></Col> <Col span={18}><Title style={{ color: 'white', marginTop: '3.5px' }}>Global Highlights Hub</Title></Col>
<Col span={2}> <Col span={2}>
<Language /> <Language />
</Col> </Col>
@ -55,7 +50,7 @@ function Standlone() {
</Layout> </Layout>
</AntApp> </AntApp>
</ConfigProvider> </ConfigProvider>
); )
} }
export default observer(Standlone); export default Standlone

@ -205,7 +205,7 @@ function Management() {
} }
// //
const onSearchClick = (current=1, status=null) => { const onSearchClick = (current = 1, status = null) => {
} }
const showDisableConfirm = () => { const showDisableConfirm = () => {
@ -401,9 +401,9 @@ function Management() {
showQuickJumper: true, showQuickJumper: true,
showLessItems: true, showLessItems: true,
showSizeChanger: true, showSizeChanger: true,
showTotal: (total) => { return `总数${total}` } showTotal: (total) => { return t('Total') + `${total}` }
}} }}
onChange={(pagination) => {onSearchClick(pagination.current)}} onChange={(pagination) => { onSearchClick(pagination.current) }}
columns={accountListColumns} dataSource={accountList} columns={accountListColumns} dataSource={accountList}
/> />
</Col> </Col>

@ -82,7 +82,7 @@ function Newest() {
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); setupCityGuide(city.cityId, guideId);
}} }}
onSearch={(value) => { onSearch={(value) => {
// console.log('search:', value); // console.log('search:', value);
@ -102,9 +102,9 @@ function Newest() {
const formValuesToSub = useFormStore((state) => state.formValuesToSub) const formValuesToSub = useFormStore((state) => state.formValuesToSub)
const [fetchAllGuideList, fetchReservationList, reservationList, reservationPage, cityList, selectReservation, getCityListByReservationId] = const [fetchAllGuideList, fetchReservationList, reservationList, reservationPage, cityList, selectReservation, getCityListByReservationId, setupCityGuide, updateReservationGuide] =
useReservationStore((state) => useReservationStore((state) =>
[state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId]) [state.fetchAllGuideList, state.fetchReservationList, state.reservationList, state.reservationPage, state.cityList, state.selectReservation, state.getCityListByReservationId, state.setupCityGuide, state.updateReservationGuide])
const { notification } = App.useApp() const { notification } = App.useApp()
@ -143,7 +143,7 @@ function Newest() {
}) })
} }
const handleOk = () => { const handleOk = () => {
reservationStore.updateReservationGuide() updateReservationGuide()
.finally(() => { .finally(() => {
setIsModalOpen(false); setIsModalOpen(false);
setDataLoading(false); setDataLoading(false);

Loading…
Cancel
Save