<template >
  <div class="flex">
    <div class="height:auto">
      <criteria-paged :model="model" v-ref:paged  >
        <criteria partial='criteria' v-ref:cri  @condition-changed='$parent.selfSearch'>

          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="col-sm-3" >
              <label class="font_normal_body" >&nbsp;开始时间</label>
              <datepicker placeholder="起始时间" style="width:60%"
                          :value.sync="model.f_start_date"
                          v-model="model.f_start_date"
                          :format="'yyyy-MM-dd'"
                          condition="f_operate_date >= '{} 00:00:00' "
              ></datepicker>
            </div>
            <div class="col-sm-3" >
              <label class="font_normal_body" >结束时间</label>
              <datepicker placeholder="结束时间" style="width:60%"
                          :value.sync="model.f_end_date"
                          v-model="model.f_end_date"
                          :format="'yyyy-MM-dd'"
                          condition="f_operate_date <= '{} 23:59:59' "
              ></datepicker>
            </div>
            <div class="span" style = "float:right;">
              <button class="button_search button_spacing" @click="search()">查询</button>
            </div>

          </div>

        </criteria>
        <data-grid :model="model" class="list_area table_sy" 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>
            </tr>
          </template>
          <template partial='body' partial='list' v-ref:grid>
            <tr >
              <td style="text-align:center">{{row.type}}</td>
              <td style="text-align:center">{{row.fee}}</td>
              <td style="text-align:center">{{row.gas}}</td>
              <td style="text-align:center">{{row.f_operator}}</td>
              <td style="text-align:center">{{row.f_operate_date}}</td>
              <td style="text-align:center">{{row.note}}</td>
            </tr>
          </template>
          <template partial='foot'>

            <td style="text-align: center;background-color: mistyrose ">
              <nobr>合计：</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.fee}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr>{{model.sums.gas}}</nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
            <td style="text-align: center;background-color: mistyrose ">
              <nobr></nobr>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'
  let readySomething = async function (self) {

    await self.$refs.paged.$refs.cri.search()
  }
  export default {
    title: '收费查询',
    data () {
      return {
        condition: '1=1',
        orgCondtionStr:'',
        model: new PagedList('api/af-revenue/sql/recordQuery', 20,{},{
          fee:0,
          gas:0
        })
        // fields:{'fee': '金额','gas':'气量','type': '类型'},
      }
    },
    props:
      {
        f_userinfo_id: ''
      },
    ready () {
      readySomething(this)
    },
    methods: {
      selfSearch (args) {
        if (!this.orgCondtionStr) {
          args.condition = `${args.condition}` + " and f_orgid = " + this.$login.f.orgid + " and f_userinfo_id = " + this.f_userinfo_id
        } else {
          args.condition = `${args.condition}` + this.orgCondtionStr
        }
        this.model.search(args.condition, args.model)
      }
    },
    computed: {
      getCondition(){
        return {condition: `${this.$refs.paged.$refs.cri.condition}`+this.orgCondtionStr}
      }
    }
  }
</script>

