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 @@