Эх сурвалжийг харах

Merge branch 'master' of http://120.55.44.4:10080/xujunjie/GtDigManageWeb

xjj 2 жил өмнө
parent
commit
6a2d7e6d2e

+ 12 - 1
.umirc.ts

@@ -40,10 +40,21 @@ export default defineConfig({
       component: './Access',
     },
     {
-      name: ' CRUD 示例',
+      name: 'CRUD 示例',
       path: '/table',
       component: './Table',
     },
+    {
+      name: '登录',
+      path: '/login',
+      component: './Login/index',
+      layout: false,
+    },
+    {
+      name: '文档管理',
+      path: '/fileManagement',
+      component: './FileManagement/index',
+    },
   ],
   npmClient: 'yarn',
 });

BIN
src/assets/login-bg.png


BIN
src/assets/login-box-top.png


+ 8 - 0
src/pages/FileManagement/index.js

@@ -0,0 +1,8 @@
+import React from 'react';
+import { TreeSelect } from 'antd';
+
+function FileManagement(props) {
+  return <div>文档</div>;
+}
+
+export default FileManagement;

+ 141 - 0
src/pages/Login/index.js

@@ -0,0 +1,141 @@
+import React, { useRef, useState } from 'react';
+import { connect, useNavigate } from 'umi';
+import { Form, Select, Input, Button, message } from 'antd';
+import { queryDepList } from '@/services/user';
+import styles from './index.less';
+import { UserOutlined, LockOutlined } from '@ant-design/icons';
+import { storeToken } from '@/utils/utils';
+const { Option } = Select;
+
+function Login(props) {
+  const {
+    submitting,
+    params,
+    dispatch,
+  } = props;
+  const [depList, setDepList] = useState([]);
+  const [hasName, setHasName] = useState(false);
+  const formRef = useRef();
+  let navigate = useNavigate();
+  const onHandleChange = async (name) => {
+    if (!name) {
+      setDepList([]);
+      setHasName(false);
+      return;
+    }
+    try {
+      var res = await queryDepList(name);
+      setDepList(res.data);
+      setHasName(true);
+      formRef.current.setFieldsValue({
+        DepId: res.data[0]?.ID + '',
+      });
+    } catch (error) {
+      setDepList([]);
+      setHasName(true);
+      message.error('用户名不存在');
+    }
+  };
+
+  const handleSubmit = (values) => {
+    dispatch({
+      type: 'login/login',
+      payload: {
+        ...values,
+        // 防止浏览器自动填充
+        password: values.password2,
+      },
+      callback: (token) => {
+        storeToken(token);
+        navigate("/home");
+      },
+    });
+  };
+  return (
+    <div className={styles.main}>
+      <div className={styles.content}>
+        <Form
+          name="basic"
+          className={styles.inp_box}
+          labelCol={{ span: 0 }}
+          wrapperCol={{ span: 24 }}
+          onFinish={handleSubmit}
+          autoComplete="new-password"
+          ref={formRef}
+        >
+          <Form.Item
+            label=""
+            name="username"
+            autoComplete="off"
+            rules={[{ required: true, message: '请输入用户名' }]}
+          >
+            <Input
+              prefix={<UserOutlined className={styles.prefixIcon} />}
+              className={styles.inp}
+              size="large"
+              autoComplete="off"
+              placeholder="请输入用户名"
+              onBlur={(e) => onHandleChange(e.target.value)}
+            />
+          </Form.Item>
+          {hasName && (
+            <Form.Item
+              label=""
+              name="DepId"
+              rules={[{ required: true, message: '请选择部门' }]}
+            >
+              <Select placeholder="请选择部门" size="large">
+                {depList.map((item) => (
+                  <Option value={item.ID + ''} key={item.ID}>
+                    {item.Name}
+                  </Option>
+                ))}
+              </Select>
+            </Form.Item>
+          )}
+
+          <Form.Item
+            label=""
+            // 不使用password,防止浏览器自动填充表单
+            name="password2"
+            className={styles.inp}
+            rules={[{ required: true, message: '请输入密码' }]}
+          >
+            <Input.Password
+              prefix={<LockOutlined className={styles.prefixIcon} />}
+              className={styles.inp}
+              size="large"
+              placeholder="请输入密码"
+              autoComplete="new-password"
+            />
+          </Form.Item>
+
+          {/* <Form.Item
+          name="remember"
+          valuePropName="checked"
+          wrapperCol={{ offset: 8, span: 16 }}
+        >
+          <Checkbox>自动登录</Checkbox>
+        </Form.Item> */}
+
+          <Form.Item>
+            <Button
+              size="large"
+              style={{ width: '100%', marginTop: 24 }}
+              loading={submitting}
+              type="primary"
+              htmlType="submit"
+            >
+              登录
+            </Button>
+          </Form.Item>
+        </Form>
+      </div>
+    </div>
+  );
+}
+
+export default connect(({ login, loading }) => ({
+  login,
+  submitting: loading.effects['login/login'],
+}))(Login);

+ 75 - 0
src/pages/Login/index.less

