<div class="row rt-margin-bottom-before-box">
    <div class="col-sm-8">
        <div class="btn-group">
            <button class="btn btn-link" data-toggle="sidebar" data-target=".sidebar-right" ng-if="vm.view.type=='default'" ng-show="vm.privilege.IsCreate"
                ui-sref=".edit({id:''})" ui-sref-opts="{location:true}">
                <i class="fa fa-plus"></i> 新建拜访计划
            </button>
            <button class="btn btn-link" ng-click="vm.actions.del()" ng-show="vm.privilege.IsDelete">
                <i class="fa fa-trash"></i> 删除
            </button>
            <button class="btn btn-link" ng-show="vm.privilege.IsExport" ng-click='vm.actions.export({
                    "OwnerIdName":"拜访人",
                    "BusinessUnitIdName":"部门",
                    "planTime":"计划时间",
                    "visit_statusName":"拜访状态",
                    "duration":"停留时长(分)",
                    "startTime":"开始拜访时间",
                    "start_addr":"签到位置",
                    "endTime":"结束拜访时间",
                    "end_addr":"签退位置",
                    "accountidName":"客户",
                    "contactidName":"沟通对象",
                    "visitassistance_owneridname":"协访人",
                    "visitassistance_done_time":"协访评分时间",
                    "VisitPurposes":"拜访目的",
                    "photocount":"照片数量"
                    },"AccountVisitExport",vm.view.selectedView.ViewName)'>
                <i class="fa fa-download"></i> 导出
            </button>
        </div>
    </div>
    <div class="col-sm-4">
        <form class="input-group">
            <input type="search" placeholder="输入代表名称或客户名称快速搜索..." class="form-control" ng-model="vm.view.searchText" />
            <span class="input-group-btn" ng-click="vm.view.search(1)">
                <button type="submit" class="btn btn-default">
                    <i class="fa fa-search"></i>
                </button>
            </span>
        </form>
    </div>
</div>

