<template>
  <v-container fluid class="body-color">
    <v-layout wrap>
      <v-flex xs12 sm6>
        <v-layout>
          <v-flex xs4 class="pt-4 subheading">
            <label class="right hidden-sm-only hidden-xs-only">Role:</label>
            <label class="right hidden-lg-only hidden-xl-only hidden-md-only">Role:</label>
          </v-flex>
          <v-flex xs8 class="ml-3">
            <v-autocomplete
              v-model="getReport.role"
              :rules="role"
              :items="getRoles"
              item-text="name"
              item-value="role"
              placeholder="Select Role"
              @change="getUserDetailWithRoles"
              required
            ></v-autocomplete>
          </v-flex>
        </v-layout>
      </v-flex>
    </v-layout>

    <!-- *** Salary Data *** -->
    <v-data-table
      :headers="headers"
      :items="roleList"
      :pagination.sync="pagination"
      :search="search"
    >
      <template slot="items" slot-scope="props">
        <tr class="tr">
          <td class="td td-row">{{ props.index + 1}}</td>
          <td class="td td-row text-xs-center">
            <v-avatar size="40">
              <img :src="props.item.profilePicUrl" v-if="props.item.profilePicUrl" />
              <img src="/static/icon/user.png" v-else-if="!props.item.profilePicUrl" />
            </v-avatar>
          </td>
          <td class="td td-row text-xs-center">{{ props.item.name}}</td>
          <td class="td td-row text-xs-center">{{ dates(props.item.joinDate)}}</td>
          <td class="text-xs-center td td-row">
            <span>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:25px; height:25px; "
                  class="mr-3"
                  @click="profile(props.item)"
                  src="/static/icon/view.png"
                />
                <span>View</span>
              </v-tooltip>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:20px; height:18px; "
                  class="mr-3"
                  @click="editItem(props.item)"
                  src="/static/icon/edit.png"
                />
                <span>Edit</span>
              </v-tooltip>
              <v-tooltip top>
                <img
                  slot="activator"
                  style="cursor:pointer; width:20px; height:20px; "
                  @click="deleteItem(props.item)"
                  src="/static/icon/delete.png"
                  class="mr-3"
                />
                <span>Delete</span>
              </v-tooltip>
            </span>
          </td>
        </tr>
      </template>
      <v-alert
        slot="no-results"
        :value="true"
        color="error"
        icon="warning"
      >Your search for "{{ search }}" found no results.</v-alert>
    </v-data-table>

    <!-- ****** PROFILE VIEW  ******  -->

    <v-dialog v-model="profileSalaryDialog" persistent>
      <v-card flat class="text-xs-center white--text">
        <v-layout>
          <v-flex xs12 class="card-style pa-2">
            <label class="title text-xs-center">View Manage Salary</label>
            <v-icon
              size="24"
              color="white"
              class="right"
              @click="profileSalaryDialog = false"
            >cancel</v-icon>
          </v-flex>
        </v-layout>
        <v-layout wrap>
          <v-flex xs12 sm12 md4>
            <v-card flat>
              <h3 class="py-2 text-xs-center card-style white--text">Profile</h3>
              <v-card-text>
                <v-container>
                  <v-layout wrap>
                    <v-flex xs12>
                      <v-layout>
                        <v-flex
                          xs12
                          class="text-xs-center text-sm-center text-md-center text-lg-center"
                        >
                          <v-avatar size="80px">
                            <img src="/static/icon/user.png" v-if="!editedItem.profilePicUrl" />
                            <img
                              :src="editedItem.profilePicUrl"
                              v-else-if="editedItem.profilePicUrl"
                            />
                          </v-avatar>
                        </v-flex>
                      </v-layout>
                      <v-layout>
                        <v-flex xs12 sm12>
                          <h3 class="text-xs-center">
                            <b>{{ editedItem.name }}</b>
                          </h3>
                          <p class="text-xs-center grey--text">{{ editedItem.roleName }}</p>
                        </v-flex>
                      </v-layout>
                      <v-layout style="border: 1px solid lightgrey;">
                        <v-flex xs6 sm6 class="pa-0">
                          <h4 class="right">
                            <b>Join Date :</b>
                          </h4>
                        </v-flex>
                        <v-flex sm6 xs6 class="pa-0">
                          <h4>{{ editedItem.joinDate }}</h4>
                        </v-flex>
                      </v-layout>
                      <v-layout style="border: 1px solid lightgrey;">
                        <v-flex xs6 sm6 class="pa-0">
                          <h4 class="right">
                            <b>Date of Birth :</b>
                          </h4>
                        </v-flex>
                        <v-flex sm6 xs6 class="pa-0">
                          <h4>{{ editedItem.dob }}</h4>
                        </v-flex>
                      </v-layout>
                      <v-layout style="border: 1px solid lightgrey;">
                        <v-flex xs6 sm6 class="pa-0">
                          <h4 class="right">
                            <b>Phone No :</b>
                          </h4>
                        </v-flex>
                        <v-flex sm6 xs6 class="pa-0">
                          <h4>{{ editedItem.mobileNo }}</h4>
                        </v-flex>
                      </v-layout>
                    </v-flex>
                  </v-layout>
                </v-container>
              </v-card-text>
            </v-card>
          </v-flex>
          <v-flex xs12 sm12 md8 v-if="viewSalary">
            <v-card flat>
              <v-flex xs12 sm12>
                <v-container fluid grid-list-md>
                  <v-layout wrap>
                    <v-flex xs12 sm12 md6>
                      <v-card flat>
                        <v-form ref="form" lazy-validation class="py-4">
                          <v-layout>
                            <v-flex xs4 class="pt-4 subheading">
                              <label class="right hidden-xs-only">Salary Grades :</label>
                            </v-flex>
                            <v-flex xs8 sm7 class="ml-3">
                              <v-flex xs8 sm7 class="ml-3">
                                <v-text-field
                                  solo
                                  v-model="editedItem.salaryTemplate.salaryGrades"
                                  readonly
                                ></v-text-field>
                              </v-flex>
                            </v-flex>
                          </v-layout>
                          <v-layout>
                            <v-flex xs4 class="pt-4 subheading">
                              <label class="right">Basic Salary :</label>
                            </v-flex>
                            <v-flex xs8 sm7 class="ml-3">
                              <v-flex xs8 sm7 class="ml-3">
                                <v-text-field
                                  solo
                                  v-model="editedItem.salaryTemplate.basicSalary"
                                  readonly
                                ></v-text-field>
                              </v-flex>
                            </v-flex>
                          </v-layout>
                        </v-form>
                      </v-card>
                    </v-flex>
                    <v-flex xs12 sm12 md5></v-flex>
                    <v-flex xs12 sm12 md6>
                      <v-card flat>
                        <v-toolbar>
                          <h3>Allowances</h3>
                        </v-toolbar>
                        <v-layout
                          v-for="(editedItem,salaryTemplate,index) in editedItem.salaryTemplate.allowances"
                          :key="index"
                        >
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field
                              readonly
                              solo
                              label="Enter Allowances Label"
                              v-model="editedItem.allowancesName"
                            ></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field
                              readonly
                              solo
                              v-model="editedItem.allowancesValue"
                              label="Enter Allowances Value"
                            ></v-text-field>
                          </v-flex>
                        </v-layout>
                      </v-card>
                    </v-flex>
                    <v-flex xs12 sm12 md6>
                      <v-card flat>
                        <v-toolbar>
                          <h3>Deduction</h3>
                        </v-toolbar>
                        <v-layout
                          v-for="(editedItem,salaryTemplate,index) in editedItem.salaryTemplate.deduction"
                          :key="index"
                        >
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field
                              readonly
                              solo
                              label="Enter Deduction Label"
                              v-model="editedItem.deductionName"
                            ></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field
                              readonly
                              solo
                              label="Enter Deduction Value"
                              v-model="editedItem.deductionValue"
                            ></v-text-field>
                          </v-flex>
                        </v-layout>
                        <!-- <v-layout>
                          <v-flex xs4 class="pt-4 subheading">
                            <v-text-field
                              v-model="editedItem.salaryTemplate.deduction.deductionName"
                              readonly
                            ></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="ml-3">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.salaryTemplate.deduction.deductionValue"
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>-->
                      </v-card>
                    </v-flex>
                    <v-flex xs12 sm12 md12 style="padding-top: 1%;">
                      <v-card>
                        <v-toolbar>
                          <h3>Total Salary Details</h3>
                        </v-toolbar>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Gross Salary"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.salaryTemplate.grossSalary"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Total Deduction"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.salaryTemplate.totalDeduction"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Net Salary"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.salaryTemplate.netSalary"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                      </v-card>
                    </v-flex>
                  </v-layout>
                </v-container>
              </v-flex>
            </v-card>
          </v-flex>
          <v-flex xs12 sm12 md8 v-if="viewHourly">
            <v-card flat>
              <v-flex xs12 sm12>
                <v-container fluid grid-list-md>
                  <v-layout wrap>
                    <v-flex xs12 sm12 md6>
                      <v-card flat>
                        <v-form ref="form" lazy-validation class="py-4">
                          <v-layout>
                            <v-flex xs4 class="pt-4 subheading">
                              <label class="right hidden-xs-only">Hourly Grades :</label>
                            </v-flex>
                            <v-flex xs8 sm7 class="ml-3">
                              <v-flex xs8 sm7 class="ml-3">
                                <v-text-field
                                  solo
                                  v-model="editedItem.hourlyTemplate.hourlyGrades"
                                  readonly
                                ></v-text-field>
                              </v-flex>
                            </v-flex>
                          </v-layout>
                          <v-layout>
                            <v-flex xs4 class="pt-4 subheading">
                              <label class="right">Hourly Rate :</label>
                            </v-flex>
                            <v-flex xs8 sm7 class="ml-3">
                              <v-flex xs8 sm7 class="ml-3">
                                <v-text-field
                                  solo
                                  v-model="editedItem.hourlyTemplate.hourlyRate"
                                  readonly
                                ></v-text-field>
                              </v-flex>
                            </v-flex>
                          </v-layout>
                        </v-form>
                      </v-card>
                    </v-flex>
                    <v-flex xs12 sm12 md12 style="padding-top: 1%;">
                      <v-card>
                        <v-toolbar>
                          <h3>Total Salary Details</h3>
                        </v-toolbar>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Gross Salary"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.hourlyTemplate.grossSalary"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Total Deduction"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.hourlyTemplate.totalDeduction"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                        <v-layout>
                          <v-flex xs4 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-text-field solo value="Net Hourly Rate"></v-text-field>
                          </v-flex>
                          <v-flex xs8 sm7 class="mt-4 hidden-xs-only hidden-sm-only">
                            <v-flex xs8 sm7 class="ml-3">
                              <v-text-field
                                v-model="editedItem.hourlyTemplate.netSalary"
                                solo
                                readonly
                              ></v-text-field>
                            </v-flex>
                          </v-flex>
                        </v-layout>
                      </v-card>
                    </v-flex>
                  </v-layout>
                </v-container>
              </v-flex>
            </v-card>
          </v-flex>
        </v-layout>
      </v-card>
    </v-dialog>

    <!-- ****** Edit  Hourly Template  ****** -->
    <v-dialog v-model="editSalaryDialog" max-width="400px" persistent>
      <v-card flat class="card-style pa-2" dark>
        <v-layout>
          <v-flex xs12>
            <label class="title text-xs-center">Edit Manage Salary</label>
            <v-icon size="24" class="right" @click="editSalaryDialog = false">cancel</v-icon>
          </v-flex>
        </v-layout>
        <v-form ref="form">
          <v-container fluid>
            <v-flex xs12 sm12>
              <v-layout>
                <v-flex xs3 class="pt-4 subheading">
                  <label class="right">Salary:</label>
                </v-flex>
                <v-flex xs8 sm7 class="ml-3">
                  <v-select
                    :items="salary"
                    v-model="editedItem.salary"
                    placeholder="please fill this field"
                    @change="selectSalary()"
                  ></v-select>
                </v-flex>
              </v-layout>
            </v-flex>
            <v-flex xs12 sm12>
              <v-layout>
                <v-flex xs3 class="pt-4 subheading">
                  <label class="right">Template:</label>
                </v-flex>
                <v-flex xs8 sm7 class="ml-3" v-if="monthlyGrade">
                  <v-autocomplete
                    v-model="editedItem.salaryId"
                    :items="salaryData"
                    item-text="salaryGrades"
                    item-value="_id"
                    placeholder="please fill this field"
                    @change="selectGrade()"
                    required
                  ></v-autocomplete>
                </v-flex>
                <v-flex xs8 sm7 class="ml-3" v-if="hourlyGrades">
                  <v-autocomplete
                    v-model="editedItem.salaryId"
                    :items="hourlyData"
                    item-text="hourlyGrades"
                    item-value="_id"
                    placeholder="please fill this field"
                    @change="selectGrade()"
                    required
                  ></v-autocomplete>
                </v-flex>
              </v-layout>
            </v-flex>
            <v-layout>
              <v-flex xs12>
                <v-layout>
                  <v-spacer></v-spacer>
                  <v-btn round dark @click="save" class="add-button">Update Salary Template</v-btn>
                  <v-spacer></v-spacer>
                </v-layout>
              </v-flex>
            </v-layout>
          </v-container>
        </v-form>
      </v-card>
    </v-dialog>
  </v-container>
