<template>
    <v-dialog v-model="dialog_delete" persistent width="40vw">
        <v-card>
            <v-card-title class="headline grey lighten-2">DELETE RECEIVE ORDER ASSET</v-card-title>
            <v-card-text>
                <v-layout row wrap>
                    <v-flex xs3 class="pr-2"><strong>Tanggal</strong></v-flex>
                    <v-flex xs9>: {{ selected_roasset.ReceiveOrderPoIDate }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Nomor</strong></v-flex>
                    <v-flex xs9>: {{ selected_roasset.ReceiveOrderPoNumber }}</v-flex>

                    <v-flex xs3 class="pr-2"><strong>Nomor Referensi</strong></v-flex>
                    <v-flex xs9>: {{ selected_roasset.ReceiveOrderPoRefNumber }}</v-flex>

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

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


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

        }
    },
    computed: {
        dialog_delete: {
            get() {
                return this.$store.state.roasset.dialog_delete;
            },
            set(val) {
                this.$store.commit("roasset/update_dialog_delete", val);
            }
        },
        selected_roasset: {
            get() {
                return this.$store.state.roasset.selected_roasset;
            },
            set(val) {
                this.$store.commit("roasset/update_selected_roasset", val);
            }
        },
        loading_process() {
            return this.$store.state.roasset.loading_process;
        }
    },
    methods: {
        batalDelete() {
            this.selected_roasset = {}
            this.dialog_delete = false
        },
        confirmDelete() {
            if (!this.loading_process) {
                const received = this.selected_roasset;
                this.$store.dispatch("roasset/deleteReceiveAsset", received.ReceiveOrderPoID);
            } else {
                const msg = "Masih terdapat proses lain yang berjalan";
                const snac = { color: 'error', msg: msg, state: false };
                this.$store.commit("roasset/update_snackbar", snac);
            }
        }
    },
    watch: {}
}
</script>
