<template >
  <div id="stand-work-list" class="flex bg-white p-10">
    <div class="height:auto">
      <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="col-sm-4" >
                <label class="font_normal_body" >状态</label>
                <v-select :value.sync="model.f_state"
                          v-model="model.f_state"
                          style="width:60%"
                          :options='$parent.$parent.charge_state' placeholder='请选择'
                          condition="f_state = '{}'"
                          close-on-select></v-select>
              </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>
              <th><nobr>操作站点</nobr></th>
            </tr>
          </template>
          <template partial='body' partial='list' v-ref:grid>
            <tr >
              <td style="text-align: center;"><nobr>{{row.f_card_id}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_meter_brand}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_type}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_othereason}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_fillgas}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_fillgas_fee}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_operate_date}}</nobr></td>
              <td style="text-align: center;"><nobr>{{row.f_operator}}</nobr></td>
            </tr>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

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

  export default {
    title: '收费',
    data () {
      return {
        condition: '1=1',
        model: new PagedList('rs/sql/fillGasQuery', 15),
        charge_state: this.$appdata.getParam('收费状态') ? [{label: '全部', value: ''},...this.$appdata.getParam('收费状态')] : [],
        row: null,
        isdeal: true,
        obj: {
          userid: this.$login.f.id,
          source: `tool.getFullTree(this.getRights().where(row.getType() == $organization$))`,
          res: this.$login.f.f_fengongsi,
          resids: this.$login.f.f_orgids
        },
        show: false
      }
    },
    props:
      {
        searchdata: {},
        isdeal: {},
        args:{}
      },
    ready () {
      this.$refs.paged.$refs.criteria.model.f_state = ['有效']
      this.$refs.paged.$refs.criteria.search()
    },
    methods: {
      search(args){
        if(this.args && this.args.model) {
          this.condition=this.condition+` and   f_state='有效' `
          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)
        }
      }
    },
    watch:{
      args(val){
        this.search()
      }
    }
  }
</script>
