<template>
  <div class="app-row" style="overflow: auto;padding-bottom: 1em">
  <partial-view v-ref:pv>
    <criteria-paged :model="model" v-ref:paged :pager="true" :simple="true">
      <accordion :one-at-atime="true" type="info" partial="list" >
        <div class="col-sm-12 col-xs-12 col-md-12 accorhead" style="margin-bottom:10px;">
          <div class="row " style="text-align:center">
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>累购次数</span></br><span>({{model.count}}次)</span>
            </strong>
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>累购金额</span></br><span>({{model.sums.f_preamount}}元)</span>
            </strong>
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>总购气量:</span></br><span>{{model.sums.f_pregas}}m³</span>
            </strong>
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>转移气量:</span></br><span>{{$parent.$parent.$parent.f_fillgas}}m³</span>
            </strong>
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>换表后累购气量:</span></br><span>{{$parent.$parent.$parent.f_total_gas}}m³</span>
            </strong>
            <strong class="col-sm-4 col-xs-4 col-md-4">
              <span>换表时间:</span></br><span>{{$parent.$parent.$parent.f_changemeter_date}}</span>
            </strong>

            <!--<strong class="col-sm-2 col-xs-2 col-md-2">-->
              <!--<span >转移气量</span>{{model.sums.returngas}}</br></span>-->
            <!--</strong>-->
          </div>
        </div>
        <div class="col-sm-12 col-xs-12 col-md-12 accorhead" style="margin-bottom:10px;">
          <div class="row "  style="text-align:center">
            <strong class="col-sm-3 col-xs-3 col-md-3"><nobr>卡号</nobr></strong>
            <strong class="col-sm-3 col-xs-3 col-md-3"><nobr>购气时间</nobr></strong>
            <strong class="col-sm-3 col-xs-3 col-md-3"><nobr>气量</nobr></strong>
            <strong class="col-sm-3 col-xs-3 col-md-3"><nobr>金额</nobr></strong>
          </div>
        </div>
        <div type="info" v-for="row in model.rows" :is-open="true" :is-click="false" style="padding:20px;">
          <span class="panel-title" slot="header" @click="$parent.$parent.$parent.selected(row)"  style="cursor: pointer;">
              <div class="col-sm-12">
                <div class="row accorbody"  style="text-align:center">
                  <p class="col-sm-3 col-xs-3 col-md-3"><nobr>{{row.f_card_id}}</nobr></p>
                  <p class="col-sm-3 col-xs-3 col-md-3"><nobr>{{row.f_delivery_date}}</nobr></p>
                  <p class="col-sm-3 col-xs-3 col-md-3"><nobr>{{row.f_pregas}}</nobr></p>
                  <p class="col-sm-3 col-xs-3 col-md-3"><nobr>{{row.f_preamount}}</nobr></p>
                  <!-- <span class="col-sm-3 col-xs-3 col-md-3"><nobr>{{row.weixiurenyuan}}</nobr></span> -->
                </div>
              </div>
          </span>
        </div>
      </accordion>
    </criteria-paged>
  </partial-view>
  </div>
</template>

<script>
  /**
   *用户档案相关信息组件
   */
  import * as Util from '../Util'
  import Vue from 'vue'
  import { PagedList } from 'vue-client'
  export default {
    title: '用户报修信息',
    data () {
      return {
        model: new PagedList(this.$androidUtil.getProxyUrl() + '/rs/sql/SafeSingleTable_OrderBy',20, {items: '"*"', tablename: '"t_sellinggas"', orderitem: '"f_delivery_date desc"'},{f_pregas: '', f_preamount: ''}),
        f_fillgas:0,
        f_total_gas:0,
        f_total_fee:0,
        f_changemeter_date:''
      }
    },
    props: {
      user:{
        type: Object
      }
    },
    methods: {
    },
    watch: {
      'user.f_card_id' (val) {
        this.model.search(`f_card_id = '${this.user.f_card_id}' and f_charge_state='有效' `)
      }
    },
    async ready(){
      if (this.user && this.user.f_card_id) {
        await this.model.search(`f_card_id = '${this.user.f_card_id}'and f_charge_state='有效'`)
        this.$resetpost(`${this.$androidUtil.getProxyUrl()}/rs/logic/getChangeGas`,{f_card_id:this.user.f_card_id}).then((res)=>{
          console.log('查询购气历史记录====》'+JSON.stringify(res))
          if(res.data.length > 0){
            this.f_fillgas = res.data.changeGas[0].f_fillgas
            this.f_total_gas = res.data.changeGas[0].f_total_gas
            this.f_total_fee = res.data.changeGas[0].f_total_fee
            this.f_changemeter_date = res.data.changeGas[0].f_changemeter_date
          }
        })
      }
    }
  }
</script>
