diff --git a/src/pages/Students/students.vue b/src/pages/Students/students.vue index fea55ea..f16a6b2 100644 --- a/src/pages/Students/students.vue +++ b/src/pages/Students/students.vue @@ -48,15 +48,15 @@ @@ -64,9 +64,9 @@ @@ -287,8 +287,8 @@ @@ -458,7 +458,7 @@ Cancel - Save + Save @@ -1870,6 +1870,7 @@ export default { text: "", showLoader: false, loading: false, + editLoading: false, date: null, search: "", menu: false, @@ -1889,6 +1890,8 @@ export default { imageName: "", imageUrl: "", imageFile: "", + editImageName: "", + editImageUrl: "", nameRules: [v => !!v || " Full Name is required"], dateRules: [v => !!v || " DOB is required"], cityRules: [v => !!v || " City Name is required"], @@ -2070,6 +2073,9 @@ export default { pickFile() { this.$refs.image.click(); }, + pickEditFile() { + this.$refs.editDataImage.click(); + }, dates: function(date) { return moment(date).format("MMMM DD, YYYY"); }, @@ -2095,24 +2101,27 @@ export default { this.imageUrl = ""; } }, - // getStudentList() { - // this.showLoader = true; - // var token = this.$store.state.token; - // http() - // .get("/getStudentsList", { - // headers: { Authorization: "Bearer " + token } - // }) - // .then(response => { - // this.desserts = response.data.data; - // this.showLoader = false; - // // console.log("getStudentList=====>",this.desserts) - // }) - // .catch(err => { - // // console.log("err====>", err); - // this.showLoader = false; - // this.$router.replace({ path: "/" }); - // }); - // }, + onEditFilePicked(e) { + console.log(e); + const files = e.target.files; + if (files[0] !== undefined) { + this.editImageName = files[0].name; + console.log("this.editImageName", this.editImageName); + + if (this.editImageName.lastIndexOf(".") <= 0) { + return; + } + const fr = new FileReader(); + fr.readAsDataURL(files[0]); + fr.addEventListener("load", () => { + this.editImageUrl = fr.result; + this.editiImageFile = files[0]; // this is an image file that can be sent to server... + }); + } else { + this.editImageName = ""; + this.editiImageFile = ""; + } + }, editItem(item) { this.editedIndex = this.desserts.indexOf(item); this.editedItem = Object.assign({}, item); @@ -2152,7 +2161,7 @@ export default { // console.log("deleteUers",deleteStudent) this.snackbar = true; this.text = "Successfully delete Existing Student"; - this.getStudentList(); + this.findStudents(); }) .catch(error => { // console.log(error); @@ -2223,6 +2232,7 @@ export default { this.text = "New Student added successfully"; // this.getStudentList(); this.clear(); + this.clearParents(); this.loading = false; }) .catch(error => { @@ -2237,6 +2247,9 @@ export default { this.$refs.form.reset(); this.imageUrl = ""; }, + clearParents() { + this.$refs.parentForm.reset(); + }, save() { let editStudent = { studentId: this.editedItem._id, @@ -2261,11 +2274,12 @@ export default { weight: this.editedItem.weight, rollNo: this.editedItem.rollNo }; - if (this.imageUrl) { - var str = this.imageUrl; - const [baseUrl, imageUrl] = str.split(/,/); - editStudent.upload = imageUrl; + if (this.editImageUrl) { + var str = this.editImageUrl; + const [baseUrl, editImageUrl] = str.split(/,/); + editStudent.upload = editImageUrl; } + this.editLoading = true; http() .put("/updateStudent", editStudent) .then(response => { @@ -2274,11 +2288,13 @@ export default { this.imageUrl = ""; this.findStudents(); this.close(); + this.editLoading = false; }) .catch(error => { // console.log(error); this.snackbar = true; this.text = error.response.data.statusText; + this.editLoading = false; }); }, submitParentDetails() {