<template>
  <div class="main">
    <a-row>
      <a-card :body-style="{ 'padding-top': '10px' }">
        <div class="block">
          <!-- <span>月份</span>
          <a-month-picker v-model="selectDate" placeholder="选择年" @change="changeDate" :disabled-date="disabledDate" :allow-clear="false"/> -->
          <!-- <a-button type="primary" icon="download" style="float: right;margin:0 5px" @click="exportExecl">导出</a-button> -->
          <a-button type="primary"  style="float: right;margin:0 5px" @click="searchExecl">查询</a-button>
        </div>
      </a-card>
    </a-row>
    <a-row>
      <form ref="formMain9" id="formMain9" target="frameMain9" :action="reportSrc" method="post">
        <input type="hidden" name="width" v-model="windowWidth">
        <input type="hidden" name="height" v-model="windowHeight">
        <input type="hidden" name="year" :value="year">
        <input type="hidden" name="month" :value="month">
        <input type="hidden" name="flag" :value="flag">
        <input type="hidden" name="excelName" v-model="excelName">
      </form>
      <a-card :body-style="{ 'height': dxdcMainHeight + 'px', 'padding': '0' }">
        <div style="width: 100%;height: 100%;">
          <iframe
            ref="frameMain9"
            id="frameMain9"
            name="frameMain9"
            src=""
            frameborder="0"
            width="100%"
            height="100%"
            style="overflow: auto"></iframe>
        </div>
      </a-card>
    </a-row>
  </div>
</template>

<script>
import moment from 'moment';
export default {
  props: ['flag', 'selectDate', 'year', 'month'],
  data() {
    return {
      moment,
      // selectDate: '',
      //  year: '',
      // month: '',
      dxdcMainHeight: window.innerHeight - 230,
      windowHeight: window.innerHeight - 200,
      windowWidth: window.innerWidth - 350,
      reportSrc:
        '/modular-source/6ace62b8e2bb467d98286d260aebcef2/demo/reportJsp/reportJsp/showReport.jsp?rpx=dc_zg_008.rpx', // /modular-source/6ace62b8e2bb467d98286d260aebcef2
      loading: true,
      excelName: '上月提交本月不同意延期',
      now: '',
    };
  },
  mounted() {
    // var date = new Date().setMonth(new Date().getMonth() - 1)
    // this.year = new Date(date).getFullYear()
    // this.month = new Date(date).getMonth() + 1
    // this.selectDate = moment(new Date(date), 'YYYY-MM')
    // this.now = moment(new Date(date), 'YYYY-MM')
    // this.searchExecl()
  },
  computed: {
    persId() {
      return localStorage.getItem('persId')
        ? localStorage.getItem('persId')
        : '';
    },
  },
  methods: {
    changeDate(date, val) {
      if (val) {
        this.year = val.split('-')[0];
        this.month = val.split('-')[1];
      } else {
        this.year = '';
        this.month = '';
      }
    },
    // 获取Excel数据
    searchExecl() {
      // console.log("搜索条件 - " + this.ids.length);
      this.$nextTick(() => {
        this.loading = true;
        // 使用form表单post提交，彻底解决参数值过长的问题
        this.$refs.formMain9.submit();
        // 使用_this
        const _this = this;
        this.$refs.frameMain9.onload = () => {
          _this.loading = false;
        };
      });
    },
    // 导出Excel数据
    exportExecl() {
      console.log(window.frames['frameMain9']);
      v = window.frames['frameMain9'];
      v.report1_saveAsExcel();
    },
    disabledDate(current) {
      if (moment(current).format('DD') >= 29) {
        return current && current > moment().endOf('day');
      } else {
        return current && current > moment(this.now).endOf('day');
      }
    },
  },
};
</script>

<style lang='less' scoped>

</style>
