<template>
  <v-dialog v-model="dialog" width="500" persistent>
    <v-card>
      <v-card-title class="headline grey lighten-2 pt-2 pb-2" primary-title>
        Pendaftaran Berhasil
      </v-card-title>
      <v-card-text class="pt-2 pb-2">
        <h6 class="display-1 text-center">
          No Reg <span class="blue--text">{{ text_labno }}</span>
        </h6>
      </v-card-text>
      <v-divider></v-divider>

      <v-card-actions>
        <v-spacer></v-spacer>
        <v-btn color="info" flat @click="printQrcode"> Print Qrcode </v-btn>
        <v-btn color="success" flat @click="printBarcode">
          Print Barcode
        </v-btn>
        <v-btn color="primary" flat @click="finish"> Tutup </v-btn>
      </v-card-actions>
    </v-card>
  </v-dialog>
</template>

<style scoped></style>

<script>
module.exports = {
  components: {},
  methods: {
    tuing: function () {
      alert("x");
    },

    finish: function () {
      console.log("aye2");
      this.dialog = false;
      this.$store.commit("order/update_tab_enable", [0, false]);
      this.$store.commit("order/update_tab_enable", [1, false]);
      //this.$store.commit('change_tab', '03')
      this.$store.dispatch("payment/reset", {
        order_id: this.$store.state.payment.order_id,
        time_start: this.$store.state.order.show_time,
        url: this.xurl,
      });
      // var mcuid = this.$store.state.order.mcuid
      //   location.replace("/one-ui/test/vuex/one-mcu-offline-preregister-app-cponev2/?mcuid=" + mcuid)
    },
    printBarcode() {
      one_print_barcode_formulir(this.text_labid);
      this.$store.dispatch("order/getbarcode", {
        id: this.text_labid,
        no_lab: this.text_labno,
        name: this.text_labname,
        register_date: this.text_labdate,
      });
    },
    printQrcode() {
      let inp = {};
      inp.id = this.text_labid;
      inp.no_lab = this.text_labno;
      inp.name = this.text_labname;
      inp.register_date = this.text_labdate;
      one_print_qrcode(inp);
      // console.log("Input prm")
      // console.log(inp)
      console.log("print barcode new");
      console.log(inp);
      one_print_qrcode_patient(inp);
      // this.$store.dispatch("order/getbarcode", {
      //   id: this.text_labid,
      //   no_lab: this.text_labno,
      //   name: this.text_labname,
      //   register_date: this.text_labdate,
      // });
    },
  },
  computed: {
    dialog: {
      get() {
        return this.$store.state.order.finish_dialog_is_active;
      },
      set(val) {
        this.$store.commit("order/update_finish_dialog_is_active", val);
      },
    },

    text_labno() {
      return this.$store.state.order.current_order.noreg;
    },
    text_labid() {
      return this.$store.state.order.current_order.id;
    },
    text_labname() {
      return this.$store.state.order.current_order.name;
    },
    text_labdate() {
      return this.$store.state.order.current_order.register_date;
    },
    xurl() {
      return this.$store.state.order.current_order.url;
    },
  },
};
</script>
