viewMark.vue 15.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
<template>
  <v-app id="pages-dasboard">
    <!-- ****** PROFILE MARK  ****** -->
    <v-container fluid grid-list-md>
      <v-layout>
        <v-flex xs12 sm8 md10>
          <v-btn class="open-dialog-button mt-3" round dark @click="print()">
            Print
            <v-icon size="18" right dark>print</v-icon>
          </v-btn>
        </v-flex>
        <v-flex xs12 sm4 md2 class="right">
          <v-select
            class
            :items="selectMark"
            label="Select"
            v-model="selectMarkList"
            @change="selectMarkData(selectMarkList)"
          ></v-select>
        </v-flex>
      </v-layout>
      <v-flex xs12 sm12 id="printMe">
        <!-- <v-layout wrap> -->
        <!-- ****** TABLE DATA MARK  ****** -->
        <v-flex xs12 sm12 md12>
          <v-layout>
            <v-flex xs12 sm12 md12 class="text-xs-center">
              <!-- <img :src="userData.schoolLogoUrl" width="140" alt="logo" /> -->
              <v-avatar>
                <img :src="userData.schoolLogoUrl" v-if="userData.schoolLogoUrl" />
                <img
                  src="/static/schoolIcons/INTRACK_White.png"
                  v-else-if="!userData.schoolLogoUrl"
                />
              </v-avatar>
              <p class="title">{{ userData.name }}</p>
              <p>{{ userData.address }}</p>
            </v-flex>
          </v-layout>
          <v-layout wrap>
            <v-flex xs12 sm12 md4>
              <v-card>
                <v-layout class="py-4">
                  <v-avatar class="mx-auto" size="70">
                    <img src="/static/icon/user.png" v-if="!markData[0].studentId.profilePicUrl" />
                    <img
                      :src="markData[0].studentId.profilePicUrl"
                      v-else-if="markData[0].studentId.profilePicUrl"
                    />
                  </v-avatar>
                </v-layout>
                <v-layout class="pa-2">
                  <v-flex xs6 sm6>
                    <h4 class="right">
                      <b>Name :</b>
                    </h4>
                  </v-flex>
                  <v-flex sm6 xs6>
                    <h4>{{ markData[0].studentId.name }}</h4>
                  </v-flex>
                </v-layout>
                <v-layout class="pa-2">
                  <v-flex xs6 sm6>
                    <h4 class="right">
                      <b>Class :</b>
                    </h4>
                  </v-flex>
                  <v-flex sm6 xs6>
                    <h4>{{ markData[0].classId.classNum }}</h4>
                  </v-flex>
                </v-layout>
                <v-layout class="pa-2">
                  <v-flex xs6 sm6>
                    <h4 class="right">
                      <b>Section :</b>
                    </h4>
                  </v-flex>
                  <v-flex sm6 xs6>
                    <h4>{{ markData[0].sectionId.name }}</h4>
                  </v-flex>
                </v-layout>
                <v-layout class="pa-2">
                  <v-flex xs6 sm6>
                    <h4 class="right">
                      <b>Roll No :</b>
                    </h4>
                  </v-flex>
                  <v-flex sm6 xs6>
                    <h4>{{ markData[0].studentId.rollNo }}</h4>
                  </v-flex>
                </v-layout>
                <!-- <p
                      style="font-size:20px;margin:0px;margin-bottom:4px;"
                    >{{ markData[0].studentId.name }}</p>
                    <p
                      style="font-size: 15px;color: #707478;margin:0px;margin-bottom:4px;"
                    >Class : {{ markData[0].classId.classNum }}</p>
                    <p
                      style="font-size: 15px;color: #707478;margin:0px;margin-bottom:4px;"
                    >Section : {{ markData[0].sectionId.name }}</p>
                    <p
                      style="font-size: 15px;color: #707478;margin:0px;margin-bottom:4px;"
                >Roll No : {{ markData[0].studentId.rollNo }}</p>-->
              </v-card>
            </v-flex>
            <v-flex xs12 sm12 md8 v-show="showMark">
              <v-card>
                <div style="overflow-x:auto;">
                  <table
                    v-for="(value, id) in filterData"
                    :key="id"
                    class="mb-5 tableRsponsive feeTypeTable subheading"
                    style="border: 1px solid black;
                      border-collapse: collapse;!important
                      table-layout: auto !important;
                      width: 100% !important;"
                  >
                    <thead style="border: 1px solid transparent !important;">
                      <td
                        colspan="4"
                        style="text-align: inherit !important;
                                border-right: inherit;
                                border-top: inherit;
                                padding:14px;"
                      >{{value[0].examId.examName}}</td>
                      <!-- </tr>   -->
                      <tr style="border: 1px solid lightgrey !important;">
                        <td
                          rowspan="2"
                          style="border: 1px solid lightgrey !important;;padding:4px; text-align: left;"
                        >Subject</td>
                        <template v-for="(studentData,ind) in  value">
                          <td
                            v-if="ind == 0"
                            colspan="2"
                            v-for="studentMark in studentData.studentsMarks"
                            style="border: 1px solid lightgrey !important;padding:10px; text-align: left;"
                          >{{studentMark.markDistributionId.distributionType}}</td>
                          <td
                            v-if="ind == 0"
                            style="border: 1px solid lightgrey !important text-align: left;"
                          >Total Marks</td>
                        </template>
                      </tr>
                      <tr
                        v-for="(subject, ind) in value"
                        v-if="ind == 0"
                        style="border: 1px solid lightgrey !important;"
                      >
                        <template v-for="(exam, i) in subject.studentsMarks">
                          <td
                            style="border: 1px solid lightgrey !important;padding: 10px; text-align: left;"
                          >Marks</td>
                          <td
                            style="border: 1px solid lightgrey !important;padding: 10px; text-align: left;"
                          >Highest Marks</td>
                        </template>
                      </tr>
                    </thead>
                    <tbody style="border: 1px solid lightgrey !important;">
                      <tr
                        v-for="subject in value"
                        style="border: 1px solid lightgrey !important;"
                        class="tr"
                      >
                        <td
                          style="border: 1px solid lightgrey !important;padding: 10px;"
                        >{{subject.subjectName}}</td>
                        <template v-for="(exam, i) in subject.studentsMarks">
                          <td
                            style="border: 1px solid lightgrey !important;padding: 10px; text-align: left;"
                          >{{exam.marksScored}}</td>
                          <td
                            style="border: 1px solid lightgrey !important;padding: 10px; text-align: left;"
                          >{{exam.markDistributionId.markValue}}</td>
                        </template>
                        <td
                          style="border: 1px solid lightgrey !important;padding: 10px; text-align: left;"
                        >{{subject.totalMarks}}</td>
                      </tr>
                    </tbody>
                  </table>
                </div>
              </v-card>
            </v-flex>
            <!-- ****** TABLE GRADE MARK  ****** -->
            <v-flex xs12 sm12 md8 v-show="showGrade">
              <v-card
                v-for="(value, id, index) in filterData"
                :key="index"
                flat
                style="border: 1px solid lightgrey;margin-bottom:14px;"
              >
                <v-card-title class="subheading">{{value[0].examId.examName}}</v-card-title>
                <table
                  class="mb-5 tableRsponsive feeTypeTable"
                  style="border: 1px solid lightgrey;
                  border-collapse: collapse;!important
                  table-layout: auto !important;
                  width: 100% !important;"
                >
                  <thead style="border: 1px solid lightgrey !important;">
                    <tr
                      class="info white--text"
                      style="border: 1px solid lightgrey !important;padding:4px;"
                    >
                      <td style="border: 1px solid lightgrey !important;padding: 10px;">Subject</td>
                      <td style="border: 1px solid lightgrey !important;padding: 10px;">Grade</td>
                    </tr>
                  </thead>
                  <tbody style="border: 1px solid lightgrey !important;">
                    <tr v-for="subject in value" style="border: 1px solid lightgrey !important;">
                      <td
                        style="border: 1px solid lightgrey !important;padding: 10px;"
                      >{{ subject.subjectName }}</td>
                      <td
                        style="border: 1px solid lightgrey !important;padding: 10px;"
                      >{{ subject.grade }}</td>
                    </tr>
                  </tbody>
                </table>
              </v-card>
              <v-card v-if="markData == ''">
                <v-layout>
                  <v-flex xs12>
                    <h5 class="text-xs-center pa-3">No Data Found</h5>
                  </v-flex>
                </v-layout>
              </v-card>
            </v-flex>
          </v-layout>
        </v-flex>
      </v-flex>
    </v-container>
    <div class="loader" v-if="showLoader">
      <v-progress-circular indeterminate color="white"></v-progress-circular>
    </div>
  </v-app>
