<header class="bar bar-header bar-{{barTheme}}" ng-class="{searching:searching}">
  <button class="button icon-left ion-ios-arrow-back button-clear sino-back-button" ng-click="goBack()"></button>
  <i class="button button-icon icon ion-ios-reloading" ng-show="loading"></i>
  <h1 class="title">任务</h1>
  <button class="button button-icon icon ion-ios-plus-empty" ng-click="createTask()"></button>
</header>

<ion-content class="task-list linker-cards has-header">
  <ion-refresher on-refresh="onRefresh()"></ion-refresher>
  <div class="search-page" ng-class="{searching:searching}" on-end="onEndEvent">
    <div class="segmented-control">
      <a class="control-item" ng-class="{active: showCard === 'entire'}" ng-click="onClickListTab()">
        全部任务
      </a>
      <a class="control-item" ng-class="{active: showCard === 'drafts'}" ng-click="onClickDraftTab()">
        草稿任务
      </a>
    </div>
    <div class="bar item-input-inset">
      <div class="item-input-wrapper">
        <i class="icon ion-ios-search placeholder-icon"></i>
        <div class="search-input-btn" ng-click="openSearch()">搜索</div>
      </div>
    </div>
    <div>
      <div class="list" ng-show="showCard === 'entire'">
        <div class="item" ng-repeat="task in tasks.items | orderBy:'status' track by task.id " ng-click="toTaskDetail(task)">
          <span class="item-note">
            <div id-to-name id="task.sendPerson" type="user"></div>
          </span>
          <h3>
            <span class="item-label" ng-class="{'balanced':task.status==='1','assertive': task.status === '0', 'positive':task.status === '2'}">{{task.status === '0'?'草稿':task.status === '1'?'办理中':'已完成'}}</span>
            {{task.title}}
          </h3>
          <p>
            <span>{{parseType(task.type)}}&nbsp;
            {{task.status === '0' || task.status === '3'?parseDateStr(task.createDate):parseDateStr(task.sendDate)}}</span>
          </p>
        </div>
      </div>
      <div class="list" ng-show="showCard === 'drafts'">
          <div class="item" ng-repeat="task in drafts.items track by task.id" ng-click="toTaskDetail(task)">
            <span class="item-note">
            <div id-to-name id="task.sendPerson" type="user"></div>
          </span>
            <h3>
              <span class="item-label" ng-class="{'balanced':task.status==='1','assertive': task.status === '0', 'positive':task.status === '2'}">{{task.status === '0'?'草稿':task.status === '1'?'办理中':'已完成'}}</span>
            {{task.title}}
            </h3>

          <p>
            <span>{{parseType(task.type)}}&nbsp;
            {{parseDateStr(task.createDate)}}</span>
          </p>
        </div>
      </div>
    </div>
    <ion-infinite-scroll on-infinite="loadMore()" distance="0%">
    </ion-infinite-scroll>
  </div>
</ion-content>
<div class="sino-search-modal" ng-show="searchopen" ng-class="{open: searchopen}" ng-click="closeSearch()">
  <div class="bar item-input-inset" stop-event>
    <label class="item-input-wrapper">
      <i class="icon ion-ios-search placeholder-icon"></i>
      <input type="search" placeholder="搜索" ng-model="search.text">
    </label>
    <button class="button button-clear cancel" ng-click="closeSearch()">
      取消
    </button>
  </div>
  <ion-content class="card has-search-header" ng-show="search.text !== ''" scroll="true" on-touch="closeKeyBoard()" delegate-handle="searchTaskScroll">
    <ul class="list" ng-show="searchItems.length > 0">
      <li class="item" ng-repeat="item in searchItems" ng-click="toTaskDetail(item)">
      <span class="item-note">
        <div id-to-name id="item.sendPerson" type="user"></div>
      </span>
      <h3>
        <span class="item-label" ng-class="{'balanced':item.status==='1','assertive': item.status === '0', 'positive':item.status === '2'}">{{item.status === '0'?'草稿':item.status === '1'?'办理中':'已完成'}}</span>
        {{item.title}}
      </h3>
      <p>
        <span>{{parseType(item.type)}}&nbsp;
        {{parseDateStr(item.createDate)}}</span>
      </p>
      </li>
    </ul>
    <div ng-show="searchItems.length === 0">
      <span class="search-none">无结果</span>
    </div>
  </ion-content>
</div>
