<template>
  <div class="flex">
    <section>
      <div class="basic-main row" style="height: 100%">
        <criteria-paged :model="model" v-ref:paged>
          <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
            <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
              <div class="row">
                <div class="col-sm-3 form-group form-input-group" style="width: 30%;">
                  <role-selector-safe
                    role-name="安检员"
                    role-lable="安&nbsp;检&nbsp;员&nbsp;"
                    @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="col-sm-3 form-group form-input-group" style="width: 20%;">
                  <label for="startDate" class="font_normal_body">起始时间</label>
                  <datepicker
                    class="select_list select"
                    :value.sync="model.startDate"
                    id="startDate"
                    placeholder='开始时间' style="width: 60%"
                    :disabled-days-of-week="[]"
                    :format="'yyyy-MM-dd 00:00:00'"
                    :show-rest-button="reset"
                    v-model="model.startDate"
                    condition="f_upload_date > ='{} '">
                  </datepicker>
                </div>
                <div class="col-sm-3 form-group form-input-group" style="width: 20%;">
                  <label for="endDate" class="font_normal_body">结束时间</label>
                  <datepicker
                    class="select_list select"
                    :value.sync="model.endDate"
                    id="endDate"
                    placeholder='结束日期' style="width: 60%"
                    :disabled-days-of-week="[]"
                    :format="'yyyy-MM-dd 23:59:59'"
                    :show-rest-button="reset"
                    v-model="model.endDate"
                    condition="f_upload_date <='{} '">
                  </datepicker>
                </div>
                <div class="col-sm-3 form-group form-input-group" style="width: 20%;float: right;">
                  <report-print class="button_export button_spacing" style="width:28%" id='tongchuan'></report-print>
                  <export-excel-safe :data="$parent.$parent.searchData"
                                     :field="$parent.$parent.excelHeaders"
                                     sqlurl="rs/logic/SafeExportExcel"
                                     sql-name="SafecheckSummary"
                                     :template-name="$parent.$parent.excelTitle">
                  </export-excel-safe>
                  <button type="button" name="button" class="button_search" style="margin-left: 9px" @click="search">查询</button>
                </div>
              </div>
            </div>
          </criteria>
          <data-grid :model="model" partial='list' class="list_area table_sy" id="tongchuan" v-ref:grid >
            <template partial='head'>
              <tr>
                <th>
                  <nobr>序号</nobr>
                </th>
                <th>
                  <nobr>安检月份</nobr>
                </th>
                <th>
                  <nobr>安检员</nobr>
                </th>
                <th>
                  <nobr>已检</nobr>
                </th>
                <th>
                  <nobr>入户</nobr>
                </th>
                <th>
                  <nobr>到访不遇</nobr>
                </th>
                <th>
                  <nobr>拒检</nobr>
                </th>
                <th>
                  <nobr>隐患数</nobr>
                </th>
              </tr>
            </template>
            <template partial='body'>
              <tr>
                <td style="text-align:center">{{$index + 1}}</td>
                <td style="text-align:center">
                  <nobr>{{ row.yuefeng }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.f_checker_name }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.yijian }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.ruhu }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.daofang }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.jujian }}</nobr>
                </td>
                <td style="text-align:center">
                  <nobr>{{ row.yinhuan }}</nobr>
                </td>
              </tr>
            </template>
            <template partial="foot">
              <td style="text-align: center"><span><b>合计：</b></span></td>
              <td style="text-align: center"><span><b> </b></span></td>
              <td style="text-align: center"><span><b> </b></span></td>
              <td style="text-align: center">{{model.sums.yijian}}</td>
              <td style="text-align: center">{{model.sums.ruhu}}</td>
              <td style="text-align: center">{{model.sums.daofang}}</td>
              <td style="text-align: center">{{model.sums.jujian}}</td>
              <td style="text-align: center">{{model.sums.yinhuan}}</td>
            </template>
          </data-grid>
        </criteria-paged>
      </div>
    </section>
  </div>
</template>
<script>
import {PagedList, HttpResetClass} from 'vue-client'
import * as Util from '../Util'
import {toEndDateString, toStartDateString} from '../Util'

export default {
  title: '无计划安检汇总',
  data () {
    let model = new PagedList('rs/sql/SafecheckSummary', 20, {
      f_filiale_id: 'this.f_filiale_id'
    },{yijian:'',ruhu:'',daofang:'',jujian:'',yinhuan:''})
    model.f_filiale_id = `('${this.$login.f.orgid}')`
    return {
      f_filiale_id: `('${this.$login.f.orgid}')`, // 分公司id
      model: model,
      source: 'tool.getFullTree(this.getRights().where(row.getType() != $zone$).where(row.getType() == $organization$))', //获取公司参数
      userid: this.$login.f.id,
      orgname: '',
      // checker:{},
      searchData: {
        condition: '',
        f_filiale_id: ''
      },
      excelHeaders: {
        'yuefeng': '安检月份',
        'f_checker_name': '安检员',
        'yijian': '已检',
        'ruhu': '入户',
        'daofang': '到访不遇',
        'jujian': '拒检',
        'yinhuan': '隐患数'
      }
    }
  },
  methods: {
    getRes (obj) {
      this.f_filiale_id = this.$login.convertToIn(obj.resids)
      this.orgname = obj.res[0]
      this.$set('orgname', obj.res[0])
      console.log(
        `%c 无计划安检汇总公司名 %c 呼叫模块 %c`,
        'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px;  color: #fff',
        'background:#41b883 ; padding: 1px; border-radius: 0 3px 3px 0;  color: #fff',
        'background:transparent',
        this.orgname
      )
    },
    selfSearch (args) {
      if (!this.f_filiale_id) {
        return this.$showMessage("请选择公司进行查询！！！")
      }
      this.model.f_filiale_id = this.f_filiale_id // 只有选择了下面的条件才会变化
      this.searchData.f_filiale_id = this.f_filiale_id //导出
      this.searchData.condition=args.condition //导出
      this.model.search(args.condition, args.model)
    }
  },
  computed: {
    excelTitle() {
      return `${this.orgname }无计划安检汇总`
    },
  },
  watch: {
  },
  ready () {
    this.orgname = this.$login.f.orgs
    this.$refs.paged.$refs.cri.model.startDate=Util.toStartDateString() +' 00:00:00'
    this.$refs.paged.$refs.cri.model.endDate=Util.toEndDateString() +' 23:59:59'

  }

}
</script>

<style lang="less" >
.tableinfo {
  text-align: center;
  background-color: #00A3F0;
  color: #0c2e4d;
  font-size: 26px;
}
</style>
