<div class="box box-primary">
    <div class="box-header with-border">
        <h3 class="box-title">筛选</h3>
        <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                <i class="fa fa-minus"></i>
            </button>
        </div>
    </div>
    <form class="form-horizontal">
        <div class="box-body">
            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-2 control-label">统计维度</label>
                    <button class="btn" ng-class="{'btn-primary': !vm.isShowOwner, 'btn-default':vm.isShowOwner}" style="margin-left: 15px;float: left;"
                        ng-click="vm.isShowOwner = false">不显示代表</button>
                    <button class="btn" ng-class="{'btn-primary': vm.isShowOwner, 'btn-default':!vm.isShowOwner}" style="margin-left: 15px;float: left;"
                        ng-click="vm.isShowOwner = true">显示代表</button>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-2 control-label">时间筛选</label>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='fullYear', 'btn-default':dateSelect!='fullYear'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('fullYear')">全年</button>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='thisMonth', 'btn-default':dateSelect!='thisMonth'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('thisMonth')">本月</button>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='lastMonth', 'btn-default':dateSelect!='lastMonth'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('lastMonth')">上月</button>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='thisQuarter', 'btn-default':dateSelect!='thisQuarter'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('thisQuarter')">本季度</button>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='lastQuarter', 'btn-default':dateSelect!='lastQuarter'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('lastQuarter')">上季度</button>
                    <button class="btn" ng-class="{'btn-primary': dateSelect=='custom', 'btn-default':dateSelect!='custom'}" style="margin-left: 15px;float: left;"
                        ng-click="vm.changeDate('custom')">自定义</button>

                    <div class="col-sm-3" style="width:15%;" ng-if="dateSelect=='custom'">
                        <rt-datetime-no-label ng-model="vm.sYm" rt-type="month"></rt-datetime-no-label>
                    </div>
                    <div style="float: left;" ng-show="dateSelect=='custom'">~</div>
                    <div class="col-sm-3" style="width:15%;" ng-if="dateSelect=='custom'">
                        <rt-datetime-no-label ng-model="vm.eYm" rt-type="month"></rt-datetime-no-label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-12">
                    <label class="col-sm-2 control-label">类型筛选</label>
                    <button class="btn" ng-class="{'btn-primary': vm.typeSelect==='noCustomCategory', 'btn-default':vm.typeSelect!='noCustomCategory'}"
                        style="margin-left: 15px;float: left;" ng-click="vm.typeSelect = 'noCustomCategory'">不分指标类型</button>
                    <button class="btn" ng-class="{'btn-primary': vm.typeSelect==='customCategoryByAmount', 'btn-default':vm.typeSelect!='customCategoryByAmount'}"
                        style="margin-left: 15px;float: left;" ng-click="vm.typeSelect = 'customCategoryByAmount'">按指标类型（金额）</button>
                    <button class="btn" ng-class="{'btn-primary': vm.typeSelect==='customCategoryByQty', 'btn-default':vm.typeSelect!='customCategoryByQty'}"
                        style="margin-left: 15px;float: left;" ng-click="vm.typeSelect = 'customCategoryByQty'">按指标类型（数量）</button>

                    <div class="col-sm-3" style="width:20%;" ng-if="vm.typeSelect ==='customCategoryByAmount' || vm.typeSelect ==='customCategoryByQty'">
                        <ui-select allow-clear ng-model="vm.cuSelected" theme="bootstrap">
                            <ui-select-match>{{$select.selected.name}}</ui-select-match>
                            <ui-select-choices repeat="item in vm.customCategoryList | filter: $select.search">
                                <span ng-bind-html="item.name| highlight: $select.search"></span>
                            </ui-select-choices>
                        </ui-select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-12">
                    <rt-bu-tree-lookup rt-title="部门筛选" rt-multiple="true" ng-model="vm.nodeSelected" rt-col="8" rt-label-col="2"></rt-bu-tree-lookup>
                </div>
            </div>
        </div>
        <div class="box-footer">
            <div class="btn-group pull-right">
                <button class="btn btn-primary" ng-click="vm.getReportData()">查询</button>
                <button class="btn btn-default" ng-if="!vm.isShowOwner && vm.typeSelect=='noCustomCategory'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-不显示代表-不分指标类型")'>导出</button>
                <button class="btn btn-default" ng-if="!vm.isShowOwner && vm.typeSelect=='customCategoryByAmount'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-不显示代表-按指标类型(金额)")'>导出</button>
                <button class="btn btn-default" ng-if="!vm.isShowOwner && vm.typeSelect=='customCategoryByQty'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-不显示代表-按指标类型(数量)")'>导出</button>
                <button class="btn btn-default" ng-if="vm.isShowOwner && vm.typeSelect=='noCustomCategory'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-显示代表-不分指标类型")'>导出</button>
                <button class="btn btn-default" ng-if="vm.isShowOwner && vm.typeSelect=='customCategoryByAmount'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-显示代表-按指标类型(金额)")'>导出</button>
                <button class="btn btn-default" ng-if="vm.isShowOwner && vm.typeSelect=='customCategoryByQty'" ng-click='vm.actions.export({},"importantHospitalExport","终端纯销指标达成-显示代表-按指标类型(数量)")'>导出</button>

            </div>
        </div>
    </form>
