<template>
  <a-layout style="height:100%;">
    <a-layout-header style="display:flex;align-items:center;" v-if="vShow">
      <p>人员名称</p>
      <a-input v-model:value="persName" allow-clear style="width: 150px;margin-left:10px;margin-right:15px" size="small"></a-input>
      <p>机构名称</p>
      <a-input
        v-model:value="orgName"
        allow-clear
        style="width: 150px;margin-left:10px;margin-right:15px"
        size="small"></a-input>
      <a-button
        type="primary"
        
        style="margin-left:5px;"
        plain
        @click="searchExecl">查询</a-button>
      <span style="margin-left:15px;" v-show="!show">(<b style="color:red;">注意：Excel文件导入操作会覆盖本页所有数据，请谨慎操作。</b>)</span>
    </a-layout-header>
    <a-layout-content id="dcjhMain">
      <div :style="{'height':dxdcMainHeight + 'px','padding':'0','width':'100%','overflow':'hidden'}" v-loading="false">
        <iframe
          ref="myIframe"
          id="frameMainDcry"
          src=""
          frameborder="0"
          width="100%"
          height="100%"
          style="overflow: auto"></iframe>
      </div>
    </a-layout-content>
  </a-layout>
</template>

<script>
import request from '../../../utils/gw_ajax_request.js';
import { dateFormat } from '../../../utils/gw_date.js';
export default {
  props: [
    'show',
    'persNameStr',
    'orgNmStr',
    'pageStr',
    'heightStr',
    'widthStr',
    'dxdcMainHeightStr',
  ],
  data() {
    return {
      loading: true,
      reportSrc: '/demo/reportJsp/showInput.jsp?sht=renyuan_baseInfo_line.sht',
      excelName: '督查人员基础信息表',
      dxdcMainHeight: window.innerHeight - 130,
      windowHeight: window.innerHeight - 130,
      windowWidth: window.innerWidth - 10,
      vShow: true,
      persName: '',
      orgName: '',
      page: 1,
    };
  },
  computed: {
    userId: () =>
      localStorage.getItem('persId')
        ? localStorage.getItem('userid')
        : '1098101939614724096',
  },
  mounted() {
    if (this.show != undefined) {
      this.vShow = this.show;
    }
    if (this.persNameStr != undefined) {
      this.persName = this.persNameStr;
    }
    if (this.orgNmStr != undefined) {
      this.orgName = this.orgNmStr;
    }
    if (this.pageStr != undefined) {
      this.page = this.pageStr;
    }
    if (this.heightStr != undefined) {
      this.windowHeight = this.heightStr;
    }
    if (this.widthStr != undefined) {
      this.windowWidth = this.widthStr;
    }
    if (this.dxdcMainHeightStr != undefined) {
      this.dxdcMainHeight = this.dxdcMainHeightStr;
    }
    this.searchExecl();
  },
  methods: {
    // 获取Excel数据
    searchExecl() {
      this.loading = true;
      const iframe = document.getElementById('frameMainDcry');
      const src = this.reportSrc;
      const _persName = this.persName == '' ? 'all' : this.persName;
      const _orgName = this.orgName == '' ? 'all' : this.orgName;
      const _page = this.page;
      iframe.src =
        src +
        '&width=' +
        this.windowWidth +
        '&height=' +
        this.windowHeight +
        '&excelName=' +
        this.excelName +
        '&persName=' +
        _persName +
        '&orgName=' +
        _orgName +
        '&page=' +
        _page;

      if (iframe.attachEvent) {
        iframe.attachEvent('onload', () => {
          this.loading = false;
        });
      } else {
        iframe.onload = () => {
          this.loading = false;
        };
      }
    },
    // 导出Excel数据
    exportExecl() {
      v = window.frames['frameMainDcry'];
      v.report1_saveAsExcel();
    },
  },
};
</script>

<style lang='less' scoped>

</style>
