diff --git a/mock/modules/lcz.js b/mock/modules/lcz.js index f981a3a..d5b0fd0 100644 --- a/mock/modules/lcz.js +++ b/mock/modules/lcz.js @@ -29,41 +29,29 @@ export default [ { url: '/api-updateStudent', 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, + response(req) { + // 假设req.body的结构是{Id: '唯一标识', ...其他字段} + const requestBody = req.body; + const studentId = requestBody.Id; + + // 模拟检查数据库中是否存在该id + // 在真实环境中,这一步应当由后端服务完成 + const students = getMockStudents(); // 假设这是存储模拟学生数据的地方 + const existingStudent = students.find(student => student.id === studentId); + + if (existingStudent) { + // 更新数据库中的学生信息(在模拟中,我们直接修改内存中的数据) + Object.assign(existingStudent, requestBody); + return { + code: 200, + message: '更新成功', + data: existingStudent + }; + } else { + return { + code: 404, + message: '未找到具有该ID的学生' + }; } } }, diff --git a/package.json b/package.json index beb66d2..cfb60b4 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "file-saver": "^2.0.5", "less": "^4.2.0", "mockjs": "^1.1.0", + "pdfmake": "^0.2.10", "pinia": "^2.1.7", "pinia-plugin-persistedstate": "^3.2.1", "tdesign-vue-next": "^1.9.3", @@ -26,6 +27,7 @@ "devDependencies": { "@vitejs/plugin-vue": "^5.0.4", "@vitejs/plugin-vue-jsx": "^3.1.0", + "gulp": "^5.0.0", "sass": "^1.74.1", "vite": "^5.1.6" } diff --git a/src/api/login.js b/src/api/login.js index 3bde586..0af5169 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -4,5 +4,5 @@ const API = { LOGIN_URL: "/api/login", }; -export const reqUser = () => request.post(API.LOGIN_URL); +export const reqUser = (data) => request.post(API.LOGIN_URL,data); // 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 10f9583..d4ba5d1 100644 --- a/src/api/students.js +++ b/src/api/students.js @@ -9,4 +9,10 @@ export function getStudents(studentData) { export function updateStudent(updateStudent) { return request.post('/api-updateStudent', updateStudent) -} \ No newline at end of file +} + +// const API = { +// STUDENT_URL: "/api/user", +// }; + +// export const reqStudent = () => request.get(API.STUDENT_URL); \ No newline at end of file diff --git a/src/layout/components/LayoutAside.vue b/src/layout/components/LayoutAside.vue index c3eb3b1..8f15e23 100644 --- a/src/layout/components/LayoutAside.vue +++ b/src/layout/components/LayoutAside.vue @@ -34,6 +34,9 @@ 报表明细 + + 票据列表 +