<template>
    <v-dialog
        v-model="dialog"
        persistent
        max-width="500px"
    >
        <v-card>
            <v-card-text>
                <h3 class="title mb-2">Serah terima kurir berhasil.</h3>
                <h3 class="subheading">Nomor SJ : {{ selected_order.T_OrderRefOutHeaderNumber }}</h3>
                <h3 class="subheading">Kurir : {{ selected_courier.M_StaffName }}</h3>

            </v-card-text>

            <v-card-actions>
                <v-btn color="primary" flat @click="dialog=false">Tutup</v-btn>
                <v-spacer></v-spacer>
                <v-btn color="orange" dark @click="printSJ">Cetak Surat Jalan</v-btn>
            </v-card-actions>
        </v-card>
    </v-dialog>
</template>

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

    computed : {
        selected_order () {
            return this.$store.state.order.selected_order
        },

        selected_courier () {
            return this.$store.state.order.selected_courier
        },

        dialog : {
            get () { return this.$store.state.order.dialog_finish },
            set (v) { this.$store.commit('order/update_dialog_finish', v) }
        }
    },

    methods : {
        printSJ () {
            this.$store.commit('order/update_dialog_print', true)
        }
    },

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