</div>


<div class="box box-primary" style="float:left;">
    <div class="box-header with-border">
        <h3 class="box-title">达成列表</h3>
        <div class="box-tools pull-right">
            <button type="button" class="btn btn-box-tool" data-widget="collapse">
                <i class="fa fa-minus"></i>
            </button>
        </div>
    </div>
    <div class="box-body">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.getReportData()"
            rt-rows="vm.reportData" rt-auto-height="{{tableMaxHeight}} ">
            <table class="table table-condensed table-hover ng-scope" style="white-space:nowrap;" id="rt-report-header">
                <thead>
                    <tr>
                        <th rowspan="6" ng-if='vm.isShowOwnerHeader'>省区/地区</th>
                        <th rowspan="6" ng-if='vm.isShowOwnerHeader'>省区经理</th>
                        <th rowspan="6" ng-if='vm.isShowOwnerHeader'>代表</th>
                        <th rowspan="6">客户</th>
                        <th rowspan="3" ng-if='vm.typeSelectHeader != "customCategoryByQty"'>累计达成额</th>
                        <th rowspan="3" ng-if='vm.typeSelectHeader != "customCategoryByQty"'>达成额排名</th>
                        <th rowspan="3" ng-if='vm.typeSelectHeader == "customCategoryByQty"'>累计达成量</th>
                        <th rowspan="3" ng-if='vm.typeSelectHeader == "customCategoryByQty"'>达成量排名</th>
                        <th rowspan="3">累计达成率</th>
                        <th rowspan="3">达成率排名</th>
                        <th align="center" colspan="3" ng-repeat="item in vm.MonDataList">{{item}} 月</th>
                    </tr>
                    <tr>
                        <td align="center" ng-repeat="Mtext in vm.TbMessText track by $index">{{Mtext}}
                        </td>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.reportData.DataList ">
                        <td ng-if='vm.isShowOwnerHeader'>{{row.businessunitidname}}</td>
                        <td ng-if='vm.isShowOwnerHeader'>{{row.businessunitowneridname}}</td>
                        <td ng-if='vm.isShowOwnerHeader'>{{row.owneridname}}</td>
                        <td>{{row.accountidname}}</td>
                        <td ng-if='vm.typeSelectHeader != "customCategoryByQty"'>{{row.act_amount|toFixNumber:2}}万元</td>
                        <td ng-if='vm.typeSelectHeader == "customCategoryByQty"'>{{row.act_amount}}</td>
                        <td>{{row.act_amount_rank}}</td>
                        <td>{{row.year_percent|toFixNumber:2}}%</td>
                        <td>{{row.year_percent_rank}}</td>
                        <td ng-repeat="mItem in row.monthList track by $index" class="rt-number-align">
                            <span ng-if="$index%3===0 && vm.typeSelectHeader != 'customCategoryByQty'">{{mItem|toFixNumber:2}}万元</span>
                            <span ng-if="$index%3===0 && vm.typeSelectHeader == 'customCategoryByQty'">{{mItem}}</span>
                            <span ng-if="$index%3===1 && vm.typeSelectHeader != 'customCategoryByQty'">{{mItem|toFixNumber:2}}万元</span>
                            <span ng-if="$index%3===1 && vm.typeSelectHeader == 'customCategoryByQty'">{{mItem}}</span>
                            <span ng-if="$index%3===2">{{mItem|toFixNumber:2}}%</span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>