<template>
  <item-detail :is-edit="false" />
</template>

<script>
import itemDetail from './components/detail.vue'

export default {
  name: 'createPrintBill',
  components: { itemDetail },
  beforeRouteLeave(to,from,next) {
    if (to.name == undefined || to.name == null) {
      const answer = window.confirm('当前页面数据未保存，确定要离开？')
      if (answer) {
        next()
      } else {
        next(false)
      }
    } else {
      next()
    }
  },
  mounted() {
    window.onbeforeunload = function (e) {
      e = e || window.event;
      // 兼容IE8和Firefox 4之前的版本
      if (e) {
        e.returnValue = '关闭提示';
      }
      // Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
      return '关闭提示';
    }
  },
  destroyed() {
    window.onbeforeunload = null
  }
}
</script>

