This commit is contained in:
ycy 2024-04-06 18:21:02 +08:00
commit 9aa7386b7e
4 changed files with 98 additions and 15 deletions

View File

@ -2,7 +2,7 @@ import request from "@/utils/request";
// 统一管理接口
const API = {
LOGIN_URL: "/api/user",
udaiu: "/user",
};
export const reqUser = () => request.get(API.LOGIN_URL);
export const reqUserone = (data) => request.post(API.LOGIN_URL, data);
export const reqUserone = (data) => request.post(API.LOGIN_URL, data);

View File

@ -14,7 +14,7 @@
>
<h2 class="login-title">登录</h2>
<t-form-item name="account">
<t-form-item label="账号" name="account">
<t-input
clearable
v-model="formData.account"
@ -23,7 +23,7 @@
<desktop-icon slot:string="prefix-icon"></desktop-icon>
</t-input>
</t-form-item>
<t-form-item name="password">
<t-form-item label="密码" name="password">
<t-input
type="password"
clearable
@ -35,6 +35,8 @@
</t-form-item>
<t-form-item>
<t-button theme="primary" type="submit" block>登录</t-button>
<button @click.prevent="showForgotPasswordModal">忘记密码</button>
</t-form-item>
</t-form>
</div>
@ -45,8 +47,10 @@
<script setup>
import { MessagePlugin } from "tdesign-vue-next";
import { reactive, ref } from "vue";
import { reactive, ref, onMounted } from "vue";
import { reqUser } from "@/api/login";
import router from "@/router";
// import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next";
// import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue";
const INITIAL_DATA = {
@ -90,21 +94,49 @@ const rules = reactive({
});
const onReset = () => {
//
formData.account = "";
formData.password = "";
MessagePlugin.success("重置成功");
};
const onSubmit = async ({ validateResult, firstError }) => {
await reqUser();
if (validateResult === true) {
MessagePlugin.success("提交成功");
} else {
console.log("Errors: ", validateResult);
MessagePlugin.warning(firstError);
// const onSubmit = () => {
// this.$refs.form.validateResult((valid,errors) => {
// console.log(valid);
// if (valid) {
// MessagePlugin.success("");
// } else {
// MessagePlugin.error("");
// console.log("Errors: ", errors);
// return false;
// }
// });
// };
const onSubmit = async () => {
try {
const validateResult = await this.$refs.form.validate();
if (validateResult.result) {
await reqUser();
MessagePlugin.success("提交成功");
await router.push("/");
} else {
const firstError = validateResult.errors[0]?.message || "未知错误";
console.log("Errors: ", validateResult.errors);
MessagePlugin.warning(firstError);
}
} catch (error) {
console.error("请求失败:", error);
MessagePlugin.error("提交失败");
}
};
const Login = async () => {
await reqLogin();
};
// const Login = async () => {
// await reqUser();
// };
onMounted(() => {
reqUser();
});
</script>
<style lang="less" scoped>

View File

@ -0,0 +1,45 @@
<template>
<div>
students
<t-space direction="vertical">
<!-- 按钮操作区域 -->
<div>
<t-radio-group v-model="size" variant="default-filled">
<t-radio-button value="small">小尺寸</t-radio-button>
<t-radio-button value="medium">中尺寸</t-radio-button>
<t-radio-button value="large">大尺寸</t-radio-button>
</t-radio-group>
</div>
<t-space>
<t-checkbox v-model="stripe">显示斑马纹</t-checkbox>
<t-checkbox v-model="bordered">显示表格边框</t-checkbox>
<t-checkbox v-model="hover">显示悬浮效果</t-checkbox>
<t-checkbox v-model="tableLayout">宽度自适应</t-checkbox>
<t-checkbox v-model="showHeader">显示表头</t-checkbox>
</t-space>
<!-- 当数据为空需要占位时会显示 cellEmptyContent -->
<t-table
rowKey="index"
:data="data"
:columns="columns"
:stripe="stripe"
:bordered="bordered"
:hover="hover"
:size="size"
:table-layout="tableLayout ? 'auto' : 'fixed'"
:pagination="pagination"
:showHeader="showHeader"
cellEmptyContent="-"
resizable
></t-table>
</t-space>
</div>
</template>
<script setup>
</script>
<style lang="scss" scoped>
</style>

View File

@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from "vue-router";
import FinanceBillManage from "./modules/financeBillManage";
import ReceivablesManagement from "./modules/receivables-management";
import Login from "@/pages/login/index.vue";
import Student from "@/pages/students/student.vue";
import Layout from "@/layout/index.vue";
const router = createRouter({
@ -13,6 +14,11 @@ const router = createRouter({
name: "login",
component: Login,
},
{
path: "/student",
name: "student",
component: Student,
},
...FinanceBillManage,
...ReceivablesManagement
],