<template>
  <div class="flex">
    <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="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(), $parent.$parent.clean()">
          </div>
          <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_user_name" placeholder='客户名称'
                   @keyup.enter="search(), $parent.$parent.clean()" condition="f_user_name like '%{}%'">
          </div>
            <div class="span" style="float:right;">
              <button class="button_search button_spacing" @click="search()" >查询</button>
              <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</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>
          <!--<div class="row" v-show="$parent.$parent.criteriaShow">-->
          <!---->
          <!--</div>-->

      </criteria>
      <data-grid  :model="model" partial='list' style="overflow: auto" class="list_area table_sy"  v-ref:grid>
        <template partial='head'>
          <tr>
            <th style="white-space: nowrap;" >序号</th>
            <!--<th>-->
            <!--<data-order field="f_userinfo_code" name="客户编号"-->
            <!--:order.sync="$parent.$parent.$parent.orderFields.f_userinfo_code"></data-order>-->
            <!--</th>-->
            <th style="white-space: nowrap;" >客户编号</th>
            <th style="white-space: nowrap;" >客户基本信息</th>
            <th style="white-space: nowrap;" >表具信息</th>

          </tr>
        </template>
        <template partial='body'>
          <tr>
            <td  :class="{'bg-danger' : row.f_table_state === '停用' }" style="text-align: center;">{{$index + 1}}</td>
            <td  :class="{'bg-danger' : row.f_table_state === '停用' }"><nobr>
              <span @click="$parent.$parent.$parent.showUploadFiles(row)"><a>{{row.f_userinfo_code}}</a></span>
            </nobr> </td>
            <td style="white-space: nowrap;" :class="{'bg-danger' : row.f_table_state === '停用' }">{{row.f_user_name}}&nbsp;&nbsp;{{row.f_user_phone}}&nbsp;&nbsp;{{row.f_address}}</td>
            <td style="white-space: nowrap;" :class="{'bg-danger' : row.f_table_state === '停用' }">{{row.f_user_id}}&nbsp;&nbsp;{{row.f_gasproperties}}&nbsp;&nbsp;{{row.f_meter_brand}}
              &nbsp;&nbsp;{{row.f_meter_style}}&nbsp;&nbsp;{{row.f_price_type}}&nbsp;&nbsp;{{row.f_price_name}}
            </td>

          </tr>
        </template>
        <template partial='foot'></template>
      </data-grid>
    </criteria-paged>
    <modal :show.sync="showfiles" v-ref:modal large backdrop="false">

      <article slot="modal-body" class="modal-body">
        <upload-file-history  :userinfo="userinfo" :files="[]" ></upload-file-history>
      </article>
      <footer slot="modal-footer" class="modal-footer">
      </footer>
    </modal>
  </div>

</template>

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

  export default {
    data () {
      return {
        criteriaShow: false,
        model: new PagedList('rs/sql/sale_getUser', 30),
        addflag: false,
        addtitle: '',
        // 公司下拉
        curorgid: [this.$login.f.orgid],
        f_orgid: '',
        showfiles: false,
        userinfo: '',
        // 文件上传弹框
        showFile: false
      }
    },
    title: '附件查询',
    props: {

    },
    ready () {
      this.search()
    },
    methods: {
      hidden () {
        this.criteriaShow = !this.criteriaShow
      },
      showUploadFiles (row) {
        this.userinfo = row
        this.showfiles = true
      },

      search () {
        this.$refs.paged.$refs.cri.search()
      },

      selfSearch (args) {
        if (!this.f_orgid) {
          this.getorg([this.$login.f.orgid])
        }

        args.condition = `${args.condition} and u.f_filialeid =  '${this.$login.f.orgid}'`
        this.model.search(args.condition, args.model)
      },

      // 清空
      clear () {
        this.$refs.paged.$refs.cri.model = {}
      },
      getorg (val) {
        this.f_orgid = this.$login.convertToIn(val)
        this.f_filialeids = val[0]
      }
    },
    watch: {
      'showfiles' (val) {
        if (val == false) {
          this.userinfo = {}
        }
      }
    },
    events: {

    }

  }
</script>
