<template>
  <div class="basic-main">
    <criteria-paged :model="model" :pager='false' v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:criteria>
        <p class="bg-info text-center" style="padding: 8px;">机表收费统计</p>
        <div class="form-group" v-if="!$parent.$parent.data.f_files_path"></div>
        <div novalidate class="form-horizontal select-overspread container-fluid auto"  partial  >
          <div class="row">
            <div class="col-sm-2" >
              <label class="font_normal_body" for="startDate">开始日期:</label>
              <datepicker id="startDate" placeholder="开始日期" style="width: 60%"
                          v-model="model.startDate"
                          :value.sync="model.startDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2" >
              <label class="font_normal_body" for="startDate">结束日期:</label>
              <datepicker id="endDate" placeholder="开始日期" style="width: 60%"
                          v-model="model.endDate"
                          :value.sync="model.endDate"
                          :disabled-days-of-Week="[]"
                          :format="'yyyy-MM-dd HH:mm:ss'"
                          :show-reset-button="reset">
              </datepicker>
            </div>
            <div class="col-sm-2">
              <label class="font_normal_body">&nbsp;&nbsp;&nbsp;公司&nbsp;&nbsp;&nbsp; </label>
              <res-select restype='organization'
                          @res-select="$parent.$parent.getRes"
                          :initresid="$parent.$parent.id">
              </res-select>
            </div>
            <div class="col-sm-2">
              <label class="font_normal_body">&nbsp;&nbsp;&nbsp;部门&nbsp;&nbsp;&nbsp; </label>
              <res-select restype='department'
                          is-mul="false"
                          @res-select="$parent.$parent.getdep"
                          :parentresid="$parent.$parent.depresid"
                          :initresid='$parent.$parent.depid'>
              </res-select>
            </div>
          </div>
          <div class="span" style = "float:right;">
            <button class="button_search" @click="$parent.$parent.searchData()">查询</button>
            <report-print id='gasprice' top='3cm' left='0' width='100%' height='100%'></report-print>
            <report-excel id='gasprice'></report-excel>
          </div>
        </div>
      </criteria>
      <div  partial='list' v-el:handcollect id='gasprice' style="height: 98%;overflow-y: scroll">
        <table class='tableprint' style="margin: 0px auto"  v-if="true">
          <thead>
          <tr>
            <th colspan='11' style="font-weight: normal; text-align: left;">
              <h3 style="text-align: center">机表收费统计</h3>
            </th>
          </tr>
          <tr>
            <th colspan='11' style="font-weight: normal; text-align: left;">&nbsp;
              打印时间：{{{$parent.printTime}}}
            </th>
          </tr>
          </thead>
          <tr>
            <td colspan='11'>
              {{{ model.data.substring(26,model.data.length-8) }}}
            </td>
          </tr>
          <tfoot>
          <tr style="text-align: left">
          </tr>
          </tfoot>
        </table>
        {{{ $parent.reportStr}}}
      </div>
    </criteria-paged>
  </div>
</template>

<script>
  import { DataModel } from 'vue-client'
  import co from 'co'

  export default {
    title: '机表收费统计',
    data () {
      return {
        printTime: this.$login.toStandardTimeString(),
        id: [this.$login.f.orgid],
        depresid: [],
        userresid: [],
        f_orgid: this.$login.f.orgid,
        f_depid: '',
        operatorid: [],
        depid: [],
        orgCondtionStr: '1=1',
        model: new DataModel('rs/report/machine-charge', {startDate: 'this.model.startDate', endDate: 'this.model.endDate',
          f_orgid: 'this.model.f_orgid'}),
        reportStr: null,
        show: false,
      }
    },
    ready () {
      this.$refs.paged.$refs.criteria.model.startDate = this.$login.toStandardDateString() + ' 00:00:00'
      this.$refs.paged.$refs.criteria.model.endDate = this.$login.toStandardDateString() + ' 23:59:59'
      this.$refs.paged.$refs.criteria.search()
      console.log(this.$login.f)
    },
    methods: {
      searchData () {
        this.$refs.paged.$refs.criteria.search()
      },
      selfSearch (args) {
        this.printTime = this.$login.toStandardTimeString()
        let orgcondition = 's.f_orgid = ' + this.f_orgid
        if (this.f_depid[0]) {
          orgcondition += ' and s.f_depid = ' + this.f_depid
        }
        this.$refs.paged.$refs.criteria.model.f_orgid = orgcondition
        this.$refs.paged.search(args)
      },
      getRes (obj) {
        this.depresid = obj
        this.f_orgid = obj
      },
      getdep (obj, val) {
        // this.depname = val[0]
        this.userresid = obj
        this.f_depid = obj
      }
    }
  }
</script>
<style scoped>
  .noborder{
    border: none;
  }
</style>
