修复分页总数错误;供应商变更不能修改原来内容。

release
Jimmy Liow 2 years ago
parent ec27fb6732
commit 20daa50c5b

@ -4,6 +4,8 @@ import { HT_HOST } from "@/config";
import { isNotEmpty, prepareUrl } from '@/utils/commons';
const KEY_LOGIN_TOKEN = 'KEY_LOGIN_TOKEN';
const KEY_TRAVEL_AGENCY_ID = 'KEY_TRAVEL_AGENCY_ID';
const KEY_USER_ID = 'KEY_USER_ID';
class Auth {
@ -11,12 +13,11 @@ class Auth {
makeAutoObservable(this, { rootStore: false });
this.root = root;
this.login.token = root.getSession(KEY_LOGIN_TOKEN);
this.login.userId = root.getSession(KEY_USER_ID);
this.login.travelAgencyId = root.getSession(KEY_TRAVEL_AGENCY_ID);
if (isNotEmpty(this.login.token)) {
this.fetchUserDetail();
}
setInterval(() => {
// console.info('Auth.check.token.');
}, 10000);
}
valdateUserPassword(usr, pwd) {
@ -29,6 +30,7 @@ class Auth {
.then(json => {
if (json.errcode == 0) {
this.login.token = json.Result.token;
this.login.timeout = false;
this.root.putSession(KEY_LOGIN_TOKEN, json.Result.token);
return json.Result.WU_LMI_SN;
} else {
@ -46,14 +48,17 @@ class Auth {
.then(json => {
if (json.errcode == 0) {
runInAction(() => {
this.login.userId = json.Result.LMI_SN,
this.login.username = json.Result.LoginName,
this.login.travelAgencyId = json.Result.LMI_VEI_SN,
this.login.travelAgencyName = json.Result.VName,
this.login.telephone = json.Result.LkPhone,
this.login.emailAddress = json.Result.LMI_listmail,
this.login.cityId = json.Result.citysn
this.login.userId = json.Result.LMI_SN;
this.login.username = json.Result.LoginName;
this.login.travelAgencyId = json.Result.LMI_VEI_SN;
this.login.travelAgencyName = json.Result.VName;
this.login.telephone = json.Result.LkPhone;
this.login.emailAddress = json.Result.LMI_listmail;
this.login.cityId = json.Result.citysn;
this.root.putSession(KEY_TRAVEL_AGENCY_ID, this.login.travelAgencyId);
this.root.putSession(KEY_USER_ID, this.login.userId);
});
this.startTokenInterval(this.login.token);
return this.login;
} else {
throw new Error(json.errmsg + ': ' + json.errcode);
@ -61,6 +66,40 @@ class Auth {
});
}
startTokenInterval(loginToken) {
const authStore = this;
async function fetchLastRequet() {
const fetchUrl = prepareUrl(HT_HOST + '/service-CooperateSOA/GetLastReqDate')
.append('token', loginToken)
.build();
const json = await fetchJSON(fetchUrl)
if (json.errcode == 0 && isNotEmpty(json.result)) {
return json.result.LastReqDate;
} else {
return 0;
}
}
setInterval(async () => {
const lastRequest = await fetchLastRequet();
console.info(lastRequest);
const lastReqDate = new Date(lastRequest);
const now = new Date();
const diffTime = now.getTime() - lastReqDate.getTime();
const diffMinute = diffTime/1000/60;
console.info(now);
console.info(lastReqDate);
console.info('diffTime: ' + diffTime);
console.info('diffMinute: ' + diffMinute);
if (diffMinute > 3) {
console.info('timeout...');
runInAction(() => {
authStore.login.timeout = true;
});
}
}, 1000*60*1);
}
changeUserPassword(password, newPassword) {
const formData = new FormData();
formData.append('UserID', this.login.userId);
@ -80,14 +119,15 @@ class Auth {
}
login = {
token: '',//'249FC25C949B4BB182431F89762AE5E8',
userId: 1, // LMI_SN
username: 'Vu Xuan Giang',
travelAgencyId: 32531, // VEI_SN
travelAgencyName: 'ANP',
telephone: '000',
emailAddress: 'abc@123.com',
cityId: 0
token: '',
userId: 0, // LMI_SN
username: '0',
travelAgencyId: 0, // VEI_SN
travelAgencyName: '',
telephone: '',
emailAddress: '',
cityId: 0,
timeout: false
}
}

@ -43,7 +43,7 @@ class Reservation {
guide: data.Guide
}
});
this.reservationPage.total = (json?.Result??[{RsTotal: 0}]).RsTotal;
this.reservationPage.total = (json?.Result??[{RsTotal: 0}])[0].RsTotal;
});
} else {
throw new Error(json.errmsg + ': ' + json.errcode);

@ -2,7 +2,7 @@ import { Outlet, Link, useHref, useNavigate, NavLink } from "react-router-dom";
import { useEffect } from "react";
import { observer } from "mobx-react";
import { toJS } from "mobx";
import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge, Typography, Divider, App as AntApp } from "antd";
import { Layout, Menu, ConfigProvider, theme, Dropdown, Space, Row, Col, Badge, Typography, Modal, Input, Button, App as AntApp } from "antd";
import { DownOutlined } from "@ant-design/icons";
import "antd/dist/reset.css";
import AppLogo from "@/assets/logo-gh.png";
@ -32,14 +32,14 @@ const items = [
function App() {
const { authStore, noticeStore } = useStore();
const { login } = authStore;
const login = toJS(authStore.login);
const { noticeUnRead } = noticeStore;
const href = useHref();
const loginToken = toJS(login).token;
const loginToken = login.token;
const navigate = useNavigate();
useEffect(() => {
// Check location
console.info("href: " + href + '; login.token: ' + loginToken);
console.info("href: " + href + '; login.token: ' + loginToken + '; timeout: ' + login.timeout);
if (href !== '/login' && isEmpty(loginToken)) {
navigate('/login');
}
@ -65,6 +65,25 @@ function App() {
algorithm: theme.defaultAlgorithm,
}}>
<AntApp>
<Modal
centered
closable={false}
maskClosable={false}
footer={null}
open={false}
// open={isModalOpen} onOk={handleOk} onCancel={handleCancel}
>
<Title level={4}>Login timeout</Title>
<Space direction="horizontal">
<Input.Password addonBefore={login.username} />
<Button
style={{
width: 80,
}}
onClick={() => setPasswordVisible((prevState) => !prevState)}
></Button></Space>
</Modal>
<Layout
style={{
minHeight: "100vh",
@ -115,7 +134,6 @@ function App() {
</Col>
</Row>
</Header>
<Content
style={{
padding: 24,

@ -5,7 +5,7 @@ import { toJS } from "mobx";
import { Row, Col, Space, Button, Table, Input, Typography, Modal, App } from 'antd';
import { useStore } from '@/stores/StoreContext.js';
const { Title } = Typography;
const { Title, Paragraph } = Typography;
const { TextArea } = Input;
function Detail() {
@ -43,6 +43,7 @@ function Detail() {
const [isModalOpen, setIsModalOpen] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const [confirmText, setConfirmText] = useState('');
const [newConfirmText, setNewConfirmText] = useState('');
const [dataLoading, setDataLoading] = useState(false);
const { notification } = App.useApp();
const { reservationId } = useParams();
@ -68,8 +69,9 @@ function Detail() {
const handleOk = () => {
setConfirmLoading(true);
reservationStore.submitConfirmation(confirmText)
reservationStore.submitConfirmation(confirmText + ';' +newConfirmText)
.finally(() => {
setNewConfirmText('');
setIsModalOpen(false);
setConfirmLoading(false);
});
@ -102,9 +104,12 @@ function Detail() {
open={isModalOpen} onOk={handleOk} onCancel={handleCancel}
>
<Title level={4}>Confirm</Title>
<Paragraph>
<blockquote>{confirmText}</blockquote>
</Paragraph>
<TextArea
value={confirmText}
onChange={(e) => setConfirmText(e.target.value)}
value={newConfirmText}
onChange={(e) => setNewConfirmText(e.target.value)}
autoSize={{
minRows: 5,
maxRows: 8,

@ -91,6 +91,7 @@ function Newest() {
const location = useLocation();
const { reservationStore } = useStore();
const { reservationList, reservationPage, referenceNo, arrivalDateRange, cityList, cityGuideList } = reservationStore;
console.info(reservationPage);
const [isModalOpen, setIsModalOpen] = useState(false);
const [dataLoading, setDataLoading] = useState(false);
const { notification } = App.useApp();

Loading…
Cancel
Save