<template>
  <div class="flex">
    <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-4" >
              <label class="font_normal_body">客户编号</label>
              <input type="text" class="input_search" style="width:60%" v-model="model.f_userinfo_code" placeholder='客户编号'
                     condition="f_userinfo_code = '{}'" @keyup.enter="search()">
            </div>
            <div class="form-group col-sm-4 button-range" >
              <button class="button_search" style="margin-right: 10px"  @click="search()" v-el:cba>查询</button>
              <export-excel
                :data="$parent.$parent.condition"
                :field="$parent.$parent.getfield"
                sqlurl="api/af-revenue/logic/openapi/exportfile" sql-name="handPeopleuser" :template-name="$parent.$parent.inputtor+'抄表册用户'"
                :choose-col="true"></export-excel>
            </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>
          </tr>
        </template>
        <template partial='body' >
          <tr >
            <td style="text-align:center;">{{$index+1}}</td>
            <td style="text-align:center">{{row.f_userinfo_code}}</td>
            <td style="text-align:center">{{row.f_user_name}}</td>
            <td style="text-align:center;white-space: nowrap;">{{row.f_address}}</td>
          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

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

  export default {
    title: '抄表人员',
    data () {
      return {
        //model: new PagedList('api/af-revenue/sql/getGasUser', 20, {}),
        model: new PagedList('api/af-revenue/sql/handPeopleuser', 30,{startDate: 'this.model.startDate', endDate: 'this.model.endDate'}),
        condition:'',
        getfield: {},
        show:false,
        gasproperties: [],
        newinfo:{
        },
        config: {
          excelHeaders: {
            'f_inputtor':'抄表员','f_userinfo_code': '客户编号','f_user_name': '客户姓名', 'f_address': '客户地址'
          }
        },
      }
    },
    props: ['inputtor','f_filialeid','startDate','endDate'],
    ready () {
      this.search()
      this.getfield = this.config.excelHeaders
    },
    methods: {
      close() {
        this.show = false
        this.newinfo = {

        }
      },
      search() {
        this.$refs.paged.$refs.criteria.model.f_inputtor=this.inputtor
        this.$refs.paged.$refs.criteria.model.startDate=this.startDate
        this.$refs.paged.$refs.criteria.model.endDate=this.endDate
        this.$refs.paged.$refs.criteria.search()
      },
      changeprice(){
        this.battchbuttonClick=false
        this.show=true
      },
      selfSearch(args) {
        args.condition = `${args.condition} and f_inputtor = '${this.inputtor}'`
        this.condition = {
          startDate: this.$refs.paged.$refs.criteria.model.startDate,
          endDate: this.$refs.paged.$refs.criteria.model.endDate,
          condition: args.condition
        }
        this.$refs.paged.$refs.criteria.model.startDate=this.startDate
        this.$refs.paged.$refs.criteria.model.endDate=this.endDate
        this.model.search(args.condition, args.model)
      },
    },
    watch:{
      'inputtor'(){
        this.search()
      },
      'f_filialeid' (val) {
        console.log('监听到了')
        loadParamGem(this)
      }
    }
  }
</script>
