<template>
  <div style="flex:1; " class="flex">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-inline" partial>
          <div >
            <input type="text" class="input_search" style="width:60%" v-model="model.f_userinfo_code"
                   condition="f_userinfo_code='{}'" placeholder='客户编号'
                   :size="model.f_userinfo_code ? model.f_userinfo_code.length : 4">
          </div>
          <div >
            <input type="text" class="input_search" style="width:60%" v-model="model.f_user_name"
                   condition="f_user_name = '{}'" placeholder='用户姓名'
                   :size="model.f_user_name ? model.f_user_name.length * 2 : 4">
          </div>
          <div >
            <button class="btn btn-success width-100" @click="$parent.$parent.search()" v-el:cx id="comprehen-gasBra-gasBraLis-查询">查询</button>
          </div>
        </div>
      </criteria>
      <data-grid  :model="model" partial='list' v-ref:grid>
        <template partial='head'>
          <tr>
            <th>序号</th>
            <th>购气量</th>
            <th>购气金额</th>
            <th>收费类型</th>
            <th>收费状态</th>
            <th>收费日期</th>
            <th>操作</th>
          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td style="text-align:center">{{$index+1}}</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_type}}</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">
              <button type="button" name="button" class="btn btn-link" :disabled="$index !== 0"
                      @click.stop="$parent.$parent.$parent.cancel(row)">冲正</button>
            </td>
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  /**
   *阶梯气价查询列表
   */
  import { PagedList } from 'vue-client'
  export default {
    title: '用户信息',
    data () {
      return {
        model: new PagedList('rs/sql/singleTable_OrderBy', 30, {items: '"*"', tablename: '"t_sellinggas"', orderitem: '"f_operate_date  desc"'})
      }
    },
    props: ['row'],
    ready () {
      console.log('传过来的row', this.row)
      this.search()
    },
    methods: {
      search () {
        this.$refs.paged.$refs.cri.search()
      },
      selfSearch (args) {
        args.condition = `${args.condition} and f_userinfo_id = '${this.row.f_userinfo_id}' and f_filialeids  = '${this.$login.f.f_orgids}'`
        this.model.search(args.condition, args.model)
      },
      cancel (row) {
        console.log('冲正收费', row)
      }
    }
  }
</script>