@@ -0,0 +1,75 @@
+
+.main {
+  width: 100%;
+  height: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  background-image: url('@/assets/login-bg.png');
+  background-repeat: no-repeat;
+  background-position: 50%;
+  background-size: 100%;
+}
+
+.prefixIcon {
+  color: #42a0e0;
+  font-size: 18px;
+}
+
+.content {
+  width: 428px;
+  height: 300px;
+  border-radius: 8px;
+  padding-top: 162px;
+  background: #fff url('@/assets/login-box-top.png') no-repeat top center;
+
+  @media screen and (max-width: 576px) {
+    width: 95%;
+  }
+
+  .inp_box {
+    width: 80%;
+    margin: 0 auto;
+    padding-top: 40px;
+
+    a {
+      color: #999;
+    }
+  }
+
+  .inp {
+    input {
+      border-radius: 0px;
+      padding: 2px 4px;
+    }
+
+    i {
+      color: #42a0e0;
+      font-size: 18px;
+    }
+  }
+
+
+  .icon {
+    margin-left: 16px;
+    color: rgba(0, 0, 0, 0.2);
+    font-size: 24px;
+    vertical-align: middle;
+    cursor: pointer;
+    transition: color 0.3s;
+
+    &:hover {
+      color: #1890ff;
+    }
+  }
+
+  .other {
+    margin-top: 24px;
+    line-height: 22px;
+    text-align: left;
+
+    .register {
+      float: right;
+    }
+  }
+}

+ 27 - 0
src/pages/Login/models/login.js

@@ -0,0 +1,27 @@
+import { Login } from '@/services/user';
+
+export default {
+  namespace: 'login',
+
+  state: {},
+
+  effects: {
+    *login({ payload, callback }, { call, put }) {
+      try {
+        let response = null;
+        response = yield call(Login, payload);
+        const { user, token } = response.data;
+
+        callback?.(token);
+        // yield put({
+        //   type: 'changeLoginStatus',
+        //   payload: response,
+        // });
+      } catch (error) {
+        console.error(error);
+      }
+    },
+  },
+
+  reducers: {},
+};

+ 11 - 0
src/services/user.js

@@ -44,3 +44,14 @@ export async function updateUser(param) {
 export async function queryDepV2(params) {
   return request(`/api/v2/dep?${stringify(params)}`);
 }
+export async function queryDepList(userName) {
+  return request(`/api/v2/user/dep`, {
+    params: { userName },
+  });
+}
+export async function Login(data) {
+  return request('/api/v2/user/login', {
+    method: 'POST',
+    data,
+  });
+}

+ 12 - 12
yarn.lock

@@ -3530,9 +3530,9 @@ camelize@^1.0.0:
   integrity sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==
 
 caniuse-lite@^1.0.30001449, caniuse-lite@^1.0.30001464:
-  version "1.0.30001474"
-  resolved "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001474.tgz#13b6fe301a831fe666cce8ca4ef89352334133d5"
-  integrity sha512-iaIZ8gVrWfemh5DG3T9/YqarVZoYf0r188IjaGwx68j4Pf0SGY6CQkmJUIE+NZHkkecQGohzXmBGEwWDr9aM3Q==
+  version "1.0.30001476"
+  resolved "https://registry.npmmirror.com/caniuse-lite/-/caniuse-lite-1.0.30001476.tgz#759906c53eae17133217d75b482f9dc5c02f7898"
+  integrity sha512-JmpktFppVSvyUN4gsLS0bShY2L9ZUslHLE72vgemBkS43JD2fOvKTKs+GtRwuxrtRGnwJFW0ye7kWRRlLJS9vQ==
 
 chalk@5.2.0:
   version "5.2.0"
@@ -4222,9 +4222,9 @@ eastasianwidth@^0.2.0:
   integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==
 
 electron-to-chromium@^1.4.284:
-  version "1.4.355"
-  resolved "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.355.tgz#539484310e5a94133bc3df8ba4b6a9dde7a506a4"
-  integrity sha512-056hxzEE4l667YeOccgjhRr5fTiwZ6EIJ4FpzGps4k3YcS8iAhiaBYUBrv5E2LDQJsussscv9EEUwAYKnv+ZKg==
+  version "1.4.356"
+  resolved "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.356.tgz#b75a8a8c31d571f6024310cc980a08cd6c15a8c5"
+  integrity sha512-nEftV1dRX3omlxAj42FwqRZT0i4xd2dIg39sog/CnCJeCcL1TRd2Uh0i9Oebgv8Ou0vzTPw++xc+Z20jzS2B6A==
 
 elliptic@^6.5.3:
   version "6.5.4"
@@ -6036,9 +6036,9 @@ lines-and-columns@^1.1.6:
   integrity sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==
 
 lint-staged@^13.0.3:
-  version "13.2.0"
-  resolved "https://registry.npmmirror.com/lint-staged/-/lint-staged-13.2.0.tgz#b7abaf79c91cd36d824f17b23a4ce5209206126a"
-  integrity sha512-GbyK5iWinax5Dfw5obm2g2ccUiZXNGtAS4mCbJ0Lv4rq6iEtfBSjOYdcbOtAIFtM114t0vdpViDDetjVTSd8Vw==
+  version "13.2.1"
+  resolved "https://registry.npmmirror.com/lint-staged/-/lint-staged-13.2.1.tgz#9d30a14e3e42897ef417bc98556fb757f75cae87"
+  integrity sha512-8gfzinVXoPfga5Dz/ZOn8I2GOhf81Wvs+KwbEXQn/oWZAvCVS2PivrXfVbFJc93zD16uC0neS47RXHIjXKYZQw==
   dependencies:
     chalk "5.2.0"
     cli-truncate "^3.1.0"
@@ -9145,9 +9145,9 @@ typed-array-length@^1.0.4:
     is-typed-array "^1.1.9"
 
 typescript@^5.0.0:
-  version "5.0.3"
-  resolved "https://registry.npmmirror.com/typescript/-/typescript-5.0.3.tgz#fe976f0c826a88d0a382007681cbb2da44afdedf"
-  integrity sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==
+  version "5.0.4"
+  resolved "https://registry.npmmirror.com/typescript/-/typescript-5.0.4.tgz#b217fd20119bd61a94d4011274e0ab369058da3b"
+  integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==
 
 umi-request@^1.4.0:
   version "1.4.0"