<template >
  <div id="stand-work-list" class="flex bg-white p-10">
      <criteria-paged :model="model" v-ref:paged  >
        <criteria partial='criteria' v-ref:criteria  @condition-changed='$parent.search'>
          <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
            <div class="row" width="100%">
              <div class="col-sm-4" >
                <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 >= to_date('{} 00:00:00','yyyy-mm-dd hh24:mi:ss')"
                ></datepicker>
              </div>
              <div class="col-sm-4" >
                <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 <= to_date('{} 23:59:59','yyyy-mm-dd hh24:mi:ss')"
                ></datepicker>
              </div>
              <div class="span" style="float:right;">
                <button class="btn btn-success"  @click="search()" v-el:cba>查询</button>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid :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>
            </tr>
          </template>
          <template partial='body' partial='list' v-ref:grid>
            <tr >
              <td style="text-align:center">{{row.f_operat_type}}</td>
              <td style="text-align:center">{{row.type}}</td>
              <td style="text-align:center">{{row.gas}}</td>
              <td style="text-align:center">{{row.fee}}</td>
              <td style="text-align:center">{{row.f_operator}}</td>
              <td style="text-align:center">{{row.op_spot}}</td>
              <td style="text-align:center">{{row.f_operate_date}}</td>
              <td style="text-align:center">{{row.note}}</td>
            </tr>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </criteria-paged>
      <table class="table-hover">
        <tr  class="table-bordered">
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px;color: #5CB95C;font-weight: bold">汇总信息</td>
          <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">换表后气量合计:&emsp;{{sumsmodel.gas1}}</td>
        </tr>
      </table>
  </div>
</template>

<script>
  import {PagedList} from 'vue-client'

  export default {
    title: '流水查询',
    data () {
      return {
        condition: '1=1',
        model: new PagedList('rs/sql/sale_RecordQuery', 20,
          null,{gas1: 0}),
        row: null,
        isdeal: true,
        show: false,
        sumsmodel: {}
      }
    },
    props:
      {
        searchdata: {},
        isdeal: {},
        args:{}
      },
    ready () {
      this.$refs.paged.$refs.criteria.search()
    },
    methods: {
      search(args){
      if(this.args && this.args.model) {
        if(this.searchdata.f_user_id) {
          this.condition = `${this.$refs.paged.$refs.criteria.condition} and f_user_id = '${this.searchdata.f_user_id}'`
        } else if(this.searchdata.f_card_id){
          this.condition = `${this.$refs.paged.$refs.criteria.condition} and f_card_id = '${this.searchdata.f_card_id}'`
        }else if(this.searchdata.f_userinfo_id) {
          this.condition = `${this.$refs.paged.$refs.criteria.condition} and f_userinfo_id = '${this.searchdata.f_userinfo_id}'`
        }else {
          return
        }
        this.model.search(this.condition, this.args.model)
        this.sumsmodel = this.$refs.paged.$refs.grid.model.sums
      }
    }
  },
    watch:{
      args(val){
        this.search()
      }
    }
  }
</script>

