<template>
  <div>
    <Modal v-model="showDiagramModalOriginalRecordLook" title="原始记录" width="1300" class="footer-hidden">
      <div id="iframeAppendOriginalRecordLookFive" style="text-align:center;align-content:center;width: 100%;height: 790px">
      </div>
      <div slot="footer">
      </div>
    </Modal>
  </div>
</template>
<script>
/**
 * 详情
 */
export default {
  data() {
    return {
      showDiagramModalOriginalRecordLook: false,
      templateId: '',
      again: true,
      itemIds: [],
      recordId: 0
    }
  },
  mounted() {
    // 监听原始记录消息
    window.addEventListener('message', this._saveOriginal)
  },
  methods: {
    _saveOriginal(data) {
      console.log('data11111', data)
      if (this.again) {
        this.again = false
        if (data.data.msg === true) {
          this.$store
            .dispatch('FoodItem/saveAppendFormForItem', {
              ids: this.itemIds,
              formId: this.recordId
            })
            .then(() => {
              this._cancel()
            })
        } else {
          this._cancel()
        }
      }
    },
    _cancel() {
      this.showDiagramModalOriginalRecordLook = false
    },
    _open(itemIds, formId) {
      this.itemIds = itemIds
      this.recordId = formId
      this.again = true
      this.showDiagramModalOriginalRecordLook = true
      let url = ''
      url += 'http://record.patzn.com:7000/print/v1/eln/form_' + formId
      $('#iframeAppendOriginalRecordLookFive').html(
        '<iframe style="padding: 0px;width:100%;height:100%" frameborder="0" src=' +
          encodeURI(url) +
          '></iframe>'
      )
    }
  }
}
</script>
