<template>
<div>
   <v-card  class="mt-2" v-for="(detail,index) in xtests" elevation="3" class="mb-2">
        <v-layout v-if="parseInt(detail.id) === 0" style="background:lightcoral;font-weight: 900;" align-center class="text-xs-center" row>
            <v-flex pl-1 pa-1 xs11>
                <h3 class="mono">{{detail.promisedatetime}}</h3>
            </v-flex>
            <v-flex pl-1 pa-1 xs1>
                <v-flex text-xs-right>
                    <v-btn @click="copypromise(detail)" style="min-width:10px;margin:0" flat small color="#825c59"><v-icon>file_copy</v-icon></v-btn>
                </v-flex>
            </v-flex>
        </v-layout>
        <v-divider></v-divider>
        <v-layout  row>
            <v-flex pa-1 xs12>
                <v-chip v-for="test in detail.arr_test" style="font-size: 16px;font-weight:500" label color="pink" text-color="white">
                    {{test.name}}
                </v-chip>
            </v-flex>
        </v-layout>
    </v-card>
</div>
</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 = {
   methods : {
      isSelected(p) {
         return p.id == this.$store.state.samplecall.selected_test.id
      },
      selectMe(test) {
            var tests = this.$store.state.samplecall.tests
            this.$store.commit("samplecall/update_selected_test",test)
            var idx = _.findIndex(tests, function(o) { return o.orderid == test.orderid })
            var prm = test
            prm.orderid = this.$store.state.samplecall.selected_patient.orderid
            this.$store.dispatch("samplecall/getdatapromises",prm)
      },
      copypromise(value){
          var xdatetime = value.promisedatetime
          this.$store.commit("samplecall/update_copied_promise",xdatetime)
      }
   },
   computed: {
        isLoading() {
            return this.$store.state.samplecall.search_status == 1
        },
        xtests() {
            return this.$store.state.samplecall.tests
        },
        copiedpromise: {
         get() {
            return this.$store.state.samplecall.copied_promise
         },
         set(val) {
            this.$store.commit("samplecall/update_copied_promise",val)
         }
      },
   },
   watch: {
    search_company(val, old) {
      if (val == old) return;
      if (!val) return;
      if (val.length < 1) return;
      if (this.$store.state.samplecall.update_autocomplete_status == 1) return;
      this.thr_search_company();
    }
  },
   data() {
      return {
         msgalertconfirmation:"Perubahan yang telah dilakukan belum disimpan dong !",
         items: [],
         search_company: "",
         //isLoading: false,
         page:1,
         headers: [
            {
               text: "TEST",
               align: "left",
               sortable: false,
               value: "mr",
               width: "10%",
               class: "pa-2 blue lighten-3 white--text"
            }
         ]
      };
   }
}
</script>
