<template>
   <v-layout class="fill-height" column>
      <v-card class="grow">
         <v-subheader class="mb-2">
            <h3 class="title">DETAIL TEMPLATE</h3>
            <v-spacer></v-spacer>
            <v-btn 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)">
                   <span v-bind:class="['ml-' + (props.item.Mcu_ReportTemplateDetailLeftMargin),
                                    'pl-' + (props.item.Mcu_ReportTemplateDetailLeftMargin) ]">
                      {{ props.item.Mcu_ReportTemplateDetailDesc }}
                   </span>
                  
               </td>

               <td class="text-xs-left pa-2" 
                   @click="select(props.item)">
                  {{ props.item.Mcu_ReportTemplateDetailIsTest }}
               </td>

               <td class="text-xs-left pa-2" 
                   @click="select(props.item)">
                  {{ props.item.Mcu_ReportTemplateDetailT_TestCode }}
               </td>

               <td class="text-xs-left pa-2">
                  <v-btn color="primary" small class="ma-0" @click="edit(props.item)">Edit</v-btn>
                  <v-btn color="red" dark small class="ma-0">Hapus</v-btn>
               </td>
            </template>

         </v-data-table>

      </v-card>
      <one-dialog-new></one-dialog-new>
   </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 = {
   components: {
      'one-dialog-new': httpVueLoader('./oneMcuReportTemplateDetailDialogNew.vue')
   },

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

            {
               text: "IS TEST",
               align: "left",
               sortable: false,
               value: "mr",
               width: "10%",
               class: "pa-2 blue lighten-3 white--text"
            },

            {
               text: "KODE TEST",
               align: "left",
               sortable: false,
               value: "mr",
               width: "20%",
               class: "pa-2 blue lighten-3 white--text"
            },

            {
               text: "ACTION",
               align: "left",
               sortable: false,
               value: "mr",
               width: "20%",
               class: "pa-2 blue lighten-3 white--text"
            }
         ],


         isLoading: false
         
      };
   },

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

      select (item) {
         // 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')
      },

      add_new() {
         this.$store.commit('template_detail/update_is_edit', false)
         this.$store.commit('template_detail/update_dialog_new', true)
      },

      edit (item) {
         this.$store.commit('template_detail/update_template_detail_id', item.Mcu_ReportTemplateDetailID)
         this.$store.commit('template_detail/update_is_edit', true)
         this.$store.commit('template_detail/update_template_new',
            {is_test:item.Mcu_ReportTemplateDetailIsTest, desc:item.Mcu_ReportTemplateDetailDesc})
         this.$store.commit('template_detail/update_dialog_new', true)

      }
   },

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

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