<template>
  <div class="flex-row">
    <div style="flex: 1.5;" class="flex">
      <div class="flex">
        <criteria-paged :model="model" v-ref:paged :pager="!row && !areainfo" @sort="sort">
          <criteria partial='criteria' v-ref:criteria @condition-changed="$parent.selfSearch">
            <div novalidate class="form-inline auto" partial>
              <div class="form-group">
                <input type="text" class="form-control" v-model="model.f_userinfo_code"
                       condition="f_userinfo_code='{}'" placeholder='客户编号'>
              </div>
              <div class="form-group">
                <input type="text" class="form-control" v-model="model.f_user_name"
                       condition="f_user_name = '{}'" placeholder='用户姓名'>
              </div>
              <div class="form-group">
                <input type="text" class="form-control" v-model="model.f_user_phone" placeholder='电话'
                       condition="f_user_phone = '{}'">
              </div>
              <div class="form-group">
                <input type="text" class="form-control" v-model="model.f_address"
                       condition="f_address like '%{}%'" placeholder='用户地址'>
              </div>
              <div class="form-group">
                <v-select :value.sync="model.f_user_state" v-model="model.f_user_state"
                          :options='$parent.$parent.userstates' placeholder='用户状态'
                          close-on-select condition="f_user_state='{}'"></v-select>
              </div>
              <div class="form-group">
                <v-select :value.sync="model.f_adjustable_id" :options='$parent.$parent.adjustables' placeholder='调压箱'
                          close-on-select
                          v-model='model.f_adjustable_id' condition="f_adjustable_id = '{}'" :search='true'></v-select>
              </div>
              <div class="form-group">
                <button class="btn btn-success" @click="search(), $parent.$parent.clean()">查询</button>
              </div>
            </div>
          </criteria>
          <data-grid :model="model" v-ref:grid partial='list'>
            <template partial='head'>
              <tr>
                <th>
                  <nobr>序号</nobr>
                </th>
                <th>
                  <data-order field="f_userinfo_code" name="客户编号"
                              :order.sync="$parent.$parent.$parent.orderFields.f_userinfo_code"></data-order>
                </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'>
              <td style="text-align: center;">{{$index + 1}}</td>
              <td>{{row.f_userinfo_code}}</td>
              <td>{{row.f_user_name}}&nbsp;&nbsp;{{row.f_user_phone ? row.f_user_phone : ''}}</td>
              <td>{{row.f_address_detail ? row.f_address + row.f_address_detail : row.f_address}}</td>
              <td>{{row.f_meternumber}}&nbsp;&nbsp;{{row.f_meter_brand}}&nbsp;&nbsp;{{row.f_table_state}}</td>
              <td style="text-align: center;">{{row.f_user_state}}</td>
              <td style="text-align: center;">
                <!-- <td style="text-align: center;" v-show= "$parent.$parent.$parent.jurisdiction.includes('档案修正权限')"> -->
                <button type="button" name="button" class="btn btn-link" v-if="row.f_user_state === '正常'"
                        @click.stop="$parent.$parent.$parent.modifyUser(row)">修正
                </button>
                <button type="button" name="button" v-if="row.f_user_state !== '正常' && row.f_user_state !== '销户'"
                        class="btn btn-link"
                        @click.stop="$parent.$parent.$parent.buildFile(row)">建档
                </button>
              </td>
            </template>
          </data-grid>
        </criteria-paged>
      </div>
      <div style="height: 500px;" v-show="row || areainfo" class="select-overspread">
        <user-general-info v-if="row || areainfo" :row="row" @clean="clean" :areainfo="areainfo" @success="renew"
                           @build-success="buildFileSuccess"></user-general-info>
      </div>
      <div style="height: 500px;" v-if="batcan || batenable">
        <batch-cancellation v-if="batcan" :useraccount="model.rows"  @clean="batchClean" @success="batchSuccess"></batch-cancellation>
        <batch-enable v-if="batenable" :useraccount="model.rows" @clean="batchClean" @success="batchSuccess"></batch-enable>
      </div>
    </div>
    <div style="width: 30.5%;overflow:auto;white-space:nowrap;margin-right: 0.5%">
    </div>
  </div>
</template>
