<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-if="vm.view.type=='grid'" ng-click="vm.actions.showForm('')" ng-show="vm.privilege.IsCreate">
                    <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-click="vm.actions.activate()" ng-show="vm.privilege.IsWrite">
                    <i class="fa fa-check"></i> 激活
                </button>
            <button class="btn btn-link" ng-click="vm.actions.deactivate()" ng-show="vm.privilege.IsWrite">
                    <i class="fa fa-ban"></i> 停用
                </button>
            <button class="btn btn-link" ng-disabled="false" ng-click='vm.actions.import({
                            Title:"销售协议",
                            ModuleName:"salesagreementImport",
                            EntityName:"sales_agreement",
                          Columns:[
                                {ColumnName:"agr_no",DisplayName:"协议单号*",IsRequired:true,IsKey:true},
                                {ColumnName:"agr_type",DisplayName:"协议类型*",IsRequired:true,IsKey:false},
                                {ColumnName:"accountnumber",DisplayName:"客户编码",IsRequired:false,IsKey:false},
                                {ColumnName:"accountId",DisplayName:"客户*",IsRequired:true,IsKey:false},
                                {ColumnName:"OwnerId",DisplayName:"业务代表*",IsRequired:true,IsKey:false},
                                {ColumnName:"target_amount",DisplayName:"任务金额(元)",IsRequired:false,IsKey:false},
                                {ColumnName:"startdate",DisplayName:"协议开始日期*",IsRequired:true,IsKey:false},
                                {ColumnName:"enddate",DisplayName:"协议结束日期*",IsRequired:true,IsKey:false},
                                {ColumnName:"signdate",DisplayName:"协议签订日期",IsRequired:false,IsKey:false},
                            ]
                        })'>
                    <i class="fa fa-upload"></i> 导入
                </button>
            <button class="btn btn-link" ng-show="vm.privilege.IsExport" ng-click='vm.actions.export({
                        "agr_no":"协议单号",
                        "agr_typeName":"协议类型",
                        "accountnumber":"客户编码",
                        "accountIdName":"客户",
                        "OwnerIdName":"业务代表",
                        "target_amount":"任务金额(元)",
                        "startdateFormat":"协议开始日期",
                        "enddateFormat":"协议结束日期",
                        "signdateFormat":"协议签订日期"
                        },"SalesAgreementExport",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" 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>
    </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-condensed table-hover">
                    <thead>
                        <tr>
                            <th>
                                <rt-header-checkbox></rt-header-checkbox>
                            </th>
                            <!-- @@ 视图表头 -->
                            <th rt-field-code="agr_no">协议单号</th>
                            <th>协议类型</th>
                            <th rt-field-code="buidName">事业部</th>
                            <th rt-field-code="bigdeptName">业务线/大区</th>
                            <th rt-field-code="BusinessUnitIdName">省区/地区</th>
                            <th>客户编码</th>
                            <th>客户</th>
                            <th>业务代表</th>
                            <th>任务金额(元)</th>
                            <th rt-field-code="startdate">协议开始日期</th>
                            <th rt-field-code="enddate">协议结束日期</th>
                            <th rt-field-code="signdate">协议签订日期</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}"> {{row.agr_no}}</a>
                            </td>
                            <td ng-if="vm.view.type=='grid'">
                                <a href="javascript:;" ng-click="vm.actions.showForm(row.Id)"> {{row.agr_no}}   </a>
                            </td>
                            <td>{{row.agr_type.Name}}</td>
                            <td>{{row.buid.Name}}</td>
                            <td>{{row.bigdept.Name}}</td>
                            <td>{{row.BusinessUnitId.Name}}</td>
                            <td>{{row.accountnumber}}</td>
                            <td>{{row.accountId.Name}}</td>
                            <td>{{row.OwnerId.Name}}</td>
                            <td>{{row.target_amount |currency:'￥':2 }}</td>
                            <td>{{row.startdate|date:'yyyy-MM-dd'}}</td>
                            <td>{{row.enddate|date:'yyyy-MM-dd'}}</td>
                            <td>{{row.signdate|date:'yyyy-MM-dd'}}</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>