<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged >
        <criteria partial='criteria' class="search_area" @condition-changed='$parent.selfSearch' v-ref:criteria>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row">
              <div class="col-sm-4" style="margin-bottom: 0px">
                <role-selector-safe
                  role-name="安检员"
                  role-lable="安&nbsp;检&nbsp;员&nbsp;"
                  @re-res="$parent.$parent.getRes"
                  :value.sync="model.f_checker"
                  v-model="model.f_checker"
                  condition="f_checker = '{}'">
                </role-selector-safe>
              </div>
              <div class="form-group col-sm-2" >
                <label class="font_normal_body">计划起始</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_pstart_date"
                  placeholder='开始时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_pstart_date"
                  >
                </datepicker>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">计划截止</label>
                <datepicker
                  :value.sync="model.f_pend_date"
                  placeholder='结束时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_pend_date"
                  >
                </datepicker>
              </div>
              <div class="form-group col-sm-2" >
                <label class="font_normal_body">安检起始</label>
                <datepicker
                  class="select_list select"
                  :value.sync="model.f_start_date"
                  placeholder='开始时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_start_date"
                  >
                </datepicker>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">安检结束</label>
                <datepicker
                  :value.sync="model.f_end_date"
                  placeholder='结束时间' style="width: 60%"
                  :disabled-days-of-week="[]"
                  :format="'yyyy-MM-dd'"
                  :show-rest-button="reset"
                  v-model="model.f_end_date"
                  >
                </datepicker>
              </div>
              <div class="form-group col-sm-2" style="width: auto;margin-top:8px;float: right">
                <!--<export-excel-safe :data="{
                                          f_checker:$parent.$parent.model.f_checker,
                                          f_pstart_date:$parent.$parent.model.f_pstart_date,
                                          f_pend_date:$parent.$parent.model.f_pend_date,
                                          f_start_date:$parent.$parent.model.f_start_date,
                                          f_end_date:$parent.$parent.model.f_end_date,
                                          f_filialeids:$parent.$parent.model.f_filialeids,
                                          condition:$parent.$parent.model.condition
                                        }"
                                   :field="$parent.$parent.excelHeaders"
                                   progress="safeGetExportProgress"
                                   sqlurl="rs/logic/SafeExportExcel" sql-name="zhoukouCheckCount" template-name='安检工作考核明细'></export-excel-safe>-->
                <export-excel :data="{
                f_checker:$parent.$parent.model.f_checker,
                f_pstart_date:$parent.$parent.model.f_pstart_date,
                f_pend_date:$parent.$parent.model.f_pend_date,
                f_start_date:$parent.$parent.model.f_start_date,
                f_end_date:$parent.$parent.model.f_end_date,
                f_filialeids:$parent.$parent.model.f_filialeids,
                condition:$parent.$parent.model.condition
                }"
                :field="$parent.$parent.excelHeaders"
                progress="safeGetExportProgress"
                sqlurl="rs/logic/SafeExportExcel" sql-name="zhoukouCheckCount" template-name='安检工作考核明细'></export-excel>
                <button class="button_spacing button_search" @click="search()">查询</button>
