From 48926b7ec02a53ddf0230b5d7b64aecb6434071b Mon Sep 17 00:00:00 2001 From: ZhangEnJing <2868849437@qq.com> Date: Thu, 5 Dec 2024 11:03:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E5=AD=A6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/student/index.js | 13 +++++-- src/utils/studentLsUtils.js | 11 +++++- src/views/student/components/item-main.vue | 4 +- src/views/student/components/item-overlay.vue | 37 +++++++++++++------ src/views/student/index.vue | 19 ++++++---- 5 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/controller/student/index.js b/src/controller/student/index.js index 6306bed..a348883 100644 --- a/src/controller/student/index.js +++ b/src/controller/student/index.js @@ -20,7 +20,7 @@ const studentController = { //提交用户 submitStudent(student, isUpdate) { if (isUpdate) { - + localStorageUtils.update(student); } else { // 生成一个实时id const options = { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }; @@ -48,10 +48,15 @@ const studentController = { } } if (phoneNum != null) { - if (!(studentList[i].class).includes(classId)) { + if (!(studentList[i].phoneNum).includes(phoneNum)) { continue; } } + // if (phoneNum != null) { + // if (studentList[i].id != Id) { + // continue; + // } + // } showStudents.push(studentList[i]) } @@ -61,8 +66,8 @@ const studentController = { getStudents() { return localStorageUtils.getAllStudents(); }, - deleteStudents(deleteStudentsId){ - for(let i = 0;i{{ getGenderName(item.gender) }} {{ item.contact }} {{ item.phoneNum }} - + @@ -95,6 +95,8 @@ export default { console.log(this.deleteStudentsId); controller.methods.deleteStudents(this.deleteStudentsId) this.loadPage(); + },updateStudent(student){ + this.$emit("updateStudent",student); } } diff --git a/src/views/student/components/item-overlay.vue b/src/views/student/components/item-overlay.vue index 302776e..c2354a8 100644 --- a/src/views/student/components/item-overlay.vue +++ b/src/views/student/components/item-overlay.vue @@ -3,7 +3,7 @@
-

学生

+

{{ headText }}

*学生姓名
@@ -16,8 +16,7 @@
- + 请输入学生姓名
@@ -118,6 +117,7 @@ export default { classMessage: false } return { + headText: "学生", classes: [], isUpdate: false, message, @@ -126,6 +126,21 @@ export default { }, methods: { hideOverlay() { + var myStudent = { + name: "", + class: 0, + gender: 0, + birthday: "", + address: "", + contact: "", + phoneNum: "", + password: "123123", + id: "", + isCreateIM: false + } + this.isUpdate = false; + this.headText = "学生"; + this.student = myStudent; this.$emit("hideOverlay"); }, submitStudent() { @@ -148,18 +163,18 @@ export default { } let flag = controller.methods.submitStudent(this.student, this.isUpdate); + this.isUpdate = false; console.log("提交用户..."); console.log(this.student) - if(flag){ + if (flag) { location.reload(); } - // if(flag){ - // console.log("提交成功..."); - // alert("提交成功!"); - // }else{ - // console.error("提交失败..."); - // alert("提交失败!"); - // } + }, updateStudent(student) { + console.log("修改用户"); + console.log(student); + this.headText = "修改学生"; + this.student = student; + this.isUpdate = true; } }, mounted() { diff --git a/src/views/student/index.vue b/src/views/student/index.vue index 3884a47..b91820e 100644 --- a/src/views/student/index.vue +++ b/src/views/student/index.vue @@ -3,9 +3,9 @@
-
+
- +
@@ -24,20 +24,23 @@ export default { Top, Drawer, Overlay, Main }, data() { - return{ - isOverlay:false + return { + isOverlay: false } }, - methods:{ - showOverlay(){ + methods: { + showOverlay() { this.isOverlay = true; }, - hideOverlay(){ + hideOverlay() { this.isOverlay = false; - },deleteStudent(){ + }, deleteStudent() { if (this.$refs.mainComponent && this.$refs.mainComponent.deleteStudent()) { this.$refs.mainComponent.deleteStudent(); } + }, updateStudent(student) { + this.showOverlay(); + this.$refs.overlayComponent.updateStudent(student); } } }