<template>
  <div>
    <criteria-paged :model="model" :pager='false' v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.search' v-ref:criteria>
        <div novalidate class="form-inline auto " partial>
          <div class="flex-row auto" style="justify-content: space-between">
            <div class="form-group">
              <label for="startDate">起始时间:</label>
              <datepicker id="startDate" placeholder="起始时间"
                          :value.sync="$parent.$parent.startDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd 00:00:00'"
                          :select-month="true"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="form-group">
              <label for="startDate">结束时间:</label>
              <datepicker id="endDate" placeholder="结束时间"
                          :value.sync="$parent.$parent.endDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd 23:59:59'"
                          :select-month="true"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="form-group">
              <button class="btn btn-success width-100" @click="search">查询</button>
              <report-print id='bussummary' top='1cm' left='2cm' width='100%' height='100%'></report-print>
              <report-excel id='bussummary'></report-excel>
            </div>
          </div>
        </div>
      </criteria>
      <div partial='list' v-el:handcollect id='bussummary'>
        <table class='tableprint' style="margin: 0px auto">
          <thead>
          <tr>
            <th colspan='12' style="font-weight: normal; text-align: left;">
              <h3 style="text-align: center">安检小区用户数据报表</h3>
            </th>
          </tr>
          </thead>
          <tr>
            <td colspan='12'>
              {{{ model.data.substring(26,model.data.length-8) }}}
            </td>
          </tr>
        </table>
      </div>
    </criteria-paged>
    <work-busy :is-busy="isBusy"></work-busy>
  </div>
</template>

<script>
  import {DataModel, HttpResetClass} from 'vue-client'
  import * as Util from '../Util'
  import {toStartDateYearString} from '../Util'
  export default {
    title: '安检小区用户数据报表',
    props: ['data'],
    data() {
      let model = new DataModel('rs/report/safePaperDataSummary', {startDate: 'this.startDate', endDate: 'this.endDate'});
      model.startDate = ''
      model.endDate = ''
      return {
        model: model,
        startDate: Util.toStartDateYearString() + ' 00:00:00',
        endDate: Util.toEndDateString() + ' 23:59:59'
      }
    },
    ready() {

    },
    methods: {
      // 根据文件路径获取储存的报表内容
      getFileContent(path) {
        this.$resetpost('rs/logic/getReportFileContent', {f_files_path: path}, {resolveMsg: null, rejectMsg: null}).then((res) => {
          this.reportStr = res.data.filecontent
          this.model.state = '正确'
        })
      },
      async search(args){
        this.condition = ' 1 = 1 '
        if(!this.startDate){
          this.$showMessage('请选择起始时间')
          return
        }
        if(!this.endDate){
          this.$showMessage('请选择结束时间')
          return
        }
        this.isBusy = true
        this.model.startDate = this.startDate
        this.model.endDate = this.endDate
        await this.model.search(args.condition, args.model)
        this.isBusy = false
      }
    },
    computed: {
    },
    watch: {
    }
  }
</script>
<style>
  .noshow{
    display: none;
  }
  .report-center{
    text-align: center;
  }
</style>
