diff --git a/mock/modules/lcz.js b/mock/modules/lcz.js new file mode 100644 index 0000000..19e4c97 --- /dev/null +++ b/mock/modules/lcz.js @@ -0,0 +1,70 @@ +import Mock from "mockjs" + +const student = Mock.mock({ + "list|100": [ + { + "Id|+1": 1, + "name": "@cname", + "gender":`@pick(['男', '女'])`, + "studentId": "@integer(1000000000,9999999999)", + "department":`@pick(['机电工程系', '护理分院','建筑系','材料科学与工程系','环境科学与工程系'])`, + "major":`@pick(['机械制造与自动化', '材料科学与工程', '环境科学与工程', '建筑工程', '护理学'])`, + "classes":`@pick(['机制1班', '材料1班', '环境1班', '建筑1班','护理1班'])`, + "status":`@pick(['休学', '退学', '复学'])`, + }, + ], + }); + + export default [ + { + url:'/api-list', + method:'get', + response: () => { + return { + code: 200, + data: student + } + } + }, + { + url: '/api-student', + method: 'post', + response: (req) => { + if (req.body.name !== '') { + return student.list.filter(item => item.name.includes(req.body.name)) + } + else if (req.body.studentId !== '') { + const studentId = Number(req.body.studentId) + if (!isNaN(studentId)) { + return student.list.filter(item => item.studentId === studentId) + } else { + return { + code: 400, + message: 'Invalid student number format' + } + } + } + else if (req.body.name !== '') { + return student.list.filter(item => item.name.includes(req.body.name)) + } + else if (req.body.gender !== '') { + return student.list.filter(item => item.gender.includes(req.body.gender)) + } + else if (req.body.department !== '') { + return student.list.filter(item => item.grade.includes(req.body.department)) + } + else if (req.body.major !== '') { + return student.list.filter(item => item.major.includes(req.body.major)) + } + else if (req.body.classes !== '') { + return student.list.filter(item => item.classes.includes(req.body.classes)) + } + else if (req.body.status !== '') { + return student.list.filter(item => item.major.includes(req.body.status)) + } + return { + code: 200, + } + } + } + ] \ No newline at end of file diff --git a/src/api/login.js b/src/api/login.js index 9efab9a..3bde586 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -5,4 +5,4 @@ const API = { }; export const reqUser = () => request.post(API.LOGIN_URL); -export const reqUserone = (data) => request.post(API.LOGIN_URL, data); \ No newline at end of file +// export const reqUserone = (data) => request.post(API.LOGIN_URL, data); \ No newline at end of file diff --git a/src/api/students.js b/src/api/students.js index b85d7e0..0bc246a 100644 --- a/src/api/students.js +++ b/src/api/students.js @@ -1,7 +1,8 @@ -import request from "@/utils/request"; -// 统一管理接口 -const API = { - STUDENT_URL: "/api/student", -}; +import request from '@/utils/request' -export const reqStudent = () => request.post(API.STUDENT_URL); \ No newline at end of file +export function getList() { + return request.get('/api-list') +} +export function getStudents(studentData) { + return request.post('/api-student', studentData) +} \ No newline at end of file diff --git a/src/pages/login/index.vue b/src/pages/login/index.vue index e95ce92..a987da9 100644 --- a/src/pages/login/index.vue +++ b/src/pages/login/index.vue @@ -55,7 +55,7 @@ import { MessagePlugin } from "tdesign-vue-next"; import { reactive, ref, onMounted } from "vue"; import { reqUser } from "@/api/login"; import { useRouter } from "vue-router"; -import axios from 'axios'; +// import axios from 'axios'; // import { TForm, TFormItem, TInput, TButton } from "tdesign-vue-next"; // import { DesktopIcon, LockOnIcon } from "tdesign-icons-vue"; @@ -103,7 +103,11 @@ onMounted(() => { const onSubmit = async () => { try { - const validateResult = await from.value?.validate(); + if (!form || !form.value) { + console.warn("form 或 form.value 不存在,无法进行表单验证"); + return; + } + const validateResult = await form.value?.validate(); if (validateResult?.result) { await reqUser(formData.account, formData.password); MessagePlugin.success("提交成功"); diff --git a/src/pages/students/student.vue b/src/pages/students/student.vue index dad652e..96d80dd 100644 --- a/src/pages/students/student.vue +++ b/src/pages/students/student.vue @@ -1,146 +1,275 @@