<template>
  <el-dialog title="打印" :visible.sync="printVisible" width="30%">
    <div style="text-align:center" id="print">
      <vue-qr :text="token" :size="200"></vue-qr>
      <p style="font-size:18px">姓名:{{name}}</p>
      <p style="font-size:18px">{{organization}}</p>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="printVisible = false">取 消</el-button>
      <el-button type="primary" v-print="'#print'" @click="handClick">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
import vueQr from "vue-qr";

export default {
  name: "printCode",
  data() {
    return {
      printVisible: false,
      name: "",
      organization: "",
      meetingId: "",
      token: ""
    };
  },
  created() {},
  components: {
    vueQr
  },
  computed: {},
  beforeMount() {},
  mounted() {},
  methods: {
    init(data) {
      this.printVisible = true;
      this.name = data.truename;
      this.organization = data.organization;
      this.aid = data.aid;
      this.token =
        window.SITE_CONFIG['img']+"/qrcode/webmeeting.html?token=" + data.symbol + "&meetingId=" + data.meetingId;
    },
    handClick() {
      this.$http({
        url: this.$http.adornUrl(`/admin/sign/printcode/${this.aid}`),
        method: "post",
        data: {
        }
      })
        .then(({ data }) => {
          if (data && data.code === 0) {
            this.printVisible = false;
            this.$emit("getData");
            return;
          }
        })
        .catch(error => {
          console.log(error);
        });
    }
  },
  watch: {}
};
</script>
<style scoped>
</style>
