<template >
  <div class="flex" style="justify-content: space-between;">
    <div @keyup.enter="search">
      <criteria-paged :model="model" v-ref:paged>
        <criteria @condition-changed='$parent.search' partial='criteria' v-ref:criteria>
          <div class="form-horizontal select-overspread container-fluid auto" novalidate partial>
            <div class="row" width="100%">
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">开始时间</label>
                <datepicker :format="'yyyy-MM-dd'" :value.sync="model.f_start_date"
                            class="datepicker"
                            condition="f_operate_date >= '{} 00:00:00' "
                            placeholder="起始时间"
                            style="width:60%"
                            v-model="model.f_start_date"
                ></datepicker>
              </div>
              <div class="col-sm-2 form-group" >
                <label class="font_normal_body" >结束时间</label>
                <datepicker :format="'yyyy-MM-dd'" :value.sync="model.f_end_date"
                            class="datepicker"
                            condition="f_operate_date <= '{} 23:59:59' "
                            placeholder="结束时间"
                            style="width:60%"
                            v-model="model.f_end_date"
                ></datepicker>
              </div>
              <div class="col-sm-2 form-group">
                <label class="font_normal_body">缴费状态</label>
                <v-select :value.sync="model.f_state" v-model='model.f_state'
                          style="width:60%"
                          :options='$parent.$parent.jiaofeistates' placeholder='缴费状态'
                          close-on-select
                          condition="f_state = '{}'"></v-select>
              </div>

              <div style="float: right">
                <button @click="search()" class="button_search" style="margin-right: 10px" v-el:cba>查询</button>
<!--                <print-data :defaultfield="$parent.$parent.defaultfield" :field="$parent.$parent.fields" :is-selected="true" :model="$parent.$parent.printModel"-->
<!--                            @print-data="$parent.$parent.print()" print-name="购气流水"></print-data>-->
              </div>
            </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>
              <th><nobr>操作人</nobr></th>
            </tr>
          </template>
          <template partial='body' partial='list' v-ref:grid>
            <tr >
              <td style="text-align:center">{{row.f_type}}</td>
              <td style="text-align:center">{{row.f_pregas}}</td>
              <td style="text-align:center">{{row.f_preamount}}</td>
              <td style="text-align:center">{{row.f_state}}</td>
              <td style="text-align:center">{{row.f_operate_date}}</td>
              <td style="text-align:center">{{row.f_depname}}</td>
              <td style="text-align:center">{{row.f_operator}}</td>
            </tr>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </criteria-paged>
    </div>
    <table class="table-hover">
      <tr class="table-bordered" style="position: relative">
        <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;{{model.sums.f_pregas}}
        </td>
        <td style="display: inline-block;width: auto;border-right: 1px solid #F2F6FA;padding: 0px 10px 0px 10px">
          金额合计:&emsp;{{model.sums.f_preamount}}
        </td>
      </tr>
    </table>

  </div>
</template>

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

export default {
    title: '累购查询',
    data () {
      return {
        condition: '1=1',
        model: new PagedList('rs/sql/sale_Repurchase', 20, {}, {
          f_preamount: 0,
          f_pregas: 0
        }),
        jiaofeistates: this.$appdata.getParam('缴费状态') ? [{
          label: '全部',
          value: ''
        }, ...this.$appdata.getParam('缴费状态')] : [],
        fields: {'f_userinfo_code': '客户编号', 'f_user_name': '客户姓名', 'f_preamount': '购气金额', 'f_pregas': '购气量', 'f_operate_date,': '缴费时间', 'f_operator': '操作员', 'f_comments': '备注'},
        defaultfield: [
          'f_userinfo_code', 'f_user_name', 'f_preamount', 'f_pregas', 'f_operate_date', 'f_operator', 'f_comments'
        ]
      }
    },
    props: ['row'],
    ready () {
      this.$refs.paged.$refs.criteria.model.f_state = ['有效']
      this.$refs.paged.$refs.criteria.search()
    },
    methods: {
      async search () {
        console.log('aaa:', this.$refs.paged.$refs.criteria.condition)
        this.condition = `${this.$refs.paged.$refs.criteria.condition} and f_userfiles_id = '${this.row.f_userfiles_id}'`
        this.model.search(this.condition, this.model)
      }
    },
    computed: {
    }
  }
</script>

