<template>
   <v-layout class="fill-height" column>
      <v-card class="grow">
         <v-subheader class="pl-1 pr-1">
            
                    
               <v-text-field class="flex ma-1"
                           label=""
                           placeholder="Search"
                           single-line
                           solo
                           hide-details
                           v-model="query"
               ></v-text-field>

            <v-spacer></v-spacer>

            <v-btn class="flex ma-1" color="orange" dark @click="search" >
               Search
            </v-btn>

            <v-btn class="flex ma-1" color="success" @click="add_new" >
               Tambah
            </v-btn>
            
         </v-subheader>
            <hr style="border-top:0px solid #c8c8c8;" />
         <v-data-table
            :headers="headers" :items="templates"
            :loading="isLoading"
            hide-actions class="xelevation-1">
            <template slot="items" slot-scope="props">
               <td class="text-xs-left pa-2" 
                   @click="select(props.item)">
                  {{ props.item.Mcu_ReportTemplateName }}
               </td>
            </template>

         </v-data-table>

      </v-card>
      <one-dialog-new></one-dialog-new>
      
   </v-layout>
</template>

<style scoped>

.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;
}

.v-subheader {
   height: auto
}

</style>

<script>
module.exports = {
   components: {
      'one-dialog-new': httpVueLoader('./oneMcuReportTemplateDialogNew.vue')
   },

   data() {
      return {
         query: "",
         items: [],
         headers: [
            {
               text: "NAMA TEMPLATE",
               align: "left",
               sortable: false,
               value: "mr",
               width: "100%",
               class: "pa-2 blue lighten-3 white--text"
            }
         ],


         isLoading: false
         
      };
   },

   methods : {
      oneMoment : function(d) {
         return window.oneMoment(d)
      },

      select (item) {
         this.$store.commit('template/update_selected_template', item)
         this.$store.commit('template_detail/update_template_id', item.Mcu_ReportTemplateID)
         this.$store.dispatch('template_detail/search')
         // this.$store.commit('ver_verification/update_selected_sent_sample', item)
      },

      remove (item) {
        //  this.$store.commit('receive_patient/update_selected_sent_sample', item)
        //  this.$store.dispatch('receive_patient/remove')
      },

      search () {
         return
      },

      add_new() {
         this.$store.commit('template/update_dialog_new', true)
      }
   },

   computed : {
      templates () {
         return this.$store.state.template.templates
      }
   },

   mounted () {
      this.$store.dispatch('template/search')
   }
}
</script>
