<template>
    <v-dialog v-model="dialog_deleteorder" persistent width="40vw">
        <v-card>
            <v-card-title class="headline grey lighten-2">DELETE REQUEST PO</v-card-title>
            <v-card-text>
                <v-layout row wrap>
                    <v-flex xs3 class="pr-2"><strong>Nomor</strong></v-flex>
                    <v-flex xs9>: {{ selected_orderaset.PurchaseOrderNumber }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Tanggal</strong></v-flex>
                    <v-flex xs9>: {{ selected_orderaset.PurchaseOrderDate }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Cabang</strong></v-flex>
                    <v-flex xs9>: {{ selected_orderaset.M_BranchName }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Supplier</strong></v-flex>
                    <v-flex xs9>: {{ selected_orderaset.SupplierName }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Catatan</strong></v-flex>
                    <v-flex xs9>: {{ selected_orderaset.PurchaseOrderNote }}</v-flex>
                </v-layout>
            </v-card-text>
            <v-card-actions>
                <v-spacer></v-spacer>
                <v-btn @click="batalhapus()" color="error" class="white--text">Batal</v-btn>
                <v-btn @click="hapusorder()" color="primary" class="white--text">Hapus</v-btn>
            </v-card-actions>
        </v-card>
    </v-dialog>
</template>

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

        }
    },
    computed: {
        dialog_deleteorder: {
            get() {
                return this.$store.state.common.dialog_deleteorder
            },
            set(val) {
                this.$store.commit('common/update_dialog_deleteorder', val)
            }
        },
        selected_orderaset() {
            return this.$store.state.common.selected_orderaset
        },
        loading_process() {
            return this.$store.state.common.loading_process
        }
    },
    methods: {
        batalhapus() {
            this.dialog_deleteorder = false
        },
        hapusorder() {
            if (!this.loading_process) {
                this.$store.dispatch("common/deleteOrderAsset")
            } else {
                const snac = { color: 'warning', msg: 'proses sedang berjalan', state: true };
                this.$store.commit('common/update_snackbar', snac);
            }
        }
    },
}
</script>
