diff --git a/src/pages/Report/idCard.vue b/src/pages/Report/idCard.vue index 4169ebf..7bb4b1d 100644 --- a/src/pages/Report/idCard.vue +++ b/src/pages/Report/idCard.vue @@ -7,13 +7,13 @@ - + + - + + - + + - + + - + + - + - + + - + + - + + @@ -371,46 +372,7 @@ > {{ getCard.name}}

- - - - +

!!v || "Librarian Field is required"], - // typeRules: [v => !!v || "Type is required"], + typeRules: [v => !!v || "Type is required"], // backgroundRules: [v => !!v || "Background is required"], typeList: [ { @@ -596,7 +558,7 @@ export default { this.showLibrarian = false; this.showStudents = false; this.showSections = false; - this.getUsersList(); + this.getUsersList(role); } if (role === 7) { this.showLibrarian = true; @@ -606,7 +568,7 @@ export default { this.showClass = false; this.showStudents = false; this.showSections = false; - this.getUsersList(); + this.getUsersList(role); } }, @@ -714,60 +676,62 @@ export default { }); }, getCards() { - http() - .get("/getIdCardDetail", { - headers: { - Authorization: "Bearer " + this.token - }, - params: { - profileId: this.getReport._id, - role: this.getReport.role - } - }) - .then(response => { - this.getCard = ""; - var data = response.data.data; - if ( - Object.keys(data.adminData).length != 0 && - data.adminData.constructor === Object - ) { - this.getCard = response.data.data.adminData; - console.log("this.getCard ", this.getCard); - } - if ( - Object.keys(data.teachersData).length != 0 && - data.teachersData.constructor === Object - ) { - this.getCard = response.data.data.teachersData; - console.log("this.getCard--teachersData ", this.getCard); - } - if ( - Object.keys(data.studentData).length != 0 && - data.studentData.constructor === Object - ) { - this.getCard = response.data.data.studentData; - console.log("this.getCard--studentData ", this.getCard); - } - if ( - Object.keys(data.usersData).length != 0 && - data.usersData.constructor === Object - ) { - this.getCard = response.data.data.usersData; - console.log("this.getCard--usersData ", this.getCard); - } - // console.log("this.getCard--all ", response.data.data); - this.showLoader = false; - this.showReport = true; - }) - .catch(error => { - this.showLoader = false; - console.log("error", error.response.data.errors); - if (error.response.data.errors) { - this.snackbar = true; - this.text = " Field is required"; - this.color = "error"; - } - }); + if (this.$refs.form.validate()) { + http() + .get("/getIdCardDetail", { + headers: { + Authorization: "Bearer " + this.token + }, + params: { + profileId: this.getReport._id, + role: this.getReport.role + } + }) + .then(response => { + this.getCard = ""; + var data = response.data.data; + if ( + Object.keys(data.adminData).length != 0 && + data.adminData.constructor === Object + ) { + this.getCard = response.data.data.adminData; + console.log("this.getCard ", this.getCard); + } + if ( + Object.keys(data.teachersData).length != 0 && + data.teachersData.constructor === Object + ) { + this.getCard = response.data.data.teachersData; + console.log("this.getCard--teachersData ", this.getCard); + } + if ( + Object.keys(data.studentData).length != 0 && + data.studentData.constructor === Object + ) { + this.getCard = response.data.data.studentData; + console.log("this.getCard--studentData ", this.getCard); + } + if ( + Object.keys(data.usersData).length != 0 && + data.usersData.constructor === Object + ) { + this.getCard = response.data.data.usersData; + console.log("this.getCard--usersData ", this.getCard); + } + // console.log("this.getCard--all ", response.data.data); + this.showLoader = false; + this.showReport = true; + }) + .catch(error => { + this.showLoader = false; + console.log("error", error.response.data.errors); + if (error.response.data.errors) { + this.snackbar = true; + this.text = " Field is required"; + this.color = "error"; + } + }); + } }, getTeacherList() { this.showLoader = true; @@ -789,11 +753,11 @@ export default { } }); }, - getUsersList() { + getUsersList(role) { this.showLoader = true; var token = this.$store.state.token; http() - .get("/getUsersList", { + .get("/getUsersList?role=" + role, { headers: { Authorization: "Bearer " + token } }) .then(response => {