<template>
    <v-dialog
        v-model="dialog"
        max-width="500px"
    >
        <v-card>
            <v-card-text>
                <v-layout row wrap>
                    <v-flex xs12>
                        <v-text-field
                            label="Pemeriksaan"
                            v-model="selected_px.t_testname"
                            readonly
                        ></v-text-field>
                    </v-flex>

                    <v-flex xs12>
                        <v-text-field
                            label="Metode sekarang"
                            v-model="selected_px.methode_name"
                            readonly
                        ></v-text-field>
                    </v-flex>

                    <v-flex xs12>
                        <v-select
                            :items="methods"
                            item-text="Nat_MethodeName"
                            item-value="Nat_MethodeID"
                            return-object
                            v-model="selected_method"
                            label="Pilih Metode baru"
                        ></v-select>
                    </v-flex>
                </v-layout>
                
            </v-card-text>
            <v-card-actions>
                <v-btn color="primary" flat @click="dialog=!dialog">Tutup</v-btn>
                <v-spacer></v-spacer>
                <v-btn color="primary" dark @click="save">Simpan</v-btn>
            </v-card-actions>
        </v-card>
    </v-dialog>
</template>

<script>
module.exports = {
    data () {
        return {

        }
    },

    computed : {
        dialog : {
            get () { return this.$store.state.normal_method.dialog_method },
            set (v) { this.$store.commit('normal_method/update_dialog_method', v) }
        },

        methods () {
            return this.$store.state.normal_method.methods
        },

        selected_method : {
            get () { return this.$store.state.normal_method.selected_method },
            set (v) { this.$store.commit('normal_method/update_selected_method', v) }
        },

        selected_px () {
            return this.$store.state.re_px.selected_px
        }
    },

    methods : {
        save () {
            this.$store.dispatch('normal_method/save_method')
        }
    },

    watch : {
        dialog(val, old) {
            if (val && !old) {
                this.$store.dispatch('normal_method/search_method')
            }
        }
    }
}
</script>