<div class="box box-primary">
    <div class="box-header with-border" style="cursor: move;">
        <div class="pull-left">
            <div class="btn-group">
                <button class="btn btn-default dropdown-toggle" id="dropdownMenuViewSelect" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    {{vm.view.selectedView.ViewName}}
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenuViewSelect">
                    <li ng-repeat="view in vm.view.list track by view.Id" ng-click="vm.view.select(view)"><a href="javascript:void(0)">{{view.ViewName}}</a></li>
                </ul>
            </div>
            <div class="btn-group">
                <button class="btn btn-default dropdown-toggle" id="dropdownMenuBuSelect" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                        {{vm.visitStatusSelected==null?"所有拜访类型":vm.visitStatusSelected.name}}
                        <span class="caret"></span>
                </button>
                <ul class="dropdown-menu" aria-labelledby="dropdownMenuBuSelect">
                    <li ng-click="vm.visitStatusSelected = null;vm.view.search(1);"><a href="javascript:void(0)">所有拜访类型</a></li>
                    <li ng-repeat="item in vm.visitStatusList" ng-click="vm.visitStatusSelected = item;vm.view.search(1);"><a href="javascript:void(0)">{{item.name}}</a></li>
                </ul>
            </div>

            <button class="btn btn-default" ng-class="{true:'active',false:'inactive'}[vm.view.isShowSearchList]" ng-click="vm.view.isShowSearchList = !vm.view.isShowSearchList;overHeightTable();">
                <i class="fa fa-filter"></i> 更多筛选 <i class="fa fa-angle-double-down"></i>
            </button>
        </div>
    </div>
    <div ng-show="vm.view.isShowSearchList" class="box box-widget">
        <!-- form start -->
        <form class="form-horizontal">
            <div class="box-body">
                <div class="form-group">
                    <rt-datetime ng-model="vm.sYm" rt-type="date" rt-title="开始日期" rt-col="3" rt-label-col="2"></rt-datetime>
                    <rt-datetime ng-model="vm.eYm" rt-type="date" rt-title="结束日期" rt-col="3" rt-label-col="2"></rt-datetime>
                    <div class="btn-group" class="col-sm-2">
                        <button class="btn btn-primary" ng-click="vm.view.search(1)">查询</button>
                    </div>
                </div>
                <div class="form-group">
                    <rt-bu-tree-lookup rt-title="事业部/大区/地区" rt-multiple="true" ng-model="vm.nodeSelected" rt-col="8"></rt-bu-tree-lookup>
                </div>
            </div>
        </form>
    </div>
    <div class="nav-tabs-custom">
        <div class="tab-content">
            <rt-data-grid rt-page-record-count="vm.page.recordCount"  rt-page-index="vm.page.index" rt-page-size="vm.page.size" rt-get-data="vm.view.search()" rt-sort-field="vm.view.sortField"
                rt-rows="vm.data" rt-selected-ids="vm.view.selectedIds" rt-auto-height="{{vm.view.autoHeight}}">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>
                                <rt-header-checkbox></rt-header-checkbox>
                            </th>
                            <th>查看</th>
                            <th rt-field-code="OwnerIdName">拜访人</th>
                            <th rt-field-code="BusinessUnitIdName">部门</th>
                            <th>计划时间</th>
                            <th rt-field-code="visit_statusName">拜访状态</th>
                            <th>停留时长(分)</th>
                            <th>开始拜访时间</th>
                            <th rt-field-code="start_addr">签到位置</th>
                            <th>结束拜访时间</th>
                            <th rt-field-code="end_addr">签退位置</th>
                            <th rt-field-code="accountidName">客户</th>
                            <th rt-field-code="contactidName">沟通对象</th>
                            <th rt-field-code="visitassistance_owneridname">协访人</th>
                            <th rt-field-code="visitassistance_done_time">协访评分时间</th>
                            <th>拜访目的</th>
                            <th>照片</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr ng-repeat="row in vm.data track by row.Id">
                            <td>
                                <rt-data-checkbox value="{{row.Id}}" />
                            </td>
                            <td ng-if="vm.view.type=='default'">
                                <a id="{{row.Id}}" data-toggle="sidebar" data-target=".sidebar-right" ui-sref=".edit({id:row.Id})" ui-sref-opts="{location:true}">查看</a>
                            </td>
                            <td ng-if="vm.view.type=='grid'">
                                <a href="javascript:;" ng-click="vm.actions.showForm(row.Id)"> </a>
                            </td>
                            <td ng-if="vm.view.type=='post'">
                                <a id="{{row.Id}}" data-toggle="sidebar" data-target=".sidebar-right" ui-sref=".edit({id:row.Id})" ui-sref-opts="{location:true}">查看</a>
                            </td>
                            <td>
                                {{row.OwnerIdName}}
                            </td>
                            <td>
                                {{row.BusinessUnitIdName}}
                            </td>
                            <td>
                                {{ row.plan_time | date: 'yyyy-MM-dd HH:mm'}}
                            </td>
                            <td>
                                {{row.visit_statusName}}
                            </td>
                            <td class="rt-number-align">{{row.Duration}}</td>
                            <td>
                                {{row.start_time | date: 'yyyy-MM-dd HH:mm'}}
                            </td>
                            <td>{{row.start_addr}}</td>
                            <td>
                                {{row.end_time | date: 'yyyy-MM-dd HH:mm'}}
                            </td>
                            <td>
                                {{row.end_addr}}
                            </td>
                            <td>
                                {{row.accountidName}}
                            </td>
                            <td>
                                {{row.contactidName}}
                            </td>
                            <td>
                                {{row.visitassistance_owneridname}}
                            </td>
                            <td>
                                {{row.visitassistance_done_time | date: 'yyyy-MM-dd HH:mm'}}
                            </td>
                            <td>
                                <span ng-repeat="purpose in row.VisitPurpose track by $index">
								{{purpose.Name}}
							</span>
                            </td>
                            <td>
                                <a href="javascript:;" ng-click="vm.showImage(row.Id)">{{row.photocount}}</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </rt-data-grid>
        </div>
    </div>
</div>

<div class="sidebar sidebar-right sidebar-animate rt-shadow-border-left content-wrapper" ng-if="vm.view.type=='default'">
    <div ui-view class="content"></div>
</div>