<template>
  <div id='app' class="basic-main">
    <criteria-paged :model="model" :pager='false' v-ref:cp>
      <criteria partial='criteria' @condition-changed='search' class="search_area">
        <div novalidate class="form-inline auto" partial>
          <div class="row">
            <div class="col-sm-2">
              <label class="font_normal_body">分公司:</label>
              <right-tree :userid.sync='$parent.$parent.userid' style="width: 60%;" :source.sync='$parent.$parent.source' @re-res="$parent.$parent.getRes" ></right-tree>
            </div>
            <div class="col-sm-2">
              <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'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2">
              <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'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-3" 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">
        <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'

  export default {
    title: '安检情况报表',
    data () {

      let model =  new DataModel('rs/report/safesituation',{startDate: 'this.model.startDate', endDate: 'this.model.endDate',f_subcompany: 'this.f_subcompany',plantype:'this.plantype[0]'})
      model.f_subcompany = ''
      model.plantype = ['']
      return {
        filialeNameStr:'',
        filialeCodeStr:'',
        userid: this.$login.f.id,
        source: `tool.getFullTree(this.getRights().where(row.getType() != $zone$).where(row.getType() == $organization$))`,
        model:model,
        f_plantype:[{label:'集中安检',value:'集中安检'},{label:'计划安检',value:'计划安检'},{label:'临时安检',value:'临时安检'}]
      }
    },
    methods: {
      // 获取组织结构
      getRes(obj) {
        //tag
        let fengongsi=obj.res.toString().split('.')
        //tag
        //tag
        this.model.f_subcompany = fengongsi[fengongsi.length-1]
        //tag
        // this.model.filialeCodeStr = obj.resids
        // this.model.filialeCodeStr = this.model.filialeCodeStr.replace(/\./g, '')
      },
    },
    ready(){
    },
    watch: {
      'model.plantype'(){
        //tag
      },
    },
    computed: {
      selected() {
        return this.$refs.grid.selected
      },
      // outlets () {
      //   return [{label: '全部', value: ''}, ...AppData.getParam('营业网点')]
      // },
      // operator () {
      //   return [{label: '全部', value: ''}, ...AppData.getParam('操作员')]
      // }
    }
  }
</script>