</template>

<script>
import http from "@/Services/http.js";
import moment from "moment";
import _ from "underscore";

export default {
  data: () => ({
    showLoader: true,
    nameShow: false,
    showMark: true,
    showGrade: false,
    markData: [],
    token: "",
    markDistributions: [],
    markParticularDistributionData: [],
    filterData: [],
    output: null,
    gradeAPlus: "A+",
    gradeA: "A",
    gradeBPlus: "B+",
    gradeB: "B",
    gradeCPlus: "C+",
    gradeC: "C",
    selectMarkList: "Mark",
    selectMark: ["Mark", "Grade"],
    MarkData: "",
    userData: {}
  }),
  mounted() {
    this.token = this.$store.state.token;
    this.getMarkList();
    this.getUserData();
  },
  methods: {
    getMarkList() {
      this.showLoader = true;
      http()
        .get("/getParticularMark", {
          params: { studentId: this.$route.params.markId },
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.markData = response.data.data;
          let newData = response.data.data;
          // console.log("newData", newData);
          for (var i = 0; i < newData.length; i++) {
            newData[i].examination = newData[i].examId._id;
          }
          this.filterData = _.groupBy(newData, ["examination"]);
          // console.log("this.filterData", this.filterData);
          for (let data in this.filterData) {
            for (let item in this.filterData[data]) {
              var totalMarks = 0;
              for (
                let i = 0;
                i < this.filterData[data][item].studentsMarks.length;
                i++
              ) {
                // console.log("this.filterData[data][item].studentsMarks[i]",this.filterData[data][item].studentsMarks[i]
                //   .marksScored)
                totalMarks += this.filterData[data][item].studentsMarks[i]
                  .marksScored;
              }
              this.filterData[data][item].totalMarks = totalMarks;

              if (totalMarks > 90) {
                this.filterData[data][item].grade = this.gradeAPlus;
              } else if (totalMarks > 80 && totalMarks < 90) {
                this.filterData[data][item].grade = this.gradeA;
              } else if (totalMarks > 70 && totalMarks < 80) {
                this.filterData[data][item].grade = this.gradeBPlus;
              } else if (totalMarks > 60 && totalMarks < 70) {
                this.filterData[data][item].grade = this.gradeB;
              } else if (totalMarks > 50 && totalMarks < 60) {
                this.filterData[data][item].grade = this.gradeCPlus;
              } else if (totalMarks > 40 && totalMarks < 50) {
                this.filterData[data][item].grade = this.gradeC;
              }
            }
          }
          this.showLoader = false;
        })
        .catch(error => {
          this.showLoader = false;
          this.snackbar = true;
          this.text = error.response.data.message;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },
    print() {
      // Pass the element id here
      this.$htmlToPaper("printMe");
    },
    getUserData() {
      http()
        .get("/getParticularUserDetail")
        .then(response => {
          this.userData = response.data.data;
        })
        .catch(error => {
          // if (error.response.status === 401) {
          //   this.$router.replace({ path: "/" });
          //   this.$store.dispatch("setToken", null);
          //   this.$store.dispatch("Id", null);
          // }
        });
    },
    selectMarkData(select) {
      if (select == "Mark") {
        this.showMark = true;
        this.showGrade = false;
      } else if (select == "Grade") {
        this.showGrade = true;
        this.showMark = false;
      }
    }
  }
};
</script>

<style scoped>
.add-button {
  background: #feb83c !important;
  border-color: #feb83c !important;
  text-transform: none !important;
  -webkit-box-shadow: none !important;
  box-shadow: none !important;
}
.card-styles {
  background: #7f62f8 !important;
  border-color: #7f62f8 !important;
}
.open-dialog-button {
  background: #827bfa !important;
  border-color: #827bfa !important;
  text-transform: none !important;
}
/* table {
  border-collapse: collapse;
  border: 1px solid #e2e7eb;
}
th,
td {
  border: 1px solid #e2e7eb;
  text-align: center;
}
table.feeTypeTable {
  table-layout: auto !important;
  width: 100% !important;
} */
.bg-sky {
  background-color: #98b2cc !important;
}
.bg-sky-light {
  background-color: #89a0b8;
}
.bg-purple {
  background-color: #9583ac;
}
.bg-skyDark {
  background-color: #956785;
}
.loader {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  text-align: center;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
/* .tr:nth-child(odd){background-color: #f2f2f2} */

.loader > div {
  position: relative;
  top: calc(50% - 16px);
}
@media screen and (max-width: 380px) {
  .tableRsponsive {
    /* display: block; */
    position: relative;
    overflow: scroll;
  }
}
</style>