<template>
  <v-layout row justify-center>
    <v-dialog v-model="dialog_dnafragmentasi" persistent max-width="40%">
      <v-card>
        <v-card-title>
          <span class="headline">DNA FRAGMENTASI INDEKS</span>
        </v-card-title>
        <v-card-text>
            <v-layout mb-2 row>
              <v-flex pa-2 xs6>
                  <v-select
                      class="mini-select"
                      item-text="name"
                      return-object
                      outline
                      :items="doctors"
                      v-model="selected_doctor"
                      disabled
                      hide-details
                      label="Dokter"
                  ></v-select>
                  <p v-if="error_doctor" class="error pl-2 pr-2" style="color:#fff">Dokternya siapa ? jangan lupa ya ...</p>
              </v-flex>
              <v-flex pa-2 xs6>
                  <v-select
                      class="mini-select"
                      item-text="name"
                      disabled
                      return-object
                      outline
                      :items="methodes"
                      v-model="selected_methode"
                      hide-details
                      label="Metode"
                  ></v-select>
              </v-flex>
            </v-layout>
            
            <v-layout wrap>
              <v-flex  xs12>
                <v-layout  mb-2 row>
                    <v-flex pa-2 xs6>
                       <v-text-field
                       disabled
                            label="Sperma dengan Halo Luas"
                            outline
                            v-model="results.halo_luas"
                            hide-details
                        ></v-text-field>
                    </v-flex>
                    <v-flex pa-2 xs6>
                        <v-text-field
                            label="Sperma dengan Halo Sedang"
                            outline
                            disabled
                            v-model="results.halo_sedang"
                            hide-details
                        ></v-text-field>
                    </v-flex>
                </v-layout>
                <v-layout  mb-2 row>
                    <v-flex pa-2 xs6>
                        <v-text-field
                        disabled
                            label="Sperma dengan Halo Sempit"
                            outline
                            v-model="results.halo_sempit"
                            hide-details
                        ></v-text-field>
                    </v-flex>
                    <v-flex pa-2 xs6>
                       <v-text-field
                       disabled
                            label="Sperma dengan Tanpa Halo"
                            outline
                            v-model="results.tanpa_halo"
                            hide-details
                        ></v-text-field>
                    </v-flex>
                </v-layout>
                <v-layout  mb-2 row>
                    <v-flex pa-2 xs4>
                        <v-text-field
                            label="DFI"
                            outline
                            disabled
                            v-model="results.dfi"
                            hide-details
                        ></v-text-field>
                    </v-flex>
                    <v-flex pa-2 xs4>
                        <v-textarea
                            auto-grow
                            label="Keterangan"
                            outline
                            disabled
                            grow
                            v-model="results.kesimpulan"
                            hide-details
                        ></v-textarea>
                    </v-flex>
                    <v-flex pa-2 xs4>
                        <v-textarea
                            auto-grow
                            label="Catatan"
                            outline
                            disabled
                            grow
                            v-model="results.catatan"
                            hide-details
                        ></v-textarea>
                    </v-flex>
                </v-layout>
              </v-flex>
            </v-layout>
        </v-card-text>
        <v-card-actions>
          <v-spacer></v-spacer>
          <v-btn color="blue darken-1" flat @click="dialog_dnafragmentasi = false">Tutup</v-btn>
         
        </v-card-actions>
      </v-card>
    </v-dialog>
  </v-layout>
</template>

 <script>
 module.exports = {
   mounted() {
       console.log("dialog dna fragmentasi")
      //this.$store.dispatch("re_fragmentasi/get_doctors",{token:''})
   },
   data() {
      return {
        error_doctor:false
        
      };
   },
    computed: {
       onprocess(){
          return this.$store.state.re_dnafragmentasi.onprocess
        },
        dialog_dnafragmentasi: {
            get() {
                return this.$store.state.re_dnafragmentasi.dialog_dnafragmentasi
            },
            set(val) {
                this.$store.commit("re_dnafragmentasi/update_dialog_dnafragmentasi", val)
            }
        },
        results: {
            get() {
                return this.$store.state.re_dnafragmentasi.results
            },
            set(val) {
                this.$store.commit("re_dnafragmentasi/update_results", val)
            }
        },
        doctors(){
          return this.$store.state.re_dnafragmentasi.doctors
        },
        selected_doctor: {
            get() {
                return this.$store.state.re_dnafragmentasi.selected_doctor
            },
            set(val) {
                this.$store.commit("re_dnafragmentasi/update_selected_doctor", val)
            }
        },
        methodes(){
          return this.$store.state.re_dnafragmentasi.methodes
        },
        selected_methode: {
            get() {
                return this.$store.state.re_dnafragmentasi.selected_methode
            },
            set(val) {
                this.$store.commit("re_dnafragmentasi/update_selected_methode", val)
            }
        }
    },
    methods: {
        saveResult_DNAFragmentasi(){
          console.log('in save')
          //this.$store.dispatch("re_fragmentasi/saveresult_cytologi",{results:this.results})
          if(_.isEmpty(this.selected_doctor) || this.selected_doctor == '0'){
              this.error_doctor = true

            }else
            this.$store.commit("re_dnafragmentasi/update_onprocess", true)
              this.$store.dispatch("re_dnafragmentasi/saveresult_dnafragmentasi",{methode:this.selected_methode,doctor:this.selected_doctor,results:this.results})
            
        }
    }
    
 }
</script>
