<template>
  <div id='app' class="basic-main" style="height: 100%">
    <criteria-paged :model="model" :pager='false'>
      <criteria partial='criteria' @condition-changed='$parent.search' class="search_area">
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="col-sm-4 form-group">
              <role-selector-safe-dep
                role-name="安检员"
                role-lable="安&ensp;检&ensp;员"
                @re-res="$parent.$parent.getRes"
                @alluser="$parent.$parent.getchecker"
                :value.sync="model.f_checker_id"
                v-model="model.f_checker_id"
                condition="f_checker_name like '%{}%'">
              </role-selector-safe-dep>
            </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 00:00:00'"
                          :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 23:59:59'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2 form-group">
              <label for="endDate" class="font_normal_body">班&emsp;&emsp;组</label>
              <v-select
                class="select select_list"
                :value.sync="model.depmentid"
                v-model="model.depmentid"
                :options='$parent.$parent.depments'
                condition="parentid = '{}'"
                placeholder='班&emsp;&emsp;组'
                :search="false"
                close-on-select
                value-single
              >
              </v-select>
            </div>
            <div class="col-sm-4 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 HttpResetClass from "vue-client/src/plugins/HttpResetClass";
export default {
  title: '隐患报表',
  data () {

    let model = new DataModel('rs/report/hiddensituation', {
      startDate: 'this.model.startDate',
      endDate: 'this.model.endDate',
      f_filialeid: 'this.f_filialeid'
    })
    model.f_filialeid = '(' + this.$login.f.orgid + ')'
    return {
      checker_name:'',
      depments:[],
      filialeNameStr: '',
      filialeCodeStr: '',
      userid: this.$login.f.id,
      source: `tool.getFullTree(this.getRights().where(row.getType() != $zone$).where(row.getType() == $organization$))`,
      model: model
    }
  },
  methods: {
    getchecker(val){
      if(val && val.length > 0){
        this.checker_name = ''
        val.forEach(user => {
          this.checker_name += `'${user.name}',`
        })
        this.checker_name = this.checker_name.slice(0,this.checker_name.length-1)
      }else{
        this.checker_name = ''
      }
    },
    getOrgid(){
      this.depments=[]
      let http = new HttpResetClass()
      http.load('POST','rs/logic/GetOrgid',{
        orgid: this.$login.f.orgid
      },{resolveMsg: null, rejectMsg: null}).then((ress) => {
        this.depments.push({label: '全部', value: ''})
        ress.data.forEach(ress => {
          this.depments.push({
            label: ress.name,
            value: ress.id
          })
        })
      })
    },
    getRes (obj) {
      // this.model.f_filialeid = this.$login.convertToIn(obj.resids)
      //tag
    },
    search (args) {
      // //tag
      if(this.checker_name){
        args.condition += ` and  f_checker_name in (${this.checker_name}) `
      }
      return this.model.search(args.condition, args.model)
    },
  },
  ready () {
    this.getOrgid()
  },
  computed: {
    selected () {
      return this.$refs.grid.selected
    }
    // outlets () {
    //   return [{label: '全部', value: ''}, ...AppData.getParam('营业网点')]
    // },
    // operator () {
    //   return [{label: '全部', value: ''}, ...AppData.getParam('操作员')]
    // }
  }
}
</script>
