|
@@ -1,14 +1,14 @@
|
|
|
/*
|
|
|
* @Author: your name
|
|
|
* @Date: 2021-11-09 14:58:08
|
|
|
- * @LastEditTime: 2022-11-17 09:28:57
|
|
|
+ * @LastEditTime: 2022-12-13 11:22:53
|
|
|
* @LastEditors: code4eat awesomedema@gmail.com
|
|
|
* @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
* @FilePath: /KC-MiddlePlatform/src/pages/login/index.tsx
|
|
|
*/
|
|
|
|
|
|
-import React, { useRef, useEffect, useState, Children } from 'react';
|
|
|
-import { Select, message } from 'antd';
|
|
|
+import React, { useRef, useEffect, useState, Children, ReactEventHandler } from 'react';
|
|
|
+import { Select, message, Row, Col } from 'antd';
|
|
|
import './style.less';
|
|
|
|
|
|
import { useModel, history, Location, Helmet } from 'umi';
|
|
@@ -30,15 +30,17 @@ export interface LoginPageType {
|
|
|
}
|
|
|
|
|
|
const LoginPage: React.FC<LoginPageType> = ({ location, children, title }) => {
|
|
|
-
|
|
|
+
|
|
|
const loginPageRef = useRef<HTMLDivElement>(null);
|
|
|
const [subHospList, setSubHospList] = useState<{ name: string; value: string | number }[]>([]); //分院列表
|
|
|
const [ifLoading, setIfLoading] = useState(false);
|
|
|
// const [systemList, setSystemList] = useState<userRelationInfo.OwnAppsItem[]>([]); //可选平台列表
|
|
|
const [currentHospName, setCurrentHospName] = useState('欢迎进入医务管理系统');
|
|
|
const { initialState, setInitialState } = useModel('@@initialState');
|
|
|
+ const [windowWidth, set_windowWidth] = useState(0);
|
|
|
+ const [ifShowLeftBlock, set_ifShowLeftBlock] = useState(true);
|
|
|
+
|
|
|
|
|
|
-
|
|
|
|
|
|
//获取当前账号分院列表
|
|
|
const getSubHospFunc = async () => {
|
|
@@ -58,7 +60,7 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children, title }) => {
|
|
|
|
|
|
const onFinish = async (values: LoginPageTypes.LoginInfo) => {
|
|
|
setIfLoading(true);
|
|
|
- const hospSign = history.location.query?.hospSign as string;
|
|
|
+ const hospSign = localStorage.getItem('hospSign');
|
|
|
if (!hospSign) {
|
|
|
notification.error({
|
|
|
message: '网址标记缺失,请检查网址!',
|
|
@@ -72,27 +74,51 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children, title }) => {
|
|
|
hospSign: hospSign,
|
|
|
// remember:false,
|
|
|
});
|
|
|
+
|
|
|
setIfLoading(false);
|
|
|
if (resp) {
|
|
|
localStorage.setItem('userData', JSON.stringify(resp));
|
|
|
- localStorage.setItem('hospSign', hospSign);
|
|
|
- setInitialState((s) => ({ ...s,userData:resp }));
|
|
|
+ setInitialState((s) => ({ ...s, userData: resp }));
|
|
|
history.replace('/index');
|
|
|
|
|
|
setIfLoading(false);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const handleResize = (e: Event) => {
|
|
|
+ // console.log('innerWidth',(e.target as Window).innerWidth);
|
|
|
+ set_windowWidth((e.target as Window).innerWidth);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
useEffect(() => {
|
|
|
setCurrentHospName(title);
|
|
|
}, [title]);
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
+ if (windowWidth <= 1000) {
|
|
|
+ set_ifShowLeftBlock(false);
|
|
|
+ } else {
|
|
|
+ set_ifShowLeftBlock(true);
|
|
|
+ }
|
|
|
+ }, [windowWidth]);
|
|
|
+
|
|
|
|
|
|
useEffect(() => {
|
|
|
//根据hospSign获取分院信息
|
|
|
location.pathname == '/login' && getSubHospFunc();
|
|
|
setInitialState((s) => ({ ...s, currentSelectedSys: undefined, openedSysLists: [] }));
|
|
|
+
|
|
|
+ window.addEventListener('resize', (e) => handleResize(e)); //监听窗口大小改变
|
|
|
+
|
|
|
+ const hospSign = history.location.query?.hospSign as string;
|
|
|
+ localStorage.setItem('hospSign', hospSign);
|
|
|
+
|
|
|
+ return ()=>{
|
|
|
+ window.removeEventListener('resize',handleResize);
|
|
|
+ }
|
|
|
+
|
|
|
}, []);
|
|
|
|
|
|
|
|
@@ -103,57 +129,80 @@ const LoginPage: React.FC<LoginPageType> = ({ location, children, title }) => {
|
|
|
</Helmet>
|
|
|
|
|
|
{location.pathname == '/login' ? (
|
|
|
- <>
|
|
|
- <div className='left'>
|
|
|
- <div className='topLogo'>
|
|
|
- <img className='logo' src={logo} alt="康程智医" />
|
|
|
- <div className='logoDesc'>助力医疗机构高质量发展</div>
|
|
|
- </div>
|
|
|
- <img className='loginbanner' src={require('../../../public/images/loginBannner.png')} alt="" />
|
|
|
- </div>
|
|
|
- <div className="rightLoginArea">
|
|
|
- <div className="subHospSelector">
|
|
|
- {subHospList.length > 0 && (
|
|
|
- <KCSelect
|
|
|
- allowClear={false}
|
|
|
- style={{ width: 180}}
|
|
|
- defaultValue={subHospList[0].value}
|
|
|
- suffixIcon={<img style={{ width: '10px', height: '6px' }} src={require('../../../public/images/arrow.png')} />}
|
|
|
- >
|
|
|
- {subHospList.map((item) => {
|
|
|
- return (
|
|
|
- <Option value={item.value} key={item.value}>
|
|
|
- {item.name}
|
|
|
- </Option>
|
|
|
- );
|
|
|
- })}
|
|
|
- </KCSelect>
|
|
|
- )}
|
|
|
- </div>
|
|
|
- <div className="systemName">{currentHospName}</div>
|
|
|
- <Form onFinish={onFinish}>
|
|
|
- <Form.Item name="account" rules={[{ required: true, message: '请输入用户名!' }]}>
|
|
|
- <Input className="input" placeholder="请输入用户名" />
|
|
|
- </Form.Item>
|
|
|
-
|
|
|
- <Form.Item name="password" rules={[{ required: true, message: '请输入密码!' }]}>
|
|
|
- <Input.Password className="input" placeholder="请输入密码" />
|
|
|
- </Form.Item>
|
|
|
-
|
|
|
- <Form.Item>
|
|
|
- <Button className="loginBtn" type="primary" htmlType="submit" loading={ifLoading}>
|
|
|
- 登录
|
|
|
- </Button>
|
|
|
- </Form.Item>
|
|
|
- {/* <Form.Item name="remember" valuePropName="checked">
|
|
|
+ <Row style={{ height: '100%' }}>
|
|
|
+ {
|
|
|
+ ifShowLeftBlock && (
|
|
|
+ <Col flex="500px">
|
|
|
+ <div className='left'>
|
|
|
+ <div className='topLogo'>
|
|
|
+ <img className='logo' src={logo} alt="康程智医" />
|
|
|
+ <div className='logoDesc'>助力医疗机构高质量发展</div>
|
|
|
+ </div>
|
|
|
+ <img className='loginbanner' src={require('../../../public/images/loginBannner.png')} alt="" />
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ )
|
|
|
+ }
|
|
|
+ <Col flex="auto">
|
|
|
+ <div className="rightLoginArea">
|
|
|
+ {
|
|
|
+ !ifShowLeftBlock && (
|
|
|
+ <div className='topLogo'>
|
|
|
+ <img className='logo' src={logo} alt="康程智医" />
|
|
|
+ <div className='logoDesc'>助力医疗机构高质量发展</div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ <div className="subHospSelector">
|
|
|
+ {subHospList.length > 0 && (
|
|
|
+ <KCSelect
|
|
|
+ allowClear={false}
|
|
|
+ style={{ width: 180 }}
|
|
|
+ defaultValue={subHospList[0].value}
|
|
|
+ onSelect={(val:any)=>{
|
|
|
+ localStorage.removeItem('hospSign');
|
|
|
+ localStorage.setItem('hospSign', val);
|
|
|
+ }}
|
|
|
+ suffixIcon={<img style={{ width: '10px', height: '6px' }} src={require('../../../public/images/arrow.png')} />}
|
|
|
+ >
|
|
|
+ {subHospList.map((item) => {
|
|
|
+ return (
|
|
|
+ <Option value={item.value} key={item.value}>
|
|
|
+ {item.name}
|
|
|
+ </Option>
|
|
|
+ );
|
|
|
+ })}
|
|
|
+ </KCSelect>
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ <div className="systemName">{currentHospName}</div>
|
|
|
+ <Form onFinish={onFinish}>
|
|
|
+
|
|
|
+ <Form.Item name="account" rules={[{ required: true, message: '请输入用户名!' }]}>
|
|
|
+ <Input className="input" placeholder="请输入用户名" />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item name="password" rules={[{ required: true, message: '请输入密码!' }]}>
|
|
|
+ <Input.Password className="input" placeholder="请输入密码" />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item>
|
|
|
+ <Button className="loginBtn" type="primary" htmlType="submit" loading={ifLoading}>
|
|
|
+ 登录
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ {/* <Form.Item name="remember" valuePropName="checked">
|
|
|
<Checkbox className="checkBtn">记住密码</Checkbox>
|
|
|
</Form.Item> */}
|
|
|
- </Form>
|
|
|
- <div className='bottomCopyright'>© 2022 康程智医(成都)技术部出品</div>
|
|
|
- <div className='versionInfo'>精益管理决策平台 V1.0</div>
|
|
|
- </div>
|
|
|
- </>
|
|
|
-
|
|
|
+ </Form>
|
|
|
+ <div className='bottomCopyright'>© 2022 康程智医(成都)技术部出品</div>
|
|
|
+ <div className='versionInfo'>精益管理决策平台 V1.0</div>
|
|
|
+ </div>
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+
|
|
|
) : (
|
|
|
children
|
|
|
)}
|