From ebe04cc1d7f6187aea96a97aa4aa7148988f186c Mon Sep 17 00:00:00 2001 From: Neeraj Sharma Date: Tue, 10 Sep 2019 10:30:58 +0530 Subject: [PATCH] solve issue upload image dyanmic --- src/pages/Students/students.vue | 26 +++++++++++--------------- src/pages/Subjects/subjects.vue | 6 +++--- src/pages/Teachers/teachers.vue | 26 +++++++++----------------- 3 files changed, 23 insertions(+), 35 deletions(-) diff --git a/src/pages/Students/students.vue b/src/pages/Students/students.vue index efcdee0..b7618b7 100644 --- a/src/pages/Students/students.vue +++ b/src/pages/Students/students.vue @@ -1830,10 +1830,6 @@ export default { mobile: "", state: "", gender: "", - fatherName: "", - fatherCellNo: "", - motherName: "", - motherCellNo: "", select: "", selectSection: "", bloodGroup: "", @@ -2068,10 +2064,6 @@ export default { mobile: this.addStudents.mobile, state: this.addStudents.state, gender: this.addStudents.gender, - fatherName: this.addStudents.fatherName, - fatherCellNo: this.addStudents.fatherCellNo, - motherName: this.addStudents.motherName, - motherCellNo: this.addStudents.motherCellNo, establishmentYear: this.addStudents.establishmentYear, classId: this.addStudents.select, sectionId: this.addStudents.selectSection, @@ -2079,9 +2071,14 @@ export default { allergies: this.addStudents.allergies, medicalNotes: this.addStudents.medicalNotes, height: this.addStudents.height, - weight: this.addStudents.weight, - upload: this.imageUrl + weight: this.addStudents.weight }; + if (this.imageUrl) { + var str = this.imageUrl; + const [baseUrl, imageUrl] = str.split(/,/); + console.log("imageUrlimageUrlimageUrlimageUrl", imageUrl); + addStudent.upload = imageUrl; + } this.loading = true; http() .post("/createStudent", addStudent) @@ -2123,10 +2120,6 @@ export default { mobile: this.editedItem.mobile, state: this.editedItem.state, gender: this.editedItem.gender, - fatherName: this.editedItem.fatherName, - fatherCellNo: this.editedItem.fatherCellNo, - motherName: this.editedItem.motherName, - motherCellNo: this.editedItem.motherCellNo, establishmentYear: this.editedItem.establishmentYear, classId: this.editedItem.select, sectionId: this.editedItem.selectSection, @@ -2137,7 +2130,10 @@ export default { weight: this.editedItem.weight }; if (this.imageUrl) { - editStudent.upload = this.imageUrl; + var str = this.imageUrl; + const [baseUrl, imageUrl] = str.split(/,/); + console.log("imageUrlimageUrlimageUrlimageUrl", imageUrl); + editStudent.upload = imageUrl; } http() .put("/updateStudent", editStudent) diff --git a/src/pages/Subjects/subjects.vue b/src/pages/Subjects/subjects.vue index cefd297..0b84aaf 100644 --- a/src/pages/Subjects/subjects.vue +++ b/src/pages/Subjects/subjects.vue @@ -271,16 +271,16 @@ - + > diff --git a/src/pages/Teachers/teachers.vue b/src/pages/Teachers/teachers.vue index 04da4d2..b80ac1d 100644 --- a/src/pages/Teachers/teachers.vue +++ b/src/pages/Teachers/teachers.vue @@ -1327,18 +1327,6 @@ export default { // }, submit() { if (this.$refs.form.validate()) { - // let images = new FormData(); - // images.append("upload",this.imageUrl); - // console.log(images); - // var form_data = new FormData(); - // for (var key in addTeacher) { - // if (key === 'upload') { - // form_data.append(key, this.imageFile); - // } else { - // form_data.append(key, addTeacher[key]) - // } - // } - // console.log("images",images) let addTeacher = { name: this.addTeachers.name, email: this.addTeachers.email, @@ -1351,11 +1339,13 @@ export default { presentAddress: this.addTeachers.presentAddress, mobileNo: this.addTeachers.mobileNo, state: this.addTeachers.state, - joinDate: this.addTeachers.joinDate, - upload: this.imageUrl - // upload:this.imageFile + joinDate: this.addTeachers.joinDate }; - // console.log("addTeacher============>", addTeacher); + if (this.imageUrl) { + var str = this.imageUrl; + const [baseUrl, imageUrl] = str.split(/,/); + addTeacher.upload = imageUrl; + } this.loading = true; http() .post("/createTeacher", addTeacher) @@ -1401,7 +1391,9 @@ export default { joinDate: this.editedItem.joinDate }; if (this.imageUrl) { - editTeacher.upload = this.imageUrl; + var str = this.imageUrl; + const [baseUrl, imageUrl] = str.split(/,/); + editTeacher.upload = imageUrl; } http() .put("/updateTeacher", editTeacher) -- 2.0.0