<template>
  <kr-print-designer ref="printDesigner" :temp-value="value" :widget-options="widgets" @save="handleSave" />
</template>
<script>
import { OutStockOptions, InStockOptions } from '../data/options'
export default {
  data() {
    return {
      index: '',
      printData: [],
      value: {
        title: 'demo',
        width: 750,
        height: 550,
        pageWidth: 750,
        pageHeight: 550,
        tempItems: [],
      },
      widgets: OutStockOptions,
    }
  },

  created() {
    this.index = this.$route.query.index
    this.printData = this.$route.query.printData
    try {
      this.value = this.printData
      this.widgets = OutStockOptions
    } catch (err) {
      console.error(err)
    }
  },
  methods: {
    handleSave(data) {
      console.log(data, 'data')
      this.$router.back()
    },
    // 手动初始话模板数据
    initTemp() {
      this.$refs.printDesigner.initTemp(this.value, this.widgets)
    }
  },
}
</script>
