<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">
                    <rt-datetime ng-model="vm.eYm" rt-type="month" rt-title="开始年月" rt-required="true" rt-col="3" rt-label-col="2">
                    </rt-datetime>
                    <label class="col-sm-2 control-label">（年月的前三个月）</label>
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-12">
                    <rt-input ng-model="vm.max" rt-type="text" rt-placeholder="4" rt-title="增长倍数" rt-required="false" rt-col="3" rt-label-col="2"></rt-input>
                    <rt-input ng-model="vm.min" rt-type="text" rt-placeholder="0.6" rt-title="减少率" rt-required="false" rt-col="3" rt-label-col="2"></rt-input>
                </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 class="form-group">
                <div class="col-sm-12">
                    <rt-lookup2 rt-title="药品名称" ng-model="vm.productSelected" rt-get-data-name="Product.GetProductSize" rt-order-by="name asc"
                        rt-col-list="[{Code:'name',Name:'药品名称'},{Code:'code',Name:'编号'},{Code:'size',Name:'药品品规'}]" rt-multiple="true"
                        rt-col="8"></rt-lookup2>
                </div>
            </div>

            <div class="box-footer">
                <div class="btn-group pull-right">
                    <button class="btn btn-primary" ng-click="vm.pageIndex = 1;vm.search();">查询</button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='detail'" ng-click='vm.actions.export({
                    "entname":"客户名称",
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidName":"省区/地区",
                    "BusinessUnitOwnerIdName":"经理",
                    "owneridname":"代表",
                    "salecount":"当月销售",
                    "avgcount":"前三月均量",
                    "percentSTR":"对比"
                    },"AbnormalTerExport","异常医院分析明细报表")'>导出
                </button>
                    <button class="btn btn-default" ng-if="vm.entType==2&&selectedTab=='count'" class="btn btn-primary" ng-click='vm.actions.export({
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidname":"省区/地区",
                    "businessunitowneridname":"经理",
                    "salecount":"异常家数"
                    },"AbnormalTerExport","异常医院分析统计报表")'>
                    导出
                </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='detail'" class="btn btn-primary" ng-click='vm.actions.export({
                    "entname":"客户名称",
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidName":"省区/地区",
                    "BusinessUnitOwnerIdName":"经理",
                    "owneridname":"代表",
                    "salecount":"当月销售",
                    "avgcount":"前三月均量",
                    "percentSTR":"对比"
                    },"AbnormalTerExport","异常门店分析明细报表")'>导出
                </button>
                    <button class="btn btn-default" ng-if="vm.entType==3&&selectedTab=='count'" class="btn btn-primary" ng-click='vm.actions.export({
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidname":"省区/地区",
                    "businessunitowneridname":"经理",
                    "salecount":"异常家数"
                    },"AbnormalTerExport","异常门店分析统计报表")'>
                    导出
                </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='detail'" class="btn btn-primary" ng-click='vm.actions.export({
                    "entname":"客户名称",
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidName":"省区/地区",
                    "BusinessUnitOwnerIdName":"经理",
                    "owneridname":"代表",
                    "salecount":"当月销售",
                    "avgcount":"前三月均量",
                    "percentSTR":"对比"
                    },"AbnormalTerExport","异常基层医疗机构分析明细报表")'>
                    导出
                </button>
                    <button class="btn btn-default" ng-if="vm.entType==4&&selectedTab=='count'" class="btn btn-primary" ng-click='vm.actions.export({
                    "product_categoryidname":"品种",
                    "productsize":"规格",
                    "businessunitidname":"省区/地区",
                    "businessunitowneridname":"经理",
                    "salecount":"异常家数"
                    },"AbnormalTerExport","异常基层医疗机构分析统计报表")'>
                    导出
                </button>
                </div>
            </div>
        </div>
    </form>
</div>

<div class="box box-primary" style="float:left;">
    <div class="box-header with-border">
        <h4 class="box-title" style="font-size: 14px;">
            <ul class="nav nav-tabs">
                <li class="active" ng-click="selectTab('detail')">
                    <a href="#c1" onclick="return false;" data-toggle="tab">明细</a>
                </li>
                <li ng-click="selectTab('count')">
                    <a href="#c2" onclick="return false;" data-toggle="tab">统计</a>
                </li>
            </ul>
        </h4>
        <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 active" id="c1" ng-if="selectedTab=='detail'">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.search()"
            rt-rows="vm.data" rt-auto-height="{{tableMaxHeight}} ">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;">
                <thead>
                    <tr id="rt-report-header">
                        <th class="rt-text-align">客户名称</th>
                        <th class="rt-text-align">品种</th>
                        <th class="rt-text-align">规格</th>
                        <th class="rt-text-align">省区/地区</th>
                        <th class="rt-text-align">经理</th>
                        <th class="rt-text-align">代表</th>
                        <th class="rt-number-align">当月销量</th>
                        <th class="rt-number-align">前3个月均量</th>
                        <th class="rt-number-align">对比</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.data">
                        <td class="rt-text-align">{{row.entname}}</td>
                        <td class="rt-text-align">{{row.product_categoryidname}}</td>
                        <td class="rt-text-align">{{row.productsize}}</td>
                        <td class="rt-text-align">{{row.businessunitidName}}</td>
                        <td class="rt-text-align">{{row.BusinessUnitOwnerIdName}}</td>
                        <td class="rt-text-align">{{row.owneridname}}</td>
                        <td class="rt-number-align">{{row.salecount}}</td>
                        <td class="rt-number-align">{{row.avgcount}}</td>
                        <td class="rt-number-align">{{row.percent|toFixNumber:2}}%</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>

    <div class="box-body" id="c2" ng-if="selectedTab=='count'">
        <rt-data-grid rt-page-record-count="vm.recordCount" rt-page-index="vm.pageIndex" rt-page-size="vm.pageSize" rt-get-data="vm.search()"
            rt-rows="vm.data" rt-auto-height="{{tableMaxHeight}} ">
            <table class="table table-condensed table-hover ng-scope" style="white-space: nowrap;">
                <thead>
                    <tr id="rt-report-header">
                        <th class="rt-text-align">品种</th>
                        <th class="rt-text-align">规格</th>
                        <th class="rt-text-align">省区/地区</th>
                        <th class="rt-text-align">经理</th>
                        <th class="rt-number-align">异常家数</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in vm.data">
                        <td class="rt-text-align">{{row.product_categoryidname}}</td>
                        <td class="rt-text-align">{{row.productsize}}</td>
                        <td class="rt-text-align">{{row.businessunitidname}}</td>
                        <td class="rt-text-align">{{row.businessunitowneridname}}</td>
                        <td class="rt-number-align">{{row.salecount}}</td>
                    </tr>
                </tbody>
            </table>
        </rt-data-grid>
    </div>
</div>