<template>
    <v-layout class="fill-height" column>
      <v-card class="grow">
         <!-- <v-subdetail>
            <h3 class="title">DAFTAR PASIEN</h3>
         </v-subdetail> -->
            <hr style="border-top:0px solid #c8c8c8;" />
         <v-data-table
            :headers="headers" :items="patients"
            :loading="isLoading"
            hide-actions class="xelevation-1">
            <template slot="items" slot-scope="props">
               <td class="text-xs-center pa-2 green--text" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.T_OrderHeaderLabNumber}}
               </td>
               <td class="text-xs-left pa-2 green--text" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.patient_name}}
               </td>
               <td class="text-xs-left pa-2 green--text" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.T_TestName}}
               </td>
               <td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.T_OrderRefIntDetailPromise}}
               </td>
               <td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.M_StatusRefName}}
               </td>
               <td class="text-xs-left pa-2" v-bind:class="is_selected(props.item)"
                   @click="select(props.item)">
                  {{props.item.T_OrderRefIntDetailResult}}
               </td>
            </template>

         </v-data-table>
         <v-pagination
            v-model="curr_patient_page"
            :length="total_patient_page"
            :total-visible="5"
            @input="change_page"
         ></v-pagination>
      </v-card>
   </v-layout>
</template>

<style scoped>
.searchbox .v-input.v-text-field .v-input__slot{
   min-height:60px;
}
.searchbox .v-btn {
   min-height:60px;
}
table.v-table tbody td,table.v-table tbody th {
   height: 40px;
}

table.v-table thead tr {
   height: 40px;
}
</style>

<script>
module.exports = {
    data() {
      return {
         query: "",
         items: [],
         headers: [
            {
               text: "NO LAB",
               align: "left",
               sortable: false,
               value: "mr",
               width: "15%",
               class: "pa-2 blue lighten-3 white--text"
            },
            {
               text: "NAMA",
               align: "left",
               sortable: false,
               value: "mr",
               width: "20%",
               class: "pa-2 blue lighten-3 white--text"
            },
            {
               text: "PEMERIKSAAN",
               align: "left",
               sortable: false,
               value: "mr",
               width: "20%",
               class: "pa-2 blue lighten-3 white--text"
            },
            {
               text: "JANJI HASIL",
               align: "left",
               sortable: false,
               value: "mr",
               width: "15%",
               class: "pa-2 blue lighten-3 white--text"
            },
            {
               text: "STATUS",
               align: "left",
               sortable: false,
               value: "mr",
               width: "15%",
               class: "pa-2 blue lighten-3 white--text"
            },
            {
               text: "HASIL",
               align: "left",
               sortable: false,
               value: "mr",
               width: "15%",
               class: "pa-2 blue lighten-3 white--text"
            }
         ],


         isLoading: false
      }
    },

    computed : {
        patients () {
            return this.$store.state.detail.details
        },

        curr_patient_page () {
            return this.$store.state.detail.curr_detail_page
        },

        total_patient_page () {
            return this.$store.state.detail.total_detail_page
        },

        selected_patient : {
            get () { return this.$store.state.detail.selected_detail },
            set (v) { this.$store.commit('detail/update_selected_detail', v) }
        }
    },

    methods : {
        change_page () {
            return
        },

        is_selected (x) {
            let y = this.selected_patient
            if (x.T_OrderRefIntDetailID == y.T_OrderRefIntDetailID)
                return true
            return false
        },

        select (x) {
            this.selected_patient = x
        }
    }
}
</script>