<template>
   <v-layout class="fill-height" column>
      <v-dialog v-model="dialognormalvalue" persistent  max-width="850">
         <v-card>
            <v-card-title color="warning"  class="headline">NILAI NORMAL</v-card-title>
               <v-card-text>
                     <v-layout row>
                        <v-flex xs4 pa-1>
                           <v-select
                              outline
                              item-text="name"
                              return-object
                              :items="xfiltermethode" 
                              v-model="xselected_filter_methode"
                              @change="getdatas()"
                              label="Pilih Methode"
                           ></v-select>
                        </v-flex>
                     </v-layout>
                     <v-layout row>
                        <v-flex xs12 pa-1>
                           <v-data-table 
                                 :headers="headers" 
                                 :items="xdatas"
                                 :loading="isLoading"
                                 hide-actions class="elevation-1">
                                 <template slot="items" slot-scope="props">
                                    <td class="text-xs-left pa-2" v-html="props.item.normalvalue_description"></td>
                                    <!--<td class="text-xs-center pa-2" v-bind:class="{'amber lighten-4':isSelected(props.item)}" @click="selectMe(props.item)">
                                       <div>
                                             <v-btn @click="addToLists(props.item)" v-if="checkInLists(props.item) === false" small color="error"><v-icon left>close</v-icon>  Belum dipilih</v-btn>
                                             <v-btn v-if="checkInLists(props.item) === true" flat small color="success"><v-icon left>check</v-icon> Sudah terpilih</v-btn>
                                       </div>
                                    </td>-->
                                 </template>
                           </v-data-table>
                        </v-flex>
                     </v-layout>
               </v-card-text>
               <v-card-actions>
               <v-spacer></v-spacer>
               <v-btn color="warning"  @click="closeDialogNormalValue()">Tambahkan</v-btn>
               </v-card-actions>
            </v-card>
         </v-dialog>
    </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 = {
    mounted() {
      this.$store.dispatch("sample/getnormalvalue",{
            methodeid:this.$store.state.sample.selected_filter_methode.id
         })
   },
   methods : {
       getdatas(){
           this.$store.dispatch("sample/getnormalvalue",{
            methodeid:this.$store.state.sample.selected_filter_methode.id
         })
       },
       closeDialogNormalValue(){
           var datas = this.$store.state.sample.normal_values
            this.$store.commit("sample/update_criterias",datas)
            this.$store.commit("sample/update_dialog_normal_value",false)
            
       }
   },
   computed: {
       dialognormalvalue:{
         get() {
               return this.$store.state.sample.dialog_normal_value
         },
         set(val) {
               this.$store.commit("sample/update_dialog_normal_value",val)
         }
      },
        isLoading() {
         return this.$store.state.sample.search_status == 1
      },
      xfiltermethode(){
         return this.$store.state.sample.filter_methodes
      },
      xselected_filter_methode:{
         get() {
               return this.$store.state.sample.selected_filter_methode
         },
         set(val) {
               this.$store.commit("sample/update_selected_filter_methode",val)
         }
      },
      xdatas(){
         return this.$store.state.sample.normal_values
      },
   },
   data() {
      return {
         msgalertconfirmation:"Perubahan yang telah dilakukan belum disimpan dong !",
         menufilterdatestart:false,
         menufilterdateend:false,
         date: new Date().toISOString().substr(0, 10),
         items: [],
         name: '',
         page:1,
         headers: [
            {
               text: "NILAI NORMAL",
               align: "left",
               sortable: false,
               width: "100%",
               class: "pa-2 blue lighten-3 white--text"
            }
         ],
         pagination:{
            descending: false,
            page: 1,
            rowsPerPage: 5,
            sortBy: 'trx_id ASC',
            totalItems: this.$store.state.sample.total_transactions
         }
      };
   }
}
</script>
