<template >
  <div id="stand-work-list" >
    <div @keyup.enter="search" class="span">
      <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">

              <div class="col-sm-2 form-group ">
                <label class="font_normal_body">上报时间</label>
                <datepicker :format="'yyyy-MM-dd HH:mm:ss'" :value.sync="model.f_start_date"
                            class="datepicker"
                            condition="m.f_hand_date >= '{}'"
                            placeholder="大于等于"
                            style="width: 60%"
                            v-model="model.f_start_date"
                ></datepicker>
              </div>
              <div class="col-sm-2 form-group " >
                <label class="font_normal_body">&nbsp;至</label>
                <datepicker :format="'yyyy-MM-dd HH:mm:ss'" :value.sync="model.f_end_date"
                            class="datepicker"
                            condition="m.f_hand_date <= '{}'"
                            placeholder="小于等于"
                            style="width: 60%"
                            v-model="model.f_end_date"
                ></datepicker>
              </div>
              <div style="float: right">
                <button  @click="search()"  class="button_search" v-el:cba>查询</button>
              </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>
              <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'>
            <tr >
              <td style="text-align:center"><nobr>{{row.f_hand_date}}</nobr></td>
              <th style="text-align:center"><nobr>{{row.f_jval}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_tablebase}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_valvestate == 0 ? '开阀' : '关阀'}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_upload_type}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_insert_date}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_meterdebitgas}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_signal}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_snr}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_batterylevel}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_lowlithiumbattery ? ((row.f_lowlithiumbattery - 0) == 0 ? '正常' : '异常') : '未知'}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_networkshutvalve}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_wmprepaytype}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_moneystate}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_magneticInterference}}</nobr></th>
              <th style="text-align:center"><nobr>{{row.f_compensateState}}</nobr></th>
            </tr>
          </template>
          <template partial='foot'></template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

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

  export default {
    title: 'WatchCollection',
    data () {
      return {
        model: new PagedList('rs/sql/iot_getNewLoseUserQuery', 50)
      }
    },
    props: ['row'],
    ready () {
      this.$refs.paged.$refs.criteria.search()
    },
    methods: {
      search (args) {
        args.condition = `${args.condition} and f_userfiles_id='${this.row.f_userfiles_id}'`
        this.model.search(args.condition, args.model)
      }
    },
    watch: {
      // 监听查询对象
      'row' (val) {
        if (this.row != null) {
          this.$refs.paged.$refs.criteria.search()
        }
      }
    }
  }
</script>

