Commit 3815afe8cd62671bb4aee0f7464c17845425fa52
1 parent
3ce6253e23
Exists in
master
and in
3 other branches
fixed all bugs in student
Showing
1 changed file
with
48 additions
and
32 deletions
Show diff stats
src/pages/Students/students.vue
... | ... | @@ -48,15 +48,15 @@ |
48 | 48 | <v-avatar size="160px"> |
49 | 49 | <img |
50 | 50 | src="/static/icon/user.png" |
51 | - v-if="!editedItem.profilePicUrl && !imageUrl" | |
51 | + v-if="!editedItem.profilePicUrl && !editImageUrl" | |
52 | 52 | /> |
53 | 53 | <img |
54 | 54 | :src="editedItem.profilePicUrl" |
55 | - v-else-if="editedItem.profilePicUrl && !imageUrl" | |
55 | + v-else-if="editedItem.profilePicUrl && !editImageUrl" | |
56 | 56 | /> |
57 | 57 | <img |
58 | - v-if="imageUrl" | |
59 | - :src="imageUrl" | |
58 | + v-if="editImageUrl" | |
59 | + :src="editImageUrl" | |
60 | 60 | height="150" |
61 | 61 | style="border-radius:50%; width:200px" |
62 | 62 | /> |
... | ... | @@ -64,9 +64,9 @@ |
64 | 64 | <input |
65 | 65 | type="file" |
66 | 66 | style="display: none" |
67 | - ref="image" | |
67 | + ref="editDataImage" | |
68 | 68 | accept="image/*" |
69 | - @change="onFilePicked" | |
69 | + @change="onEditFilePicked" | |
70 | 70 | /> |
71 | 71 | </v-flex> |
72 | 72 | </v-layout> |
... | ... | @@ -287,8 +287,8 @@ |
287 | 287 | <v-flex xs8 class="ml-3"> |
288 | 288 | <v-text-field |
289 | 289 | label="Select Image" |
290 | - @click="pickFile" | |
291 | - v-model="imageName" | |
290 | + @click="pickEditFile" | |
291 | + v-model="editImageName" | |
292 | 292 | append-icon="attach_file" |
293 | 293 | ></v-text-field> |
294 | 294 | </v-flex> |
... | ... | @@ -458,7 +458,7 @@ |
458 | 458 | <v-btn round dark @click.native="close">Cancel</v-btn> |
459 | 459 | </v-flex> |
460 | 460 | <v-flex xs6> |
461 | - <v-btn @click="save" round dark :loading="loading" class="right">Save</v-btn> | |
461 | + <v-btn @click="save" round dark :loading="editLoading" class="right">Save</v-btn> | |
462 | 462 | </v-flex> |
463 | 463 | </v-layout> |
464 | 464 | </v-flex> |
... | ... | @@ -1870,6 +1870,7 @@ export default { |
1870 | 1870 | text: "", |
1871 | 1871 | showLoader: false, |
1872 | 1872 | loading: false, |
1873 | + editLoading: false, | |
1873 | 1874 | date: null, |
1874 | 1875 | search: "", |
1875 | 1876 | menu: false, |
... | ... | @@ -1889,6 +1890,8 @@ export default { |
1889 | 1890 | imageName: "", |
1890 | 1891 | imageUrl: "", |
1891 | 1892 | imageFile: "", |
1893 | + editImageName: "", | |
1894 | + editImageUrl: "", | |
1892 | 1895 | nameRules: [v => !!v || " Full Name is required"], |
1893 | 1896 | dateRules: [v => !!v || " DOB is required"], |
1894 | 1897 | cityRules: [v => !!v || " City Name is required"], |
... | ... | @@ -2070,6 +2073,9 @@ export default { |
2070 | 2073 | pickFile() { |
2071 | 2074 | this.$refs.image.click(); |
2072 | 2075 | }, |
2076 | + pickEditFile() { | |
2077 | + this.$refs.editDataImage.click(); | |
2078 | + }, | |
2073 | 2079 | dates: function(date) { |
2074 | 2080 | return moment(date).format("MMMM DD, YYYY"); |
2075 | 2081 | }, |
... | ... | @@ -2095,24 +2101,27 @@ export default { |
2095 | 2101 | this.imageUrl = ""; |
2096 | 2102 | } |
2097 | 2103 | }, |
2098 | - // getStudentList() { | |
2099 | - // this.showLoader = true; | |
2100 | - // var token = this.$store.state.token; | |
2101 | - // http() | |
2102 | - // .get("/getStudentsList", { | |
2103 | - // headers: { Authorization: "Bearer " + token } | |
2104 | - // }) | |
2105 | - // .then(response => { | |
2106 | - // this.desserts = response.data.data; | |
2107 | - // this.showLoader = false; | |
2108 | - // // console.log("getStudentList=====>",this.desserts) | |
2109 | - // }) | |
2110 | - // .catch(err => { | |
2111 | - // // console.log("err====>", err); | |
2112 | - // this.showLoader = false; | |
2113 | - // this.$router.replace({ path: "/" }); | |
2114 | - // }); | |
2115 | - // }, | |
2104 | + onEditFilePicked(e) { | |
2105 | + console.log(e); | |
2106 | + const files = e.target.files; | |
2107 | + if (files[0] !== undefined) { | |
2108 | + this.editImageName = files[0].name; | |
2109 | + console.log("this.editImageName", this.editImageName); | |
2110 | + | |
2111 | + if (this.editImageName.lastIndexOf(".") <= 0) { | |
2112 | + return; | |
2113 | + } | |
2114 | + const fr = new FileReader(); | |
2115 | + fr.readAsDataURL(files[0]); | |
2116 | + fr.addEventListener("load", () => { | |
2117 | + this.editImageUrl = fr.result; | |
2118 | + this.editiImageFile = files[0]; // this is an image file that can be sent to server... | |
2119 | + }); | |
2120 | + } else { | |
2121 | + this.editImageName = ""; | |
2122 | + this.editiImageFile = ""; | |
2123 | + } | |
2124 | + }, | |
2116 | 2125 | editItem(item) { |
2117 | 2126 | this.editedIndex = this.desserts.indexOf(item); |
2118 | 2127 | this.editedItem = Object.assign({}, item); |
... | ... | @@ -2152,7 +2161,7 @@ export default { |
2152 | 2161 | // console.log("deleteUers",deleteStudent) |
2153 | 2162 | this.snackbar = true; |
2154 | 2163 | this.text = "Successfully delete Existing Student"; |
2155 | - this.getStudentList(); | |
2164 | + this.findStudents(); | |
2156 | 2165 | }) |
2157 | 2166 | .catch(error => { |
2158 | 2167 | // console.log(error); |
... | ... | @@ -2223,6 +2232,7 @@ export default { |
2223 | 2232 | this.text = "New Student added successfully"; |
2224 | 2233 | // this.getStudentList(); |
2225 | 2234 | this.clear(); |
2235 | + this.clearParents(); | |
2226 | 2236 | this.loading = false; |
2227 | 2237 | }) |
2228 | 2238 | .catch(error => { |
... | ... | @@ -2237,6 +2247,9 @@ export default { |
2237 | 2247 | this.$refs.form.reset(); |
2238 | 2248 | this.imageUrl = ""; |
2239 | 2249 | }, |
2250 | + clearParents() { | |
2251 | + this.$refs.parentForm.reset(); | |
2252 | + }, | |
2240 | 2253 | save() { |
2241 | 2254 | let editStudent = { |
2242 | 2255 | studentId: this.editedItem._id, |
... | ... | @@ -2261,11 +2274,12 @@ export default { |
2261 | 2274 | weight: this.editedItem.weight, |
2262 | 2275 | rollNo: this.editedItem.rollNo |
2263 | 2276 | }; |
2264 | - if (this.imageUrl) { | |
2265 | - var str = this.imageUrl; | |
2266 | - const [baseUrl, imageUrl] = str.split(/,/); | |
2267 | - editStudent.upload = imageUrl; | |
2277 | + if (this.editImageUrl) { | |
2278 | + var str = this.editImageUrl; | |
2279 | + const [baseUrl, editImageUrl] = str.split(/,/); | |
2280 | + editStudent.upload = editImageUrl; | |
2268 | 2281 | } |
2282 | + this.editLoading = true; | |
2269 | 2283 | http() |
2270 | 2284 | .put("/updateStudent", editStudent) |
2271 | 2285 | .then(response => { |
... | ... | @@ -2274,11 +2288,13 @@ export default { |
2274 | 2288 | this.imageUrl = ""; |
2275 | 2289 | this.findStudents(); |
2276 | 2290 | this.close(); |
2291 | + this.editLoading = false; | |
2277 | 2292 | }) |
2278 | 2293 | .catch(error => { |
2279 | 2294 | // console.log(error); |
2280 | 2295 | this.snackbar = true; |
2281 | 2296 | this.text = error.response.data.statusText; |
2297 | + this.editLoading = false; | |
2282 | 2298 | }); |
2283 | 2299 | }, |
2284 | 2300 | submitParentDetails() { | ... | ... |