<template>
  <div id='app' class="basic-main" style="height: 100%">
    <criteria-paged :model="model" :pager='false' v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.search' class="search_area" v-ref:criteria>
        <div novalidate class="form-inline auto" partial>
          <div class="row">
            <div class="col-sm-4 form-group">
              <role-selector-safe
                role-name="安检员"
                role-lable="安&ensp;检&ensp;员"
                @re-res="$parent.$parent.getRes"
                :value.sync="model.f_checker_id"
                v-model="model.f_checker_id"
                condition="f_checker_name = '{}'">
              </role-selector-safe>
            </div>
            <div  :class="{'form-group col-sm-3':$parent.$parent.$parent.isdetail,'form-group col-sm-2':!$parent.$parent.$parent.isdetail}">
              <label class="font_normal_body">小区名称</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_residential_area" placeholder='小区名称'
                     condition="f_residential_area like '%{}%'" v-next-el="cx" v-el:qjmc>
            </div>
            <div class="col-sm-2 form-group">
              <label for="startDate" class="font_normal_body">开始日期:</label>
              <datepicker id="startDate" placeholder="开始日期"
                          v-model="model.startDate"
                          :value.sync="model.startDate"
                          style="width: 60%;"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2 form-group">
              <label for="endDate" class="font_normal_body">结束日期:</label>
              <datepicker id="endDate" placeholder="结束日期"
                          v-model="model.endDate"
                          :value.sync="model.endDate"
                          :disabled-days-of-Week="[]"
                          style="width: 60%;"
                          :format="'yyyy-MM-dd HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-3 form-group" style="margin-top: 8px">
              <button class="button_search button_spacing" @click="search()">查询</button>
              <report-print class="button_export button_spacing" style="width:28%" id='shexian'></report-print>
              <report-excel class="button_export button_spacing" style="width:28%" id='shexian'></report-excel>
            </div>
          </div>
        </div>
      </criteria>
      <div partial='list' id='shexian' class="list_area" style="overflow-y: scroll">
        <table class='tableprint' style="margin: 0px auto">
          <thead>
          <tr>
            <th colspan='5' style="font-weight: normal; text-align: left;">
              <h3 style="text-align: center">安检数据报表</h3>
            </th>
          </tr>
          <tr>
            <th colspan='5' style="font-weight: normal; text-align: center;">
              开始时间：{{model.model.startDate}}&nbsp;&nbsp;&nbsp;
              结束时间：{{ model.model.endDate }}
            </th>
          </tr>
          </thead>
          <tr>
            <th colspan='5' style="font-weight: normal;">
              {{{ model.data.substring(26,model.data.length-8) }}}
            </th>
          </tr>
        </table>
      </div>
    </criteria-paged>
  </div>

</template>

<script>
  import {DataModel} from 'vue-client'
  import * as Util from "../Util";

  export default {
    title: '维修员报表',
    data() {
      let model = new DataModel('/rs/safecheck/report/CheckPlanCountChartArea', {startDate: 'this.model.startDate', endDate: 'this.model.endDate', f_filialeid: 'this.f_filialeid'})
      model.f_filialeid = '(' + this.$login.f.orgid + ')'
      return {
        filialeNameStr: '',
        filialeCodeStr: '',
        userid: this.$login.f.id,
        source: `tool.getFullTree(this.getRights().where(row.getType() != $zone$).where(row.getType() == $organization$))`,
        model: model
      }
    },
    methods: {
      getRes(obj) {
        this.model.f_filialeid = this.$login.convertToIn(obj.resids);
      },
      search(args){
        if (args.model.endDate){
          args.condition += ` and f_offsite_time <= '${args.model.endDate}'`
        }
        if (args.model.startDate){
          args.condition += ` and f_offsite_time >= '${args.model.startDate}'`
        }
        this.model.search(args.condition,args.model)
      }
    },
    ready() {
      this.$refs.paged.$refs.criteria.model.startDate = Util.toStandardDateString()+' 00:00:00'
      this.$refs.paged.$refs.criteria.model.endDate = Util.toStandardDateString()+' 23:59:59'
    },
    computed: {
      selected() {
        return this.$refs.grid.selected
      },
    }
  }
</script>