<!--                <button class="button_spacing button_search" @click="$parent.$parent.addAno()">新增</button>-->
                <!--<div style="float: right" class="button_spacing"
                     :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                     @click="$parent.$parent.hidden()"></div>-->
              </div>

            </div>
            <modal :show.sync="$parent.$parent.showModal" v-ref:modal>
              <div slot="modal-header" class="modal-header">
                <h4 class="modal-title">
                  选择计划
                </h4>
              </div>
              <div slot="modal-body" class="modal-body">
                <plan-chooser :f.sync="$parent.$parent.fun" v-ref:chooser></plan-chooser>
              </div>
              <div slot="modal-footer" class="modal-footer" style="text-align: center">
                <button class="button_search" @click="$parent.$parent.ok">确认</button>
                <button class="button_search" @click="$parent.$parent.cancel">取消</button>
              </div>
            </modal>
          </div>
        </criteria>
        <data-grid class="list_area table_sy" style="overflow: hidden" :model="model" partial='list' 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>
              <th>
                <nobr>到访不遇</nobr>
              </th>
              <th>
                <nobr>拒检</nobr>
              </th>
              <th>
                <nobr>长期无人</nobr>
              </th>
            </tr>
          </template>
          <template partial='body'>

            <td style="text-align: center">{{$index+1}}</td>
            <td style="text-align: center">{{row.f_checker}}</td>
            <td style="text-align: center">{{row.plannum}}</td>
            <td style="text-align: center">{{row.wj}}</td>
            <td style="text-align: center">{{row.ruhu}}</td>
            <td style="text-align: center">{{row.kabiao}}</td>
            <td style="text-align: center">{{row.jibiao}}</td>
            <td style="text-align: center">{{row.wlw}}</td>
            <td style="text-align: center">{{row.daofang}}</td>
            <td style="text-align: center">{{row.jujian}}</td>
            <td style="text-align: center">{{row.wuren}}</td>

          </template>
          <template partial="foot">
            <td style="text-align: center"><span><b>合计：</b></span></td>
            <td style="text-align: center">{{model.sums.c}}</td>
            <!--<td style="text-align: center">{{model.sums.checked}}</td>-->
            <td style="text-align: center">{{model.sums.plannum}}</td>
            <td style="text-align: center">{{model.sums.wj}}</td>
            <td style="text-align: center">{{model.sums.ruhu}}</td>
            <td style="text-align: center">{{model.sums.kabiao}}</td>
            <td style="text-align: center">{{model.sums.jibiao}}</td>
            <td style="text-align: center">{{model.sums.wlw}}</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.wuren}}</td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
import {PagedList} from 'vue-client'
import Vue from 'vue'
import co from 'co'
import AppData from '../../stores/AppData'
import * as Util from '../Util'
import getNowDate from "../../utils/getNowDate";
import HttpResetClass from "vue-client/src/plugins/HttpResetClass";
import BenzAMRRecorder from 'benz-amr-recorder'



export default {
  title: '安检员考核',
  data() {
    let model = new PagedList('rs/sql/zhoukouCheckCount', 20, {
      f_checker:'this.f_checker',
      f_pstart_date:'this.f_pstart_date',
      f_pend_date:'this.f_pend_date',
      f_start_date:'this.f_start_date',
      f_end_date:'this.f_end_date',
      f_filialeids:`this.f_filialeids`
    },{plannum: '', wj: '', ruhu: '', kabiao: '',
      jibiao:'',wlw:'',
      daofang:'',jujian:'',wuren:''})
    model.f_checker=''
    model.f_start_date=''
    model.f_end_date=''
    model.f_filialeids=`(${this.$login.f.orgid})`
    return {
      model: model,
      excelHeaders: {
        //searchData:searchData,
        'f_checker': '安检员'
      }
    }
  },
  computed:{
  },
  methods: {
    getRes(obj){
      this.model.f_filialeids = this.$login.convertToIn(obj.resids);
    },
    search() {
      this.$refs.paged.$refs.criteria.search()
    },
    selfSearch(args) {
      if(!this.model.f_filialeids){
        this.$showMessage("请选择分公司！")
        return
      }
      this.model.f_checker=this.$refs.paged.$refs.criteria.model.f_checker
      this.model.f_pstart_date=this.$refs.paged.$refs.criteria.model.f_pstart_date?this.$refs.paged.$refs.criteria.model.f_pstart_date+" 00:00:00":''
      this.model.f_pend_date=this.$refs.paged.$refs.criteria.model.f_pend_date?this.$refs.paged.$refs.criteria.model.f_pend_date+" 00:00:00":''
      this.model.f_start_date=this.$refs.paged.$refs.criteria.model.f_start_date?this.$refs.paged.$refs.criteria.model.f_start_date+" 00:00:00":''
      this.model.f_end_date=this.$refs.paged.$refs.criteria.model.f_end_date?this.$refs.paged.$refs.criteria.model.f_end_date+" 23:59:59":''
      this.model.search(args.condition, args.model, args.condValue)
    }
  },

  ready() {
    this.$refs.paged.$refs.criteria.model.f_pstart_date=Util.toStartDateYearString()

  },
  watch: {
    'model.rows.length'() {
      // 如果查询无结果，将合计置为0
      if(this.model.rows.length < 1){
        this.model.sums.plannum = 0
        this.model.sums.wj = 0
        this.model.sums.ruhu = 0
        this.model.sums.kabiao = 0
        this.model.sums.jibiao = 0
        this.model.sums.wlw = 0
        this.model.sums.daofang = 0
        this.model.sums.jujian = 0
        this.model.sums.wuren = 0
      }
    }
  }

}
</script>