</template>

<script>
import http from "@/Services/http.js";
import Util from "@/util";
import moment from "moment";
export default {
  data: () => ({
    search: "",
    pagination: {
      rowsPerPage: 10
    },

    role: [v => !!v || "Role Name is required"],
    getRoles: [],
    teacherList: [],
    roleList: [],
    salaryData: [],
    hourlyData: [],
    salary: ["Monthly", "Hourly"],

    salaryItem: "",

    getReport: {
      role: ""
    },

    showTeacher: false,
    editSalaryDialog: false,
    profileSalaryDialog: false,
    monthlyGrade: false,
    hourlyGrades: false,
    viewSalary: false,
    viewHourly: false,

    editedItem: {
      salaryTemplate: {
        allowances: {},
        deduction: {}
      },
      hourlyTemplate: {}
    },

    // salaryGrades: {},
    // salaryTemplate: {
    //   salaryGrades: ""
    // },
    // salaryTemplate :{
    //   allowances: {
    //     allowancesName: "",
    //     allowancesValue: ""
    //   },
    //   deduction: {
    //     deductionName: "",
    //     deductionValue: ""
    //   }
    // },

    headers: [
      {
        text: "No",
        align: "",
        sortable: false,
        value: "No"
      },
      {
        text: "Profile Pic",
        value: "profilePicUrl",
        sortable: false,
        align: "center"
      },
      { text: "Name", value: "name", sortable: false, align: "center" },
      {
        text: "Join Date",
        value: "joinDate",
        sortable: false,
        align: "center"
      },
      { text: "Action", value: "", sortable: false, align: "center" }
    ],
    desserts: []
  }),

  methods: {
    close() {
      this.editHourDialog = false;
    },
    dates: function(date) {
      return moment(date).format("MMMM DD, YYYY");
    },
    editItem(item) {
      this.editedIndex = this.roleList.indexOf(item);
      this.editedItem = Object.assign({}, item);
      this.editSalaryDialog = true;
    },
    profile(item) {
      this.editedIndex = this.roleList.indexOf(item);
      this.editedItem = Object.assign({}, item);
      this.profileSalaryDialog = true;
      // console.log("item", item);
      if (item.salaryTemplate) {
        this.viewSalary = true;
        this.viewHourly = false;
      } else {
        this.viewHourly = true;
        this.viewSalary = false;
      }
    },
    getRole() {
      this.showLoader = true;
      var token = this.$store.state.token;
      http()
        .get("/getRolesList", {
          headers: { Authorization: "Bearer " + token }
        })
        .then(response => {
          this.getRoles = response.data.data;
          // if (this.getRoles[2].role !== 3) {
          //   this.getRoles = response.data.data;
          //   console.log("roles", this.getRoles[2].role);
          // }
          this.getRoles = response.data.data;
          var removedRoles = _.remove(this.getRoles, function(c) {
            //remove if color is green or yellow
            return c.role === 1 ||  c.role === 4 || c.role === 5;
            // console.log(c);
          });
          this.showLoader = false;
        })
        .catch(error => {
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },

    getRoleInputs(role) {
      // console.log("role", role);
      if (role === 3) {
        this.showTeacher = true;
        this.getTeacherList();
      }
    },

    getTeacherList() {
      this.showLoader = true;
      var token = this.$store.state.token;
      http()
        .get("/getTeachersList", {
          headers: { Authorization: "Bearer " + token }
        })
        .then(response => {
          this.teacherList = response.data.data;
          this.showTeacher = true;
          this.showLoader = false;
        })
        .catch(error => {
          this.showLoader = false;
          if (error.response.status === 401) {
            this.$router.replace({ path: "/" });
            this.$store.dispatch("setToken", null);
            this.$store.dispatch("Id", null);
          }
        });
    },

    getUserDetailWithRoles() {
      this.showLoader = true;
      http()
        .get(
          "/getUserDetailWithRoles",
          { params: { role: this.getReport.role } },
          {
            headers: { Authorization: "Bearer " + this.token }
          }
        )
        .then(response => {
          this.roleList = response.data.data;
          this.showLoader = false;
        })
        .catch(err => {
          this.showLoader = false;
        });
    },
    getSalaryList() {
      this.showLoader = true;
      this.loadingSearch = true;
      http()
        .get("/getSalaryList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.salaryData = response.data.data;
          this.showLoader = false;
          this.loadingSearch = false;
        })
        .catch(error => {
          // console.log("err====>", err);
          this.showLoader = false;
          this.loadingSearch = 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);
          }
        });
    },
    getHourlyList() {
      this.showLoader = true;
      this.loadingSearch = true;
      http()
        .get("/getHourlyList", {
          headers: { Authorization: "Bearer " + this.token }
        })
        .then(response => {
          this.hourlyData = response.data.data;
          this.showLoader = false;
          this.loadingSearch = false;
        })
        .catch(error => {
          // console.log("err====>", err);
          this.showLoader = false;
          this.loadingSearch = 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);
          }
        });
    },
    editItem(item) {
      this.editedIndex = this.salaryData.indexOf(item);
      this.editedIndex = this.hourlyData.indexOf(item);
      this.editedItem = Object.assign({}, item);
      this.editedItem.date =
        this.editedItem.date != undefined
          ? (this.editedItem.date = this.editedItem.date.substring(0, 10))
          : (this.editedItem.date = "");
      this.editSalaryDialog = true;
    },
    selectSalary() {
      if (this.editedItem.salary === "Monthly") {
        this.monthlyGrade = true;
        this.hourlyGrades = false;
      } else {
        this.monthlyGrade = false;
        this.hourlyGrades = true;
      }
    },
    selectGrade() {
      console.log("this.editedItem", this.editedItem);
    },
    selectView() {
      if (this.editedItem.view.png === "Monthly") {
        this.viewSalary = true;
        this.viewHourly = false;
      } else {
        this.viewSalary = false;
        this.viewHourly = true;
      }
    },

    save() {
      var updateSalary = {
        role: this.editedItem.role,
        userId: this.editedItem._id,
        templateName: this.editedItem.salary,
        templateId: this.editedItem.salaryId
      };
      http()
        .put("/updateUserSalary", updateSalary, {
          headers: {
            Authorization: "Bearer " + this.token
          }
        })
        .then(response => {
          this.getUserDetailWithRoles();
          this.close();
          this.snackbar = true;
          this.text = response.data.message;
          this.color = "green";
          this.editSalaryDialog = false;
        })
        .catch(error => {
          console.log("error", error);
          this.snackbar = true;
          this.color = "red";
        });
    },

    deleteItem(item) {
      // let deleteGrade = {
      //   hourlyId: item._id
      // };
      // http()
      //   .delete(
      //     "/deleteHourly",
      //     confirm("Are you sure you want to delete this?") && {
      //       params: deleteGrade
      //     },
      //     {
      //       headers: {
      //         Authorization: "Bearer " + this.token
      //       }
      //     }
      //   )
      //   .then(response => {
      //     this.snackbar = true;
      //   //   this.text = "Successfully Delete Salary ";
      //     this.text = response.data.message;
      //     this.color = "green";
      //     this.getUserDetailWithRoles();
      //   })
      //   .catch(error => {
      //     console.log("error", error);
      //     this.snackbar = true;
      //     this.text = error.response.data.message;
      //     this.color = "red";
      //   });
    }

    // selectAllowances() {
    //   this.salaryTypeData.push({
    //     allowancesValue: (this.salaryType.allowancesValue = "")
    //   });
    //   //   console.log("this.salaryTypeData", this.salaryTypeData);
    //   var totalAllowances = "";
    //   this.salaryTypeData.forEach(allowancesValue_ => {
    //     if (allowancesValue_.allowancesValue != "") {
    //       // console.log("allowances", allowancesValue_.allowancesValue);
    //       totalAllowances =
    //         Number(totalAllowances) + Number(allowancesValue_.allowancesValue);
    //     }
    //     this.grossSalary =
    //       totalAllowances + Number(this.salaryType.basicSalary);
    //   });
    // },
    // allowancesAdd() {
    //   this.editedItem.allowances.push({
    //     allowancesValue: (this.salaryType.allowancesValue = "")
    //   });
    //   var totalAllowances = "";
    //   this.editedItem.allowances.forEach(allowancesValue_ => {
    //     if (allowancesValue_.allowancesValue != "") {
    //       //   console.log("allowances", allowancesValue_.allowancesValue);
    //       totalAllowances =
    //         Number(totalAllowances) + Number(allowancesValue_.allowancesValue);
    //       console.log("totalAllowances", totalAllowances);
    //     }
    //     this.editedItem.grossSalary =
    //       totalAllowances + Number(this.editedItem.basicSalary);
    //     console.log("this.editedItem.grossSalary", this.editedItem.grossSalary);
    //   });
    // },
    // selectDeduction() {
    //   this.salaryTypeDeductionData.push({
    //     deductionValue: (this.salaryType.deductionValue = "")
    //   });
    //   var totalDeductions = "";
    //   this.salaryTypeDeductionData.forEach(deductionValue_ => {
    //     if (deductionValue_.deductionValue != "") {
    //       //   console.log("deduction", deductionValue_.deductionValue);
    //       totalDeductions =
    //         Number(totalDeductions) + Number(deductionValue_.deductionValue);
    //     }
    //   });
    // },
    // deductionAdd() {
    //   this.editedItem.deduction.push({
    //     deductionValue: (this.salaryType.deductionValue = "")
    //   });
    //   var totalDeductions = "";
    //   this.editedItem.deduction.forEach(deductionValue_ => {
    //     if (deductionValue_.deductionValue != "") {
    //       //   console.log("deduction", deductionValue_.deductionValue);
    //       totalDeductions =
    //         Number(totalDeductions) + Number(deductionValue_.deductionValue);
    //       console.log("this.totalDeductions", totalDeductions);
    //     }
    //     // this.editedItem.totalDeduction = totalDeductions;
    //     // console.log("this.totalDeduction", this.editedItem.totalDeduction);
    //   });
    // },
    // deleteSelectAllowances: function(index) {
    //   this.salaryTypeData.splice(index, 1);
    // },
    // deleteallowancesAdd: function(index) {
    //   this.editedItem.allowances.splice(index, 1);
    // },
    // deleteSelectDeduction: function(index) {
    //   this.salaryTypeDeductionData.splice(index, 1);
    // },
    // deletedeductionAdd: function(index) {
    //   this.editedItem.deduction.splice(index, 1);
    // },
    // clear() {
    //   this.$refs.form.reset();
    //   this.disable = false;
    // }
  },

  mounted() {
    this.token = this.$store.state.token;
    this.getRole();
    this.getSalaryList();
    this.getHourlyList();
  }
};
</script>