<template>
  <div style="flex:1;" class="flex-auto">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div :class="$parent.$parent.style">
            <label class="font_normal_body">用户编号</label>
            <input  type="text" class="input_search" style="width:60%" v-model="model.ename" style="width: 90px"
                    condition="f_userinfo_code like '%{}%'" placeholder="用户编号"
            />
          </div>
          <div :class="$parent.$parent.style">
            <label class="font_normal_body">用户姓名</label>
            <input  type="text" class="input_search" style="width:60%" v-model="model.name" style="width: 90px"
                    condition="f_user_name like '%{}%'" placeholder="用户姓名"
            />
          </div>
          <div :class="$parent.$parent.style">
            <label class="font_normal_body">&nbsp;&nbsp;&nbsp;电话&nbsp;&nbsp;&nbsp;</label>
            <input  type="text" class="input_search" style="width:60%" v-model="model.f_user_phone" placeholder='电话'
                    condition="f_user_phone = '{}'"
                    :size="model.f_user_phone ? model.f_user_phone.length : 2">
          </div>
          <div :class="$parent.$parent.style">
            <label class="font_normal_body">&nbsp;&nbsp;&nbsp;地址&nbsp;&nbsp;&nbsp;</label>
            <input  type="text" class="input_search" style="width:60%" v-model="model.f_address" placeholder='用户地址'
                    condition="f_address like '%{}%'"
                    :size="model.f_address ? model.f_address.length * 2 : 4">
          </div>
          <div class="span" style="float:right;">
            <button class="button_search" style="width:80px;margin-left:30px;" @click="$parent.$parent.search()" v-el:cx>查询</button>
            <button class="button_export" style="width: max-content" @click="$parent.$parent.add()" v-el:cx>新增黑名单</button>
            <!--<div style="float: right"  class="button_spacing" :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"    @click="$parent.$parent.hidden()"></div>-->
          </div>

        </div>
      </criteria>
      <data-grid :model="model" partial='list' class="list_area table_sy" @dblclick="$parent.dblclick" v-ref:grid>
        <template partial='head'>
          <tr>
            <th style="text-align: center; ">序号</th>
            <th style="text-align: center;">用户编号</th>
            <th style="text-align: center;">姓名</th>
            <th style="text-align: center;">&nbsp;&nbsp;&nbsp;电话&nbsp;&nbsp;&nbsp;</th>
            <th style="text-align: center;">地址</th>
          </tr>
        </template>
        <template partial='body'>

          <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;">{{row.f_user_phone}}</td>
          <td style="text-align: center;">{{row.f_address}}</td>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>

  import {PagedList} from 'vue-client'
  import Vue from 'vue'


  export default {
    data () {
      return {
        model: new PagedList('rs/sql/sale_getBlackList', 20),
        // 公司下拉
        curorgid: [this.$login.f.orgid],
        f_orgid: ''
      }
    },
    props: {
      style: {
        type: String,
        default: 'col-sm-2'
      },
      row: {},
      ispartial: false
    },
    ready () {
      this.search()
    },
    methods: {
      search () {
        this.$refs.paged.$refs.cri.search()
        this.$dispatch('search')
      },
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
      },
      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorg([this.$login.f.orgid])
        }
        console.log('查询。。。', this.f_orgid)
        if (this.f_orgid) {
         // args.condition = `${args.condition} and s.f_filialeid  in ${this.f_orgid}`
          args.condition = `${args.condition} and i.f_orgid  in ${this.f_orgid}`
        }

        this.model.search(args.condition, args.model)
      },
      add () {
        this.style = 'col-sm-3'
        this.$dispatch('add')
      },
      dblclick(val){
        console.log(val)
        this.$emit('dblclick',val)
      }

    },
    watch: {
      'model.rows.length' (val) {
        if (val === 1) {
          this.$refs.paged.$refs.grid.select(this.model.rows[0])
        }
      }
    }
  }
</script>
