<template>
  <div class="auto select-overspread">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:criteria>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="form-group col-sm-3" >
              <label class="font_normal_body">单位名称</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_residential_area" placeholder='单位名称'
                     condition="f_company_name like '%{}%'" @keyup.enter="search()">
            </div>
            <div class="form-group col-sm-2 button-range" >
              <button class="button_search" style="margin-right: 10px"  @click="search()" v-el:cba>查询</button>
            </div>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" class="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>
          </tr>
        </template>
        <template partial='body' >
          <tr >
            <td style="text-align:center">{{row.f_company_name}}</td>
            <td style="text-align:center">{{row.f_user_name}}</td>
            <td style="text-align:center">{{row.f_userinfo_code}}</td>
            <td style="text-align:center">{{row.f_meternumber}}</td>
            <td style="text-align:center">{{row.f_usegas}}</td>
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

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

export default {
  title: '非民用片区用户',
  props: ['checkbookid'],
  data () {
    return {
      rowdata: this.row,
      userlogin:{
        id:this.$login.f.id,
        name:this.$login.f.name,
        orgid:this.$login.f.orgid,
        orgstr:this.$login.f.orgs,
      },
      model: new PagedList('rs/sql/getCheckBookCompanyUser', 50),
    }
  },
  ready(){
    if (this.checkbookid) {
      const condition  = `f_check_book_id =${this.checkbookid}`
      this.model.search(condition)
    }
  },
  watch: {
    'checkbookid' (val) {
      if (val) {
        const condition =  `f_check_book_id =${val}`
        this.model.search(condition)
      }
    }
  },
  methods: {
    selfSearch (args) {
      if (this.checkbookid) {
        args.condition += `and f_check_book_id = ${this.checkbookid}`
        this.model.search(args.condition)
      } else {
        this.$showMessage('请选择片区')
      }
    }
  }
}
</script>
