From fecbc1d0961811b1fccd173ab819981105e5ed6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=95=E6=89=8D=E5=8D=93?= <2284808383@qq.com> Date: Mon, 8 Apr 2024 18:13:54 +0800 Subject: [PATCH] stu --- mock/index.js | 4 +- mock/modules/lcz.js | 40 +++++ src/api/students.js | 8 +- src/pages/students/student.vue | 262 ++++++++++++++++++++++----------- 4 files changed, 220 insertions(+), 94 deletions(-) create mode 100644 mock/modules/lcz.js diff --git a/mock/index.js b/mock/index.js index 26d10f5..692d1ff 100644 --- a/mock/index.js +++ b/mock/index.js @@ -1,6 +1,8 @@ import sdy from './modules/sdy' import ycy from './modules/ycy' +import lcz from './modules/lcz' export default [ ...sdy, - ...ycy + ...ycy, + ...lcz, ] \ No newline at end of file diff --git a/mock/modules/lcz.js b/mock/modules/lcz.js new file mode 100644 index 0000000..766a4e6 --- /dev/null +++ b/mock/modules/lcz.js @@ -0,0 +1,40 @@ +import Mock from "mockjs"; + +function randomGender() { + return ['男', '女'][Math.floor(Math.random() * 2)]; +} +const student = Mock.mock({ + "list|100": [ + { + id: '@id', + name: '@cname', + gender: randomGender(), + studentId: '@id', + department: function () { + return ['计算机科学系', '数学系', '物理系', '化学系'][this.random(0, 3)]; + }, + major: function () { + return ['计算机科学与技术', '数学', '物理学', '化学', '生物学', '经济学'][this.random(0, 5)]; + }, + classes: function () { + return ['一班', '二班', '三班', '四班', '五班'][this.random(0, 4)]; + }, + status: function () { + return ['休学', '退学', '复学'][this.random(0, 2)]; + } + } + ] +}) + +export default [ + { + url: '/api/student', + method: 'post', + response: (config) => { + return { + code: 200, + data: student.list + }; + } + } +]; \ No newline at end of file diff --git a/src/api/students.js b/src/api/students.js index b85d7e0..54f6343 100644 --- a/src/api/students.js +++ b/src/api/students.js @@ -1,7 +1,5 @@ import request from "@/utils/request"; -// 统一管理接口 -const API = { - STUDENT_URL: "/api/student", -}; -export const reqStudent = () => request.post(API.STUDENT_URL); \ No newline at end of file +export function APIStudent(data) { + return request.post('/api/student', data) +} \ No newline at end of file diff --git a/src/pages/students/student.vue b/src/pages/students/student.vue index dad652e..1592743 100644 --- a/src/pages/students/student.vue +++ b/src/pages/students/student.vue @@ -1,129 +1,193 @@