<template>
  <div id="test" v-if="showReport">
    <XReport
      @updateImg="updateImg"
      ref="main"
      :use-oss-for-img="false"
      config-name="outpatientWait"
      server-name="af-his"
      :show-img-in-cell="true"
      :display-only="displayOnly"
      :edit-mode="false"
      :show-save-button="false"
      :dont-format="true"/>
  </div>
</template>

<script>
import XReport from '@vue2-client/base-client/components/common/XReportGrid/XReport'
// eslint-disable-next-line no-unused-vars
import { exportHTMLNodeToPDF } from '@vue2-client/utils/htmlToPDFApi'

export default {
  name: 'Example',
  components: {
    XReport
  },
  mounted () {
    console.log(this.$route)
  },
  data () {
    return {
      test: {
        title: {
          type: 'titleKey',
          value: 'f_type'
        },
        designMode: 'json',
      },
      total: 1,
      registerMap: [],
      displayOnly: true,
      showReport: true
    }
  },
  methods: {
    updateImg (data) {
      console.warn('demo', data)
    },
    testExport () {
      this.showReport = false
      this.displayOnly = true
      this.$nextTick(() => {
        this.showReport = true
        setTimeout(() => {
          exportHTMLNodeToPDF('123', '#test')
          this.showReport = false
          this.displayOnly = false
          this.$nextTick(() => {
            this.showReport = true
          })
        }, 500)
      })
    },
    testSave () {
      const result = []
      this.registerMap.forEach(item => {
        result.push(item.exportData())
      })
      console.warn('save', result)
    }
  }
}
</script>
<style scoped>

</style>
