<ion-modal-view class="crm-bg">
  <!-- <ion-header-bar>
    <button class="button button-icon" ng-click="modal.hide()">取消</button>
    <h1 class="title">选择客户</h1>
  </ion-header-bar> -->
  
  <!-- 搜索框 -->
  <div class="bar bar-header search-header-bar stable-bg" ng-hide="searchMode">
    <button class="button button-block button-small fsm button-light" ng-click="searchMode = true">
      <i class="ion-ios-search fsu vam"></i>&nbsp;客户名称
    </button>
  </div>

  <div class="bar bar-header item-input-inset search-header-bar" ng-hide="!searchMode">
    <label class="item-input-wrapper">
      <i class="ion-ios-search fsu coyness"></i>
      <input type="text" placeholder="搜索" ng-model="search.key" focus-on="searchMode" focus-delay="200">
    </label>
    <button type="button" class="button button-positive button-clear" ng-click="searchMode = false; search.key = ''">
      取消
    </button>
  </div>

  <ion-content class="has-header has-mb-footer">
    <div class="list">
      <div class="item item-divider" ng-repeat-start="letter in (clients|filterBy:['fullname','firstCase']:search.key|groupAndOrder:'firstLetter') as letters">{{ letter }}</div>
      <div class="item item-indent common" ng-repeat-end ng-repeat="client in letters.grouped[letter]" ng-click="select(client)">
        {{ client.fullname }}
        <span class="item-note ion-checkmark fsu positive" ng-if="cid == client.cid"></span>
      </div>

      <crm-empty-tip ng-if="!letters.length" text="您需要先创建一个客户"></crm-empty-tip>
    </div>
  </ion-content>

  <ion-footer-bar class="mb-footer">
    <button class="button button-block button-light" ng-click="modal.hide()">
      取消
    </button>
  </ion-footer-bar>
</ion-modal-view>